lm32_multiplier.v

Mon, 05 Apr 2010 21:00:31 +0100

author
Philip Pemberton <philpem@philpem.me.uk>
date
Mon, 05 Apr 2010 21:00:31 +0100
changeset 6
a8e459b24c31
parent 0
cd0b58aa6f83
child 26
73de224304c1
permissions
-rw-r--r--

reduce size of caches to fit in DE1 FPGA

The default cache size makes the Icache and Dcache "just a bit" too big to
fit in the EP2C20 FPGA on the DE1 board. This commit reduces the Icache and
Dcache sizes to the defaults shown in the LatticeMico32 Processor Reference
Manual (pages 36 and 37).

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