|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity scan is
port(clk:in bit;
clr:in bit;
led_sel: out std_logic_vector(5 downto 0);
led_data: out bit_vector(7 downto 0)
);
end scan;
architecture logic of scan is
type display is array(16 downto 0)of bit_vector(7 downto 0);
signal count : integer:=0;
signal led_sel_t : std_logic_vector(5 downto 0) :="000001";
--
signal led_data_t: bit_vector(7 downto 0);
signal clk1: bit ;
signal count1 : integer range 0 to 12 :=11;
constant led_display: display:=("11111111","11111111","11111111","11111111","11111111",
"00100101","00011001","00000011","00001101","00100101","00000011",
"11111111","11111111","11111111","11111111","11111111","11111111"
);
begin
process(clk,clr)
begin
if clr='1'then
count<=0;clk1<='0';
elsif(clk'event and clk='1')then
if(count=5)then
count<=0;
clk1<=not clk1;
else
count<=count+1;
end if;
end if;
end process;
-------------------------------------
-------------------数据滚动------------
process(clk,clr)
begin
if clr='1'then
count1<=0;
elsif(clk1'event and clk1='1')then
if(count1=12)then
count1<=0;
else
count1<=count1+1;
end if;
end if;
end process;
----------------------------------------
----动态扫描 -----------
process(clr,clk)
variable count2: integer range 5 downto 0 :=5;
begin
if clr='1'then
count2:=0;
led_data_t<="11111111";
led_sel_t<="111110";
elsif(clk'event and clk='1')then
for count2 in 5 downto 0 loop
led_data_t<=led_display(count1 + count2); ----led_data对应赋值----------
led_sel_t<=led_sel_t(4 downto 0) & led_sel_t(5); --------位选移位--------
end loop;
end if;
end process;
led_sel<=led_sel_t;
led_data<=led_data_t;
-------------------------------
end logic; |
|