我正在尝试为一个学校项目的实验室工作。我们应该最终制作一个程序,将有符号的整数值显示给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