eda实验报告全加器四选一数据选择器交通灯.docx
- 文档编号:12314200
- 上传时间:2023-06-05
- 格式:DOCX
- 页数:15
- 大小:161.85KB
eda实验报告全加器四选一数据选择器交通灯.docx
《eda实验报告全加器四选一数据选择器交通灯.docx》由会员分享,可在线阅读,更多相关《eda实验报告全加器四选一数据选择器交通灯.docx(15页珍藏版)》请在冰点文库上搜索。
eda实验报告全加器四选一数据选择器交通灯
浙师大数理与信息工程学院
学生实验报告
实验一简单组合逻辑电路设计
1、实验目的
熟悉软件使用,了解CPLD设计的过程。
用画逻辑图和直接使用VHDL语言的两种方法进行逻辑设计。
2、实验内容
用开关K7,K8作为输入设置,从输出指示LED观察OUT21,22,23,24等的变化。
3、实验条件
EDA实验箱、QUARTUS2软件
4、实验设计
原理图
VHDL源程序
libraryieee;
useieee.std_logic_1164.all;
entityshieris
Port(k7,k8:
instd_logic;
out20,out21,out22,out23,out24:
outstd_logic);
endshier;
architecturesrofshieris
begin
out20<=k7;
out21<=notk7;
out22<=k7andk8;
out23<=k7ork8;
out24<=k7xork8;
endsr;
波形仿真
实验二三八译码器电路设计
1、实验目的
熟悉软件使用,了解CPLD设计的过程。
用画逻辑图和直接使用VHDL语言的两种方法进行逻辑设计。
2、实验内容
用开关K1,K2,K3,K4作为输入设置,组成一个高输出有效的三八译码器,从输出指示LED观察OUT1到OUT8随K1,K1,K3置值的改变而引起相应的变化。
3、实验条件
EDA实验箱、QUARTUS2软件
4、实验设计
原理图
VHDL源程序
libraryieee;
useieee.std_logic_1164.all;
entityshisanis
port(a,b,c:
instd_logic;
y:
outstd_logic_vector(7downto0));
endshisan;
architectureoneofshisanis
begin
process(a,b,c)
variabled:
std_logic_vector(2downto0);
begin
d:
=(c&b&a);
ifd<="000"then
y<="00000001";
elsifd<="001"then
y<="00000010";
elsifd<="010"then
y<="00000100";
elsifd<="011"then
y<="00001000";
elsifd<="100"then
y<="00010000";
elsifd<="101"then
y<="00100000";
elsifd<="110"then
y<="01000000";
elsifd<="111"then
y<="10000000";
elsenull;
endif;
endprocess;
endone;
波形仿真
实验四四选一数据选择器电路设计
1、实验目的
熟悉和了解VHDL语言涉及数字电路的流程,掌握完整的EDA设计方法。
2、实验内容
用VHDL语言编程实现一个四选一电路。
开关K5,K6作为控制端来确定K1,K2,K3,K4四个输入中的一个作为输入信号,并将结果从OUT1输出。
3、实验条件
EDA实验箱、QUARTUS2软件
4、实验设计
VHDL源程序
libraryieee;
useieee.std_logic_1164.all;
entityshisiis
port(s1,s2,k1,k2,k3,k4:
instd_logic;
y:
outstd_logic);
endshisi;
architecturemuxofshisiis
signals:
std_logic_vector(1downto0);
begin
s<=(s1&s2);
process(s,s1,s2,k1,k2,k3,k4)
begin
casesis
when"00"=>y<=k1;
when"01"=>y<=k2;
when"10"=>y<=k3;
when"11"=>y<=k4;
whenothers=>null;
endcase;
endprocess;
endmux;
波形仿真:
实验五全加器电路设计
1、实验目的
熟悉VHDL语言的模块化设计,了解元件例化和打包调用语句。
2、实验内容
用VHDL语言设计一个半加器电路。
然后用元件例化语句调用两个半加器电路,用结构描述实现一个全加器。
3、实验条件
EDA实验箱、QUARTUS2软件
4、实验设计
VHDL源程序
libraryieee;
useieee.std_logic_1164.all;
entitybanjiais
port(a,b:
instd_logic;
so,co:
outstd_logic);
endbanjia;
architecturemuxofbanjiais--半加器
begin
so<=axorb;
co<=aandb;
endmux;
libraryieee;
useieee.std_logic_1164.all;
entityor1is
port(a,b:
instd_logic;
c:
outstd_logic);
endor1;
architectureorrofor1is--与门
begin
c<=aorb;
endorr;
libraryieee;
useieee.std_logic_1164.all;
packagemy_pkgis
componentbanjia--元件声明
port(a,b:
instd_logic;
so,co:
outstd_logic);
endcomponent;
componentor1--元件声明
port(a,b:
instd_logic;
c:
outstd_logic);
endcomponent;
endmy_pkg;
libraryieee;
useieee.std_logic_1164.all;
usework.my_pkg.all;--打开程序包
entityshiwuis
port(ain,bin,cin:
instd_logic;
cout:
outstd_logic;
sum:
bufferstd_logic);
endshiwu;
architecturequanjiaofshiwuis--元件例化
signalx,y,z:
std_logic;
begin
u1:
banjiaportmap(a=>cin,b=>y,co=>z,so=>sum);--关联方式
u2:
banjiaportmap(a=>ain,b=>bin,co=>x,so=>y);--关联方式
u3:
or1portmap(a=>x,b=>z,c=>cout);--关联方式
endquanjia;
波形仿真
实验六交通灯电路设计
1、实验目的
熟悉软件使用,了解CPLD设计过程。
设计逻辑电路,完成交通灯控制逻辑。
2、实验内容
1、设计电路,交通灯控制逻辑
2、了解状态变化电路的设计
3、实验条件
EDA实验箱、QUARTUS2软件
5、实验设计
VHDL源程序
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entityjiaotongdengis
generic(
cnt_green1:
integer:
=25;--定义主通道绿灯亮的时间25秒
cnt_yellow1:
integer:
=5;--定义主通道黄灯亮的时间5秒
cnt_green2:
integer:
=15;--定义支路绿灯亮的时间15秒
cnt_yellow2:
integer:
=5);--定义支路绿灯亮的时间5秒
port(clk,rst:
instd_logic;--时钟信号、复位信号
lgt1_yellow:
outstd_logic;--主通道黄灯控制信号
lgt1_green:
outstd_logic;--主通道绿灯控制信号
lgt1_red:
outstd_logic;--主通道红灯控制信号
lgt2_yellow:
outstd_logic;--支路黄灯控制信号
lgt2_green:
outstd_logic;--支路绿灯控制信号
lgt2_red:
outstd_logic);--支路红灯控制信号
endjiaotongdeng;
architectureartofjiaotongdengis
typestatesis--状态机
(st0,st1,st2,st3);--状态机的各种状态
signalstate:
states:
=st0;
signalcnt:
integerrange0to30:
=0;--定义计数器
signalcnt_en:
std_logic:
='0';--计数使能信号
begin
process(clk,rst,cnt)
begin
ifrst='1'then--复位信号有效则执行复位操作
state<=st0;
cnt<=0;
elsif(rising_edge(clk))then--时钟上升沿到来
ifcnt_en='1'then
cnt<=cnt+1;--计数器计数
Else
cnt<=0;--计数器清零
endif;
casestateis
whenst0=>
ifcnt=cnt_green1then--主通道绿灯亮了25秒转换到状态1
state<=st1;
else
state<=st0;
endif;
whenst1=>
ifcnt=cnt_yellow1then--主通道黄灯亮了5秒转换到状态2
state<=st2;
else
state<=st1;
endif;
whenst2=>
ifcnt=cnt_green2then--支路绿灯亮了15秒转换到状态3
state<=st3;
else
state<=st2;
endif;
whenst3=>
ifcnt=cnt_yellow2then--支路黄灯亮了5秒转换到状态0
state<=st0;
else
state<=st3;
endif;
endcase;
endif;
endprocess;
process(state,cnt)
begin
casestateis
whenst0=>--状态0时主通道绿灯亮,支路红灯亮
lgt1_green<='1';
lgt1_yellow<='0';
lgt1_red<='0';
lgt2_green<='0';
lgt2_yellow<='0';
lgt2_red<='1';
cnt_en<='1';--开始计数
ifcnt=cnt_green1then
cnt_en<='0';--到25秒停止计数
endif;
whenst1=>--状态0时主通道黄灯亮,支路红灯亮
lgt1_green<='0';
lgt1_yellow<='1';
lgt1_red<='0';
lgt2_green<='0';
lgt2_yellow<='0';
lgt2_red<='1';
cnt_en<='1';--开始计数
ifcnt=cnt_yellow1then
cnt_en<='0';--到5秒停止计数
endif;
whenst2=>--状态0时主通道红灯亮,支路绿灯亮
lgt1_green<='0';
lgt1_yellow<='0';
lgt1_red<='1';
lgt2_green<='1';
lgt2_yellow<='0';
lgt2_red<='0';
cnt_en<='1';--开始计数
ifcnt=cnt_green2then
cnt_en<='0';--到15秒停止计数
endif;
whenst3=>--状态0时主通道红灯亮,支路黄灯亮
lgt1_green<='0';
lgt1_yellow<='0';
lgt1_red<='1';
lgt2_green<='0';
lgt2_yellow<='1';
lgt2_red<='0';
cnt_en<='1';--开始计数
ifcnt=cnt_yellow2then
cnt_en<='0';--计数到5秒停止计数
endif;
endcase;
endprocess;
endart;
波形仿真
由于交通灯程序中绿灯设定时间较长,仿真时只能看到部分波形,因此仿真时将绿灯时间缩短以便观察到完整的波形
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- eda 实验 报告 全加器 四选一 数据 选择器 交通灯