达到迭代限制 - VHDL FSM中的简单计数器

时间:2016-07-02 23:51:46

标签: iteration vhdl limit counter fsm

我已达到"达到了迭代限制"简单FSM中的错误。 这是我必须为类分配做的更大FSM的一部分,我跟踪了这​​个特定部分的问题。 FSM将控制计数器,状态IDLE等待输入,ZERO将计数器设置为零,INCREMENT状态将计数器递增1。

模拟时,错误发生在第一次输入" inc"很高,时钟上升。 如果我改变语句" temp:= temp + 1;"对于" temp:=任何"错误停止。我真的不知道什么是错的,因为我发现当在流程本身内部的过程敏感性列表中更改信号时会发生此错误。

我使用Quartus II进行模拟。

对不起英文错误。

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use IEEE.NUMERIC_STD.all;

entity fsm is
    port
    (
        clock:      in std_logic;
        reset:      in std_logic;

        inc:            in std_logic;

        count:      out std_logic_vector (13 downto 0);
        cur_state:  out std_logic_vector (1 downto 0)
    );
end fsm;

architecture behaviour of fsm is
    type state_type is (IDLE, INCREMENT, ZERO);
    signal PS, NS: state_type;  

begin       
    sync_proc: process (clock, reset)
    begin   
        if (reset = '1') then
            PS <= ZERO;
        elsif (rising_edge(clock)) then
            PS <= NS;           
        end if;
    end process sync_proc;

    comb_proc: process (PS, inc)
        variable temp: unsigned (13 downto 0);
    begin
        case PS is
            when IDLE =>
                if (inc = '1') then
                    NS <= INCREMENT;
                else
                    NS <= IDLE;
                end if;             
            when INCREMENT =>
                temp := temp + 1;
                NS <= IDLE;
            when ZERO =>
                temp := "00000000000000";
                NS <= IDLE;
            when others =>
                NS <= IDLE;
        end case;

        count <= std_logic_vector(temp);
    end process comb_proc;

    with PS select
        cur_state <=    "00" when IDLE,
                             "01" when INCREMENT,
                             "10" when ZERO,
                             "11" when others;  
end behaviour;

1 个答案:

答案 0 :(得分:1)

您的案件陈述中存在非常严重的概念错误。因为它产生一个组合电路(你的FSM的组合部分),它没有内存,所以它不能实现方程式“temp:= temp + 1”(因为没有内存,它不知道是什么temp的值是)。

你可以在麻省理工学院出版的V.Pedroni的“硬件中的有限状态机......”的第11章中看到更多相关信息。