EDN首页   博客首页

日志档案

发表于 2008-8-19 13:18:12

1

标签: 无标签

循环彩灯8路

点击下载library ieee ;

use ieee.std_logic_1164.all;

entity lamp is

port (nrst : in std_logic;         --negative

      shift_direction:in std_logic;--'1' for right ; '0' for left

      clk:in std_logic;

      Q : out std_logic_vector(7 downto 0) --controll 8 led lamp

     );

end lamp;

architecture lamp of lamp is

signal temp :  std_logic_vector(7 downto 0);

begin

 

process(clk,nrst,shift_direction)

 

begin

if nrst='0' then

temp(7 downto 0) <="10000000";

elsif clk'event and clk = '1' then

    if  shift_direction = '1' then

        temp(7 downto 0) <= temp(0) & temp(7 downto 1) ;

    else

        temp(7 downto 0) <= temp(6 downto 0) & temp(7);

    end if;

end if;

q(7 downto 0)<=temp(7 downto 0);

end process;

end lamp;

系统分类: CPLD/FPGA   |   用户分类: VHDL/FPGA学习   |   来源: 原创   |   【推荐给朋友】   |   【添加到收藏夹】

    阅读(473)    回复(0)  

投一票您将和博主都有获奖机会!