Skip to content

Commit cc74e3e

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 6f3ea13 commit cc74e3e

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
@@ -37,7 +37,7 @@
3737

3838
module ad9084_ebz_spi #(
3939
parameter NUM_OF_SLAVES = 8,
40-
parameter IS_4WIRE = 8'b00000001
40+
parameter [NUM_OF_SLAVES-1:0] IS_4WIRE = 8'b00000001
4141
) (
4242
input [NUM_OF_SLAVES-1:0] spi_csn,
4343
input spi_clk,
@@ -58,7 +58,8 @@ module ad9084_ebz_spi #(
5858
wire spi_csn_s;
5959
wire spi_enable_s;
6060

61-
wire [NUM_OF_SLAVES-1:0] spi_csn_4wire;
61+
wire any_4wire_sel;
62+
wire any_3wire_sel;
6263

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

@@ -87,17 +88,11 @@ module ad9084_ebz_spi #(
8788
end
8889
end
8990

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

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

10398
endmodule

0 commit comments

Comments
 (0)