Sat, 06 Aug 2011 01:48:48 +0100
Update to LM32 DMA v3.3
+// Version : 3.2
+// : 1. Support for 8/32-bit WISHBONE Data Bus. The Control and
+// : Read/Write Ports can be independently configured.
+// : 2. Support for "retry" on receipt of a WISHBONE RTY. This
+// : retry results in the current burst or classic cycle
+// : being issued again after a retry timeout.
+// : 3. Support for "error" on receipt of a WISHBONE ERR. This
+// : results in the current dma transfer being terminated
+// : and the error is updated within the STATUS CSR.
+// : 4. Support for burst size of 64.
+// :
+// Version : 3.3
+// : Support for MachXO2 added. The MachXO2 only has a FIFO
+// : with separate read/write clocks.
| philpem@1 | 1 | // ================================================================== |
| philpem@1 | 2 | // >>>>>>>>>>>>>>>>>>>>>>> COPYRIGHT NOTICE <<<<<<<<<<<<<<<<<<<<<<<<< |
| philpem@1 | 3 | // ------------------------------------------------------------------ |
| philpem@1 | 4 | // Copyright (c) 2006-2011 by Lattice Semiconductor Corporation |
| philpem@1 | 5 | // ALL RIGHTS RESERVED |
| philpem@1 | 6 | // ------------------------------------------------------------------ |
| philpem@1 | 7 | // |
| philpem@1 | 8 | // IMPORTANT: THIS FILE IS AUTO-GENERATED BY THE LATTICEMICO SYSTEM. |
| philpem@1 | 9 | // |
| philpem@1 | 10 | // Permission: |
| philpem@1 | 11 | // |
| philpem@1 | 12 | // Lattice Semiconductor grants permission to use this code |
| philpem@1 | 13 | // pursuant to the terms of the Lattice Semiconductor Corporation |
| philpem@1 | 14 | // Open Source License Agreement. |
| philpem@1 | 15 | // |
| philpem@1 | 16 | // Disclaimer: |
| philpem@0 | 17 | // |
| philpem@1 | 18 | // Lattice Semiconductor provides no warranty regarding the use or |
| philpem@1 | 19 | // functionality of this code. It is the user's responsibility to |
| philpem@1 | 20 | // verify the user’s design for consistency and functionality through |
| philpem@1 | 21 | // the use of formal verification methods. |
| philpem@1 | 22 | // |
| philpem@1 | 23 | // -------------------------------------------------------------------- |
| philpem@1 | 24 | // |
| philpem@1 | 25 | // Lattice Semiconductor Corporation |
| philpem@1 | 26 | // 5555 NE Moore Court |
| philpem@1 | 27 | // Hillsboro, OR 97214 |
| philpem@1 | 28 | // U.S.A |
| philpem@1 | 29 | // |
| philpem@1 | 30 | // TEL: 1-800-Lattice (USA and Canada) |
| philpem@1 | 31 | // 503-286-8001 (other locations) |
| philpem@1 | 32 | // |
| philpem@1 | 33 | // web: http://www.latticesemi.com/ |
| philpem@1 | 34 | // email: techsupport@latticesemi.com |
| philpem@1 | 35 | // |
| philpem@1 | 36 | // -------------------------------------------------------------------- |
| philpem@0 | 37 | // FILE DETAILS |
| philpem@0 | 38 | // Project : LM32 DMA Component |
| philpem@0 | 39 | // File : wb_dma_ctrl.v |
| philpem@0 | 40 | // Title : DMA controller top file |
| philpem@0 | 41 | // Dependencies : None |
| philpem@1 | 42 | // : |
| philpem@0 | 43 | // Version : 7.0 |
| philpem@0 | 44 | // : Initial Release |
| philpem@1 | 45 | // : |
| philpem@0 | 46 | // Version : 7.0SP2, 3.0 |
| philpem@1 | 47 | // : 1. Read and Write channel of DMA controller are working in |
| philpem@1 | 48 | // : parallel, due to that now as soon as FIFO is not empty |
| philpem@1 | 49 | // : write channel of the DMA controller start writing data |
| philpem@1 | 50 | // : to the slave. |
| philpem@1 | 51 | // : 2. Burst Size supported by DMA controller is increased to |
| philpem@1 | 52 | // : support bigger burst (from current value of 4 and 8 to |
| philpem@1 | 53 | // : 16 and 32). Now 4 different type of burst sizes are |
| philpem@1 | 54 | // : supported by the DMA controller 4, 8, 16 and 32. For |
| philpem@1 | 55 | // : this Burst Size field of the control register is |
| philpem@1 | 56 | // : increased to 2 bits. |
| philpem@1 | 57 | // : 3. Glitch is removed on the S_ACK_O signal. |
| philpem@1 | 58 | // : |
| philpem@0 | 59 | // Version : 3.1 |
| philpem@0 | 60 | // : Make DMA Engine compliant to Rule 3.100 of Wishbone Spec |
| philpem@0 | 61 | // : which defines alignement of bytes in sub-word transfers. |
| philpem@1 | 62 | // : |
| philpem@1 | 63 | // Version : 3.2 |
| philpem@1 | 64 | // : 1. Support for 8/32-bit WISHBONE Data Bus. The Control and |
| philpem@1 | 65 | // : Read/Write Ports can be independently configured. |
| philpem@1 | 66 | // : 2. Support for "retry" on receipt of a WISHBONE RTY. This |
| philpem@1 | 67 | // : retry results in the current burst or classic cycle |
| philpem@1 | 68 | // : being issued again after a retry timeout. |
| philpem@1 | 69 | // : 3. Support for "error" on receipt of a WISHBONE ERR. This |
| philpem@1 | 70 | // : results in the current dma transfer being terminated |
| philpem@1 | 71 | // : and the error is updated within the STATUS CSR. |
| philpem@1 | 72 | // : 4. Support for burst size of 64. |
| philpem@0 | 73 | // ============================================================================= |
| philpem@0 | 74 | |
| philpem@0 | 75 | `ifndef WB_DMA_CTRL_FILE |
| philpem@0 | 76 | `define WB_DMA_CTRL_FILE |
| philpem@0 | 77 | `include "system_conf.v" |
| philpem@1 | 78 | module wb_dma_ctrl |
| philpem@1 | 79 | #(parameter S_WB_DAT_WIDTH = 32, |
| philpem@1 | 80 | parameter S_WB_ADR_WIDTH = 32, |
| philpem@1 | 81 | parameter MA_WB_DAT_WIDTH = 32, |
| philpem@1 | 82 | parameter MA_WB_ADR_WIDTH = 32, |
| philpem@1 | 83 | parameter MB_WB_DAT_WIDTH = 32, |
| philpem@1 | 84 | parameter MB_WB_ADR_WIDTH = 32, |
| philpem@1 | 85 | parameter RETRY_TIMEOUT = 16, |
| philpem@1 | 86 | parameter FIFO_IMPLEMENTATION = "EBR") |
| philpem@1 | 87 | ( |
| philpem@1 | 88 | // master read port |
| philpem@1 | 89 | output [MA_WB_ADR_WIDTH-1:0] MA_ADR_O, |
| philpem@1 | 90 | output MA_WE_O, |
| philpem@1 | 91 | output [MA_WB_DAT_WIDTH/8-1:0] MA_SEL_O, |
| philpem@1 | 92 | output MA_STB_O, |
| philpem@1 | 93 | output MA_CYC_O, |
| philpem@1 | 94 | output MA_LOCK_O, |
| philpem@1 | 95 | output [2:0] MA_CTI_O, |
| philpem@1 | 96 | output [1:0] MA_BTE_O, |
| philpem@1 | 97 | output [MA_WB_DAT_WIDTH-1:0] MA_DAT_O, |
| philpem@1 | 98 | input [MA_WB_DAT_WIDTH-1:0] MA_DAT_I, |
| philpem@1 | 99 | input MA_ACK_I, |
| philpem@1 | 100 | input MA_ERR_I, |
| philpem@1 | 101 | input MA_RTY_I, |
| philpem@1 | 102 | // master write port |
| philpem@1 | 103 | output [MB_WB_ADR_WIDTH-1:0] MB_ADR_O, |
| philpem@1 | 104 | output [MB_WB_DAT_WIDTH-1:0] MB_DAT_O, |
| philpem@1 | 105 | output MB_WE_O, |
| philpem@1 | 106 | output [MB_WB_DAT_WIDTH/8-1:0] MB_SEL_O, |
| philpem@1 | 107 | output MB_STB_O, |
| philpem@1 | 108 | output MB_CYC_O, |
| philpem@1 | 109 | output MB_LOCK_O, |
| philpem@1 | 110 | output [2:0] MB_CTI_O, |
| philpem@1 | 111 | output [1:0] MB_BTE_O, |
| philpem@1 | 112 | input [MB_WB_DAT_WIDTH-1:0] MB_DAT_I, |
| philpem@1 | 113 | input MB_ACK_I, |
| philpem@1 | 114 | input MB_ERR_I, |
| philpem@1 | 115 | input MB_RTY_I, |
| philpem@1 | 116 | // slave port |
| philpem@1 | 117 | input [S_WB_ADR_WIDTH-1:0] S_ADR_I, |
| philpem@1 | 118 | input [S_WB_DAT_WIDTH-1:0] S_DAT_I, |
| philpem@1 | 119 | input S_WE_I, |
| philpem@1 | 120 | input S_STB_I, |
| philpem@1 | 121 | input S_CYC_I, |
| philpem@1 | 122 | input [S_WB_DAT_WIDTH/8-1:0] S_SEL_I, |
| philpem@1 | 123 | input S_LOCK_I, |
| philpem@1 | 124 | input [2:0] S_CTI_I, |
| philpem@1 | 125 | input [1:0] S_BTE_I, |
| philpem@1 | 126 | output [S_WB_DAT_WIDTH-1:0] S_DAT_O, |
| philpem@1 | 127 | output S_ACK_O, |
| philpem@1 | 128 | output S_ERR_O, |
| philpem@1 | 129 | output S_RTY_O, |
| philpem@1 | 130 | output S_INT_O, |
| philpem@1 | 131 | // system clock and reset |
| philpem@1 | 132 | input CLK_I, |
| philpem@1 | 133 | input RST_I |
| philpem@1 | 134 | ); |
| philpem@1 | 135 | |
| philpem@1 | 136 | assign MA_BTE_O = 0; |
| philpem@1 | 137 | assign MB_BTE_O = 0; |
| philpem@1 | 138 | assign S_ERR_O = 0; |
| philpem@1 | 139 | assign S_RTY_O = 0; |
| philpem@1 | 140 | |
| philpem@1 | 141 | wire [31:0] reg_00_data; |
| philpem@1 | 142 | wire [31:0] reg_04_data; |
| philpem@1 | 143 | wire [31:0] reg_08_data; |
| philpem@1 | 144 | wire [7:0] reg_rdelay; |
| philpem@0 | 145 | |
| philpem@1 | 146 | // slave port:master write/read data to/from register file. |
| philpem@1 | 147 | SLAVE_REG |
| philpem@1 | 148 | #(.S_WB_DAT_WIDTH (S_WB_DAT_WIDTH), |
| philpem@1 | 149 | .S_WB_ADR_WIDTH (S_WB_ADR_WIDTH), |
| philpem@1 | 150 | .FIFO_IMPLEMENTATION (FIFO_IMPLEMENTATION) |
| philpem@1 | 151 | ) |
| philpem@1 | 152 | SLAVE_REG |
| philpem@1 | 153 | ( |
| philpem@1 | 154 | .S_ADR_I (S_ADR_I ), |
| philpem@1 | 155 | .S_DAT_I (S_DAT_I ), |
| philpem@1 | 156 | .S_SEL_I (S_SEL_I ), |
| philpem@1 | 157 | .S_WE_I (S_WE_I ), |
| philpem@1 | 158 | .S_STB_I (S_STB_I ), |
| philpem@1 | 159 | .S_CYC_I (S_CYC_I ), |
| philpem@1 | 160 | .S_CTI_I (S_CTI_I ), |
| philpem@1 | 161 | .S_DAT_O (S_DAT_O ), |
| philpem@1 | 162 | .S_ACK_O (S_ACK_O ), |
| philpem@1 | 163 | .S_INT_O (S_INT_O ), |
| philpem@1 | 164 | // internal signals |
| philpem@1 | 165 | .reg_start (reg_start ), |
| philpem@1 | 166 | .reg_status (reg_status ), |
| philpem@1 | 167 | .reg_interrupt (reg_interrupt ), |
| philpem@1 | 168 | .reg_busy (reg_busy ), |
| philpem@1 | 169 | .reg_bt3 (reg_bt3 ), |
| philpem@1 | 170 | .reg_bt2 (reg_bt2 ), |
| philpem@1 | 171 | .reg_bt1 (reg_bt1 ), |
| philpem@1 | 172 | .reg_bt0 (reg_bt0 ), |
| philpem@1 | 173 | .reg_s_con (reg_s_con ), |
| philpem@1 | 174 | .reg_d_con (reg_d_con ), |
| philpem@1 | 175 | .reg_incw (reg_incw ), |
| philpem@1 | 176 | .reg_inchw (reg_inchw ), |
| philpem@1 | 177 | .reg_rdelay (reg_rdelay ), |
| philpem@1 | 178 | .reg_00_data (reg_00_data ), |
| philpem@1 | 179 | .reg_04_data (reg_04_data ), |
| philpem@1 | 180 | .reg_08_data (reg_08_data ), |
| philpem@1 | 181 | // system clock and reset |
| philpem@1 | 182 | .CLK_I (CLK_I ), |
| philpem@1 | 183 | .RST_I (RST_I ) |
| philpem@1 | 184 | ); |
| philpem@0 | 185 | |
| philpem@1 | 186 | // Master control |
| philpem@1 | 187 | MASTER_CTRL |
| philpem@1 | 188 | #(.MA_WB_DAT_WIDTH (MA_WB_DAT_WIDTH), |
| philpem@1 | 189 | .MA_WB_ADR_WIDTH (MA_WB_ADR_WIDTH), |
| philpem@1 | 190 | .MB_WB_DAT_WIDTH (MB_WB_DAT_WIDTH), |
| philpem@1 | 191 | .MB_WB_ADR_WIDTH (MB_WB_ADR_WIDTH), |
| philpem@1 | 192 | .S_WB_DAT_WIDTH (S_WB_DAT_WIDTH), |
| philpem@1 | 193 | .FIFO_IMPLEMENTATION (FIFO_IMPLEMENTATION) |
| philpem@1 | 194 | ) |
| philpem@1 | 195 | MASTER_CTRL |
| philpem@1 | 196 | ( |
| philpem@1 | 197 | // master read port |
| philpem@1 | 198 | .MA_ADR_O (MA_ADR_O ), |
| philpem@1 | 199 | .MA_SEL_O (MA_SEL_O ), |
| philpem@1 | 200 | .MA_DAT_O (MA_DAT_O ), |
| philpem@1 | 201 | .MA_WE_O (MA_WE_O ), |
| philpem@1 | 202 | .MA_STB_O (MA_STB_O ), |
| philpem@1 | 203 | .MA_CYC_O (MA_CYC_O ), |
| philpem@1 | 204 | .MA_CTI_O (MA_CTI_O ), |
| philpem@1 | 205 | .MA_LOCK_O (MA_LOCK_O ), |
| philpem@1 | 206 | .MA_DAT_I (MA_DAT_I ), |
| philpem@1 | 207 | .MA_ACK_I (MA_ACK_I ), |
| philpem@1 | 208 | .MA_ERR_I (MA_ERR_I ), |
| philpem@1 | 209 | .MA_RTY_I (MA_RTY_I ), |
| philpem@1 | 210 | // master write port |
| philpem@1 | 211 | .MB_ADR_O (MB_ADR_O ), |
| philpem@1 | 212 | .MB_SEL_O (MB_SEL_O ), |
| philpem@1 | 213 | .MB_DAT_O (MB_DAT_O ), |
| philpem@1 | 214 | .MB_WE_O (MB_WE_O ), |
| philpem@1 | 215 | .MB_STB_O (MB_STB_O ), |
| philpem@1 | 216 | .MB_CYC_O (MB_CYC_O ), |
| philpem@1 | 217 | .MB_CTI_O (MB_CTI_O ), |
| philpem@1 | 218 | .MB_LOCK_O (MB_LOCK_O ), |
| philpem@1 | 219 | .MB_ACK_I (MB_ACK_I ), |
| philpem@1 | 220 | .MB_ERR_I (MB_ERR_I ), |
| philpem@1 | 221 | .MB_RTY_I (MB_RTY_I ), |
| philpem@1 | 222 | // register interface |
| philpem@1 | 223 | .reg_start (reg_start ), |
| philpem@1 | 224 | .reg_busy (reg_busy ), |
| philpem@1 | 225 | .reg_status (reg_status ), |
| philpem@1 | 226 | .reg_interrupt (reg_interrupt ), |
| philpem@1 | 227 | .reg_bt3 (reg_bt3 ), |
| philpem@1 | 228 | .reg_bt2 (reg_bt2 ), |
| philpem@1 | 229 | .reg_bt1 (reg_bt1 ), |
| philpem@1 | 230 | .reg_bt0 (reg_bt0 ), |
| philpem@1 | 231 | .reg_s_con (reg_s_con ), |
| philpem@1 | 232 | .reg_d_con (reg_d_con ), |
| philpem@1 | 233 | .reg_incw (reg_incw ), |
| philpem@1 | 234 | .reg_inchw (reg_inchw ), |
| philpem@1 | 235 | .reg_rdelay (reg_rdelay ), |
| philpem@1 | 236 | .reg_00_data (reg_00_data ), |
| philpem@1 | 237 | .reg_04_data (reg_04_data ), |
| philpem@1 | 238 | .reg_08_data (reg_08_data ), |
| philpem@1 | 239 | // system clock and reset |
| philpem@1 | 240 | .CLK_I (CLK_I ), |
| philpem@1 | 241 | .RST_I (RST_I ) |
| philpem@1 | 242 | ); |
| philpem@1 | 243 | |
| philpem@0 | 244 | endmodule // WB_DMA_CTRL |
| philpem@0 | 245 | `endif // WB_DMA_CTRL_FILE |