Проблема с моим VHDL конечным автоматом - PullRequest
0 голосов
/ 03 мая 2019

Я пытаюсь создать конечный автомат, который обнаружит старший или младший бит и отправит его в следующее адресуемое состояние. По некоторым причинам, кажется, что мой FSM застрял при обнаружении состояния или что-то делает сброс FSM постоянно. Когда я смотрю в отчете Synth, он говорит, что din не используется, а некоторые из моих состояний отсутствуют.

Я работаю в Vivado 2017.4, если это что-то меняет. Я попытался изменить какое состояние, если сброс = 1. По некоторым причинам, кажется, что сброс включен, если я ввожу максимум или минимум.

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity FSM_convert is
    Port (    mclk : in  STD_LOGIC;
              reset: in STD_LOGIC;            
              dout : out STD_LOGIC;
              strtcnt : out STD_LOGIC;
              din : in STD_LOGIC;
              count0ho : out STD_LOGIC;
              count0lo : out STD_LOGIC;
              count1ho : out STD_LOGIC;
              count1lo : out STD_LOGIC;
              Led : out Std_logic_vector (3 downto 0);
              count0h : in STD_LOGIC;
              count0l : in STD_LOGIC;
              count1h : in STD_LOGIC;
              count1l : in STD_LOGIC
              );
end FSM_convert;
architecture Behavioral of FSM_convert is
type state_names is (  t0h,t0l,t1h,t1l,detect);
signal state_reg, state_next: state_names; 

begin

Sync_process: process(mclk,reset)--
   begin

     if reset='0' then
        state_reg <=detect ;--detect
     elsif rising_edge(mclk) then
         state_reg <= state_next;   -- this is where the next state becoes `the new current state
     end if;
   end process;


    -- next-state logic -- using the current state and the inputs, determine `what the next state should be at the next
    --  rising edge of the FSM clock (clk)
    -- also determine outputs
CombinatorialProcess:   process(state_reg,din,count0h,count0l,count1h,count1l,reset)
   begin        
       count0ho <= '0'; -- set default values for all outputs and control `signals   
       count1ho <= '0';
       count0lo <= '0';
       count1lo <= '0';
       state_next <= detect;
       dout <= '0';
       Led <= x"0"; -- determine next state and outputs 
      case state_reg is

         when detect =>
           if din<= '0'  then      
            state_next <= t0h;
         else
             state_next <= t1h; 
         end if;
                 count0ho <= '1';
                 count1ho <= '1';
                 count0lo <= '1';
                 count1lo <= '1';
     Led <= x"1";

        when t0h =>        
           if count0h = '1' then
                         state_next <= t0l;
           else
                         state_next <= t0h;
           end if;
                dout <= '1';
           count0lo <= '1';
            Led <= x"2";
        when t0l =>        
          if count0l = '1' then
                         state_next <= detect;
          else
                         state_next <= t0l;
          end if;
           Led <= x"3";                
        when t1h =>        
           if count1h = '1' then
                         state_next <= t1l;
           else
                         state_next <= t1h;
           end if;
          dout <= '1';
         count1lo <= '1'; 
         Led <= x"4"; 
        when t1l =>      
           if count1l = '1' then
                        state_next <= detect;
           else
                        state_next <= t1l;
         end if;              
          Led <= x"5";             
        end case;
    end process;
end Behavioral;`

Что должно произойти, так это то, что состояние обнаружения получает текущее значение din и отправляет его в другое состояние. В настоящее время происходит то, что остается в любом случае, если reset = '0', то

    state_reg <=detect ;

1 Ответ

0 голосов
/ 04 мая 2019

Может быть, сначала синтезировать FSM_convert в качестве отдельного модуля и прочитать предупреждения синтезатора vivado. Если, например, din присутствует в автономном модуле, то, возможно, другой модуль, который вы написали, поддерживает его на низком уровне, поэтому синтез vivado удаляет его из сущности RTL. Также следите за полярностью сброса во всей конструкции, распространенной ошибкой является управление некоторыми модулями с активным высоким сбросом и другими с активным низким ...

---------- EDIT ------------------------------------ -----------

Помещенный объект в vivado и только порты, удаленные синтезом, это порт LED [3] и strcnt. Так что если din удален в rtl, то это определенно из-за верхнего модуля или сигналов сброса.

...