本科实验报告
实验名称:数字系统设计与实验(软件部分)
实验一 QuartusII 9.1软件的使用
一、实验目的
1、通过实现简单组合逻辑电路,掌握QUARTUSII 9.1软件的使用;
2、编程实现3-8译码电路以掌握VHDL组合逻辑的设计以及QUARTUSII 9.1软件的使用。;
二、实验内容
1、3-8译码电路VHDL组合逻辑的设计
A、3-8译码电路真值表
B、功能仿真波形图:
C、时序仿真波形图:
D、VHDL代码
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity decoder3_8 is
port(en:in std_logic;
sel:in std_logic_vector(2 downto 0);
qout:out std_logic_vector(7 downto 0)); end decoder3_8;
architecture beha of decoder3_8 is
signal sina_in:std_logic_vector(2 downto 0); signal sina_out:std_logic_vector(7 downto 0);
begin
sina_in<=sel;
process(sina_in,en)
begin
if(en='0')then
case sina_in is
when"000"=>sina_out<="00000001";
when"001"=>sina_out<="00000010"; when"010"=>sina_out<="00000100"; when"011"=>sina_out<="00001000"; when"100"=>sina_out<="00010000"; when"101"=>sina_out<="00100000"; when"110"=>sina_out<="01000000"; when"111"=>sina_out<="10000000"; when others=>sina_out<="00000000"; end case; end if; qout<=sina_out; end process; end beha;
2、共阳极七段译码器VHDL 组合逻辑的设计
A 、共阳极七段译码器管脚分布及电路结构
a
b
c
d
e
f
g
如下如所示:显示0时,a,b,c,d,e,f 管脚接低电平,g 管脚接高电平点亮的二极管会显示数字0 。如图所示:
B功能仿真波形图:
C时序仿真波形图:
D、VHDL代码
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity seg7 is
port(clk,load,en:in std_logic;
data_in:in std_logic_vector(3 downto 0);
seg:out std_logic_vector(6 downto 0)); end seg7;
architecture beha of seg7 is
signal qout:std_logic_vector(3 downto 0); signal q_temp:std_logic_vector(3 downto 0);
begin
process(clk,load)
begin
if(load='1')then
q_temp<=data_in;
elsif(clk'event and clk='1')then
if(en='0')then
qout<=qout;
elsif(qout="1001")then
qout<="0000";
else
qout<=qout+1;
end if;
q_temp<=qout;
end if;
end process;
process(q_temp)
begin
case q_temp is
when"0000"=>seg<="1000000";
when"0001"=>seg<="1111001";
when"0010"=>seg<="0100100";
when"0011"=>seg<="0110000";
when"0100"=>seg<="0011001";
when"0101"=>seg<="0010010";
when"0110"=>seg<="0000010";
when"0111"=>seg<="1111000";
when"1000"=>seg<="0000000";
when"1001"=>seg<="0010000";
when others=>seg<="0001000";
end case;
end process;
end beha;
实验二模十状态机与7段译码器显示
一、实验目的
通过设计频率可选的模十状态机以及7段译码电路以进一步掌握VHDL硬件描述语言。
二、实验内容
此设计包括分频器、多路选择器、状态机和译码器。
时钟输入作为分频器的输入,输出时钟分别为2分频、4分频、8分频和16分频;
四个频率的时钟信号由4选1的多路选择器选择其中之一作为状态机的时钟输入;
使用选中的时钟频率作为输入驱动状态机按照以下的次序输出:0->2->5->6->1->9->4->8->7->3->0的顺序输出;
使用此输出作为驱动输入到7段译码器的显示逻辑。
功能仿真结果:
图1总体仿真结果
图2 二分频结果
图3 四分频结果
图4 八分频结果
图5 十六分频结果
实验三数字钟的设计与仿真
一、实验目的
通过设计实现四种频率可选的数字钟的设计与仿真,以熟悉VHDL语言编程。
二、实验内容
系统整体由分频器、多路选择器和计数器三个模块组成。
输入引脚有5根,分别为时钟(提供整个系统的时钟信号)、选择器输入Sel1、Sel0(选择不同的频率输入)、复位信号,以及置位信号。
输出引脚有24根,分别为时个位hour_low(3 downto 0)和十位hour_high (3 downto 0)、分钟个位min_low(3 downto 0)和十位min_high (3 downto 0)、秒个位second_low(3 downto 0)和十位secondr_high (3 downto 0)。
功能仿真结果如下图所示:
图1 总体功能仿真
图2 59秒跳变
图3 9分59秒跳变
图4 59分59秒跳变
图5 9时59分59秒跳变
图6 23时59分59秒跳变
【实验心得】
本次实验比较难,设计的知识点比较多,开始的时候感觉难以下手,最初并不知道因为线路重叠要采取一些特殊的方法,把代码打上去结果程序不能运行成功,在仔细阅读使用手册后才发现这个问题,所以前面浪费了一些时间,总体来说,本次的所用到的模块基本在以前的试验中都有使用,问题的难点就在于,如何把这些代码结合起来而不出差错,在此,我又能体会到规范编程的重要性,实验中还有一个需要解决的问题就是数码管显示不稳定,会有闪烁的现象,请教了同学也查阅了资料才得以解决。最后能够把程序运行成功,自己也很开心,学到了很多知识,也锻炼了自己的综合编程能力。