如何在The Logic Lab上做出一个半加器全加器实验结论和一个全加器的例子

 上传我的文档
 下载
 收藏
大学生,医学专业,因为课间很多自己的资料希望分享
 下载此文档
正在努力加载中...
-比较器 全加器.
下载积分:2000
内容提示:-比较器 全加器.
文档格式:PPT|
浏览次数:0|
上传日期: 00:33:10|
文档星级:
该用户还上传了这些文档
-比较器 全加器.
官方公共微信查看: 2109|回复: 0
VHDL之加法器系列(四位 八位 半加器 全加器)
一、半加器
Use ieee.std_logic_1164.
Entity halfadd is
Port(a,b:in std_
& &&&S,c:out std_logic);
Architecture add of halfadd is
二、全加器
Use ieee.std_logic_1164.
Entity fulladd is
Port(a,b,cin:in std_
& &&&S,c:out std_logic);
Architecture add of fulladd is
signal m,n,k:std_
component halfadd is
Port(a,b:in std_
& &&&S,c:out std_logic);
U0:halfadd port map(a,b,m,n);
U1:halfadd port map(m,cin,S,k);
三、四位加法器
一)元件化全加器实现
Use ieee.std_logic_1164.
Entity adder4 is
Port(a,b:in std_logic_vector(3 downto 0);
& && &cin:in std_
& && &S:out std_logic_vector(3 downto 0);
& && &co:out std_logic);
end adder4;
Architecture add of adder4 is
signal c:std_logic_vector(3 downto 0);
component fulladd is
Port(a,b,cin:in std_
& &&&S,c:out std_logic);
U0:fulladd port map(a(0),b(0),cin,S(0),c(0));
U1:fulladd port map(a(1),b(1),c(0),S(1),c(1));
U2:fulladd port map(a(2),b(2),c(1),S(2),c(2));
U3:fulladd port map(a(3),b(3),c(2),S(3),co);
二)循环语句实现
Use ieee.std_logic_1164.
Entity adder4 is
Port(a,b:in std_logic_vector(3 downto 0);
& && &cin:in std_
& && &S:out std_logic_vector(3 downto 0);
& && &co:out std_logic);
end adder4;
Architecture add of adder4 is
Process(a,b,cin)
variable c:std_logic_vector(4 downto 0);
for i in 0 to 3 loop
&&s(i)&=a(i) xor b(i) xor c(i);
&&c(i+1):=((a(i) xor b(i))and c(i))or (a(i) and b(i));
三)子程序实现
Use ieee.std_logic_1164.
Entity adder4 is
Port(a,b:in std_logic_vector(3 downto 0);
& && &cin:in std_
& && &S:out std_logic_vector(3 downto 0);
& && &co:out std_logic);
end adder4;
Architecture add of adder4 is
Procedure sam(ai,bi,ci:in std_
& && && && && &so,co: out std_logic) is&&
& &co:=((ai xor bi)and ci)or(ai and bi);
Process(a,b,cin)
variable c:std_logic_vector(4 downto 0);
variable sum:std_logic_vector(3 downto 0);
for i in 0 to 3 loop
&&sam(a(i),b(i),c(i),Sum(i),c(i+1));
-------n-1位加法器,修改n的值,可以改变运算位数--------
Use ieee.std_logic_1164.
entity adder_n is
generic(n:integer:=4);----改变w的值可以改变运算宽度
port(a,b:in std_logic_vector(n-1 downto 0);
& &&&cin:in std_
& &&&Sum:out std_logic_vector(n-1 downto 0);
& &&&co:out std_logic);
Architecture add of adder_n is
&&---------------以下子程序---------------------
procedure fulladder(ai,bi,ci:in std_
& && && && && && && &s,cc:out std_logic)is
& && & begin
& && &&&s:=
& && &&&cc:=((ai xor bi)and ci)or(ai and bi);
&&------------------------------------------
&&process(a,b,cin)
& &---loop循环语句必须在process中使用,切子程序要求使用变量,所以在此不使用信号------
& &variable ss:std_logic_vector(n-1 downto 0);
& &variable c:std_logic_vector(n downto 0);
& &-----------------------------------------------------------------------
&&for i in 0 to n-1 loop
& & fulladder(a(i),b(i),c(i),ss(i),c(i+1));
& & co&=c(n);
四、八位二进制数相加
一)元件化实现
Use ieee.std_logic_1164.
Entity adder8 is
Port(a,b:in std_logic_vector(7 downto 0);
& && &cin:in std_
& && &S:out std_logic_vector(7 downto 0);
& && &co:out std_logic);
end adder8;
Architecture add of adder8 is
signal a1,a2,b1,b2,s1,s2:std_logic_vector(3 downto 0);
signal cc:std_
component adder4 is
Port(a,b:in std_logic_vector(3 downto 0);
& &&&cin:in std_
& &&&S:out std_logic_vector(3 downto 0);
& &&&co:out std_logic);
a1&=a(3 downto 0);a2&=a(7 downto 4);
b1&=b(3 downto 0);b2&=b(7 downto 4);
U0:adder4 port map(a1,b1,cin,S1,cc);
U1:adder4 port map(a2,b2,cc,S2,co);
S(7 downto 4)&=S2;S(3 downto 0)&=S1;
二)循环语句实现
Use ieee.std_logic_1164.
Entity adder4 is
Port(a,b:in std_logic_vector(3 downto 0);
& && &cin:in std_
& && &S:out std_logic_vector(3 downto 0);
& && &co:out std_logic);
end adder4;
Architecture add of adder4 is
variable c:std_logic_vector(8 downto 0);
Process(a,b,cin)
for i in 0 to 7 loop
&&s(i)&=a(i) xor b(i) xor c(i);
&&c(i+1)&=((a(i) xor b(i))and c(i))or (a(i) and b(i));
三)子程序实现
Use ieee.std_logic_1164.
Entity adder8 is
Port(a,b:in std_logic_vector(7 downto 0);
& && &cin:in std_
& && &S:out std_logic_vector(7 downto 0);
& && &co:out std_logic);
end adder8;
Architecture add of adder4 is
Procedure sam(ai,bi,ci:in std_
& && && && && &so,co: out std_logic) is&&
& &co:=((ai xor bi)and ci)or(ai and bi);
Process(a,b,cin)
variable c:std_logic_vector(8 downto 0);
variable sum:std_logic_vector(7 downto 0);
for i in 0 to 7 loop
&&sam(a(i),b(i),c(i),Sum(i),c(i+1));
减法器接下篇:
Powered by扫扫二维码,随身浏览文档
手机或平板扫扫即可继续访问
VHDL语言中配置语句的使用探讨
举报该文档为侵权文档。
举报该文档含有违规或不良信息。
反馈该文档无法正常浏览。
举报该文档为重复文档。
推荐理由:
将文档分享至:
分享完整地址
文档地址:
粘贴到BBS或博客
flash地址:
支持嵌入FLASH地址的网站使用
html代码:
&embed src='/DocinViewer-.swf' width='100%' height='600' type=application/x-shockwave-flash ALLOWFULLSCREEN='true' ALLOWSCRIPTACCESS='always'&&/embed&
450px*300px480px*400px650px*490px
支持嵌入HTML代码的网站使用
您的内容已经提交成功
您所提交的内容需要审核后才能发布,请您等待!
3秒自动关闭窗口实验8、半加器和全加器_图文_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
评价文档:
实验8、半加器和全加器
上传于||暂无简介
大小:378.50KB
登录百度文库,专享文档复制特权,财富值每天免费拿!
你可能喜欢

我要回帖

更多关于 半加器和全加器的区别 的文章

 

随机推荐