赞
踩
名称:多路彩灯控制器led流水灯VHDL速度可调
软件:Quartus
语言:VHDL
代码功能:
使用VHDL设计彩灯控制器,共24个led灯,分为5种不同的花样,可以通过按键切换花样的变化速度。
代码下载:
部分代码展示
LIBRARY ieee; USE ieee.std_logic_1164.all; USE ieee.std_logic_unsigned.all; --彩灯控制模块 ENTITY caideng_ctrl IS PORT ( clk_div : IN STD_LOGIC;--控制时钟 reset_p : IN STD_LOGIC;--高电平复位 led : OUT STD_LOGIC_VECTOR(23 DOWNTO 0)--输出灯 ); END caideng_ctrl; ARCHITECTURE ctrl OF caideng_ctrl IS --中间信号 SIGNAL led_buf : STD_LOGIC_VECTOR(23 DOWNTO 0) := "000000000000000000000000"; SIGNAL state_count : STD_LOGIC_VECTOR(7 DOWNTO 0) := "00000000";--状态计数器 BEGIN PROCESS (clk_div, reset_p) BEGIN IF (reset_p = '1') THEN--复位清零 state_count <= "00000000"; ELSIF (clk_div'EVENT AND clk_div = '1') THEN IF (state_count = "01010001") THEN state_count <= "00000000";--运行结束后循环 ELSE state_count <= state_count + "00000001";--计数 END IF; END IF; END PROCESS; led<=led_buf; PROCESS (clk_div, reset_p) BEGIN IF (reset_p = '1') THEN--复位清零 led_buf <= "000000000000000000000000"; ELSIF (clk_div'EVENT AND clk_div = '1') THEN CASE state_count IS --模式1 WHEN "00000000" => led_buf <= "000000000000000000000000"; WHEN "00000001" => led_buf <= "110011100011100011000110"; WHEN "00000010" => led_buf <= "001100111000111000111001"; WHEN "00000011" => led_buf <= "101110001110001110011100"; WHEN "00000100" => led_buf <= "000111000111000111001110"; WHEN "00000101" => led_buf <= "001100011100011100011100"; --模式2 WHEN "00000110" => led_buf <= "100000000000000000000000"; WHEN "00000111" => led_buf <= "101000000000000000000000"; WHEN "00001000" =>
设计文档:
1. 工程文件
2. 程序文件
3. 程序编译
4. RTL图
5. 仿真文件
Testbench
6. 仿真图
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。