Skip to content

Commit a427062

Browse files
committed
SPI MASTER [BUGFIX]: Fix CS_N and null array of addr_reg for SLAVE_COUNT=1
1 parent 87ef439 commit a427062

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

rtl/spi_master.vhd

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,21 @@ begin
160160
end if;
161161
end process;
162162

163-
cs_n_g : for i in 0 to SLAVE_COUNT-1 generate
164-
cs_n_p : process (addr_reg, chip_select_n)
165-
begin
166-
if (addr_reg = i) then
167-
CS_N(i) <= chip_select_n;
168-
else
169-
CS_N(i) <= '1';
170-
end if;
171-
end process;
163+
one_slave_g: if (SLAVE_COUNT = 1) generate
164+
CS_N(0) <= chip_select_n;
165+
end generate;
166+
167+
more_slaves_g: if (SLAVE_COUNT > 1) generate
168+
cs_n_g : for i in 0 to SLAVE_COUNT-1 generate
169+
cs_n_p : process (addr_reg, chip_select_n)
170+
begin
171+
if (addr_reg = i) then
172+
CS_N(i) <= chip_select_n;
173+
else
174+
CS_N(i) <= '1';
175+
end if;
176+
end process;
177+
end generate;
172178
end generate;
173179

174180
-- -------------------------------------------------------------------------

0 commit comments

Comments
 (0)