0
我創建一個函數來生成一個隨機數。這個數字代表了一年。我需要找出那一年是否是一個閏年。生成的數字範圍在2000到2017之間,所以我認爲我可以使用一個案例而不是應用公式來查找閏年。VHDL病例聲明錯誤
architecture arh_afisare of afisare is
signal year: integer;
signal leap_year: integer;
begin
process
begin
year <= random_gen(2000, 2017);
case year is
when '2000' => leap_year <='1';
when '2004' => leap_year <='1';
when '2008' => leap_year <='1';
when '2012' => leap_year <='1';
when '2016' => leap_year <='1';
when others => leap_year <='0';
end case;
wait for 100 ns;
end process;
end architecture;
我在'when'期待最後一行的每一行都得到這個錯誤。
Error: COMP96_0019: Afisare.vhd : (28, 9): Keyword 'others' expected.
另外,將leap_year更改爲std_logic。 – FritzDC
@FritzDC不一定,我們不知道上下文。如果它是「整數」或更好,「自然範圍0到1」,你可以將它添加到daysPerYar等等(但是你也必須在那裏失去報價) –
是的,「或者失去引號」將會是爲了。話雖如此,在編寫VHDL時,將std_logic用於二進制邏輯可能是學習的好習慣。 – FritzDC