跪求8位彩灯控制器VHDL代码,最好能附原理图!!!

小弟是测控专业学生,最近在数电课程设计,任务就是彩灯控制器,要求花样是彩灯隔行循环点亮,急求啊!... 小弟是测控专业学生,最近在数电课程设计,任务就是彩灯控制器,要求花样是彩灯隔行循环点亮,急求啊! 展开
 我来答
ecpq48
2010-11-10 · TA获得超过148个赞
知道答主
回答量:504
采纳率:0%
帮助的人:261万
展开全部
library ieee;
use ieee.std_logic_1164.all;
entity fengxi is port(
q:in std_logic_vector(5 downto 0);
rst,adjust,clk:in std_logic;
y:out std_logic_vector(7 downto 0));
end;

architecture behavioal of fengxi is
type states is (s0,s1,s2,s3,s4,s5,s6);
signal state:states;
signal k:integer range 0 to 3;
signal en,clk_low,clk_use:std_logic;
signal y_out,y_out1:std_logic_vector(7 downto 0);
begin
process(clk,rst)--分频
begin
if rst='1' then
k<=0;clk_low<='0';
else
if(clk'event and clk='1') then
if k=3 then
k<=0; clk_low<=not clk_low;
else
k<=k+1;
end if;
end if;
end if;
end process;

process(clk,adjust)==调速
begin
if adjust='1' then
clk_use<=clk;end if;
if adjust='0' then
clk_use<=clk_low;
end if;
end process;

process(q)--手动
begin
if q="000000" then en<='1';else en<='0'; end if;

if q="000001" then y_out1<="00000001";end if;
if q="000010" then y_out1<="00000010";end if;
if q="000100" then y_out1<="00000011";end if;
if q="001000" then y_out1<="00000100";end if;
if q="010000" then y_out1<="00000101";end if;
if q="100000" then y_out1<="00000110";end if;

end process;

process(rst)--循环
begin
if (rst='1') then
state<=s0;else
if(clk_use'event and clk_use='1') then
case state is
when s0 =>
state<=s1;
when s1=>
state<=s2;
when s2=>
state<=s3;
when s3 =>
state<=s4;
when s4=>
state<=s5;
when s5=>
state<=s6;
when s6=>
state<=s1;
end case;
end if;
end if;
end process;

process(rst,q)
begin
if rst='1' then
y_out<="00000000";
else
case state is
when s0=>
y_out<="00000000";
when s1=>
y_out<="00000001";
when s2=>
y_out<="00000010";
when s3=>
y_out<="00000011";
when s4=>
y_out<="00000100";
when s5=>
y_out<="00000101";
when s6=>
y_out<="00000110";

end case;
end if;
if en='1' then
y<=y_out;end if;
if en='0' then
y<=y_out1;end if;
end process;

end;
请参考
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式