电子设计自动化.docx
- 文档编号:8262445
- 上传时间:2023-01-30
- 格式:DOCX
- 页数:13
- 大小:166.98KB
电子设计自动化.docx
《电子设计自动化.docx》由会员分享,可在线阅读,更多相关《电子设计自动化.docx(13页珍藏版)》请在冰豆网上搜索。
电子设计自动化
电子设计自动化报告
班级:
电气0906
学号:
09272001
姓名:
陈怀鑫
实验一
熟悉QUARTUS2软件的使用(略)
实验二
组合电路设计
1.设计一个四位的全加器,进位输出是快速进位法。
A.设计思路:
全加器是对两个多位二进制数a和b进行加法运算,同时产生进位。
当两个二进制数a和b相加时,较高高位相加时必须加入较低位的进位项(cin),以得到输出为和(s)和进位(cout)。
参考数据(十进制0到15)如图所示:
a
b
cin
cout
s
0
0
0
0
0
1
5
0
0
6
4
2
1
0
7
5
6
0
0
11
10
12
0
1
6
12
12
1
1
9
根据全加器的的输出和输入的关系,以及进位和输入的关系:
s=abcin-1cout=ab+abcin-1
由此可以用基本等式算法便能很直观的设计出程序。
B.流程图:
a+b+cin=和
判断
和大于15
和小于15
cout=1
s=和-15
cout=0
s=和
C.程序:
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entityadder4bitis
port(cin:
instd_logic;
a,b:
instd_logic_vector(3downto0);
s:
outstd_logic_vector(3downto0);
cout:
outstd_logic);
endadder4bit;
architecturebehofadder4bitis
signalsint:
std_logic_vector(4downto0);
signalaa,bb:
std_logic_vector(4downto0);
begin
aa<='0'&a(3downto0);
bb<='0'&b(3downto0);
sint<=aa+bb+cin;
s(3downto0)<=sint(3downto0);
cout<=sint(4);
endbeh;
D.仿真波形:
2.用if语句和case语句设计一个4-16译码器。
dq
~0000~0000000000000001
~0001~0000000000000010
~0010~0000000000000100
~0011~0000000000001000
~0100~0000000000010000
~0101~0000000000100000
~0110~0000000001000000
~0111~0000000010000000
~1000~0000000100000000
~1001~0000001000000000
~1010~0000010000000000
~1011~0000100000000000
~1100~0001000000000000
~1101~0010000000000000
~1110~010*********
~1111~1000000000000000
A.设计思路:
我们知道4_16
译码器的端口中,有4个输入
端,16个输出端,4个输入端
代表十进制输数到15,会对应
不同的输出。
原理图如图所示:
B.流程图:
输入四位二进制数d
根据输入
用if或case语句
选择输出数据
输出十六位二进制数q
C.程序:
①if语句
libraryIEEE;
useIEEE.std_logic_1164.all;
entityencoder4_16is
port(d:
inSTD_LOGIC_VECTOR(3downto0);
q:
outSTD_LOGIC_VECTOR(15downto0));
endencoder4_16;
architectureencoder_ifofencoder4_16is
begin
process(d)
begin
ifd="0000"thenq<=(0=>'1',others=>'0');
elsifd="0001"thenq<=(1=>'1',others=>'0');
elsifd="0010"thenq<=(2=>'1',others=>'0');
elsifd="0011"thenq<=(3=>'1',others=>'0');
elsifd="0100"thenq<=(4=>'1',others=>'0');
elsifd="0101"thenq<=(5=>'1',others=>'0');
elsifd="0110"thenq<=(6=>'1',others=>'0');
elsifd="0111"thenq<=(7=>'1',others=>'0');
elsifd="1000"thenq<=(8=>'1',others=>'0');
elsifd="1001"thenq<=(9=>'1',others=>'0');
elsifd="1010"thenq<=(10=>'1',others=>'0');
elsifd="1011"thenq<=(11=>'1',others=>'0');
elsifd="1100"thenq<=(12=>'1',others=>'0');
elsifd="1101"thenq<=(13=>'1',others=>'0');
elsifd="1110"thenq<=(14=>'1',others=>'0');
elsifd="1111"thenq<=(15=>'1',others=>'0');
elseq<=(others=>'0');
endif;
endprocess;
endencoder_if;
②case语句
libraryieee;
useieee.std_logic_1164.all;
entitydecoder4_16is
port(data:
instd_logic_vector(3downto0);
en:
instd_logic;
y:
outstd_logic_vector(15downto0));
endentitydecoder4_16;
architecturearch1ofdecoder4_16is
begin
process(en,data)
begin
ifen='1'then
casedatais
when"0000"=>y(15downto0)<="1111111111111110";
when"0001"=>y(15downto0)<="1111111111111101";
when"0010"=>y(15downto0)<="1111111111111011";
when"0011"=>y(15downto0)<="1111111111110111";
when"0100"=>y(15downto0)<="1111111111101111";
when"0101"=>y(15downto0)<="1111111111011111";
when"0110"=>y(15downto0)<="1111111110111111";
when"0111"=>y(15downto0)<="1111111101111111";
when"1000"=>y(15downto0)<="1111111011111111";
when"1001"=>y(15downto0)<="1111110111111111";
when"1010"=>y(15downto0)<="1111101111111111";
when"1011"=>y(15downto0)<="1111011111111111";
when"1100"=>y(15downto0)<="1110111111111111";
when"1101"=>y(15downto0)<="1101111111111111";
when"1110"=>y(15downto0)<="1011111111111111";
when"1111"=>y(15downto0)<="0111111111111111";
whenothers=>y(15downto0)<="1111111111111111";
endcase;
endif;
endprocess;
endarchitecture;
D.仿真波形
实验三
时序电路设计
1.设计4位二进制同步加/减法可逆计算器。
A.设计思路:
已知要求为:
输入:
clr:
异步清零(高电平有效)
clk:
时钟输入
load:
同步预置使能端(低电平有效)
D3~D0:
4位二进制数输入端
updown:
加/减法控制信号
(‘1’加,‘0’减)
输出:
Q3~Q0:
4位二进制计数输出
CO:
进位输出
BO:
借位输出
本题虽然输入输出数据很多思路还是比较简单,明确。
比如各种各样的约束条件如clr,clk,load端,我使用IF和WHEN语句,和IF-ELSE语句来实现程序所需功能。
首先判断clr端,若为1,则输出0000,若为低电平,否则进行下一步:
判断时钟同步预置使能端load,若为0,Q3~Q0输出为D3~D0,否则进行下一步:
判断updown:
加/减法控制信号,若为1,输出根据clk:
时钟输入作加法运算输出,若为0,输出根据clk:
时钟输入作减法运算输出。
B.流程图:
输入:
clr,clk,load,updown,D3~D0
输出:
CO,BO,Q3~Q0
为1
判断clr值输出0000
为0
为0
判断load值输出为D3~D0
为1
判断updown值
为0
为1
加法器减法器
C.程序:
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entityjishuqiis
port(clr,clk,load,updown:
instd_logic;
d:
instd_logic_vector(3downto0);
co,bo:
outstd_logic;
q:
bufferstd_logic_vector(3downto0));
endentityjishuqi;
architecturewtfofjishuqiis
begin
co<='1'when(q="0000"andupdown='1')else'0';
bo<='1'when(q="1111"andupdown='0')else'0';
process(clk,clr,updown)is
begin
if(clr='1')thenq<="0000";
elsif(clk'eventandclk='1')then
if(load='0')thenq<=d;
elseif(updown='1')thenq<=q+1;
Elseq<=q-1;
endif;
endif;
endif;
endprocess;
endarchitecturewtf;
D.仿真波形:
清零端为高电平有效:
清零端为低电平,load端为低电平有效:
清零端为低电平,load端为高电平,updown为1
清零端为低电平,load端为高电平,updown为
0
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 电子设计 自动化