【发布时间】:2017-06-10 00:01:58
【问题描述】:
我正在尝试使用 modelsim 在 vhdl 中创建 fsm,但是当我尝试编译我的代码时出现此错误
** 错误:C:/Users/manor/Desktop/ldh/mult_fsm.vhd(34): near "when": (vcom-1576) 期待 END。
** 错误:C:/Users/manor/Desktop/ldh/mult_fsm.vhd(60): near "when": (vcom-1576) 期待 END。
** 错误:C:/Users/manor/Desktop/ldh/mult_fsm.vhd(72): near "else": (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;
我尝试自己修复代码,但我无法弄清楚它有什么问题。
【问题讨论】: