VHDL程序设计题Word文档格式.docx
《VHDL程序设计题Word文档格式.docx》由会员分享,可在线阅读,更多相关《VHDL程序设计题Word文档格式.docx(18页珍藏版)》请在冰点文库上搜索。
![VHDL程序设计题Word文档格式.docx](https://file1.bingdoc.com/fileroot1/2023-4/28/6494e3fb-018f-4fc0-a0c7-3598f1fc9af4/6494e3fb-018f-4fc0-a0c7-3598f1fc9af41.gif)
--与y<
=NOT(aANDb);
等价(10)ENDnand2_1;
3、根据下表填写完成一个3-8线译码器的VHDL程序(16分)。
ENTITYdecoder_3_to_8IS
PORT(a,b,c,g1,g2a,g2b:
OUTSTD_LOGIC_VECTOR(7DOWNTO0));
ENDdecoder_3_to_8;
ARCHITECTURErtlOFdecoder_3_to_8IS
SIGNALindata:
STD_LOGIC_VECTOR(2DOWNTO0);
(4)BEGIN
indata<
=c&
b&
a;
PROCESS(indata,g1,g2a,g2b)BEGIN
IF(g1='
1'
ANDg2a='
0'
ANDg2b='
)THEN(8)
CASEindataIS
WHEN"
000"
=>
y<
="
11111110"
;
001"
=>
11111101"
010"
11111011"
(10)WHEN"
011"
11110111"
100"
11101111"
101"
11011111"
110"
10111111"
(12)WHEN"
111"
01111111"
WHENOTHERS=>
XXXXXXXX"
ENDCASE;
ELSE
11111111"
(14)
ENDIF;
ENDPROCESS;
(16)
ENDrtl;
4、三态门电原理图如右图所示,真值表如左图所示,请完成其VHDL程序构造体部分。
(本题14分)
ENTITYtri_gateISPORT(din,en:
s:
instd_logic_vector(1downto0);
(4)
d:
instd_logic_vector(3downto0);
(6)
);
outstd_logic
(8)
endMUX4;
architecturebehaveofMUX4isbegin
process(s)
if(s="
00"
)then
y<
=d(0);
elsif(s="
01"
)theny<
=d
(1);
10"
=d
(2);
11"
=d(3);
else
null;
endif;
endprocess;
endbehave;
2、编写一个数值比较器VHDL程序的进程(不必写整个结构框架),要求使能信号g低电平时比较器开始工作,输入信号p=q,输出equ为‘0’,否则为‘1’。
(本题10分)
process(p,q)
(2)
ifg='
then(4)
ifp=qthen
equ<
='
(6)
endif;
endprocess;
3、填写完成一个8-3线编码器的VHDL程序(16分)。
Libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_arith.all;
useieee.std_logic_unsigned.all;
entityeight_triisport(
endeight_tri;
b:
instd_logic_vector(7downto0);
en:
instd_logic;
outstd_logic_vector(2downto0)(4)
architectureaofeight_triis(6)
signalsel:
std_logic_vector(8downto0);
begin
sel<
=en&
b;
(8)
=“000”when(sel=”100000001”)else
“001”when(sel=”100000010”)else(10)“010”when(sel=”100000100”)else
“011”when(sel=”100001000”)else
“100”when(se1l=0001”0000”)else(12)“101”wh(esnel=”100100000”)else
“110”when(sel=”101000000”)else(14)
“111”when(se1l=1000”0000”)else(16)“zzz”;
enda;
4、图中给出了4位逐位进位全加器,请完成其VHDL程序。
(本题16分)
libraryIEEE;
useIEEE.std_logic_1164.all;
useIEEE.std_logic_arith.all;
useIEEE.std_logic_unsigned.all;
entityfull_addisport(
a,b:
in
std_logic_vector(3downto0);
(2)
carr:
sum:
inout
out
std_logic_vector(4downto0);
std_logic_vector(3downto0)
endfull_add;
architecturefull_add_archoffull_addis
componentadder(4)
port(
a,b,c:
carr:
inoutstd_logic;
outstd_logic(6)
endcomponent;
carr(0)<
='
u0:
adderportmap(a(0),b(0),carr(0),carr
(1),sum(0));
u1:
adderportmap(a
(1),b
(1),carr
(1),carr
(2),sum
(1));
(8)(10)
u2:
adderportmap(a
(2),b
(2),carr
(2),carr(3),sum
(2));
(12)
u3:
adderportmap(a(3),b(3),carr(3),carr(4),sum(3));
(14)(16)endfull_add_arch;
四、编程(共50分)
1、完成下图所示的触发器。
(本题10分)
CLRQ
CLK
DQN
entityVposDffis
port(CLK,CLR,D:
inSTD_LOGIC;
----------2分
Q,QN:
outSTD_LOGIC);
----------4分
endVposDff;
architectureVposDff_archofVposDffisbegin
process(CLK,CLR)----------6分
ifCLR='
thenQ<
QN<
elsifCLK'
eventandCLK='
then
Q<
=D;
=notD;
----------8分
----------10分
endVposDff_arch;
2、完成以下4位全加器代码(本题10分)
cin:
std_logic;
cout:
outstd_logic;
architecturefull_add_archoffull_addiscomponentadder
port(a,b,c:
outstd_logic;
outstd_logic);
signalc1,c2,c3:
std_logic;
2分
3、补充完整如下代码,使之完成
4状态不断循环。
(本题
10分)
ARCHITECTUREarcOFssIS
typestatesis(st0,st1,st2,st3
signaloutc:
states;
2分
4分
BEGIN
ENDPROCESS;
ENDarc;
WHENOTHERS=>
outc<
=st0;
4、设计异或门逻辑:
(本题20分)
如下异或门,填写右边的真值表。
(此项5分)
A
B
Y
1
其表达式可以表示为:
(此项5分)a
这一关系图示如下:
a
b&
y
b+
&
试编写完整的VHDL代码实现以上逻辑。
可以采用任何描述法。
(此项10分)libraryieee;
1分
entityyihuo1is
port(a,b:
instd_logic;
y:
outstd_logic);
endyihuo1;
4分
architectureyihuo1_behaviorofyihuo1is
begin7分
process(a,b)y<
=axorb;
begin(第2种写法)
ifa=bthen
.'
endyihuo1_behavior;
10分
四、编程(共50分,除特殊声明,实体可只写出PORT语句,结构体要写完整)
1、用IF语句编写一个二选一电路,要求输入a、b,sel为选择端,输出q。
Entitysel2isPort(
a,b:
sel:
q:
outstd_logic
Endsel2;
(3)
Architectureaofsel2isbegin
ifsel=‘0’then
=a;
=b;
(9)
2、编写一个4位加法计数器VHDL程序的进程(不必写整个结构框架),要求复位信号
reset低电平时计数器清零,变高后,在上升沿开始工作;
输入时钟信号为clk,输出为q。
Process(reset,clk)
(2)
en
b
y0y1y2
00000000
000
00000010
001
00000100
010
00001000
011
00010000
100
00100000
101
01000000
110
10000000
111
xxxxxxxx
高阻态
en:
outstd_logic_vector(2downto0)
architectureaofeight_triis
(4)begin
=“000”when(sel=”100000001”)else“001”when(sel=”100000010”)else“010”when(sel=”100000100”)else“011”when(sel=”100001000”)else
“100”
when(sel=
”100010000
”)else
“101”
”100100000
“110”
”101000000
“111”
”110000000
(9)
“zzz”;
(10)
4、根据已给出的全加器的VHDL程序,试写出一个4位逐位进位全加器的VHDL程序。
(本题15分)libraryIEEE;
entityadderis
endadder;
inoutstd_logic;
architectureadder_archofadderisbegin
sum<
=axorbxorc;
carr<
=(aandb)or(bandc)or(aandc);
endadder_arch;
entityfull_addis
instd_logic_vector(3downto0);
inoutstd_logic_vector(4downto0);
outstd_logic_vector(3downto0)
(5)
inoutstd_logic;
sum:
outstd_logic
adderportmap(a
(1),b
(1),carr
(1),carr
(2),sum
(1));
adderportmap(a(3),b(3),carr(3),carr(4),sum(3));
endfull_add_arch;
(15)
1、用IF语句编写一个四选一电路,要求输入d0~d3,s为选择端,输出y。
entityMUX4isport(
instd_logic_vector(1downto0);
instd_logic_vector(3downto0);
y:
(4)
(7)
endbehave;
equ_tmp<
3、填写完成一个3-8线译码器的真值表(5分),并写出其VHDL程序(10分)。
3-8译码器的真值表
a2a1a0
00000001
entitytri_eightisport(
a:
instd_logic_vector(2downto0);
outstd_logic_vector(7downto0)
endtri_eight;
architectureaoftri_eightis
std_logic_vector(3downto0);
sel(0)<
=a(0);
sel
(1)<
=a
(1);
sel
(2)<
=a
(2);
sel(3)<
=en;
(5)withselselect
00000001"
when"
1000"
"
00000010"
1001"
00000100"
1010"
00001000"
1011"
00010000"
1100"
00100000"
1101"
01000000"
1110"
10000000"
1111"
00000000"
whenothers;
4、根据已给出的二-十(BCD)进制优先权编码器功能表,试写出其VHDL程序。
15分)
输入
输出
I1
I2
I3
I4
I5
I6
I7
I8
I9
Y3
Y2
Y1
Y0
X
entityprioris
port(
d:
instd_logic