VHDL 中的状态机 - 未知(无法识别)输出值

State machine in VHDL - unknow (unrecognized) output value

我是 VHDL 编码的初学者,我的简单状态机有些问题。我只是想让这台机器在状态改变的时候改变输出值loc_RL。当我模拟时,loc_RL.

没有值(如 'U')

这是我的代码:

library ieee;
use ieee.std_logic_1164.all;

entity RL is
    port (clk, reset, pon_RL, rtl_RL, ACDS_RL, LADS_RL, REN_RL, LLO_RL, MLA_RL, GTL_RL : in std_logic;
                                     loc_RL : out std_logic);
    end RL;

architecture behavioral of RL is

    type STATE_TYPE is (LOCS, REMS, LWLS, RWLS);
    signal state : STATE_TYPE;

begin
    process(clk, reset)
            begin
                if reset='1' then
                 state <= LOCS;
                elsif (rising_edge(clk)) then
                    case state is
                        when LOCS =>
                            if pon_RL = '1' then
                                state <= REMS;
                            else
                                state <= LOCS;
                            end if;
                        when REMS =>
                            if pon_RL = '1' then
                                state <= LWLS;
                            else
                                state <= REMS;
                            end if;
                        when LWLS =>
                            if pon_RL = '1' then
                                state <= RWLS;
                            else
                                state <= LWLS;
                            end if;
                        when RWLS =>
                            if pon_RL = '1' then
                                state <= LOCS;
                            else
                                state <= RWLS;
                            end if;
                    end case;
                end if;
    end process;


    process(state)
            begin
                case state is
                    when LOCS =>
                        loc_RL <= '1';
                    when REMS =>
                        loc_RL <= '0';
                    when LWLS =>
                        loc_RL <= '1';
                    when RWLS =>
                        loc_RL <= '0';
                end case;
    end process;

end behavioral;

测试台:

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

entity RL_tb is
end RL_tb;

architecture testbench of RL_tb is
    component RL
    port (clk, reset, pon_RL, rtl_RL, ACDS_RL, LADS_RL, REN_RL, LLO_RL, MLA_RL, GTL_RL : in std_logic;
                                     loc_RL : out std_logic);
    end component;

    --wejscia
    signal tclk : std_logic;
    signal treset: std_logic;
    signal tpon_RL : std_logic;
    signal trtl_RL : std_logic;
    signal tACDS_RL : std_logic;
    signal tLADS_RL : std_logic;
    signal tREN_RL : std_logic;
    signal tLLO_RL : std_logic;
    signal tMLA_RL : std_logic;
    signal tGTL_RL : std_logic;

    --wyjscia
    signal loc_RL : std_logic;

    --definicja zegara
    constant clk_period : time := 40 ns;

begin
    --inicjalizacja UUT

    uut: RL port map (
                tclk,
                treset,
                tpon_RL,
                trtl_RL,
                tACDS_RL,
                tLADS_RL,
                tREN_RL,
                tLLO_RL,
                tMLA_RL,
                tGTL_RL
            );


    process
    begin
        tclk <= '0';
        wait for clk_period/2;
        tclk <= '1';
        wait for clk_period/2;
    end process;

    process
    begin
        treset <= '1';
        wait for 10 ns;
        treset <= '0';
        tpon_RL <= '1';


    end process;

end;

编译正确,可以进行仿真了。我正在使用 Cadence 的 NCLaunch。在此先感谢您的帮助。

分析、详细说明和模拟您的设计和测试台给出:

查看测试台显示:

architecture testbench of RL_tb is
    component RL
        port (
            clk,
            reset,
            pon_RL,
            rtl_RL,
            ACDS_RL,
            LADS_RL,
            REN_RL,
            LLO_RL,
            MLA_RL,
            GTL_RL:     in  std_logic;
            loc_RL:     out std_logic
        );
    end component;

    --wejscia
    signal tclk:        std_logic;
    signal treset:      std_logic;
    signal tpon_RL:     std_logic;
    signal trtl_RL:     std_logic;
    signal tACDS_RL:    std_logic;
    signal tLADS_RL:    std_logic;
    signal tREN_RL:     std_logic;
    signal tLLO_RL:     std_logic;
    signal tMLA_RL:     std_logic;
    signal tGTL_RL:     std_logic;
    --wyjscia
    signal loc_RL:      std_logic;
    --definicja zegara
    constant clk_period:  time := 40 ns;

begin
    --inicjalizacja UUT
uut: 
    RL 
        port map (
            tclk,
            treset,
            tpon_RL,
            trtl_RL,
            tACDS_RL,
            tLADS_RL,
            tREN_RL,
            tLLO_RL,
            tMLA_RL,
            tGTL_RL
        );

    process
    begin
        tclk <= '0';
        wait for clk_period/2;
        tclk <= '1';
        wait for clk_period/2;
    end process;

    process
    begin
        treset <= '1';
        wait for 10 ns;
        treset <= '0';
        tpon_RL <= '1';
    end process;

end architecture;

除了 clk、reset 和 tpon_RL。

查看 RL 过程,我们发现从 LOCS 分支出来的实际状态取决于重置不是“1”:

    process (clk, reset)
            begin
                if reset = '1' then
                 state <= LOCS;
                elsif (rising_edge(clk)) then
                    case state is
                        when LOCS =>
                            if pon_RL = '1' then
                                state <= REMS;
                            else
                                state <= LOCS;
                            end if;
                        when REMS =>

您的测试台刺激中缺少的是重置版本。

未标注进程中:

    process
    begin
        treset <= '1';
        wait for 10 ns;
        treset <= '0';
        tpon_RL <= '1';
    end process;

您缺少最后的等待语句:

    process
    begin
        treset <= '1';
        wait for 10 ns;
        treset <= '0';
        tpon_RL <= '1';
        wait;            -- added
    end process;

这会阻止您立即再次将重置分配给“1”。如果没有挂起,进程将循环,它只会在一个等待语句处挂起,在将重置设置为“0”后,它会在进程挂起之前立即将其设置为“1”,重置将只有一个“1”值。任何过程处于活动状态时都不会更新信号,任何时候都只有一个预计的输出波形值,包括当前仿真时间。对“1”的赋值会覆盖对“0”的赋值。

修正给出:

现在我们看到状态机处于活动状态。