elseL<='0';G<='0';M<='1';
endif;
endprocessp1;
endbehave;
编译:
2、功能仿真波形:
3、管脚分配情况:
A3:
SW7PIN_C13
A2:
SW6PIN_AC13
A1:
SW5PIN_AD13
A0:
SW4PIN_AF14
B3:
SW3PIN_AE14
B2:
SW2PIN_P25
B1:
SW1PIN_N26
B0:
SW0PIN_N25
G:
LEDR2PIN_AB21
M:
LEDR1PIN_AF23
L:
LEDR0PIN_AE23
实验3并行加法器设计
3.1实验目的
1.设计一个4位加法器。
2.体会用HDL进行逻辑描述的优点。
3.2实验仪器与器材
1.EDA开发软件一套
2.微机一台
3.实验开发系统一台
4.打印机一台
5.其他器件与材料若干
3.3实验说明
本实验实现一个4位二进制数加法器,其功能框图如图8.2所示。
实验时用高低电平开关作为输入,用数码管作为输出(或用发光二极管),管脚锁定可根据实验系统自行安排。
图8.2全加器功能框图
3.4实验要求
1.用硬件描述语言编写4位二进制数全加器的源文件;
2.对设计文件进行编译;
3.仿真设计文件。
4.编程下载并进行实验验证。
3.5实验报告要求
1.写出全加器的HDL源文件;
2.写出仿真和硬件测试结果;
3.管脚分配情况。
3.6实验报告内容:
1、全加器的VHDL源文件:
libraryieee;
useieee.std_logic_1164.all;
entityadder4is
port(a,b:
instd_logic_vector(3downto0);
cin:
instd_logic_vector(3downto0);
sum:
outstd_logic_vector(3downto0);
count:
outstd_logic);
endadder4;
architecturebehaveofadder4is
begin
p1:
process(a,b,cin)
variablevsum:
std_logic_vector(3downto0);
variablecarry:
std_logic;
begin
carry:
=cin(0);
foriin0to3loop
vsum(i):
=(a(i)xorb(i))xorcarry;
carry:
=(a(i)andb(i))or(carryand(a(i)orb(i)));
endloop;
sum<=vsum;
count<=carry;
endprocessp1;
endbehave;
编译:
2.、功能仿真波形和硬件测试结果:
硬件测试:
硬件测试正常,实现全加器逻辑。
4、管脚分配情况:
a[3]:
SW7PIN_C13
a[2]:
SW6PIN_AC13
a[1]:
SW5PIN_AD13
a[0]:
SW4PIN_AF14
b[3]:
SW3PIN_AE14
b[2]:
SW2PIN_P25
b[1]:
SW1PIN_N26
b[0]:
SW0PIN_N25
sum[3]:
LEDR3PIN_AC22
sum[2]:
LEDR2PIN_AB21
sum[1]:
LEDR1PIN_AF23
sum[0]:
LEDR0PIN_AE23
cin:
SW17PIN_V2
count:
LEDG7PIN_Y18
实验4计数器设计
4.1实验目的
计数器是实际中最为常用的时序电路模块之一,本实验的主要目的是掌握使用HDL描述计数器类型模块的基本方法。
4.2实验仪器与器材
1.EDA开发软件一套
2.微机一台
3.实验开发系统一台
4.打印机一台
5.其他器件与材料若干
4.3实验说明
计数器是数字电路系统中最基本的功能模块之一,设计时可以采用原理图或HDL语言完成。
下载验证时的计数时钟可选用连续或单脉冲,并用数码管显示计数值。
4.4实验要求
1.设计一个带有计数允许输入端、复位输入端和进位输出端的10进制计数器。
2.编制仿真测试文件,并进行功能仿真。
3.下载并验证计数器功能。
4.为上述设计建立元件符号。
5.选做:
在上述基础上设计按8421BCD码计数的100进制同步计数器。
4.5实验报告要求
1.画出原理图或写出HDL语言源文件。
2.打印仿真波形。
3.管脚分配情况。
4.6实验报告内容:
1、VHDL语言描述:
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entitymy_countis
port(en,reset,clk:
instd_logic;
q:
bufferstd_logic_vector(3downto0);
co:
outstd_logic);
endmy_count;
architecturebehaveofmy_countis
begin
process(clk,en)
begin
ifclk'eventandclk='1'then
ifreset='1'thenq<="0000";
elsifen='1'then
ifq<"1001"thenq<=q+'1';
elseq<="0000";
endif;
endif;
endif;
endprocess;
co<='1'whenq="1001"else'0';
endbehave;
编译:
2、仿真波形:
四线七线译码器:
libraryieee;
useieee.std_logic_1164.all;
entitydecoder4_7is
port(insign:
instd_logic_vector(3downto0);
outsign:
outstd_logic_vector(6downto0));
enddecoder4_7;
architecturebehaveofdecoder4_7is
begin
process(insign)
begin
caseinsignis
when"0000"=>outsign<="0000001";
when"0001"=>outsign<="1001111";
when"0010"=>outsign<="0010010";
when"0011"=>outsign<="0000110";
when"0100"=>outsign<="1001100";
when"0101"=>outsign<="0100100";
when"0110"=>outsign<="1100000";
when"0111"=>outsign<="0001111";
when"1000"=>outsign<="0000000";
when"1001"=>outsign<="0001100";
whenothers=>outsign<="1111111";
endcase;
endprocess;
endbehave;
1、编译:
2、仿真:
十进制计数器:
1、原理图:
2、仿真波形:
3、管脚分配情况:
clkKEY[2]PIN_P23
enSW1PIN_N26
resetSW0PIN_N25
coLEDG[7]PIN_Y18
outsign[0]HEX0[0]PIN_AF10
outsign[1]HEX0[1]PIN_AB12
outsign[2]HEX0[2]PIN_AC12
outsign[3]HEX0[3]PIN_AD11
outsign[4]HEX0[4]PIN_AE11
outsign[5]HEX0[5]PIN_V14
outsign[6]HEX0[6]PIN_V13
4、生成符号图:
百进制计数器:
1、原理图:
2、仿真波形:
3、管脚分配情况:
clkKEY[2]PIN_P23
enSW1PIN_N26
resetSW0PIN_N25
ql[0]HEX0[0]PIN_AF10
ql[1]HEX0[1]PIN_AB12
ql[2]HEX0[2]PIN_AC12
ql[3]HEX0[3]PIN_AD11
ql[4]HEX0[4]PIN_AE11
ql[5]HEX0[5]PIN_V14
ql[6]HEX0[6]PIN_V13
qh[0]HEX1[0]PIN_V20
qh[1]HEX1[1]PIN_V21
qh[2]HEX1[2]PIN_W21
qh[3]HEX1[3]PIN_Y22
qh[4]HEX1[4]PIN_AA24
qh[5]HEX1[5]PIN_AA23
qh[6]HEX1[6]PIN_AB24
coLEDG[7]PIN_Y18
4、生成符号图:
实验5巴克码发生器
5.1实验目的
1.实现一个在通信领域中经常使用的巴克码发生器。
2.掌握用大规模可编程逻辑器件实现时序电路的方法。
5.2实验仪器与器材
1.EDA开发软件一套
2.微机一台
3.实验开发系统一台
4.打印机一台
5.其他器件与材料若干
5.3实验说明
巴克码发生器在数据通信、雷达和遥控领域有相当广泛的应用。
它能自动产生周期性的序列码。
本实验要求产生的序列码信号为{1110010},可以用寄存器或同步时序电路实现。
为了能够通过实验开发系统验证实验结果,可以使用两个输出端,其中一个输出端同时输出巴克码,另一个输出端输出节拍。
巴克码发生器的功能框图见图8.4所示。
5.4实验要求
1.写出全部设计文件。
2.编写测试向量,进行功能仿真。
3.下载并用实验板验证。
5.5实验报告要求
1.写出全部设计文件。
2.
图8.4巴克码发生器示意图
打印仿真报告和波形。
3.管脚分配情况。
5.6实验报告内容:
在实验中我使用VHDL语言描述来实现巴克马发生器的功能。
1、巴克码发生器VHDL源文件:
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_arith.all;
useieee.std_logic_unsigned.all;
entitybackis
port(clk,reset:
instd_logic;
dout1,dout2:
outstd_logic);
endback;
architecturebehaveofbackis
signalcount7:
integerrange0to6;
begin
process(clk,reset)
begin
ifreset='1'thencount7<=0;
elsifclk'eventandclk='1'then
ifcount7<6then
count7<=count7+1;
elsecount7<=0;
endif;
endif;
dout2<=clk;
endprocess;
process(count7)
begin
casecount7is
when0=>dout1<='1';
when1=>dout1<='1';
when2=>dout1<='1';
when3=>dout1<='0';
when4=>dout1<='0';
when5=>dout1<='1';
when6=>dout1<='0';
whenothers=>dout1<='0';
endcase;
endprocess;
endbehave;
编译:
2、仿真波形:
为了将巴克码清楚地显示,在巴克码发生器后的输出端dout1加以一线七线译码器,然后连接到数码管显示,输出时钟用LED灯显示即可。
一线七线译码器VHDL语言描述:
libraryieee;
useieee.std_logic_1164.all;
entitydecoder1_7is
port(insign:
instd_logic_vector(0downto0);
outsign:
outstd_logic_vector(6downto0));
enddecoder1_7;
architecturebehaveofdecoder1_7is
begin
process(insign)
begin
caseinsignis
when"0"=>outsign<="0000001";
when"1"=>outsign<="1001111";
whenothers=>outsign<="1111111";
endcase;
endprocess;
endbehave;
仿真:
巴克码发生器总连接图:
总连接图仿真波形:
3、管脚分配情况:
clk:
KEY[2]PIN_P23
reset:
SW0PIN_N25
dout1[0]:
HEX0[6]PIN_V13
dout1[1]:
HEX0[5]PIN_V14
dout1[2]:
HEX0[4]PIN_AE11
dout1[3]:
HEX0[3]PIN_AD11
dout1[4]:
HEX0[2]PIN_AC12
dout1[5]:
HEX0[1]PIN_AB12
dout1[6]:
HEX0[0]PIN_AF10
dout2:
LEDG[7]PIN_Y18
4、生成符号图: