lm32_multiplier.v

Sat, 06 Aug 2011 00:02:46 +0100

author
Philip Pemberton <philpem@philpem.me.uk>
date
Sat, 06 Aug 2011 00:02:46 +0100
changeset 26
73de224304c1
parent 0
cd0b58aa6f83
child 27
d6c693415d59
permissions
-rwxr-xr-x

[UPSTREAM PULL] Update baseline to LatticeMico32 v3.8 from Diamond 1.3-lm32 distribution package (datestamp May 2011)

philpem@26 1 // ==================================================================
philpem@26 2 // >>>>>>>>>>>>>>>>>>>>>>> COPYRIGHT NOTICE <<<<<<<<<<<<<<<<<<<<<<<<<
philpem@26 3 // ------------------------------------------------------------------
philpem@26 4 // Copyright (c) 2006-2011 by Lattice Semiconductor Corporation
philpem@26 5 // ALL RIGHTS RESERVED
philpem@26 6 // ------------------------------------------------------------------
philpem@26 7 //
philpem@26 8 // IMPORTANT: THIS FILE IS AUTO-GENERATED BY THE LATTICEMICO SYSTEM.
philpem@26 9 //
philpem@26 10 // Permission:
philpem@26 11 //
philpem@26 12 // Lattice Semiconductor grants permission to use this code
philpem@26 13 // pursuant to the terms of the Lattice Semiconductor Corporation
philpem@26 14 // Open Source License Agreement.
philpem@26 15 //
philpem@26 16 // Disclaimer:
philpem@0 17 //
philpem@26 18 // Lattice Semiconductor provides no warranty regarding the use or
philpem@26 19 // functionality of this code. It is the user's responsibility to
philpem@26 20 // verify the userís design for consistency and functionality through
philpem@26 21 // the use of formal verification methods.
philpem@26 22 //
philpem@26 23 // --------------------------------------------------------------------
philpem@26 24 //
philpem@26 25 // Lattice Semiconductor Corporation
philpem@26 26 // 5555 NE Moore Court
philpem@26 27 // Hillsboro, OR 97214
philpem@26 28 // U.S.A
philpem@26 29 //
philpem@26 30 // TEL: 1-800-Lattice (USA and Canada)
philpem@26 31 // 503-286-8001 (other locations)
philpem@26 32 //
philpem@26 33 // web: http://www.latticesemi.com/
philpem@26 34 // email: techsupport@latticesemi.com
philpem@26 35 //
philpem@26 36 // --------------------------------------------------------------------
philpem@0 37 // FILE DETAILS
philpem@0 38 // Project : LatticeMico32
philpem@0 39 // File : lm32_multiplier.v
philpem@0 40 // Title : Pipelined multiplier.
philpem@0 41 // Dependencies : lm32_include.v
philpem@0 42 // Version : 6.1.17
philpem@0 43 // : Initial Release
philpem@0 44 // Version : 7.0SP2, 3.0
philpem@0 45 // : No Change
philpem@0 46 // Version : 3.1
philpem@0 47 // : No Change
philpem@0 48 // =============================================================================
philpem@0 49
philpem@0 50 `include "lm32_include.v"
philpem@0 51
philpem@0 52 /////////////////////////////////////////////////////
philpem@0 53 // Module interface
philpem@0 54 /////////////////////////////////////////////////////
philpem@0 55
philpem@0 56 module lm32_multiplier (
philpem@0 57 // ----- Inputs -----
philpem@0 58 clk_i,
philpem@0 59 rst_i,
philpem@0 60 stall_x,
philpem@0 61 stall_m,
philpem@0 62 operand_0,
philpem@0 63 operand_1,
philpem@0 64 // ----- Ouputs -----
philpem@0 65 result
philpem@0 66 );
philpem@0 67
philpem@0 68 /////////////////////////////////////////////////////
philpem@0 69 // Inputs
philpem@0 70 /////////////////////////////////////////////////////
philpem@0 71
philpem@0 72 input clk_i; // Clock
philpem@0 73 input rst_i; // Reset
philpem@0 74 input stall_x; // Stall instruction in X stage
philpem@0 75 input stall_m; // Stall instruction in M stage
philpem@0 76 input [`LM32_WORD_RNG] operand_0; // Muliplicand
philpem@0 77 input [`LM32_WORD_RNG] operand_1; // Multiplier
philpem@0 78
philpem@0 79 /////////////////////////////////////////////////////
philpem@0 80 // Outputs
philpem@0 81 /////////////////////////////////////////////////////
philpem@0 82
philpem@0 83 output [`LM32_WORD_RNG] result; // Product of multiplication
philpem@0 84 reg [`LM32_WORD_RNG] result;
philpem@0 85
philpem@0 86 /////////////////////////////////////////////////////
philpem@0 87 // Internal nets and registers
philpem@0 88 /////////////////////////////////////////////////////
philpem@0 89
philpem@0 90 reg [`LM32_WORD_RNG] muliplicand;
philpem@0 91 reg [`LM32_WORD_RNG] multiplier;
philpem@0 92 reg [`LM32_WORD_RNG] product;
philpem@0 93
philpem@0 94 /////////////////////////////////////////////////////
philpem@0 95 // Sequential logic
philpem@0 96 /////////////////////////////////////////////////////
philpem@0 97
philpem@0 98 always @(posedge clk_i `CFG_RESET_SENSITIVITY)
philpem@0 99 begin
philpem@0 100 if (rst_i == `TRUE)
philpem@0 101 begin
philpem@26 102 muliplicand <= #1 {`LM32_WORD_WIDTH{1'b0}};
philpem@26 103 multiplier <= #1 {`LM32_WORD_WIDTH{1'b0}};
philpem@26 104 product <= #1 {`LM32_WORD_WIDTH{1'b0}};
philpem@26 105 result <= #1 {`LM32_WORD_WIDTH{1'b0}};
philpem@0 106 end
philpem@0 107 else
philpem@0 108 begin
philpem@0 109 if (stall_x == `FALSE)
philpem@0 110 begin
philpem@26 111 muliplicand <= #1 operand_0;
philpem@26 112 multiplier <= #1 operand_1;
philpem@0 113 end
philpem@0 114 if (stall_m == `FALSE)
philpem@26 115 product <= #1 muliplicand * multiplier;
philpem@26 116 result <= #1 product;
philpem@0 117 end
philpem@0 118 end
philpem@0 119
philpem@0 120 endmodule