找回密码
 注册
搜索
查看: 1137|回复: 0

[讨论] vhdl如何自制一个package呢??

[复制链接]
发表于 2006-2-21 10:42:00 | 显示全部楼层 |阅读模式
各位好:
之前用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;
高级模式
B Color Image Link Quote Code Smilies

本版积分规则

Archiver|手机版|小黑屋|52RD我爱研发网 ( 沪ICP备2022007804号-2 )

GMT+8, 2025-2-2 15:05 , Processed in 0.044392 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表