From bf9a446e3f7f571eef5b67df482f20e2e3582413 Mon Sep 17 00:00:00 2001 From: Anton Blanchard Date: Mon, 4 Jan 2021 05:44:23 +1100 Subject: [PATCH] Reset cmd_ready_o in spi_txrx Initialize bit_count so that cmd_ready_o isn't X state immediately after reset. Signed-off-by: Anton Blanchard --- spi_rxtx.vhdl | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/spi_rxtx.vhdl b/spi_rxtx.vhdl index acb5bec..f8dfb88 100644 --- a/spi_rxtx.vhdl +++ b/spi_rxtx.vhdl @@ -257,12 +257,16 @@ begin count_bit: process(clk) begin if rising_edge(clk) then - if start_cmd = '1' then - bit_count <= cmd_clks_i; - elsif state /= DATA then - bit_count <= (others => '1'); - elsif sck_recv = '1' then - bit_count <= std_ulogic_vector(unsigned(bit_count) - 1); + if rst = '1' then + bit_count <= (others => '0'); + else + if start_cmd = '1' then + bit_count <= cmd_clks_i; + elsif state /= DATA then + bit_count <= (others => '1'); + elsif sck_recv = '1' then + bit_count <= std_ulogic_vector(unsigned(bit_count) - 1); + end if; end if; end if; end process;