资源描述
实验五 数字电路系统实验——设计一个方波信号输出电路
一、实验目的
1.设计一个方波信号产生电路,并在实验装置上验证所设计的电路;
2.建立自顶向下的设计思路。
二、实验要求
设计一个占空比为20%、周期为1S的方波信号,并用末位数码管进行指示——当方波信号为高电平时,数码管显示2;当方波信号为低电平时,数码管显示8。
三、实验方案
占空比为20%,周期为1S的方波,可分为0.2S的高电平和0.8S的低电平;可设计一个计数器,当计数值小于999999输出高电平,当计数值大于999999小于4999999输出低电平,大于4999999后清零重新计时。
数码管显示模块用组合逻辑电路组成,当分频计数器高电平时输出数码“2”,低电平时输出数码管“8”。
四、实验步骤
1.建立新的工程
2.建立计数分频结构
div.vhd
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity div is
port(clk:in std_logic;
divout:out std_logic;
public:out std_logic);
end;
architecture one of div is
signal cnt:std_logic_vector(9 downto 0);
signal clk_temp:std_logic;
constant m:integer:=1000; --1M div
begin
process(clk)
variable s:std_logic;
begin
if clk 'event and clk='1' then --上升沿
if cnt=m then
clk_temp<=not clk_temp;
cnt<=(others=>'0');
else
cnt<=cnt+1; --计数
clk_temp<=clk_temp; --反转
end if;
end if;
divout<=clk_temp;
s:='1';
public<=s;
end process;
end;
3.建立数码管显示结构:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity LED is
port(number:in std_logic;
ledout:out std_logic_vector(7 downto 0));
end;
architecture u1 of LED is
begin
with number select
ledout<="01011011"when'1', --高电平显示“2”
"01111111"when'0'; --低电平显示“8”
end;
4.顶层设计中将分频计数实体和数码管显示实体相连接;
5.配置引脚,编译下载。
五、实验结果
下载完成后,可以看到数码管交替显示“2” “8”,周期大约为1S。
展开阅读全文