Skip to content

Commit f7e5d78

Browse files
Filip.Ghermanbluncan
authored andcommitted
ad9084_ebz/vcu118: Fix spi2 by adding a clear muxing logic between 3w/4w and unused slave devices
Signed-off-by: Filip Gherman <filip.gherman@analog.com>
1 parent 18380c5 commit f7e5d78

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

projects/ad9084_ebz/common/ad9084_ebz_spi.v

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
module ad9084_ebz_spi #(
3939

4040
parameter NUM_OF_SLAVES = 8,
41-
parameter IS_4WIRE = 8'b00000001
41+
parameter [NUM_OF_SLAVES-1:0] IS_4WIRE = 8'b00000001
4242
) (
4343
input [NUM_OF_SLAVES-1:0] spi_csn,
4444
input spi_clk,
@@ -59,7 +59,8 @@ module ad9084_ebz_spi #(
5959
wire spi_csn_s;
6060
wire spi_enable_s;
6161

62-
wire [NUM_OF_SLAVES-1:0] spi_csn_4wire;
62+
wire any_4wire_sel;
63+
wire any_3wire_sel;
6364

6465
// check on rising edge and change on falling edge
6566

@@ -88,17 +89,11 @@ module ad9084_ebz_spi #(
8889
end
8990
end
9091

91-
// io buffer
92+
assign any_4wire_sel = |(~spi_csn & IS_4WIRE);
93+
assign any_3wire_sel = |(~spi_csn & ~IS_4WIRE);
9294

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;
95+
assign spi_miso = (any_4wire_sel) ? spi_miso_in :
96+
(any_3wire_sel) ? spi_sdio : 1'bz;
10297
assign spi_sdio = (spi_enable_s == 1'b1) ? 1'bz : spi_mosi;
10398

10499
endmodule

0 commit comments

Comments
 (0)