EDA综合实验设计报告.docx
《EDA综合实验设计报告.docx》由会员分享,可在线阅读,更多相关《EDA综合实验设计报告.docx(27页珍藏版)》请在冰豆网上搜索。
EDA综合实验设计报告
BeijingJiaotongUniversity
EDA实验设计报告
TYP
电气0906
09291183
实验1:
熟悉QUARTUSII软件的使用
通过下载及安装,可在电脑上运行Altera Quartus II。
打开软件,新建一个工程,在工程底下新建一个VHDLFile,即可实现编程功能。
编完程序后点击StartCompilation可试运行程序,待编写的程序运行无误后,再在此工程下新建一个VectorWaveformFile,给程序中的输入变量赋值,保存后点击StartSimulation即可实现程序的仿真。
实验2:
组合电路设计
1、设计一个四位的全加器,进位输出是快速进位位。
设计思路:
为实现快速进位,我选取4个一位全加器同时运行,及通过元件例化语句component,将底层的设计实体定义为一个元件,使实体中包含4个低一级的元件,并与当前设计实体中的指定端口连接,从而实现快速进位。
程序:
其中实体名为SB1,Uo:
SBportmap(a0,b0,c1,s0,d)等语句即为定义低一级的1位全加器。
具体程序如下:
libraryieee;
useieee.std_logic_1164.all;
entitySB1is
port(a0,a1,a2,a3:
instd_logic;
b0,b1,b2,b3:
instd_logic;
c1:
instd_logic;
s0,s1,s2,s3:
outstd_logic;
c0:
outstd_logic);
endSB1;
architectureyiofSB1is
componentSB
port(a,b,c:
instd_logic;
s,co:
outstd_logic);
endcomponent;
signald,e,f:
std_logic;
begin
Uo:
SBportmap(a0,b0,c1,s0,d);
U1:
SBportmap(a1,b1,d,s1,e);
U2:
SBportmap(a2,b2,e,s2,f);
U3:
SBportmap(a3,b3,f,s3,c0);
endyi;
libraryieee;
useieee.std_logic_1164.all;
entitySBis
port(a,b,c:
instd_logic;
s,co:
outstd_logic);endSB;
architectureyiofSBis
begins<=axorbxorc;
co<=(aandb)or(aandc)or(bandc);
endyi;
仿真波形:
选取第一个4位二进制数a为0010,第二个4位二进制数b为0100,进位位c1为1,得到的结果s为0111。
实际仿真波形如下图。
2、用IF语句和CASE语句设计一个4-16译码器。
设计思路:
通过if、case语句可实现使能端的控制及4-16译码器的功能,即输入一个四位二进制数,即可使输出的16个端口中相应的端口电平发生变化。
用case语句来实现译码器中相应数值选择的功能恰到好处。
程序:
其中实体名为SB2,when"0011"=>outt(15downto0)<="1111111111110111"等语句即可实现从0011译码到第4位输出发生变化。
具体程序如下:
libraryieee;
useieee.std_logic_1164.all;
entitySB2is
port(inn:
instd_logic_vector(3downto0);
shi:
instd_logic;
outt:
outstd_logic_vector(15downto0));
endentitySB2;
architecturesbofSB2is
begin
process(inn,shi)
begin
ifshi='1'then
caseinnis
when"0000"=>outt(15downto0)<="1111111111111110";
when"0001"=>outt(15downto0)<="1111111111111101";
when"0010"=>outt(15downto0)<="1111111111111011";
when"0011"=>outt(15downto0)<="1111111111110111";
when"0100"=>outt(15downto0)<="1111111111101111";
when"0101"=>outt(15downto0)<="1111111111011111";
when"0110"=>outt(15downto0)<="1111111110111111";
when"0111"=>outt(15downto0)<="1111111101111111";
when"1000"=>outt(15downto0)<="1111111011111111";
when"1001"=>outt(15downto0)<="1111110111111111";
when"1010"=>outt(15downto0)<="1111101111111111";
when"1011"=>outt(15downto0)<="1111011111111111";
when"1100"=>outt(15downto0)<="1110111111111111";
when"1101"=>outt(15downto0)<="1101111111111111";
when"1110"=>outt(15downto0)<="1011111111111111";
when"1111"=>outt(15downto0)<="0111111111111111";
whenothers=>outt(15downto0)<="1111111111111111";
endcase;
endif;
endprocess;
endarchitecture;
仿真波形:
当输入inn为1010时,输出outt中的第10个端口变为低电平,即实现了译码的功能。
实际仿真波形如下图。
实验3:
时序电路设计
设计4位二进制同步加/减法可逆计数器,其中
输入:
clr:
异步清零(高电平有效)
clk:
时钟输入
d3-d0:
4位二进制数输入端
updown:
加/减法控制信号(‘1’加,‘0’减)
输出:
q3-q0:
4位二进制计数输出
co:
进位输出
bo:
借位输出
设计思路:
用if语句实现清零及加减法的选择。
若选择updown=1,则当时钟输入为高电平时输入的d就加1,当d=1111时进位输出co就变1,最后将d中的数送给q来输出,以达到4位二进制同步加/减法可逆计数器的设计。
程序:
其中实体名为SB3,程序中两个关键的if语句即可实现加减法的控制及进位、借位的输出。
具体程序如下:
libraryIEEE;
useIEEE.std_logic_1164.all;
useIEEE.std_logic_unsigned.all;
entitySB3is
port(clk:
inSTD_LOGIC;
updown:
inSTD_LOGIC;
clr:
inSTD_LOGIC;
q:
outSTD_LOGIC_VECTOR(3downto0);
co,bo:
outstd_logic);
endSB3;
architecturesbbofSB3is
signald:
std_logic_vector(3downto0);
begin
process(clk,clr,updown)
begin
ifclr='1'then
d<="0000";
elsifclk'eventandclk='1'then
ifupdown='1'then
d<=d+'1';
co<='0';
bo<='0';
else
d<=d-'1';
co<='0';
bo<='0';
endif;
ifd="1111"andupdown='1'then
co<='1';
bo<='0';
endif;
ifd="0000"andupdown='0'then
bo<='1';
co<='0';
endif;
endif;
endprocess;
process(d)
begin
q<=d;
endprocess;
endsbb;
仿真波形:
若选取updown=1(加法),通过波形即可看出,该程序已经实现了d的加法运算,同时在d=1111时,进位输出co跳转一次,即有一个进位。
若选取updown=0(减法),该程序也实现了d的减法运算,同时在d=0000是,借位输出bo跳转一次,即有一个借位输出。
具体仿真波形如下:
updown=1(加法)
updown=0(减法)
实验感想:
其实仿真软件,不管是什么软件,都有他不可忽视的作用。
multisim可以仿真出数电模型,protues可以模拟单片机的实际运行程序,而quartusII可以模拟硬件设计,即为硬件程序烧写模拟软件,操作简单,易于运行。
我认为quartusII是一款可以与matlab媲美的软件,它使我熟练了实际硬件的使用语言和逻辑顺序,并能实现一些简单硬件的程序编制和模拟仿真,使我对VHDL和EDA有了更加具体而深刻的认识,我认为这次实验设计物超所值!
BeijingJiaotongUniversity
EDA综合设计报告
指导老师:
李景新
唐云鹏
电气0906
09291183
题目:
多路波形发生器的设计
基本要求:
1、对输入时钟信号进行分频,实现三路互差120的信号。
2、实现输出信号的占空比控制
clk:
输入时钟信号
reset:
同步复位信号(低电平有效)
div:
输入分频控制信号(注意:
6n分频)
ctrl:
占空比控制信号(H:
L)
ctrl=1,占空比1:
1
ctrl=2,占空比1:
2
ctrl=3,占空比2:
1
A、B、C:
三路输出信号
设计思路:
为实现三路互差120的信号,占空比和分频的要求,我采用了用cnt个数的不同和tmp信号的“1”/“0”变换,从而对时钟信号上升沿的计数循环变化,以分别控制占空比、分频个数和高低电平,最终达到波形按要求变化。
流程图:
定义输入、输出变量及全局变量,用以计数、显示波形等
输入变量ctrl,div,用以确定占空比和分频数
ctrl="00"
ctrl="11"
ctrl="10"
div="11"
div="00"
div="01"
div="10"
div=00
div=00
通过casectrlis,casedivis,
when3=>tmp0<='1';tmp1<='0';tmp2<='1'等语句实现占空比,分频等的循环控制,主要是对tmp的'1'/'0'选择,和cnt计数多少的控制,来实现不同输出通道对时钟上升沿个数的不同取舍,从而达到占空比、分频和输出信号角度的控制。
程序:
工程名为SB4,定义了tmp为二进制数,用以控制波形高低;cnt为整数,用以控制分频;ctrl用以控制占空比;当reset=1(非清零状态)时,通过cnt计数加一,实现波形对时间的控制。
主要程序如
casectrlis
when"01"=>
casedivis
when"00"=>
casecnt0is
when0=>tmp0<='0';tmp1<='1';tmp2<='0';
when1=>tmp0<='0';tmp1<='1';tmp2<='1';
when2=>tmp0<='0';tmp1<='0';tmp2<='1';
when3=>tmp0<='1';tmp1<='0';tmp2<='1';
when4=>tmp0<='1';tmp1<='0';tmp2<='0';
when5=>tmp0<='1';tmp1<='1';tmp2<='0';
cnt0<=0;
以上程序即可输出占空比1:
1,6分频,三路互差120°的信号。
具体程序如下:
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_arith.all;
useieee.std_logic_unsigned.all;
entitySB4is
port
(
clk,reset:
instd_logic;
div:
instd_logic_vector(1downto0);
ctrl:
instd_logic_vector(1downto0);
outa,outb,outc:
outstd_logic);
endSB4;
architectureSBofSB4is
signaltmp0:
std_logic;
signaltmp1:
std_logic;
signaltmp2:
std_logic;
signalcnt0:
integerrange0to5:
=0;
signalcnt1:
integerrange0to11:
=0;
signalcnt2:
integerrange0to17:
=0;
signalcnt3:
integerrange0to23:
=0;
begin
process(clk,reset,div,ctrl)
begin
ifclk'eventandclk='1'then
ifreset='0'then
cnt0<=0;
cnt1<=0;
cnt2<=0;
cnt3<=0;
tmp0<='0';
tmp1<='0';
tmp2<='0';
elsifreset='1'then
cnt0<=cnt0+1;
cnt1<=cnt1+1;
cnt2<=cnt2+1;
cnt3<=cnt3+1;
casectrlis
when"01"=>
casedivis
when"00"=>
casecnt0is
when0=>tmp0<='0';tmp1<='1';tmp2<='0';
when1=>tmp0<='0';tmp1<='1';tmp2<='1';
when2=>tmp0<='0';tmp1<='0';tmp2<='1';
when3=>tmp0<='1';tmp1<='0';tmp2<='1';
when4=>tmp0<='1';tmp1<='0';tmp2<='0';
when5=>tmp0<='1';tmp1<='1';tmp2<='0';
cnt0<=0;
endcase;
when"01"=>
casecnt1is
when0=>tmp0<='0';tmp1<='1';tmp2<='0';
when1=>tmp0<='0';tmp1<='1';tmp2<='0';
when2=>tmp0<='0';tmp1<='1';tmp2<='1';
when3=>tmp0<='0';tmp1<='1';tmp2<='1';
when4=>tmp0<='0';tmp1<='0';tmp2<='1';
when5=>tmp0<='0';tmp1<='0';tmp2<='1';
when6=>tmp0<='1';tmp1<='0';tmp2<='1';
when7=>tmp0<='1';tmp1<='0';tmp2<='1';
when8=>tmp0<='1';tmp1<='0';tmp2<='0';
when9=>tmp0<='1';tmp1<='0';tmp2<='0';
when10=>tmp0<='1';tmp1<='1';tmp2<='0';
when11=>tmp0<='1';tmp1<='1';tmp2<='0';
cnt1<=0;
endcase;
when"10"=>
casecnt2is
when0=>tmp0<='0';tmp1<='1';tmp2<='0';
when1=>tmp0<='0';tmp1<='1';tmp2<='0';
when2=>tmp0<='0';tmp1<='1';tmp2<='0';
when3=>tmp0<='0';tmp1<='1';tmp2<='1';
when4=>tmp0<='0';tmp1<='1';tmp2<='1';
when5=>tmp0<='0';tmp1<='1';tmp2<='1';
when6=>tmp0<='0';tmp1<='0';tmp2<='1';
when7=>tmp0<='0';tmp1<='0';tmp2<='1';
when8=>tmp0<='0';tmp1<='0';tmp2<='1';
when9=>tmp0<='1';tmp1<='0';tmp2<='1';
when10=>tmp0<='1';tmp1<='0';tmp2<='1';
when11=>tmp0<='1';tmp1<='0';tmp2<='1';
when12=>tmp0<='1';tmp1<='0';tmp2<='0';
when13=>tmp0<='1';tmp1<='0';tmp2<='0';
when14=>tmp0<='1';tmp1<='0';tmp2<='0';
when15=>tmp0<='1';tmp1<='1';tmp2<='0';
when16=>tmp0<='1';tmp1<='1';tmp2<='0';
when17=>tmp0<='1';tmp1<='1';tmp2<='0';
cnt2<=0;
endcase;
when"11"=>
casecnt3is
when0=>tmp0<='0';tmp1<='1';tmp2<='0';
when1=>tmp0<='0';tmp1<='1';tmp2<='0';
when2=>tmp0<='0';tmp1<='1';tmp2<='0';
when3=>tmp0<='0';tmp1<='1';tmp2<='0';
when4=>tmp0<='0';tmp1<='1';tmp2<='1';
when5=>tmp0<='0';tmp1<='1';tmp2<='1';
when6=>tmp0<='0';tmp1<='1';tmp2<='1';
when7=>tmp0<='0';tmp1<='1';tmp2<='1';
when8=>tmp0<='0';tmp1<='0';tmp2<='1';
when9=>tmp0<='0';tmp1<='0';tmp2<='1';
when10=>tmp0<='0';tmp1<='0';tmp2<='1';
when11=>tmp0<='0';tmp1<='0';tmp2<='1';
when12=>tmp0<='1';tmp1<='0';tmp2<='1';
when13=>tmp0<='1';tmp1<='0';tmp2<='1';
when14=>tmp0<='1';tmp1<='0';tmp2<='1';
when15=>tmp0<='1';tmp1<='0';tmp2<='1';
when16=>tmp0<='1';tmp1<='0';tmp2<='0';
when17=>tmp0<='1';tmp1<='0';tmp2<='0';
when18=>tmp0<='1';tmp1<='0';tmp2<='0';
when19=>tmp0<='1';tmp1<='0';tmp2<='0';
when20=>tmp0<='1';tmp1<='1';tmp2<='0';
when21=>tmp0<='1';tmp1<='1';tmp2<='0';
when22=>tmp0<='1';tmp1<='1';tmp2<='0';
when23=>tmp0<='1';tmp1<='1';tmp2<='0';
cnt3<=0;
endcase;
endcase;
when"10"=>
casedivis
when"00"=>
casecnt0is
when0=>tmp0<='0';tmp1<='1';tmp2<='0';
when1=>tmp0<='0';tmp1<='1';tmp2<='0';
when2=>tmp0<='0';tmp1<='0';tmp2<='1';
when3=>tmp0<='0';tmp1<='0';tmp2<='1';
when4=>tmp0<='1';tmp1<='0';tmp2<='0';
when5=>tmp0<='1';tmp1<='0';tmp2<='0';
cnt0<=0;
endcase;
when"01"=>
casecnt1is
when0=>tmp0<='0';tmp1<='1';tmp2<='0';
when1=>tmp0<='0';tmp1<='1';tmp2<='0';
when2=>tmp0<='0';tmp1<='1';tmp2<='0';
when3=>tmp0<='0';tmp1<='1';tmp2<='0';
when4=>tmp0<='0';tmp1<='0';tmp2<='1';
when5=>tmp0<='0';tmp1<='0';tmp2<='1';
when6=>tmp0<='0';tmp1<='0';tmp2<='1';
when7=>tmp0<='0';tmp1<='0';tmp2<='1';
when8=>tmp0<='1';tmp1<='0';tmp2<='0';
when9=>tmp0<='1';tmp1<='0';tmp2<='0';
when10=>tmp0<='1';tmp1<='0';tmp2<='0';
when11=>tmp0<='1';tmp1<