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 : slave_reg.v |
| philpem@0 | 40 | // Title : DMA Slave controller |
| 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@1 | 60 | // : 1. Make DMA Engine compliant to Rule 3.100 of Wishbone Spec |
| philpem@1 | 61 | // : which defines alignement of bytes in sub-word transfers. |
| philpem@1 | 62 | // : 2. Removed glitch that did not pause the burst write when |
| philpem@1 | 63 | // : the read burst was paused by the "read slave". |
| philpem@1 | 64 | // : |
| philpem@1 | 65 | // Version : 3.2 |
| philpem@1 | 66 | // : 1. Support for 8/32-bit WISHBONE Data Bus. The Control and |
| philpem@1 | 67 | // : Read/Write Ports can be independently configured. |
| philpem@1 | 68 | // : 2. Support for burst size of 64. |
| philpem@1 | 69 | // : |
| philpem@1 | 70 | // Version : 3.3 |
| philpem@1 | 71 | // : 1. Interrupt can be release by writing 0 to IE bit in the |
| philpem@1 | 72 | // : status register. |
| philpem@0 | 73 | // ============================================================================= |
| philpem@0 | 74 | |
| philpem@0 | 75 | `ifndef SLAVE_REG_FILE |
| philpem@0 | 76 | `define SLAVE_REG_FILE |
| philpem@0 | 77 | `include "system_conf.v" |
| philpem@0 | 78 | module SLAVE_REG |
| 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 RETRY_TIMEOUT = 16, |
| philpem@0 | 84 | parameter FIFO_IMPLEMENTATION = "EBR") |
| philpem@1 | 85 | ( |
| philpem@1 | 86 | input CLK_I, |
| philpem@1 | 87 | input RST_I, |
| philpem@1 | 88 | |
| philpem@1 | 89 | // Slave port |
| philpem@1 | 90 | input [S_WB_ADR_WIDTH-1:0] S_ADR_I, |
| philpem@1 | 91 | input [S_WB_DAT_WIDTH-1:0] S_DAT_I, |
| philpem@1 | 92 | input [S_WB_DAT_WIDTH/8-1:0] S_SEL_I, |
| philpem@1 | 93 | input S_WE_I, |
| philpem@1 | 94 | input S_STB_I, |
| philpem@1 | 95 | input S_CYC_I, |
| philpem@1 | 96 | input [2:0] S_CTI_I, |
| philpem@1 | 97 | output [S_WB_DAT_WIDTH-1:0] S_DAT_O, |
| philpem@1 | 98 | output reg S_ACK_O, |
| philpem@1 | 99 | output reg S_INT_O, |
| philpem@1 | 100 | |
| philpem@1 | 101 | output reg reg_start, |
| philpem@1 | 102 | input reg_status, |
| philpem@1 | 103 | input reg_interrupt, |
| philpem@1 | 104 | input reg_busy, |
| philpem@1 | 105 | output reg reg_bt3, reg_bt2, reg_bt1, reg_bt0, |
| philpem@1 | 106 | output reg reg_s_con, reg_d_con, |
| philpem@1 | 107 | output reg reg_incw, reg_inchw, |
| philpem@1 | 108 | output reg [7:0] reg_rdelay, |
| philpem@1 | 109 | output reg [31:0] reg_00_data, |
| philpem@1 | 110 | output reg [31:0] reg_04_data, |
| philpem@1 | 111 | output reg [31:0] reg_08_data |
| philpem@1 | 112 | ); |
| philpem@1 | 113 | |
| philpem@1 | 114 | parameter UDLY = 1; |
| philpem@1 | 115 | |
| philpem@1 | 116 | reg [31:0] reg_00_data_nxt, reg_04_data_nxt, reg_08_data_nxt; |
| philpem@1 | 117 | reg [7:0] reg_0c_data, reg_0c_data_nxt; |
| philpem@1 | 118 | |
| philpem@1 | 119 | always @(/*AUTOSENSE*/reg_0c_data) |
| philpem@1 | 120 | begin |
| philpem@1 | 121 | //reg_rdelay = reg_0c_data[23:16]; |
| philpem@1 | 122 | reg_rdelay = RETRY_TIMEOUT; |
| philpem@1 | 123 | reg_bt3 = reg_0c_data[7]; |
| philpem@1 | 124 | reg_bt2 = reg_0c_data[6]; |
| philpem@1 | 125 | reg_bt1 = reg_0c_data[5]; |
| philpem@1 | 126 | reg_bt0 = reg_0c_data[4]; |
| philpem@1 | 127 | reg_incw = reg_0c_data[3]; |
| philpem@1 | 128 | reg_inchw = reg_0c_data[2]; |
| philpem@1 | 129 | reg_d_con = reg_0c_data[1]; |
| philpem@1 | 130 | reg_s_con = reg_0c_data[0]; |
| philpem@1 | 131 | end |
| philpem@1 | 132 | |
| philpem@1 | 133 | reg [2:0] read_10_data; |
| philpem@1 | 134 | reg reg_ie; |
| philpem@1 | 135 | always @(/*AUTOSENSE*/reg_busy or reg_ie or reg_status) |
| philpem@1 | 136 | begin |
| philpem@1 | 137 | read_10_data[2] = reg_status; |
| philpem@1 | 138 | read_10_data[1] = reg_ie; |
| philpem@1 | 139 | read_10_data[0] = reg_busy; |
| philpem@1 | 140 | end |
| philpem@1 | 141 | |
| philpem@1 | 142 | wire master_idle, reg_wr_rd, reg_wr, reg_rd; |
| philpem@1 | 143 | assign master_idle = ~reg_busy; |
| philpem@1 | 144 | assign reg_wr_rd = S_CYC_I & S_STB_I; |
| philpem@1 | 145 | assign reg_wr = reg_wr_rd & master_idle & S_WE_I & S_ACK_O; |
| philpem@1 | 146 | assign reg_rd = reg_wr_rd & ~S_WE_I & S_ACK_O; |
| philpem@1 | 147 | |
| philpem@1 | 148 | reg s_ack_o_pre, s_ack_o_pre_nxt; |
| philpem@1 | 149 | always @(/*AUTOSENSE*/S_CYC_I or S_STB_I or S_WE_I or master_idle |
| philpem@1 | 150 | or reg_wr_rd or s_ack_o_pre) |
| philpem@1 | 151 | begin |
| philpem@1 | 152 | if ((s_ack_o_pre == 1'b0) |
| philpem@1 | 153 | && ((master_idle && reg_wr_rd) |
| philpem@1 | 154 | || ((master_idle == 1'b0) && reg_wr_rd && (S_WE_I == 1'b0)))) |
| philpem@1 | 155 | s_ack_o_pre_nxt = 1'b1; |
| philpem@1 | 156 | else |
| philpem@1 | 157 | s_ack_o_pre_nxt = 1'b0; |
| philpem@1 | 158 | |
| philpem@1 | 159 | S_ACK_O = s_ack_o_pre && S_CYC_I && S_STB_I; |
| philpem@1 | 160 | end |
| philpem@0 | 161 | |
| philpem@0 | 162 | always @(posedge CLK_I or posedge RST_I) |
| philpem@1 | 163 | if (RST_I) |
| philpem@1 | 164 | s_ack_o_pre <= #UDLY 1'b0; |
| philpem@1 | 165 | else |
| philpem@1 | 166 | s_ack_o_pre <= #UDLY s_ack_o_pre_nxt; |
| philpem@1 | 167 | |
| philpem@1 | 168 | wire dw00_cs, dw04_cs, dw08_cs, dw0c_cs, dw10_cs; |
| philpem@1 | 169 | assign dw00_cs = (S_ADR_I[5:2] == 4'h0); |
| philpem@1 | 170 | assign dw04_cs = (S_ADR_I[5:2] == 4'h1); |
| philpem@1 | 171 | assign dw08_cs = (S_ADR_I[5:2] == 4'h2); |
| philpem@1 | 172 | assign dw0c_cs = (S_ADR_I[5:2] == 4'h3); |
| philpem@1 | 173 | assign dw10_cs = (S_ADR_I[5:2] == 4'h4); |
| philpem@1 | 174 | |
| philpem@1 | 175 | wire [31:0] S_DAT_O_int = (dw00_cs |
| philpem@1 | 176 | ? reg_00_data |
| philpem@1 | 177 | : (dw04_cs |
| philpem@1 | 178 | ? reg_04_data |
| philpem@1 | 179 | : (dw08_cs |
| philpem@1 | 180 | ? reg_08_data |
| philpem@1 | 181 | : (dw0c_cs |
| philpem@1 | 182 | ? {4{reg_0c_data}} |
| philpem@1 | 183 | : (dw10_cs |
| philpem@1 | 184 | ? {4{5'h0,read_10_data}} |
| philpem@1 | 185 | : 32'h0))))); |
| philpem@1 | 186 | generate |
| philpem@1 | 187 | if (S_WB_DAT_WIDTH == 8) begin |
| philpem@1 | 188 | |
| philpem@1 | 189 | assign S_DAT_O = ((S_ADR_I[1:0] == 2'b00) |
| philpem@1 | 190 | ? S_DAT_O_int[31:24] |
| philpem@1 | 191 | : ((S_ADR_I[1:0] == 2'b01) |
| philpem@1 | 192 | ? S_DAT_O_int[23:16] |
| philpem@1 | 193 | : ((S_ADR_I[1:0] == 2'b10) |
| philpem@1 | 194 | ? S_DAT_O_int[15:8] |
| philpem@1 | 195 | : S_DAT_O_int[7:0]))); |
| philpem@1 | 196 | |
| philpem@1 | 197 | end |
| philpem@1 | 198 | else begin |
| philpem@1 | 199 | |
| philpem@1 | 200 | assign S_DAT_O = S_DAT_O_int; |
| philpem@1 | 201 | |
| philpem@1 | 202 | end |
| philpem@1 | 203 | endgenerate |
| philpem@1 | 204 | |
| philpem@1 | 205 | |
| philpem@1 | 206 | |
| philpem@1 | 207 | // Interrupt |
| philpem@1 | 208 | generate |
| philpem@1 | 209 | if (S_WB_DAT_WIDTH == 8) begin |
| philpem@1 | 210 | |
| philpem@1 | 211 | always @(posedge CLK_I or posedge RST_I) |
| philpem@1 | 212 | begin |
| philpem@1 | 213 | if(RST_I) |
| philpem@1 | 214 | S_INT_O <= #UDLY 1'b0; |
| philpem@1 | 215 | else if(reg_interrupt && reg_ie) |
| philpem@1 | 216 | S_INT_O <= #UDLY 1'b1; |
| philpem@1 | 217 | else if(dw10_cs && (reg_rd || (reg_wr && (S_DAT_I[1] == 1'b0)))) |
| philpem@1 | 218 | S_INT_O <= #UDLY 1'b0; |
| philpem@1 | 219 | end |
| philpem@1 | 220 | |
| philpem@1 | 221 | end |
| philpem@1 | 222 | else begin |
| philpem@1 | 223 | |
| philpem@1 | 224 | always @(posedge CLK_I or posedge RST_I) |
| philpem@1 | 225 | begin |
| philpem@1 | 226 | if(RST_I) |
| philpem@1 | 227 | S_INT_O <= #UDLY 1'b0; |
| philpem@1 | 228 | else if(reg_interrupt && reg_ie) |
| philpem@1 | 229 | S_INT_O <= #UDLY 1'b1; |
| philpem@1 | 230 | else if(dw10_cs && (reg_rd || (reg_wr && (S_DAT_I[25] == 1'b0)))) |
| philpem@1 | 231 | S_INT_O <= #UDLY 1'b0; |
| philpem@1 | 232 | end |
| philpem@1 | 233 | |
| philpem@1 | 234 | end |
| philpem@1 | 235 | endgenerate |
| philpem@1 | 236 | |
| philpem@1 | 237 | // reg_00 |
| philpem@1 | 238 | generate |
| philpem@1 | 239 | if (S_WB_DAT_WIDTH == 8) begin |
| philpem@0 | 240 | |
| philpem@1 | 241 | always @(/*AUTOSENSE*/S_ADR_I or S_DAT_I or dw00_cs |
| philpem@1 | 242 | or reg_00_data or reg_wr) |
| philpem@1 | 243 | begin |
| philpem@1 | 244 | if (dw00_cs && reg_wr) begin |
| philpem@1 | 245 | casez (S_ADR_I[1:0]) |
| philpem@1 | 246 | 2'b00: reg_00_data_nxt = { S_DAT_I[7:0], reg_00_data[23: 0]}; |
| philpem@1 | 247 | 2'b01: reg_00_data_nxt = {reg_00_data[31:24], S_DAT_I[7:0], reg_00_data[15: 0]}; |
| philpem@1 | 248 | 2'b10: reg_00_data_nxt = {reg_00_data[31:16], S_DAT_I[7:0], reg_00_data[ 7: 0]}; |
| philpem@1 | 249 | 2'b11: reg_00_data_nxt = {reg_00_data[31: 8], S_DAT_I[7:0] }; |
| philpem@1 | 250 | |
| philpem@1 | 251 | default: |
| philpem@1 | 252 | reg_00_data_nxt = reg_00_data; |
| philpem@1 | 253 | endcase |
| philpem@1 | 254 | end |
| philpem@1 | 255 | else |
| philpem@1 | 256 | reg_00_data_nxt = reg_00_data; |
| philpem@1 | 257 | end |
| philpem@1 | 258 | |
| philpem@1 | 259 | end |
| philpem@1 | 260 | else begin |
| philpem@1 | 261 | |
| philpem@1 | 262 | always @(/*AUTOSENSE*/S_DAT_I or S_SEL_I or dw00_cs |
| philpem@1 | 263 | or reg_00_data or reg_wr) |
| philpem@1 | 264 | begin |
| philpem@1 | 265 | if (dw00_cs && reg_wr) begin |
| philpem@1 | 266 | casez (S_SEL_I) |
| philpem@1 | 267 | 4'b1000: reg_00_data_nxt = { S_DAT_I[31:24], reg_00_data[23:0]}; |
| philpem@1 | 268 | 4'b0100: reg_00_data_nxt = {reg_00_data[31:24], S_DAT_I[23:16], reg_00_data[15:0]}; |
| philpem@1 | 269 | 4'b0010: reg_00_data_nxt = {reg_00_data[31:16], S_DAT_I[15: 8], reg_00_data[ 7:0]}; |
| philpem@1 | 270 | 4'b0001: reg_00_data_nxt = {reg_00_data[31: 8], S_DAT_I[ 7: 0] }; |
| philpem@1 | 271 | 4'b1111: reg_00_data_nxt = S_DAT_I[31: 0] ; |
| philpem@1 | 272 | |
| philpem@1 | 273 | default: |
| philpem@1 | 274 | reg_00_data_nxt = reg_00_data; |
| philpem@1 | 275 | endcase |
| philpem@1 | 276 | end |
| philpem@1 | 277 | else |
| philpem@1 | 278 | reg_00_data_nxt = reg_00_data; |
| philpem@1 | 279 | end |
| philpem@1 | 280 | |
| philpem@1 | 281 | end |
| philpem@1 | 282 | endgenerate |
| philpem@1 | 283 | |
| philpem@1 | 284 | always @(posedge CLK_I or posedge RST_I) |
| philpem@1 | 285 | if (RST_I) |
| philpem@1 | 286 | reg_00_data <= #UDLY 32'b0; |
| philpem@1 | 287 | else |
| philpem@1 | 288 | reg_00_data <= #UDLY reg_00_data_nxt; |
| philpem@1 | 289 | |
| philpem@1 | 290 | |
| philpem@1 | 291 | |
| philpem@1 | 292 | // reg_04 |
| philpem@1 | 293 | generate |
| philpem@1 | 294 | if (S_WB_DAT_WIDTH == 8) begin |
| philpem@0 | 295 | |
| philpem@1 | 296 | always @(/*AUTOSENSE*/S_ADR_I or S_DAT_I or dw04_cs |
| philpem@1 | 297 | or reg_04_data or reg_wr) |
| philpem@1 | 298 | begin |
| philpem@1 | 299 | if (dw04_cs && reg_wr) begin |
| philpem@1 | 300 | casez (S_ADR_I[1:0]) |
| philpem@1 | 301 | 2'b00: reg_04_data_nxt = { S_DAT_I[7:0], reg_04_data[23: 0]}; |
| philpem@1 | 302 | 2'b01: reg_04_data_nxt = {reg_04_data[31:24], S_DAT_I[7:0], reg_04_data[15: 0]}; |
| philpem@1 | 303 | 2'b10: reg_04_data_nxt = {reg_04_data[31:16], S_DAT_I[7:0], reg_04_data[ 7: 0]}; |
| philpem@1 | 304 | 2'b11: reg_04_data_nxt = {reg_04_data[31: 8], S_DAT_I[7:0] }; |
| philpem@1 | 305 | |
| philpem@1 | 306 | default: |
| philpem@1 | 307 | reg_04_data_nxt = reg_04_data; |
| philpem@1 | 308 | endcase |
| philpem@1 | 309 | end |
| philpem@1 | 310 | else |
| philpem@1 | 311 | reg_04_data_nxt = reg_04_data; |
| philpem@1 | 312 | end |
| philpem@1 | 313 | |
| philpem@1 | 314 | end |
| philpem@1 | 315 | else begin |
| philpem@1 | 316 | |
| philpem@1 | 317 | always @(/*AUTOSENSE*/S_DAT_I or S_SEL_I or dw04_cs |
| philpem@1 | 318 | or reg_04_data or reg_wr) |
| philpem@1 | 319 | begin |
| philpem@1 | 320 | if (dw04_cs && reg_wr) begin |
| philpem@1 | 321 | casez (S_SEL_I) |
| philpem@1 | 322 | 4'b1000: reg_04_data_nxt = { S_DAT_I[31:24], reg_04_data[23:0]}; |
| philpem@1 | 323 | 4'b0100: reg_04_data_nxt = {reg_04_data[31:24], S_DAT_I[23:16], reg_04_data[15:0]}; |
| philpem@1 | 324 | 4'b0010: reg_04_data_nxt = {reg_04_data[31:16], S_DAT_I[15: 8], reg_04_data[ 7:0]}; |
| philpem@1 | 325 | 4'b0001: reg_04_data_nxt = {reg_04_data[31: 8], S_DAT_I[ 7: 0] }; |
| philpem@1 | 326 | 4'b1111: reg_04_data_nxt = { S_DAT_I[31: 0] }; |
| philpem@1 | 327 | |
| philpem@1 | 328 | default: |
| philpem@1 | 329 | reg_04_data_nxt = reg_04_data; |
| philpem@1 | 330 | endcase |
| philpem@1 | 331 | end |
| philpem@1 | 332 | else |
| philpem@1 | 333 | reg_04_data_nxt = reg_04_data; |
| philpem@1 | 334 | end |
| philpem@1 | 335 | |
| philpem@1 | 336 | end |
| philpem@1 | 337 | endgenerate |
| philpem@1 | 338 | |
| philpem@0 | 339 | always @(posedge CLK_I or posedge RST_I) |
| philpem@1 | 340 | if (RST_I) |
| philpem@1 | 341 | reg_04_data <= #UDLY 32'b0; |
| philpem@1 | 342 | else |
| philpem@1 | 343 | reg_04_data <= #UDLY reg_04_data_nxt; |
| philpem@1 | 344 | |
| philpem@1 | 345 | |
| philpem@1 | 346 | |
| philpem@1 | 347 | // reg_08 |
| philpem@1 | 348 | generate |
| philpem@1 | 349 | if (S_WB_DAT_WIDTH == 8) begin |
| philpem@0 | 350 | |
| philpem@1 | 351 | always @(/*AUTOSENSE*/S_ADR_I or S_DAT_I or dw08_cs |
| philpem@1 | 352 | or reg_08_data or reg_wr) |
| philpem@1 | 353 | if (dw08_cs && reg_wr) begin |
| philpem@1 | 354 | casez (S_ADR_I[1:0]) |
| philpem@1 | 355 | 2'b00: reg_08_data_nxt = { S_DAT_I[7:0], reg_08_data[23: 0]}; |
| philpem@1 | 356 | 2'b01: reg_08_data_nxt = {reg_08_data[31:24], S_DAT_I[7:0], reg_08_data[15: 0]}; |
| philpem@1 | 357 | 2'b10: reg_08_data_nxt = {reg_08_data[31:16], S_DAT_I[7:0], reg_08_data[ 7: 0]}; |
| philpem@1 | 358 | 2'b11: reg_08_data_nxt = {reg_08_data[31: 8], S_DAT_I[7:0] }; |
| philpem@1 | 359 | |
| philpem@1 | 360 | default: |
| philpem@1 | 361 | reg_08_data_nxt = reg_08_data; |
| philpem@1 | 362 | endcase |
| philpem@1 | 363 | end |
| philpem@1 | 364 | |
| philpem@1 | 365 | end |
| philpem@1 | 366 | else begin |
| philpem@1 | 367 | |
| philpem@1 | 368 | always @(/*AUTOSENSE*/S_DAT_I or S_SEL_I or dw08_cs |
| philpem@1 | 369 | or reg_08_data or reg_wr) |
| philpem@1 | 370 | if (dw08_cs && reg_wr) begin |
| philpem@1 | 371 | casez (S_SEL_I) |
| philpem@1 | 372 | 4'b1000: reg_08_data_nxt = { S_DAT_I[31:24], reg_08_data[23:0]}; |
| philpem@1 | 373 | 4'b0100: reg_08_data_nxt = {reg_08_data[31:24], S_DAT_I[23:16], reg_08_data[15:0]}; |
| philpem@1 | 374 | 4'b0010: reg_08_data_nxt = {reg_08_data[31:16], S_DAT_I[15: 8], reg_08_data[ 7:0]}; |
| philpem@1 | 375 | 4'b0001: reg_08_data_nxt = {reg_08_data[31: 8], S_DAT_I[ 7: 0] }; |
| philpem@1 | 376 | 4'b1111: reg_08_data_nxt = { S_DAT_I[31: 0] }; |
| philpem@1 | 377 | |
| philpem@1 | 378 | default: |
| philpem@1 | 379 | reg_08_data_nxt = reg_08_data; |
| philpem@1 | 380 | endcase |
| philpem@1 | 381 | end |
| philpem@1 | 382 | |
| philpem@1 | 383 | end |
| philpem@1 | 384 | endgenerate |
| philpem@1 | 385 | |
| philpem@0 | 386 | always @(posedge CLK_I or posedge RST_I) |
| philpem@1 | 387 | if (RST_I) |
| philpem@1 | 388 | reg_08_data <= #UDLY 0; |
| philpem@1 | 389 | else |
| philpem@1 | 390 | reg_08_data <= #UDLY reg_08_data_nxt[31:0]; |
| philpem@1 | 391 | |
| philpem@1 | 392 | |
| philpem@1 | 393 | |
| philpem@1 | 394 | // reg_0c |
| philpem@1 | 395 | generate |
| philpem@1 | 396 | if (S_WB_DAT_WIDTH == 8) begin |
| philpem@1 | 397 | |
| philpem@1 | 398 | always @(/*AUTOSENSE*/S_DAT_I or dw0c_cs or reg_0c_data |
| philpem@1 | 399 | or reg_wr) |
| philpem@1 | 400 | if (dw0c_cs && reg_wr) |
| philpem@1 | 401 | reg_0c_data_nxt = S_DAT_I[7:0]; |
| philpem@1 | 402 | else |
| philpem@1 | 403 | reg_0c_data_nxt = reg_0c_data; |
| philpem@1 | 404 | |
| philpem@1 | 405 | end |
| philpem@1 | 406 | else begin |
| philpem@1 | 407 | |
| philpem@1 | 408 | always @(/*AUTOSENSE*/S_DAT_I or S_SEL_I or dw0c_cs |
| philpem@1 | 409 | or reg_0c_data or reg_wr) |
| philpem@1 | 410 | if (dw0c_cs && reg_wr) |
| philpem@1 | 411 | reg_0c_data_nxt = S_DAT_I[31:24]; |
| philpem@1 | 412 | else |
| philpem@1 | 413 | reg_0c_data_nxt = reg_0c_data; |
| philpem@1 | 414 | |
| philpem@1 | 415 | end |
| philpem@1 | 416 | endgenerate |
| philpem@1 | 417 | |
| philpem@0 | 418 | always @(posedge CLK_I or posedge RST_I) |
| philpem@1 | 419 | if (RST_I) |
| philpem@1 | 420 | reg_0c_data <= #UDLY 8'b0; |
| philpem@1 | 421 | else |
| philpem@1 | 422 | reg_0c_data <= #UDLY reg_0c_data_nxt; |
| philpem@1 | 423 | |
| philpem@1 | 424 | |
| philpem@1 | 425 | |
| philpem@1 | 426 | // reg_10 |
| philpem@1 | 427 | reg reg_ie_nxt, reg_start_nxt; |
| philpem@1 | 428 | generate |
| philpem@1 | 429 | if (S_WB_DAT_WIDTH == 8) begin |
| philpem@1 | 430 | |
| philpem@1 | 431 | always @(/*AUTOSENSE*/S_DAT_I or dw10_cs or reg_ie or reg_wr) |
| philpem@1 | 432 | if (dw10_cs && reg_wr) |
| philpem@1 | 433 | begin |
| philpem@1 | 434 | reg_ie_nxt = S_DAT_I[1]; |
| philpem@1 | 435 | reg_start_nxt = S_DAT_I[3]; |
| philpem@1 | 436 | end |
| philpem@1 | 437 | else |
| philpem@1 | 438 | begin |
| philpem@1 | 439 | reg_ie_nxt = reg_ie; |
| philpem@1 | 440 | reg_start_nxt = 1'b0; |
| philpem@1 | 441 | end |
| philpem@1 | 442 | |
| philpem@1 | 443 | end |
| philpem@1 | 444 | else begin |
| philpem@1 | 445 | |
| philpem@1 | 446 | always @(/*AUTOSENSE*/S_DAT_I or S_SEL_I or dw10_cs or reg_ie |
| philpem@1 | 447 | or reg_wr) |
| philpem@1 | 448 | if (dw10_cs && reg_wr) |
| philpem@1 | 449 | begin |
| philpem@1 | 450 | reg_ie_nxt = S_DAT_I[25]; |
| philpem@1 | 451 | reg_start_nxt = S_DAT_I[27]; |
| philpem@1 | 452 | end |
| philpem@1 | 453 | else |
| philpem@1 | 454 | begin |
| philpem@1 | 455 | reg_ie_nxt = reg_ie; |
| philpem@1 | 456 | reg_start_nxt = 1'b0; |
| philpem@1 | 457 | end |
| philpem@1 | 458 | |
| philpem@1 | 459 | end |
| philpem@1 | 460 | endgenerate |
| philpem@1 | 461 | |
| philpem@0 | 462 | always @(posedge CLK_I or posedge RST_I) |
| philpem@1 | 463 | if (RST_I) |
| philpem@0 | 464 | begin |
| philpem@1 | 465 | reg_ie <= #UDLY 1'b0; |
| philpem@1 | 466 | reg_start <= #UDLY 1'b0; |
| philpem@1 | 467 | end |
| philpem@1 | 468 | else |
| philpem@0 | 469 | begin |
| philpem@1 | 470 | reg_ie <= #UDLY reg_ie_nxt; |
| philpem@1 | 471 | reg_start <= #UDLY reg_start_nxt; |
| philpem@0 | 472 | end |
| philpem@1 | 473 | |
| philpem@0 | 474 | endmodule // SLAVE_REG |
| philpem@0 | 475 | `endif // SLAVE_REG_FILE |