VHDL fsm错误 - 接近"当":(vcom-1576)期待END

时间:2017-06-09 15:39:00

标签: vhdl modelsim

我正在尝试使用modelsim在vhdl中创建一个fsm但是当我尝试编译我的代码时我有这个错误

  

**错误:C:/Users/manor/Desktop/ldh/mult_fsm.vhd(34):"当":(vcom-1576)期待END。

     

**错误:C:/Users/manor/Desktop/ldh/mult_fsm.vhd(60):"当":(vcom-1576)期待END。

     

**错误:C:/Users/manor/Desktop/ldh/mult_fsm.vhd(72):接近"否则":(vcom-1576)期待END。

这是我的代码

library ieee;
use ieee.std_logic_1164.all;

entity mult_fsm is
    port(ck,adx,m: in std_logic;
        adsh,sh,cm,mdone: out std_logic);
end entity mult_fsm;

architecture ideal of mult_fsm is
    type StateType is (S0, S1, S2, S3, S4);
    signal CurrentState, NextState: StateType;
begin
    NS_CS: process( ck)
    begin
    if ck'event and ck='1' then
        case CurrentState is
            when S0=>
            if (adx='0') then
                NextState <= S0;
            else
                NextState <= S1;
            end if;

            when S1=>
                NextState <= S2;

            when S2=>
            if (m='1') then
                NextState<=S3;
            else if (m='0') then
                NextState<=S2;
            end if;

            when S3=>
                NextState <= S4;

            when S4=>
                NextState <= S0;

        end case;
    end if;
    end process NS_CS;

    OL: process (CurrentState)
    begin
        case CurrentState is
            when S0=>
            if (adx = '0') then
                adsh<='0';
                sh<='0';
                cm<='0';
                mdone<='0';
            else if (adx = '1') then
                if (m='1') then
                    adsh<='1';
                else if (m='0') then
                    sh<='1';
                end if;
            end if;
            when S1=>
            if (m='1') then
                adsh<='1';
            else if (m='0') then
                sh<='1';
            end if;
            when S2=>
            if (m='0') then
                adsh<='0';
                sh<='0';
                cm<='0';
                mdone<='0';
            else if (m='1') then
                adsh<='1';
            end if;
            when S3=>
            if (m='0') then
                sh='1';
            else if (m='1') then
                cm<='1';
                adsh<='1';
            end if;
            when S4=>
                mdone<='1';
        end case;

    end process OL;

end architecture ideal;

我自己尝试修复代码,但我无法弄清楚它的问题是什么。

2 个答案:

答案 0 :(得分:3)

amount1 = input("Insert your value: ") amount2 = input("Insert your value: ") print "Your first value is", amount1, "your second value is", amount2 替换为else if s。

在VHDL中,每个elsif都需要一个if。如果你写

end if

您需要两个if ... then ... else if ... then s - 每个end if一个:

if

VHDL有一个if ... then ... else IF ... THEN ... END IF; end if; 声明。这不会启动新的elsif语句,而是它所遵循的if语句的一部分。如果您在上面的示例中替换if,则只需要一个else IF

end if

答案 1 :(得分:2)

查看以下代码:

    if (m='1') then
      NextState<=S3;
    else if (m='0') then
      NextState<=S2;
    end if;

我认为你的意思是elsif而不是else if。或者,由于mstd_logic,您可以将此块简化为:

    if (m='1') then
      NextState<=S3;
    else
      NextState<=S2;
    end if;