繁体   English   中英

无法推断Quartus II(VHDL)中的注册

[英]Can't infer register in Quartus II (VHDL)

这是完整的代码

library ieee;
use ieee.std_logic_1164.all;

entity move_key_detector is
    PORT(
        clk : IN STD_LOGIC;
        done : IN STD_LOGIC;
        hex : IN STD_LOGIC_VECTOR(7 DOWNTO 0);
        up, down : out std_logic
    );
END move_key_detector;

architecture arch of move_key_detector is

    type statetype is (IDLE, RECEIVED_BREAK);
    signal next_state, current_state : statetype :=IDLE;

begin

process (Clk) begin
    if(rising_edge(Clk)) then
        current_state <= next_state;
    end if;
end process;


process(done) begin
next_state <= current_state;
    case current_state is
        when IDLE=>
            if(done = '1') then
                if (hex = "00011101") then up <= '1';
                elsif(hex = "00011011") then down <= '1';
                --check to see if a break code is sent
                elsif (hex = "11110000") then next_state <= RECEIVED_BREAK; 
                end if;
            end if;
        when RECEIVED_BREAK=>
            if(done ='1') then
                if (hex = "00011101") then up <= '0';
                elsif(hex="00011011") then down <= '0';
                end if;
                next_state <= IDLE;
            end if;
        end case;
end process;

错误是:

错误(10821):move_key_detector.vhd(31)处的HDL错误:无法推断寄存器是否为“ down”,因为其行为与任何受支持的寄存器模型都不匹配

信息(10041):在move_key_detector.vhd(29)处推断为“向下”的闩锁

错误(10821):move_key_detector.vhd(31)处的HDL错误:无法推断寄存器是否为“ up”,因为其行为与任何受支持的寄存器模型都不匹配

信息(10041):在move_key_detector.vhd(29)处推断为“向上”的闩锁

错误(10818):无法在move_key_detector.vhd(41)上推断“ next_state”的寄存器,因为它没有在时钟沿之外保持其值

错误(10818):无法在move_key_detector.vhd(33)上推断“ next_state”的寄存器,因为它没有在时钟沿之外保持其值

我一直在得到这种错误。 我遵循了此建议 ,阅读了HDL手册,但我仍然不知道该如何解决。

谁能帮我? 非常感谢你!

为什么要进行第二步处理? 看起来它包含旨在成为异步代码的内容。

如果需要过程,以便可以使用if和case构造,则需要将可能影响所需输出的所有内容放入过程敏感度列表中(即:done AND current_state&hex)。

您还可能会为next_state分配两个不同的值,这在以FPGA为目标时通常是一件坏事。 我建议在case语句内移动“ next_state <= current_state”,并在case / if语句的所有分支中显式分配所有术语(我在猜测您对行为的期望,但应该理解理念):

case current_state is
    when IDLE=>
        if(done = '1') then
            if (hex = "00011101") then 
                up <= '1';
                down <= '0';
                next_state <= current_state;
            elsif(hex = "00011011") then 
                up <= '0';
                down <= '1';
                next_state <= current_state;
            --check to see if a break code is sent
            elsif (hex = "11110000") then 
                up <= '0';
                down <= '0';
                next_state <= RECEIVED_BREAK; 
            ...

如果要生成异步逻辑,也可以在过程外部使用选定的信号分配。

如果您真的想推断up / down / next_state信号的锁存器,那么您需要对要发生的事情更加明确,无论是直接在您的代码中还是在您对我们的问题中,以便我们都能为您提供帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM