6 input wire [3:0] can_rx,
7 output wire [3:0] can_tx,
8 input wire [3:0] ifc_tx,
9 output wire [3:0] ifc_rx,
12 input wire [31:0] ctrl_word
24 assign {can4_line, can3_line, can2_line, can1_line} = ctrl_word[7:0];
25 assign {ifc4_line, ifc3_line, ifc2_line, ifc1_line} = ctrl_word[15:8];
26 assign can_en = ctrl_word[19:16];
27 assign can_stby = ctrl_word[20];
29 wire [3:0] can_line_rx;
33 assign ifc_rx[0] = line_rx[ifc1_line];
34 assign ifc_rx[1] = line_rx[ifc2_line];
35 assign ifc_rx[2] = line_rx[ifc3_line];
36 assign ifc_rx[3] = line_rx[ifc4_line];
38 assign can_line_rx[0] =
39 (can1_line == 0 ? can_rx[0] : 1'b1)
40 & (can2_line == 0 ? can_rx[1] : 1'b1)
41 & (can3_line == 0 ? can_rx[2] : 1'b1)
42 & (can4_line == 0 ? can_rx[3] : 1'b1);
43 assign can_line_rx[1] =
44 (can1_line == 1 ? can_rx[0] : 1'b1)
45 & (can2_line == 1 ? can_rx[1] : 1'b1)
46 & (can3_line == 1 ? can_rx[2] : 1'b1)
47 & (can4_line == 1 ? can_rx[3] : 1'b1);
48 assign can_line_rx[2] =
49 (can1_line == 2 ? can_rx[0] : 1'b1)
50 & (can2_line == 2 ? can_rx[1] : 1'b1)
51 & (can3_line == 2 ? can_rx[2] : 1'b1)
52 & (can4_line == 2 ? can_rx[3] : 1'b1);
53 assign can_line_rx[3] =
54 (can1_line == 3 ? can_rx[0] : 1'b1)
55 & (can2_line == 3 ? can_rx[1] : 1'b1)
56 & (can3_line == 3 ? can_rx[2] : 1'b1)
57 & (can4_line == 3 ? can_rx[3] : 1'b1);
59 assign line_rx[0] = can_en[0] ? can_line_rx[0] : line_tx[0];
60 assign line_rx[1] = can_en[1] ? can_line_rx[1] : line_tx[1];
61 assign line_rx[2] = can_en[2] ? can_line_rx[2] : line_tx[2];
62 assign line_rx[3] = can_en[3] ? can_line_rx[3] : line_tx[3];
64 assign can_tx[0] = can_en[0] ? line_tx[can1_line] : 1'b1;
65 assign can_tx[1] = can_en[1] ? line_tx[can2_line] : 1'b1;
66 assign can_tx[2] = can_en[2] ? line_tx[can3_line] : 1'b1;
67 assign can_tx[3] = can_en[3] ? line_tx[can4_line] : 1'b1;
69 assign line_tx[0] = (ifc1_line == 0 ? ifc_tx[0] : 1'b1)
70 & (ifc2_line == 0 ? ifc_tx[1] : 1'b1)
71 & (ifc3_line == 0 ? ifc_tx[2] : 1'b1)
72 & (ifc4_line == 0 ? ifc_tx[3] : 1'b1);
73 assign line_tx[1] = (ifc1_line == 1 ? ifc_tx[0] : 1'b1)
74 & (ifc2_line == 1 ? ifc_tx[1] : 1'b1)
75 & (ifc3_line == 1 ? ifc_tx[2] : 1'b1)
76 & (ifc4_line == 1 ? ifc_tx[3] : 1'b1);
77 assign line_tx[2] = (ifc1_line == 2 ? ifc_tx[0] : 1'b1)
78 & (ifc2_line == 2 ? ifc_tx[1] : 1'b1)
79 & (ifc3_line == 2 ? ifc_tx[2] : 1'b1)
80 & (ifc4_line == 2 ? ifc_tx[3] : 1'b1);
81 assign line_tx[3] = (ifc1_line == 3 ? ifc_tx[0] : 1'b1)
82 & (ifc2_line == 3 ? ifc_tx[1] : 1'b1)
83 & (ifc3_line == 3 ? ifc_tx[2] : 1'b1)
84 & (ifc4_line == 3 ? ifc_tx[3] : 1'b1);
88 module can_crossbar_v1_0_S00_AXI #
90 // Users to add parameters here
92 // User parameters ends
93 // Do not modify the parameters beyond this line
95 // Width of S_AXI data bus
96 parameter integer C_S_AXI_DATA_WIDTH = 32,
97 // Width of S_AXI address bus
98 parameter integer C_S_AXI_ADDR_WIDTH = 4
101 // Users to add ports here
102 input wire [3:0] can_rx,
103 output wire [3:0] can_tx,
104 input wire [3:0] ifc_tx,
105 output wire [3:0] ifc_rx,
106 output wire can_stby,
108 // Do not modify the ports beyond this line
110 // Global Clock Signal
111 input wire S_AXI_ACLK,
112 // Global Reset Signal. This Signal is Active LOW
113 input wire S_AXI_ARESETN,
114 // Write address (issued by master, acceped by Slave)
115 input wire [C_S_AXI_ADDR_WIDTH-1 : 0] S_AXI_AWADDR,
116 // Write channel Protection type. This signal indicates the
117 // privilege and security level of the transaction, and whether
118 // the transaction is a data access or an instruction access.
119 input wire [2 : 0] S_AXI_AWPROT,
120 // Write address valid. This signal indicates that the master signaling
121 // valid write address and control information.
122 input wire S_AXI_AWVALID,
123 // Write address ready. This signal indicates that the slave is ready
124 // to accept an address and associated control signals.
125 output wire S_AXI_AWREADY,
126 // Write data (issued by master, acceped by Slave)
127 input wire [C_S_AXI_DATA_WIDTH-1 : 0] S_AXI_WDATA,
128 // Write strobes. This signal indicates which byte lanes hold
129 // valid data. There is one write strobe bit for each eight
130 // bits of the write data bus.
131 input wire [(C_S_AXI_DATA_WIDTH/8)-1 : 0] S_AXI_WSTRB,
132 // Write valid. This signal indicates that valid write
133 // data and strobes are available.
134 input wire S_AXI_WVALID,
135 // Write ready. This signal indicates that the slave
136 // can accept the write data.
137 output wire S_AXI_WREADY,
138 // Write response. This signal indicates the status
139 // of the write transaction.
140 output wire [1 : 0] S_AXI_BRESP,
141 // Write response valid. This signal indicates that the channel
142 // is signaling a valid write response.
143 output wire S_AXI_BVALID,
144 // Response ready. This signal indicates that the master
145 // can accept a write response.
146 input wire S_AXI_BREADY,
147 // Read address (issued by master, acceped by Slave)
148 input wire [C_S_AXI_ADDR_WIDTH-1 : 0] S_AXI_ARADDR,
149 // Protection type. This signal indicates the privilege
150 // and security level of the transaction, and whether the
151 // transaction is a data access or an instruction access.
152 input wire [2 : 0] S_AXI_ARPROT,
153 // Read address valid. This signal indicates that the channel
154 // is signaling valid read address and control information.
155 input wire S_AXI_ARVALID,
156 // Read address ready. This signal indicates that the slave is
157 // ready to accept an address and associated control signals.
158 output wire S_AXI_ARREADY,
159 // Read data (issued by slave)
160 output wire [C_S_AXI_DATA_WIDTH-1 : 0] S_AXI_RDATA,
161 // Read response. This signal indicates the status of the
163 output wire [1 : 0] S_AXI_RRESP,
164 // Read valid. This signal indicates that the channel is
165 // signaling the required read data.
166 output wire S_AXI_RVALID,
167 // Read ready. This signal indicates that the master can
168 // accept the read data and response information.
169 input wire S_AXI_RREADY
173 reg [C_S_AXI_ADDR_WIDTH-1 : 0] axi_awaddr;
176 reg [1 : 0] axi_bresp;
178 reg [C_S_AXI_ADDR_WIDTH-1 : 0] axi_araddr;
180 reg [C_S_AXI_DATA_WIDTH-1 : 0] axi_rdata;
181 reg [1 : 0] axi_rresp;
184 // Example-specific design signals
185 // local parameter for addressing 32 bit / 64 bit C_S_AXI_DATA_WIDTH
186 // ADDR_LSB is used for addressing 32/64 bit registers/memories
187 // ADDR_LSB = 2 for 32 bits (n downto 2)
188 // ADDR_LSB = 3 for 64 bits (n downto 3)
189 localparam integer ADDR_LSB = (C_S_AXI_DATA_WIDTH/32) + 1;
190 localparam integer OPT_MEM_ADDR_BITS = 1;
191 //----------------------------------------------
192 //-- Signals for user logic register space example
193 //------------------------------------------------
194 //-- Number of Slave Registers 4
195 reg [C_S_AXI_DATA_WIDTH-1:0] slv_reg0;
196 reg [C_S_AXI_DATA_WIDTH-1:0] slv_reg1;
197 wire [C_S_AXI_DATA_WIDTH-1:0] slv_reg2;
198 reg [C_S_AXI_DATA_WIDTH-1:0] slv_reg3;
201 reg [C_S_AXI_DATA_WIDTH-1:0] reg_data_out;
204 // I/O Connections assignments
206 assign S_AXI_AWREADY = axi_awready;
207 assign S_AXI_WREADY = axi_wready;
208 assign S_AXI_BRESP = axi_bresp;
209 assign S_AXI_BVALID = axi_bvalid;
210 assign S_AXI_ARREADY = axi_arready;
211 assign S_AXI_RDATA = axi_rdata;
212 assign S_AXI_RRESP = axi_rresp;
213 assign S_AXI_RVALID = axi_rvalid;
214 // Implement axi_awready generation
215 // axi_awready is asserted for one S_AXI_ACLK clock cycle when both
216 // S_AXI_AWVALID and S_AXI_WVALID are asserted. axi_awready is
217 // de-asserted when reset is low.
219 always @( posedge S_AXI_ACLK )
221 if ( S_AXI_ARESETN == 1'b0 )
227 if (~axi_awready && S_AXI_AWVALID && S_AXI_WVALID)
229 // slave is ready to accept write address when
230 // there is a valid write address and write data
231 // on the write address and data bus. This design
232 // expects no outstanding transactions.
242 // Implement axi_awaddr latching
243 // This process is used to latch the address when both
244 // S_AXI_AWVALID and S_AXI_WVALID are valid.
246 always @( posedge S_AXI_ACLK )
248 if ( S_AXI_ARESETN == 1'b0 )
254 if (~axi_awready && S_AXI_AWVALID && S_AXI_WVALID)
256 // Write Address latching
257 axi_awaddr <= S_AXI_AWADDR;
262 // Implement axi_wready generation
263 // axi_wready is asserted for one S_AXI_ACLK clock cycle when both
264 // S_AXI_AWVALID and S_AXI_WVALID are asserted. axi_wready is
265 // de-asserted when reset is low.
267 always @( posedge S_AXI_ACLK )
269 if ( S_AXI_ARESETN == 1'b0 )
275 if (~axi_wready && S_AXI_WVALID && S_AXI_AWVALID)
277 // slave is ready to accept write data when
278 // there is a valid write address and write data
279 // on the write address and data bus. This design
280 // expects no outstanding transactions.
290 // Implement memory mapped register select and write logic generation
291 // The write data is accepted and written to memory mapped registers when
292 // axi_awready, S_AXI_WVALID, axi_wready and S_AXI_WVALID are asserted. Write strobes are used to
293 // select byte enables of slave registers while writing.
294 // These registers are cleared when reset (active low) is applied.
295 // Slave register write enable is asserted when valid address and data are available
296 // and the slave is ready to accept the write address and write data.
297 assign slv_reg_wren = axi_wready && S_AXI_WVALID && axi_awready && S_AXI_AWVALID;
299 always @( posedge S_AXI_ACLK )
301 if ( S_AXI_ARESETN == 1'b0 )
303 slv_reg0 <= 32'b0_1111_11_10_01_00_11_10_01_00;
311 case ( axi_awaddr[ADDR_LSB+OPT_MEM_ADDR_BITS:ADDR_LSB] )
313 for ( byte_index = 0; byte_index <= (C_S_AXI_DATA_WIDTH/8)-1; byte_index = byte_index+1 )
314 if ( S_AXI_WSTRB[byte_index] == 1 ) begin
315 // Respective byte enables are asserted as per write strobes
317 slv_reg0[(byte_index*8) +: 8] <= S_AXI_WDATA[(byte_index*8) +: 8];
320 for ( byte_index = 0; byte_index <= (C_S_AXI_DATA_WIDTH/8)-1; byte_index = byte_index+1 )
321 if ( S_AXI_WSTRB[byte_index] == 1 ) begin
322 // Respective byte enables are asserted as per write strobes
324 slv_reg1[(byte_index*8) +: 8] <= S_AXI_WDATA[(byte_index*8) +: 8];
327 for ( byte_index = 0; byte_index <= (C_S_AXI_DATA_WIDTH/8)-1; byte_index = byte_index+1 )
328 if ( S_AXI_WSTRB[byte_index] == 1 ) begin
329 // Respective byte enables are asserted as per write strobes
331 slv_reg2[(byte_index*8) +: 8] <= S_AXI_WDATA[(byte_index*8) +: 8];
334 for ( byte_index = 0; byte_index <= (C_S_AXI_DATA_WIDTH/8)-1; byte_index = byte_index+1 )
335 if ( S_AXI_WSTRB[byte_index] == 1 ) begin
336 // Respective byte enables are asserted as per write strobes
338 slv_reg3[(byte_index*8) +: 8] <= S_AXI_WDATA[(byte_index*8) +: 8];
341 slv_reg0 <= slv_reg0;
342 slv_reg1 <= slv_reg1;
343 //slv_reg2 <= slv_reg2;
344 slv_reg3 <= slv_reg3;
351 // Implement write response logic generation
352 // The write response and response valid signals are asserted by the slave
353 // when axi_wready, S_AXI_WVALID, axi_wready and S_AXI_WVALID are asserted.
354 // This marks the acceptance of address and indicates the status of
355 // write transaction.
357 always @( posedge S_AXI_ACLK )
359 if ( S_AXI_ARESETN == 1'b0 )
366 if (axi_awready && S_AXI_AWVALID && ~axi_bvalid && axi_wready && S_AXI_WVALID)
368 // indicates a valid write response is available
370 axi_bresp <= 2'b0; // 'OKAY' response
371 end // work error responses in future
374 if (S_AXI_BREADY && axi_bvalid)
375 //check if bready is asserted while bvalid is high)
376 //(there is a possibility that bready is always asserted high)
384 // Implement axi_arready generation
385 // axi_arready is asserted for one S_AXI_ACLK clock cycle when
386 // S_AXI_ARVALID is asserted. axi_awready is
387 // de-asserted when reset (active low) is asserted.
388 // The read address is also latched when S_AXI_ARVALID is
389 // asserted. axi_araddr is reset to zero on reset assertion.
391 always @( posedge S_AXI_ACLK )
393 if ( S_AXI_ARESETN == 1'b0 )
400 if (~axi_arready && S_AXI_ARVALID)
402 // indicates that the slave has acceped the valid read address
404 // Read address latching
405 axi_araddr <= S_AXI_ARADDR;
414 // Implement axi_arvalid generation
415 // axi_rvalid is asserted for one S_AXI_ACLK clock cycle when both
416 // S_AXI_ARVALID and axi_arready are asserted. The slave registers
417 // data are available on the axi_rdata bus at this instance. The
418 // assertion of axi_rvalid marks the validity of read data on the
419 // bus and axi_rresp indicates the status of read transaction.axi_rvalid
420 // is deasserted on reset (active low). axi_rresp and axi_rdata are
421 // cleared to zero on reset (active low).
422 always @( posedge S_AXI_ACLK )
424 if ( S_AXI_ARESETN == 1'b0 )
431 if (axi_arready && S_AXI_ARVALID && ~axi_rvalid)
433 // Valid read data is available at the read data bus
435 axi_rresp <= 2'b0; // 'OKAY' response
437 else if (axi_rvalid && S_AXI_RREADY)
439 // Read data is accepted by the master
445 // Implement memory mapped register select and read logic generation
446 // Slave register read enable is asserted when valid address is available
447 // and the slave is ready to accept the read address.
448 assign slv_reg_rden = axi_arready & S_AXI_ARVALID & ~axi_rvalid;
451 // Address decoding for reading registers
452 case ( axi_araddr[ADDR_LSB+OPT_MEM_ADDR_BITS:ADDR_LSB] )
453 2'h0 : reg_data_out <= slv_reg0;
454 2'h1 : reg_data_out <= slv_reg1;
455 2'h2 : reg_data_out <= slv_reg2;
456 2'h3 : reg_data_out <= slv_reg3;
457 default : reg_data_out <= 0;
461 // Output register or memory read data
462 always @( posedge S_AXI_ACLK )
464 if ( S_AXI_ARESETN == 1'b0 )
470 // When there is a valid read address (S_AXI_ARVALID) with
471 // acceptance of read address by the slave (axi_arready),
472 // output the read dada
475 axi_rdata <= reg_data_out; // register read data
480 // Add user logic here
481 cross_impl #() cross_inst
491 wire [3:0] test_can_rx;
492 wire [3:0] test_can_tx;
493 wire [3:0] test_ifc_rx;
494 wire [3:0] test_ifc_tx;
495 assign {test_can_rx, test_ifc_tx} = slv_reg1[7:0];
496 assign slv_reg2 = {24'h0, test_ifc_rx, test_can_tx};
497 cross_impl #() cross_test_inst
499 .can_rx(test_can_rx),
500 .can_tx(test_can_tx),
501 .ifc_rx(test_ifc_rx),
502 .ifc_tx(test_ifc_tx),