library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity adder is
port (
in1 : in bit_vector;
in2 : in bit_vector;
pout : out bit_vector
);
end adder;
architecture func of adder is
begin
process(in1,in2)
begin
pout <= in1 + in2 after 2 ns;
end process;
end func;
一开始的这个加法器的程序,在编译时通不过,出现了can't determine definition of operator'+'的这样的错误,上网找了一下,发现和我一样碰到这个问题的菜鸟(我也一样)还不在少数,经过老师的指导才知道,原来是定义输入输出数据的类型时错了,没有指明数据是多少位的,还有,after 2ns也是没必要加的,因为延迟时间只是在硬件的时候才用到.
改正的程序:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity adder is
port (
in1 : in STD_LOGIC_VECTOR(0 to 1);
in2 : in STD_LOGIC_VECTOR(0 to 1);
pout : out STD_LOGIC_VECTOR(0 to 1)
);
end adder;
architecture func of adder is
begin
process(in1,in2)
begin
pout <= in1+in2 ;
end process;
end func;
文章评论(0条评论)
登录后参与讨论