Mon, 05 Apr 2010 21:00:31 +0100
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_adder.v |
philpem@0 | 19 | // Title : Integer adder / subtractor with comparison flag generation |
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_adder ( |
philpem@0 | 36 | // ----- Inputs ------- |
philpem@0 | 37 | adder_op_x, |
philpem@0 | 38 | adder_op_x_n, |
philpem@0 | 39 | operand_0_x, |
philpem@0 | 40 | operand_1_x, |
philpem@0 | 41 | // ----- Outputs ------- |
philpem@0 | 42 | adder_result_x, |
philpem@0 | 43 | adder_carry_n_x, |
philpem@0 | 44 | adder_overflow_x |
philpem@0 | 45 | ); |
philpem@0 | 46 | |
philpem@0 | 47 | ///////////////////////////////////////////////////// |
philpem@0 | 48 | // Inputs |
philpem@0 | 49 | ///////////////////////////////////////////////////// |
philpem@0 | 50 | |
philpem@0 | 51 | input adder_op_x; // Operating to perform, 0 for addition, 1 for subtraction |
philpem@0 | 52 | input adder_op_x_n; // Inverted version of adder_op_x |
philpem@0 | 53 | input [`LM32_WORD_RNG] operand_0_x; // Operand to add, or subtract from |
philpem@0 | 54 | input [`LM32_WORD_RNG] operand_1_x; // Opearnd to add, or subtract by |
philpem@0 | 55 | |
philpem@0 | 56 | ///////////////////////////////////////////////////// |
philpem@0 | 57 | // Outputs |
philpem@0 | 58 | ///////////////////////////////////////////////////// |
philpem@0 | 59 | |
philpem@0 | 60 | output [`LM32_WORD_RNG] adder_result_x; // Result of addition or subtraction |
philpem@0 | 61 | wire [`LM32_WORD_RNG] adder_result_x; |
philpem@0 | 62 | output adder_carry_n_x; // Inverted carry |
philpem@0 | 63 | wire adder_carry_n_x; |
philpem@0 | 64 | output adder_overflow_x; // Indicates if overflow occured, only valid for subtractions |
philpem@0 | 65 | reg adder_overflow_x; |
philpem@0 | 66 | |
philpem@0 | 67 | ///////////////////////////////////////////////////// |
philpem@0 | 68 | // Internal nets and registers |
philpem@0 | 69 | ///////////////////////////////////////////////////// |
philpem@0 | 70 | |
philpem@0 | 71 | wire a_sign; // Sign (i.e. positive or negative) of operand 0 |
philpem@0 | 72 | wire b_sign; // Sign of operand 1 |
philpem@0 | 73 | wire result_sign; // Sign of result |
philpem@0 | 74 | |
philpem@0 | 75 | ///////////////////////////////////////////////////// |
philpem@0 | 76 | // Instantiations |
philpem@0 | 77 | ///////////////////////////////////////////////////// |
philpem@0 | 78 | |
philpem@0 | 79 | lm32_addsub addsub ( |
philpem@0 | 80 | // ----- Inputs ----- |
philpem@0 | 81 | .DataA (operand_0_x), |
philpem@0 | 82 | .DataB (operand_1_x), |
philpem@0 | 83 | .Cin (adder_op_x), |
philpem@0 | 84 | .Add_Sub (adder_op_x_n), |
philpem@0 | 85 | // ----- Ouputs ----- |
philpem@0 | 86 | .Result (adder_result_x), |
philpem@0 | 87 | .Cout (adder_carry_n_x) |
philpem@0 | 88 | ); |
philpem@0 | 89 | |
philpem@0 | 90 | ///////////////////////////////////////////////////// |
philpem@0 | 91 | // Combinational Logic |
philpem@0 | 92 | ///////////////////////////////////////////////////// |
philpem@0 | 93 | |
philpem@0 | 94 | // Extract signs of operands and result |
philpem@0 | 95 | |
philpem@0 | 96 | assign a_sign = operand_0_x[`LM32_WORD_WIDTH-1]; |
philpem@0 | 97 | assign b_sign = operand_1_x[`LM32_WORD_WIDTH-1]; |
philpem@0 | 98 | assign result_sign = adder_result_x[`LM32_WORD_WIDTH-1]; |
philpem@0 | 99 | |
philpem@0 | 100 | // Determine whether an overflow occured when performing a subtraction |
philpem@0 | 101 | |
philpem@0 | 102 | always @(*) |
philpem@0 | 103 | begin |
philpem@0 | 104 | // +ve - -ve = -ve -> overflow |
philpem@0 | 105 | // -ve - +ve = +ve -> overflow |
philpem@0 | 106 | if ( (!a_sign & b_sign & result_sign) |
philpem@0 | 107 | || (a_sign & !b_sign & !result_sign) |
philpem@0 | 108 | ) |
philpem@0 | 109 | adder_overflow_x = `TRUE; |
philpem@0 | 110 | else |
philpem@0 | 111 | adder_overflow_x = `FALSE; |
philpem@0 | 112 | end |
philpem@0 | 113 | |
philpem@0 | 114 | endmodule |
philpem@0 | 115 |