VHDL写的一个数码管滚动流水显示,总是显示不正确,高手帮忙验证一下。
时间:10-02
整理:3721RD
点击:
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;
先把代码写清晰,像这样乱乱的
lz把问题描述清楚吧,主要是
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);
这几行的问题吗? 如果没记错的话&应该是拼接符吧?而且究竟是什么地方错了都不知道,看到这么长的程序,就没往下读的冲动了!
请把代码排版好,什么地方出错了说明清楚,附上出错时候的波形图。
通读了下代码。技术不过关的时候,不要用constant、integer、bit_vector、variable,否则很难理解硬件和软件的区别
