我正在嘗試爲一個學校項目的實驗室工作。我們應該最終制作一個程序,將有符號的整數值顯示給altera板。這是一路上的步驟之一,我卡住了。我無法弄清楚爲什麼if/else語句不能編譯,我是VHDL的新手,請大家幫忙。VHDL If/Else語句
-----------------------------------------------------------------
-- circuit for converting a 4-bit signed integer
-- to a 1-bit sign and a 4-bit absolute value
-----------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
entity sgnabs4 is
port (X : in std_logic_vector(3 downto 0);
sgn : out std_logic;
Xabs : out std_logic_vector(3 downto 0));
end sgnabs4;
architecture sgnabs4_arch of sgnabs4 is
component twos_complement4 is
port (A : in std_logic_vector(3 downto 0);
T : out std_logic_vector(3 downto 0));
end component twos_complement4;
-- you may define internal signals here as you feel necessary
signal That: std_logic_vector(3 downto 0);
signal Ahat: std_logic_vector(3 downto 0);
begin
twos_complement4_0: twos_complement4
port map(T => That, A=> Ahat);
sgn <= That(3);
if (sgn = '1') then
sgn => Xabs(3);
Xabs(2) <= not X(2);
Xabs(1) <= not X(1);
Xabs(0) <= not X(0);
else
Xabs(3) <= '0';
Xabs(2) <= X(2);
Xabs(1) <= X(1);
Xabs(0) <= X(0);
end if;
end sgnabs4_arch;
您需要將if語句放入進程中。另外'sgn => Xabs(3)'在這裏不起作用。 – sebs