无法将计数器信号分配给输出(FSM)

问题描述 投票:0回答:1

我正在为正交编码器计数器开发 FSM,将在 Arty A7 35 上使用 --- 这是我的第一个 VHDL 项目,所以如果我遗漏了一些非常基本的东西,我深表歉意。我有一个内部计数信号,我在 FSM 中递减或递增,但是当我尝试通过 COUNT_OUT 分配该信号时<= count, COUNT_OUT stays at zero, even though I have been able to observe the state changing. I do this assignment at the very end of the FSM process.

simulation outputs

此外,我无法在模拟中观察“状态”、“下一个状态”或“计数”——我将不胜感激,并且会非常有用。这些信号也不会显示在示波器旁边的“对象”窗口中

我的实体声明如下:

entity GPIO_demo is
    Port ( BTN          : in  STD_LOGIC;
           z            : in  STD_LOGIC;
           A            : in  STD_LOGIC;
           B            : in  STD_LOGIC;
           LED          : out STD_LOGIC;
           CLK          : in  STD_LOGIC;
           UART_TXD     : out  STD_LOGIC;
           COUNT_OUT    : out unsigned(11 downto 0)
              );
end GPIO_demo;

我在架构中定义了这些相关信号:

type state_type is (S00, S01, S10, S11);
signal state, next_state: state_type;
signal count: unsigned(11 downto 0) := (others=>'0');

我的FSM如下:

SYNC_PROC: process(CLK)
begin
    if rising_edge(CLK) then
        if ( z='1' ) then
            state <= S00;
            count <= "000000000000";
        else
            state <= next_state;
        end if;
    end if;
end process;

NEXT_STATE_DECODE: process(state, A, B)
begin
    case state is
        when S00 => 
            if(A = '0' and B = '1') then
                count <= "000000000000";
                next_state <= S01;
            elsif(A = '1' and B = '0') then
                count <= "000000000000";
                next_state <= S10;
            end if;
         when S01 => 
            if(A = '1' and B = '1') then
                count <= "100000000000";
                next_state <= S11;
            elsif(A = '0' and B = '0') then
                count <= "100000000000";
                next_state <= S00;
            end if;
         when S11 => 
            if(A = '1' and B = '0') then
                count <= count - 1;
                next_state <= S10;
            elsif(A = '0' and B = '1') then
                count <= count + 1;
                next_state <= S01;
            end if;
         when S10 => 
            if(A = '0' and B = '0') then
                count <= count - 1;
                next_state <= S00;
            elsif(A = '1' and B = '1') then
                count <= count + 1;
                next_state <= S11;
            end if;
    end case;
    COUNT_OUT <= count;
end process;

知道为什么此输出不更新吗?

vhdl fpga xilinx vivado
1个回答
0
投票

我不知道它是否仍然相关,因为这个问题提出已经有一段时间了,但也许对其他人有帮助。

默认情况下,模拟中仅显示测试台的信号。但您可以手动添加来自测试组件的信号。在“来源”旁边应该有另一个选项卡“范围”。您可以在那里选择组件。在“对象”窗口中,您应该看到该组件的所有信号、常量等。您可以使用拖放或右键单击 -> 添加到波形窗口将它们中的任何一个添加到波形中。

至于解决多驱动信号计数问题,我知道有两种选择。第一个是将 Boath 进程合并为单个时钟驱动的进程。在这种情况下,您不再需要 next_state 。 第二种选择是使用新信号 next_count。在第一个过程中为 count 赋值,在第二个过程中为 next_count 赋值。就像你对 state 和 next_state 所做的那样。

© www.soinside.com 2019 - 2024. All rights reserved.