File tree Expand file tree Collapse file tree 5 files changed +24
-8
lines changed Expand file tree Collapse file tree 5 files changed +24
-8
lines changed Original file line number Diff line number Diff line change 3636`timescale 1ns/ 100ps
3737
3838module ad9084_ebz_spi #(
39- parameter NUM_OF_SLAVES = 8
39+ parameter NUM_OF_SLAVES = 8 ,
40+ parameter IS_4WIRE = 8'b00000001
4041) (
4142 input [NUM_OF_SLAVES- 1 :0 ] spi_csn,
4243 input spi_clk,
@@ -57,6 +58,8 @@ module ad9084_ebz_spi #(
5758 wire spi_csn_s;
5859 wire spi_enable_s;
5960
61+ wire [NUM_OF_SLAVES- 1 :0 ] spi_csn_4wire;
62+
6063 // check on rising edge and change on falling edge
6164
6265 assign spi_csn_s = & spi_csn;
@@ -86,7 +89,15 @@ module ad9084_ebz_spi #(
8689
8790 // io buffer
8891
89- assign spi_miso = (spi_csn[0 ] == 1'b0 ) ? spi_miso_in : spi_sdio;
92+ genvar i;
93+
94+ generate
95+ for (i = 0 ; i < NUM_OF_SLAVES ; i = i + 1 ) begin
96+ assign spi_csn_4wire[i] = (IS_4WIRE[i] == 1'b1 ) ? spi_csn[i] : 1'b1 ;
97+ end
98+ endgenerate
99+
100+ assign spi_miso = (& spi_csn_4wire == 1'b0 ) ? spi_miso_in : spi_sdio;
90101 assign spi_sdio = (spi_enable_s == 1'b1 ) ? 1'bz : spi_mosi;
91102
92103endmodule
Original file line number Diff line number Diff line change @@ -224,7 +224,8 @@ module system_top #(
224224 assign spi2_sclk = spi_clk;
225225
226226 ad9084_ebz_spi #(
227- .NUM_OF_SLAVES(2 )
227+ .NUM_OF_SLAVES(2 ),
228+ .IS_4WIRE(2'b01 )
228229 ) i_spi (
229230 .spi_csn (spi_csn[1 :0 ]),
230231 .spi_clk (spi_clk),
Original file line number Diff line number Diff line change @@ -262,13 +262,15 @@ module system_top #(
262262 .O (tx_device_clk));
263263
264264 // spi
265- assign spi2_cs[5 :0 ] = spi_csn[5 :0 ];
265+ assign spi2_cs[1 :0 ] = spi_csn[1 :0 ];
266+ assign spi2_cs[4 ] = spi_csn[2 ];
266267 assign spi2_sclk = spi_clk;
267268
268269 ad9084_ebz_spi #(
269- .NUM_OF_SLAVES(2 )
270+ .NUM_OF_SLAVES(3 ),
271+ .IS_4WIRE(3'b101 )
270272 ) i_spi (
271- .spi_csn (spi_csn[1 :0 ]),
273+ .spi_csn (spi_csn[2 :0 ]),
272274 .spi_clk (spi_clk),
273275 .spi_mosi (spi_sdio),
274276 .spi_miso (spi_sdo),
Original file line number Diff line number Diff line change @@ -313,7 +313,8 @@ module system_top #(
313313 assign spi2_sclk = spi_clk;
314314
315315 ad9084_ebz_spi #(
316- .NUM_OF_SLAVES(2 )
316+ .NUM_OF_SLAVES(2 ),
317+ .IS_4WIRE(2'b01 )
317318 ) i_spi (
318319 .spi_csn (spi_csn[1 :0 ]),
319320 .spi_clk (spi_clk),
Original file line number Diff line number Diff line change @@ -286,7 +286,8 @@ module system_top #(
286286 assign spi2_sclk = spi_clk;
287287
288288 ad9084_ebz_spi #(
289- .NUM_OF_SLAVES(2 )
289+ .NUM_OF_SLAVES(2 ),
290+ .IS_4WIRE(2'b01 )
290291 ) i_spi (
291292 .spi_csn (spi_csn[1 :0 ]),
292293 .spi_clk (spi_clk),
You can’t perform that action at this time.
0 commit comments