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 3737
3838module ad9084_ebz_spi #(
3939
40- parameter NUM_OF_SLAVES = 8
40+ parameter NUM_OF_SLAVES = 8 ,
41+ parameter IS_4WIRE = 8'b00000001
4142) (
4243 input [NUM_OF_SLAVES- 1 :0 ] spi_csn,
4344 input spi_clk,
@@ -58,6 +59,8 @@ module ad9084_ebz_spi #(
5859 wire spi_csn_s;
5960 wire spi_enable_s;
6061
62+ wire [NUM_OF_SLAVES- 1 :0 ] spi_csn_4wire;
63+
6164 // check on rising edge and change on falling edge
6265
6366 assign spi_csn_s = & spi_csn;
@@ -87,7 +90,15 @@ module ad9084_ebz_spi #(
8790
8891 // io buffer
8992
90- assign spi_miso = (spi_csn[0 ] == 1'b0 ) ? spi_miso_in : spi_sdio;
93+ genvar i;
94+
95+ generate
96+ for (i = 0 ; i < NUM_OF_SLAVES ; i = i + 1 ) begin
97+ assign spi_csn_4wire[i] = (IS_4WIRE[i] == 1'b1 ) ? spi_csn[i] : 1'b1 ;
98+ end
99+ endgenerate
100+
101+ assign spi_miso = (& spi_csn_4wire == 1'b0 ) ? spi_miso_in : spi_sdio;
91102 assign spi_sdio = (spi_enable_s == 1'b1 ) ? 1'bz : spi_mosi;
92103
93104endmodule
Original file line number Diff line number Diff line change @@ -227,7 +227,8 @@ module system_top #(
227227 assign spi2_sclk = spi_clk;
228228
229229 ad9084_ebz_spi #(
230- .NUM_OF_SLAVES(2 )
230+ .NUM_OF_SLAVES(2 ),
231+ .IS_4WIRE(2'b01 )
231232 ) i_spi (
232233 .spi_csn (spi_csn[1 :0 ]),
233234 .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 @@ -319,7 +319,8 @@ module system_top #(
319319 assign spi2_sclk = spi_clk;
320320
321321 ad9084_ebz_spi #(
322- .NUM_OF_SLAVES(2 )
322+ .NUM_OF_SLAVES(2 ),
323+ .IS_4WIRE(2'b01 )
323324 ) i_spi (
324325 .spi_csn (spi_csn[1 :0 ]),
325326 .spi_clk (spi_clk),
Original file line number Diff line number Diff line change @@ -289,7 +289,8 @@ module system_top #(
289289 assign spi2_sclk = spi_clk;
290290
291291 ad9084_ebz_spi #(
292- .NUM_OF_SLAVES(2 )
292+ .NUM_OF_SLAVES(2 ),
293+ .IS_4WIRE(2'b01 )
293294 ) i_spi (
294295 .spi_csn (spi_csn[1 :0 ]),
295296 .spi_clk (spi_clk),
You can’t perform that action at this time.
0 commit comments