本文为大家带来四种不同的vhdl数码管动态扫描程序设计。
vhdl数码管动态扫描一:循环滚动
实现的功能
循环滚动,始终点亮6个数码管,左出右进。状态为:012345-123450-234501-345012-450123-501234-012345
实现代码:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all
entity led2 is
port(clk:in std_logic;
sg:out std_logic_vector(6 downto 0); bt:out std_logic_vector(5 downto 0)); end led2;
architecture ace of led2 is component div_2k
port(clk_in:instd_logic; clk_out:outstd_logic);
end component;
signal cnt6:integer range 0 to 5;
signal a:integer range 0 to 5;
signal count:integer range 0 to 4999 := 0;
signal flag:integer range 0 to 6 := 0;
signal flag_a:integer range 0 to 5;
signal clk_tmp:std_logic;
begin
u1:div_2k port map(clk_in=>clk,clk_out=>clk_tmp);
p1:process(cnt6)
begin
case cnt6 is --3线至6线译码器
when 0 => bt <= “011111” a bt<= “101111” a bt<= “110111” a bt<= “111011” a bt<= “111101” a bt<= “111110” a null;
end case
end process p1;
p2:process(clk_tmp)
begin
if clk_tmp‘event and clk_tmp= ’1‘ then --实现模6计数器 if cnt6= 5 then cnt6<= 0; else
cnt6<=cnt6 + 1; end if;
if (flag = 6) then --设置标志 flag <= 0;
end if;
if count =4999 then
--相当于另一个时钟
count <= 0; --计数周期为5000
flag <=flag+1; --当记满5000时左移动一位 else
count <=count+1; --不满5000继续计数 end if; end if;
end process p2;
p3:process(a,flag,flag_a)
begin
flag_a sg sg sg sg sg sg null
end case
end process p3;
end ace;
代码分析:
为实现移位,关键改动为新增一个计数器,技术周期远远大于扫描周期,这样,在一个大的计数周期内,对于要显示的6位数码进行动态扫描(和实验任务1中相同),显示出6种移位状态中的一种;在下一个大的周期内,利用flag标志,并使用求余运算将显示位的数码移位,比如,大的计数周期为0时,flag为0,显示“012345”六位数码,大的周期为1时,falg为1,此时各位求余(即flag_a求余)对应的数码为123450,显示的数码也就为“123450”。以此类推,实现循环移位。
vhdl数码管动态扫描二:计数器数码管动态显示
电路的框架图
电路的框架图
顶层原理图
动态显示计数的vhdl语言描述
动态显示译码模块的vhdl语言的描述
vhdl数码管动态扫描三:数字秒表动态显示
本次设计选用的开发板在4位数码管输入方面只提供1个数据接口,用来动态显示4位数据,在数据输入信号方面要做到和势能控制信号同频率输出,才能保证数码显示不会出错或显示移位。该模块部分vhdl源程序如下:
仿真波形
vhdl数码管动态扫描四:8位数码管输出任意数值的显示电路
实验设计注意事项
在eda/sopc装置中,图示数码管显示采用的是动态扫描方式,即当扫描选通电路74ls138输入为000,(sel2、sel1、sel0为000时,)y0输出低电平,8个数码管中左边第一个数码管被选通,此时,应在数码管输入端输入相应数据。其中,74ls245起输出驱动作用。
人眼视觉暂留频率在24hz以上,如果大于该频率,点亮单个七段显示器,看上去能有8个同时显示的效果,而且显示也不闪烁。因此,选通频率要大于24hz以上。 依据实验装置电路,完成七段led显示译码器的设计应包含如下电路:
①分频电路:将10mhz脉冲分频到1khz;
②七段译码电路;
③扫描计数电路:完成模8的计数电路,为扫描选通做准备;
④扫描选通电路:利用分时传输思想,将要显示的数据依次传入数码管显示电路。
vhdl代码
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity xianshi is
port(clk:in std_logic;
smg:out std_logic_vector(7 downto 0);
sel:out std_logic_vector(2 downto 0));
end entity;
architecture func of xianshi is
signal fp,tmp:std_logic;
signal count:std_logic_vector(9 downto 0);
signal sl:std_logic_vector(2 downto 0);
begin
process(clk)
begin
if(clk‘event and clk = ’1‘)
then if(count = “1111100111”)
then count ’0‘);
tmp <= not tmp; else
count <= count + 1; end if;
end if; fp <= tmp;
end process;
process(fp)
begin
if(fp’event and fp = ‘1’)
then if(sl = “111”)
then sl <= “000”;
else
sl <= sl + 1; end if;
end if;
end process;
sel smg smg smg smg smg smg smg smg null;
end case;
end process;
end architecture;
复合材料有什么好处
海信LED65E7C电视采用四核Mali-T720 MP2图形处理器,物理分辨率高达3840*2160
Rust如何实现A*算法
1m测长机如何测量长度?
英特尔推出英特尔 XMM 7560无线调制解调器 支持下一代LTE Advanced移动终端设备
vhdl数码管动态扫描程序设计(四种设计方案)
华为nova2s拍照评测 打造既专业又惬意的拍摄体验
Waymo发布首份关于自动驾驶汽车的测试情况报告
研究人员制造出模仿昆虫的无人机
拆解分析 不算游戏手机的iQOO 3为何能成为KPL官方比赛用机
新一代SoC FPGA提供系统可信根,防止关键数据受到网络攻击
三星QLED系列通过VDE认证:认证为全球第一!
虞凌云:4000多家人工智能企业大部分未拿到投资 占比70%
利用Web技术和Apache CordoVa加速您的物联网和机器人开发
AG32VF407VGT6 PINtoPIN STMcu、GDMcu,引脚亦可转换位置灵活重新定义
荣耀手表怎么样 到底值不值得买
什么是认知制造认知技术能为制造商解决哪些问题
人工智能如何和区块链相融合
印度计划未来4年内推出5G服务,落后于中日韩
速度检测用到的传感器