案例陈述的选择只涵盖了我的自动售货机代码的10个案例中的6个,在我用VHDL语言执行非常长的程序后,我得到了这个错误。但是,它说,当其他人只能在代码的最后一条语句中使用=>时,才能避免这个特定的错误,但是,在程序中使用的语句有很多。如何解决这个问题?
library ieee;
use IEEE.std_logic_1164.all;
use ieee.numeric_std.all;
entity FSMM is
port (CLK : in std_logic; --Clock, active high
RSTn : in std_logic; --Async. Reset, active low
CoinIn : in std_logic_vector (1 downto 0); --Which coin was inserted
gum : out std_logic; --Is Soda dispensed ?
CoinOut : out std_logic_vector (1 downto 0) --Which coin is dispensed?
);
end entity;
architecture behavior of FSMM is
-- add your code here
type state_type is (idle, --start state/reset
put_money, --waiting to enter money
in_5c,in_10c,in_15c,in_20c,in_25c,in_30c,in_35c, --represent the current sum of money after returning change
gum_out --dispence soda can.
); --type of state machine.
signal current_s,next_s: state_type; --current and next state declaration.
begin
process(CLK,RSTn)
begin
if(RSTn = '0') then
current_s <= idle; --defualt state is on RESET
elsif(clk'event and clk = '1') then
current_s <= next_s;
end if;
end process;
--------------------
--FSM process:
process(current_s,CoinIn)
begin
case current_s is
when idle => --state reset or idle
gum <= '0';
CoinOut <= "00";
next_s <= put_money;
------------------------------------------------------
when put_money => --wait for money to be entered
if(CoinIn = "00")then
gum <= '0';
CoinOut <= "00";
next_s <= put_money;
elsif(CoinIn = "01")then --insert 5$
gum <= '0';
CoinOut <= "00";
next_s <= in_5c;
elsif(CoinIn = "10")then --insert 10$
gum <= '0';
CoinOut <= "00";
next_s <= in_10c;
elsif(CoinIn = "11")then --insert 25$
gum <= '0';
CoinOut <= "00";
next_s <= in_25c;
end if;
------------------------------------------------------
when in_5c =>
if(CoinIn = "00") then--stay on the same state
gum <= '0';
CoinOut <= "00";
next_s <= in_5c;
elsif(CoinIn = "01") then--inserted another 1$
gum <= '0';
CoinOut <= "00";
next_s <= in_10c;
elsif(CoinIn = "01") then--inserted another 2$
gum <= '0';
CoinOut <= "00";
next_s <= in_15c;
elsif(CoinIn = "01") then--inserted another 2$
gum <= '0';
CoinOut <= "00";
next_s <= in_20c;
elsif(CoinIn = "01") then--inserted another 2$
gum <= '0';
CoinOut <= "00";
next_s <= in_25c;
elsif(CoinIn = "01") then--inserted another 2$
gum <= '0';
CoinOut <= "00";
next_s <= in_30c;
elsif(CoinIn = "01") then--inserted another 2$
gum <= '0';
CoinOut <= "00";
next_s <= in_35c;
elsif(CoinIn = "01") then--inserted another 2$
gum <= '0';
CoinOut <= "00";
next_s <= gum_out;
end if;
------------------------------------------------------
when in_10c =>
if(CoinIn = "00") then--stay on the same state
gum <= '0';
CoinOut <= "00";
next_s <= in_10c;
elsif(CoinIn = "10") then--inserted another 1$
gum <= '0';
CoinOut <= "00";
next_s <= in_20c;
elsif(CoinIn = "10") then--inserted another 1$
gum <= '0';
CoinOut <= "00";
next_s <= in_30c;
elsif(CoinIn = "10") then--inserted another 1$
gum <= '0';
CoinOut <= "00";
next_s <= gum_out;
end if;
------------------------------------------------------
when in_25c =>
if(CoinIn = "00") then--stay on the same state
gum <= '0';
CoinOut <= "00";
next_s <= in_25c;
elsif(CoinIn = "01") then--inserted another 1$
gum <= '0';
CoinOut <= "00";
next_s <= in_30c;
elsif(CoinIn = "01") then--inserted another 1$
gum <= '0';
CoinOut <= "00";
next_s <= in_35c;
elsif(CoinIn = "01") then--inserted another 1$
gum <= '0';
CoinOut <= "00";
next_s <= gum_out;
end if;
------------------------------------------------------
when gum_out =>
gum <= '1';
CoinOut <= "00";
next_s <= put_money;
end case;
end process;
end behavior;发布于 2022-11-17 14:16:58
您的state_type被定义为10个不同值的枚举。
但是您的case语句只涵盖了其中的6个。根据标准IEEE 1076-2008的第10.9章,您需要涵盖所有的情况。
这是错误信息告诉您的。
解决方案是也涵盖所有其他情况,或者插入when others以将所有这些都捕获。
https://stackoverflow.com/questions/74469229
复制相似问题