]> jspc29.x-matter.uni-frankfurt.de Git - trbnet.git/commitdiff
fix bug when word count is set to 0
authorJan Michel <j.michel@gsi.de>
Wed, 3 Jun 2020 10:03:07 +0000 (12:03 +0200)
committerJan Michel <j.michel@gsi.de>
Wed, 3 Jun 2020 10:03:07 +0000 (12:03 +0200)
special/spi_ltc2600.vhd

index 56fd0ff6865d9e7a91b9050a57da0b527543312d..a1fdca581104b3d4978b0c1d1a88312b0eb33b5d 100644 (file)
@@ -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;