Hardware Design: SIE
Sign in or create your account | Project List | Help
Hardware Design: SIE Git Source Tree
Root/
| 1 | // ============================================================================= |
| 2 | // COPYRIGHT NOTICE |
| 3 | // Copyright 2006 (c) Lattice Semiconductor Corporation |
| 4 | // ALL RIGHTS RESERVED |
| 5 | // This confidential and proprietary software may be used only as authorised by |
| 6 | // a licensing agreement from Lattice Semiconductor Corporation. |
| 7 | // The entire notice above must be reproduced on all authorized copies and |
| 8 | // copies may only be made to the extent permitted by a licensing agreement from |
| 9 | // Lattice Semiconductor Corporation. |
| 10 | // |
| 11 | // Lattice Semiconductor Corporation TEL : 1-800-Lattice (USA and Canada) |
| 12 | // 5555 NE Moore Court 408-826-6000 (other locations) |
| 13 | // Hillsboro, OR 97124 web : http://www.latticesemi.com/ |
| 14 | // U.S.A email: techsupport@latticesemi.com |
| 15 | // =============================================================================/ |
| 16 | // FILE DETAILS |
| 17 | // Project : LatticeMico32 |
| 18 | // File : lm32_multiplier.v |
| 19 | // Title : Pipelined multiplier. |
| 20 | // Dependencies : lm32_include.v |
| 21 | // Version : 6.1.17 |
| 22 | // ============================================================================= |
| 23 | |
| 24 | `include "lm32_include.v" |
| 25 | |
| 26 | ///////////////////////////////////////////////////// |
| 27 | // Module interface |
| 28 | ///////////////////////////////////////////////////// |
| 29 | |
| 30 | module lm32_multiplier ( |
| 31 | // ----- Inputs ----- |
| 32 | clk_i, |
| 33 | rst_i, |
| 34 | stall_x, |
| 35 | stall_m, |
| 36 | operand_0, |
| 37 | operand_1, |
| 38 | // ----- Ouputs ----- |
| 39 | result |
| 40 | ); |
| 41 | |
| 42 | ///////////////////////////////////////////////////// |
| 43 | // Inputs |
| 44 | ///////////////////////////////////////////////////// |
| 45 | |
| 46 | input clk_i; // Clock |
| 47 | input rst_i; // Reset |
| 48 | input stall_x; // Stall instruction in X stage |
| 49 | input stall_m; // Stall instruction in M stage |
| 50 | input [`LM32_WORD_RNG] operand_0; // Muliplicand |
| 51 | input [`LM32_WORD_RNG] operand_1; // Multiplier |
| 52 | |
| 53 | ///////////////////////////////////////////////////// |
| 54 | // Outputs |
| 55 | ///////////////////////////////////////////////////// |
| 56 | |
| 57 | output [`LM32_WORD_RNG] result; // Product of multiplication |
| 58 | reg [`LM32_WORD_RNG] result; |
| 59 | |
| 60 | ///////////////////////////////////////////////////// |
| 61 | // Internal nets and registers |
| 62 | ///////////////////////////////////////////////////// |
| 63 | |
| 64 | reg [`LM32_WORD_RNG] muliplicand; |
| 65 | reg [`LM32_WORD_RNG] multiplier; |
| 66 | reg [`LM32_WORD_RNG] product; |
| 67 | |
| 68 | ///////////////////////////////////////////////////// |
| 69 | // Sequential logic |
| 70 | ///////////////////////////////////////////////////// |
| 71 | |
| 72 | always @(posedge clk_i `CFG_RESET_SENSITIVITY) |
| 73 | begin |
| 74 | if (rst_i == `TRUE) |
| 75 | begin |
| 76 | muliplicand <= {`LM32_WORD_WIDTH{1'b0}}; |
| 77 | multiplier <= {`LM32_WORD_WIDTH{1'b0}}; |
| 78 | product <= {`LM32_WORD_WIDTH{1'b0}}; |
| 79 | result <= {`LM32_WORD_WIDTH{1'b0}}; |
| 80 | end |
| 81 | else |
| 82 | begin |
| 83 | if (stall_x == `FALSE) |
| 84 | begin |
| 85 | muliplicand <= operand_0; |
| 86 | multiplier <= operand_1; |
| 87 | end |
| 88 | if (stall_m == `FALSE) |
| 89 | product <= muliplicand * multiplier; |
| 90 | result <= product; |
| 91 | end |
| 92 | end |
| 93 | |
| 94 | endmodule |
| 95 |
Branches:
master
