lm32_addsub.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 2
a61bb364ae1f
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_addsub.v
philpem@0 19 // Title : PMI adder/subtractor.
philpem@0 20 // Version : 6.1.17
philpem@0 21 // : Initial Release
philpem@0 22 // Version : 7.0SP2, 3.0
philpem@0 23 // : No Change
philpem@0 24 // Version : 3.1
philpem@0 25 // : No Change
philpem@0 26 // =============================================================================
philpem@0 27
philpem@0 28 `include "lm32_include.v"
philpem@0 29
philpem@0 30 /////////////////////////////////////////////////////
philpem@0 31 // Module interface
philpem@0 32 /////////////////////////////////////////////////////
philpem@0 33
philpem@0 34 module lm32_addsub (
philpem@0 35 // ----- Inputs -------
philpem@0 36 DataA,
philpem@0 37 DataB,
philpem@0 38 Cin,
philpem@0 39 Add_Sub,
philpem@0 40 // ----- Outputs -------
philpem@0 41 Result,
philpem@0 42 Cout
philpem@0 43 );
philpem@0 44
philpem@0 45 /////////////////////////////////////////////////////
philpem@0 46 // Inputs
philpem@0 47 /////////////////////////////////////////////////////
philpem@0 48
philpem@0 49 input [31:0] DataA;
philpem@0 50 input [31:0] DataB;
philpem@0 51 input Cin;
philpem@0 52 input Add_Sub;
philpem@0 53
philpem@0 54 /////////////////////////////////////////////////////
philpem@0 55 // Outputs
philpem@0 56 /////////////////////////////////////////////////////
philpem@0 57
philpem@0 58 output [31:0] Result;
philpem@0 59 wire [31:0] Result;
philpem@0 60 output Cout;
philpem@0 61 wire Cout;
philpem@0 62
philpem@0 63 /////////////////////////////////////////////////////
philpem@0 64 // Instantiations
philpem@0 65 /////////////////////////////////////////////////////
philpem@0 66
philpem@2 67 // Only use Lattice specific constructs when compiling with ispLEVER
philpem@2 68 `ifdef PLATFORM_LATTICE
philpem@0 69 generate
philpem@0 70 if (`LATTICE_FAMILY == "SC" || `LATTICE_FAMILY == "SCM") begin
philpem@2 71 `endif
philpem@0 72 wire [32:0] tmp_addResult = DataA + DataB + Cin;
philpem@0 73 wire [32:0] tmp_subResult = DataA - DataB - !Cin;
philpem@0 74
philpem@0 75 assign Result = (Add_Sub == 1) ? tmp_addResult[31:0] : tmp_subResult[31:0];
philpem@0 76 assign Cout = (Add_Sub == 1) ? tmp_addResult[32] : !tmp_subResult[32];
philpem@2 77 `ifdef PLATFORM_LATTICE
philpem@0 78 end else begin
philpem@0 79 pmi_addsub #(// ----- Parameters -------
philpem@0 80 .pmi_data_width (32),
philpem@0 81 .pmi_result_width (32),
philpem@0 82 .pmi_sign ("off"),
philpem@0 83 .pmi_family (`LATTICE_FAMILY),
philpem@0 84 .module_type ("pmi_addsub"))
philpem@0 85 addsub (// ----- Inputs -------
philpem@0 86 .DataA (DataA),
philpem@0 87 .DataB (DataB),
philpem@0 88 .Cin (Cin),
philpem@0 89 .Add_Sub (Add_Sub),
philpem@0 90 // ----- Outputs -------
philpem@0 91 .Result (Result),
philpem@0 92 .Cout (Cout),
philpem@0 93 .Overflow ());
philpem@0 94 end
philpem@0 95 endgenerate
philpem@2 96 `endif
philpem@0 97
philpem@0 98 endmodule