3

所以我有一个关于 vhdl 错误的问题,它说:意外的 OTHER。

led <= "0000001" when count = "0000" else
        "1001111" when count = "0001" else
        "0010010" when count = "0010" else
        "0110000" when count = "0011" else
        "1001101" when count = "0100" else
        "0100101" when count = "0101" else
        "0100000" when count = "0110" else
        "0001111" when count = "0111" else
        "1111111" when count = "1000" else
        "0000100" when count = "1001" else
         "1111110" when others ;
4

2 回答 2

4

你不需要写others。像这样做:

led <= "0000001" when count = "0000" else
    "1001111" when count = "0001" else
    "0010010" when count = "0010" else
    "0110000" when count = "0011" else
    "1001101" when count = "0100" else
    "0100101" when count = "0101" else
    "0100000" when count = "0110" else
    "0001111" when count = "0111" else
    "1111111" when count = "1000" else
    "0000100" when count = "1001" else
     "1111110" ;
于 2013-07-29T15:47:07.497 回答
2

一个更标准的方法是这样做。

with count select 
led <=  "0000001" when "0000",
        "1001111" when "0001",
        "0010010" when "0010",
        "0110000" when "0011",
        "1001101" when "0100",
        "0100101" when "0101",
        "0100000" when "0110",
        "0001111" when "0111",
        "1111111" when "1000",
        "0000100" when "1001",
        "1111110" when others;

你必须使用others. 因为count没有涵盖所有值。

于 2017-02-25T16:44:06.850 回答