0

我正在尝试用 VHDL 编写一个将扫描 4x4 键盘的状态机。我希望 keyP 在开始时和重置后设置为 0。我还希望Col在开始时和重置后将其设置为“1111”。

由于我不完全精通 VHDL 编程,我确信这只是一个愚蠢的语法错误。
我得到的错误是:

错误 (10818):无法在 Lab_7_Keypad.vhd(39) 中推断“Col[0]”的寄存器,因为它没有在时钟沿之外保持其值

, Col[1], Col[2],Col[3]和 forkeyP也一样。

这是我开始这一切的代码。有人可以告诉我我哪里出错了吗?

谢谢

ENTITY Lab_7_Keypad IS
PORT(
    nReset          :   IN  STD_LOGIC;
    clk             :   IN  STD_LOGIC;
    row             :   IN  STD_LOGIC_VECTOR (3 downto 0);
    Col             :   OUT STD_LOGIC_VECTOR (3 downto 0);
    data            :   OUT STD_LOGIC_VECTOR (3 downto 0);
    keyP            :   OUT STD_LOGIC);

    END Lab_7_Keypad;

ARCHITECTURE a OF Lab_7_Keypad IS   
TYPE STATE_TYPE IS ( Col1Set, Col2Set, Col3Set, Col4Set );
SIGNAL  coltest :   STATE_TYPE;

BEGIN
PROCESS (clk, nReset )
BEGIN
    keyP <= '0';
    Col <= "1111";
    IF nReset = '0' THEN                        --  asynch Reset to zero
        coltest <=  Col1Set;
        Col <="1111";
        keyP <= '0';
    ELSIF clk'EVENT AND clk = '1' THEN          --  triggers on PGT

        CASE coltest IS
            WHEN Col1Set => 
            Col <="1110";
                CASE row IS
                    WHEN    "1110"=>--row 1
                    data <= "0001";
                    keyP <= '1';
                    WHEN    "1101"=>--row 2
                    data <= "0100";
                    keyP <= '1';
                    WHEN    "1011"=>--row 3
                    data <= "0111";
                    keyP <= '1';
                    WHEN    "0111"=>--row 4
                    data <= "1110";
                    keyP <= '1';
                    WHEN OTHERS => coltest <= Col2Set;
                END CASE;
  --And continues with same Case statements three more times.
4

1 回答 1

2

您的综合错误是由于您在进程的异步复位或时钟边缘之外分配给colkeyP的事实,这没有正确描述寄存器。删除这些分配,错误应该会消失。

PROCESS (clk, nReset )
BEGIN
    --keyP <= '0';  <------- BAD!
    --Col <= "1111"; <------- BAD!
    IF nReset = '0' THEN                        --  asynch Reset to zero
        coltest <=  Col1Set;
        Col <="1111";
        keyP <= '0';
    ELSIF clk'EVENT AND clk = '1' THEN          --  triggers on PGT

        CASE coltest IS
            WHEN Col1Set => 
            Col <="1110";
                CASE row IS
                    WHEN    "1110"=>--row 1
                    data <= "0001";
                    keyP <= '1';
                    WHEN    "1101"=>--row 2
                    data <= "0100";
                    keyP <= '1';
                    WHEN    "1011"=>--row 3
                    data <= "0111";
                    keyP <= '1';
                    WHEN    "0111"=>--row 4
                    data <= "1110";
                    keyP <= '1';
                    WHEN OTHERS => coltest <= Col2Set;
                END CASE;
  --And continues with same Case statements three more times.
于 2012-05-16T09:05:11.797 回答