各位好:
之前用component的方式完成了几个项目,后来发现用function的作法好像更好用,但所使用的function必需直接放在主程式『architecture』内部,无法编成一个『package』!以下是本人欲将4bit加法器『add4』放入一『packagetest3』中但是complier时会出现以下二行讯息:第二行应该是关键吧!帮忙解解吧!tks!
info:Compiling package"PACKAGETEST3"
info:file"档案的路径名" does not contain an architecture body-stopping compilation
package packagetest3 is
function add4(a,b:bit_vector(3 downto 0))return bit_vector;
end packagetest3;
package body packagetest3 is
function add4(a,b:bit_vector(3 downto 0)) return bit_vector is
variable cout: bit;
variable cin: bit_vector(3 downto 0);
variable back: bit_vector(4 downto 0);
begin
for i in 0 to 3 loop
cin(i) := cout;
cout := (a(i) and b(i))or(b(i) and cin(i))or(cin(i) and a(i));
back(i) := a(i) xor b(i) xor cin(i);
end loop ;
back(4):=cout;
end add4;
end packagetest3;