;
文章:行业新闻EDA文摘电源技术无线通信测量仪表嵌入式类电子技术制造技术半导体网络/协议展会实验家电维修  
  下载:EDA教程电源技术电子书籍电子元件无线通信通信网络电路图纸嵌入式类单片机传感/控制电子教材模拟数字
.... 音视频类
消费电子机械电子行业软件C/C++FPGA/ASIC规则标准家电维修DSPIC资料ARM软件电路图电子技术论坛
 
位置:电子发烧友 > 行业新闻 > 嵌入式类 > FPGA/ASIC技术 >LED控制VHDL程序与仿真 退出登录 用户管理
栏目导航


· 单片机类 · 接口/总线/驱动
· ARM · DSP
· FPGA/ASIC技术 · 设计应用
· 嵌入式操作系统 · 电视卡
热门文章
· [组图] 电子元器件基础知识...
· [图文] USB接口定义
· [图文] 三极管开关电路图
· [组图] RS232 RS485接口原理...
· [组图] [组图]电动车充电器...
· [组图] 电子捕鱼器电路图
· [组图] 高品质音调电路的制...
· [组图] JRC4558电路
· [图文] M51134P低音炮电路图...
· [图文] TL494脉宽调制控制电...
相关文章

· [图文] LED控制驱动电路原理...
· 60V、高压侧检测LED...
· LCD控制VHDL程序与仿...
· [图文] 出租车计价器VHDL程...
· [组图] 出租车计价器VHDL程...
· 步进电机定位控制系...
· 多功能波形发生器VH...
· [组图] 电池供电产品的LED控...
· [组图] 电池供电产品的LED控...
· [组图] 使用LeonardoSpectr...

LED控制VHDL程序与仿真
作者:本站  来源:www.elecfans.com  发布时间:2008-6-27 11:20:40 减小字体 增大字体

LED控制VHDL程序与仿真
分别介绍采用FPGA对LED进行静态和动态显示的数字时钟控制程序。
1. 例1:FPGA驱动LED静态显示
--文件名:decoder.vhd。
--功能:译码输出模块,LED为共阳接法。
--最后修改日期:2004.3.24。
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity decoder is
Port (seg:in std_logic_vector(3 downto 0 );   --四位二进制码输入
q3:out std_logic_vector(6 downto 0) );  --输出LED七段码
end decoder;

architecture Behavioral of decoder is
begin
process(seg)
begin
case seg is
when "0000" => q3<="0000001";--0  
when "0001" => q3<="1001111";--1
when "0010" => q3<="0010010";--2
when "0011" => q3<="0000110";--3
when "0100" => q3<="1001100" --4
when "0101" => q3<="0100100";--5
when "0110" => q3<="0100000";--6
when "0111" => q3<="0001111";--7
when "1000" => q3<="0000000";--8
when "1001" => q3<="0000100";--9
when others => q3<="1111111";
end case;
end process;
end Behavioral;
2. 例2:FPGA驱动LED动态显示(4位)
--文件名:dynamic.vhd。
--功能:动态扫描模块,位选信号高电平有效。
--最后修改日期:2004.3.24。
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity dynamic is 
  Port ( clk : in std_logic;
    reset: in std_logic;
  din1 : in std_logic_vector(6 downto 0);       --译码后的数据信号1(4位2进制数据
通过例1中的decoder模块译码得到din1,din2,din3,din4)
       din2 : in std_logic_vector(6 downto 0);       --译码后的数据信号2
       din3 : in std_logic_vector(6 downto 0);       --译码后的数据信号3
       din4 : in std_logic_vector(6 downto 0);       --译码后的数据信号4
    shift: out std_logic_vector(3 downto 0);      --位选信号
       bus4 : out std_logic_vector(6 downto 0));     --数据信号
end dynamic;

architecture Behavioral of dynamic is
  signal scan_clk:std_logic_vector(1 downto 0);
begin
process(clk,scan_clk,reset)                        --分频进程
variable scan:std_logic_vector(17 downto 0);
begin
if reset='1' then
scan:="000000000000000000";
 scan_clk<="00";
elsif clk'event and clk='1'then
scan:=scan+1;
end if;
 scan_clk<=scan(17 downto 16);
end process;

process(scan_clk,din1,din2,din3,din4)       --扫描进程
begin
case scan_clk is
when "00"=>
   bus4<=din1;
   shift<="0001";
 when "01"=>
   bus4<=din2;
   shift<="0010";
 when "10"=>
   bus4<=din3;
   shift<="0100";
when "11"=>
   bus4<=din4;
   shift<="1000";
 when others=> bus4<="0000000";shift<="0000";
end case;
end process; 

end Behavioral;

[] [返回上一页] [打 印] [收 藏]
 
∷相关文章评论∷    (评论内容只代表网友观点,与本站立场无关!) [更多评论...]
 
关于本站- 意见反馈 - 网站导航 - 帮助 - 隐私政策 - 联系我们 - 使用条款 - 安全承诺 - 友情连接
站长QQ:39550527 Powered by: 飓风网络(电路图
Copyright 2006-2008 Elecfans.Com.电子发烧友: 粤ICP备07065979号All Rights Reserved