From 14b2877b04da6c8d526f0cf9e53da06fdef6f1b0 Mon Sep 17 00:00:00 2001 From: Jan Michel Date: Wed, 3 Jun 2020 12:03:07 +0200 Subject: [PATCH] fix bug when word count is set to 0 --- special/spi_ltc2600.vhd | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/special/spi_ltc2600.vhd b/special/spi_ltc2600.vhd index 56fd0ff..a1fdca5 100644 --- a/special/spi_ltc2600.vhd +++ b/special/spi_ltc2600.vhd @@ -51,13 +51,13 @@ architecture spi_ltc2600_arch of spi_ltc2600 is signal spi_sdo : std_logic; signal spi_sdi : std_logic; - signal word_count : integer range 0 to BITS-1; + signal word_count : integer range 0 to 31 := 1; signal bit_count : integer range 0 to BITS-1; signal time_count : integer range 0 to 1023; signal readback : std_logic_vector(31 downto 0); signal blocked : std_logic; signal sudolock : std_logic; - + signal reset_fsm : std_logic; type fsm_t is (IDLE, WAIT_STATE, SET, TOGGLE_CS, TOGGLE_CS_0, TOGGLE_CS_1, TOGGLE_CS_2, FINISH); signal fsm_state : fsm_t; signal word_length : integer range 0 to BITS := BITS; @@ -75,6 +75,7 @@ begin BUS_ACK_OUT <= '0'; BUS_BUSY_OUT <= '0'; start <= '0'; + reset_fsm <= '0'; if BUS_WRITE_IN = '1' then if fsm_state = IDLE and blocked = '0' then @@ -100,13 +101,14 @@ begin wait_cycles <= to_integer(unsigned(BUS_DATA_IN(9 downto 0))); elsif BUS_ADDR_IN(3 downto 0) = x"1" then --0x11 ctrl_reg <= BUS_DATA_IN; - blocked <= BUS_DATA_IN(16); - start <= not sudolock or BUS_DATA_IN(17) ; + blocked <= BUS_DATA_IN(16) and or_all(BUS_DATA_IN(4 downto 0)); + start <= (not sudolock or BUS_DATA_IN(17)) and or_all(BUS_DATA_IN(4 downto 0)); elsif BUS_ADDR_IN(3 downto 0) = x"0" then --0x10 chipselect_reg <= BUS_DATA_IN(15 downto 0); end if; elsif BUS_ADDR_IN = "10011" then --Reg. 0x13 sudolock <= BUS_DATA_IN(17); + reset_fsm <= BUS_DATA_IN(31); BUS_ACK_OUT <= '1'; else BUS_BUSY_OUT <= '1'; @@ -253,7 +255,7 @@ begin time_count <= time_count - 1; end if; end case; - if RESET_IN = '1' then + if RESET_IN = '1' or reset_fsm = '1' then fsm_state <= IDLE; end if; end process; -- 2.43.0