一段小程序,求解...
library IEEE;use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
--******************实体定义***********************
ENTITY dianzhen IS
PORT(clk : IN STD_LOGIC;--时钟输入
l : out STD_LOGIC_VECTOR(7 downto 0);--输出点阵行控制
bell: out std_logic;--蜂鸣器输出
b : out STD_LOGIC_VECTOR(7 downto 0)--点阵列控制
);
END dianzhen;
--******************构造体定义*********************
ARCHITECTURE led OF dianzhen IS
signal clk_1k :std_logic;--1k时钟
signal clk_1h :std_logic;--1h时钟
signal p:integer range 0 to 15;
signal c : integer range 0 to 15;
BEGIN
bell<='1';
--led<="00000000";
--l1<="111111";
--**************1k分频进程***************************
process(clk)
variable cnt1 : integer range 0 to 124;
variable cnt2 : integer range 0 to 199;
begin
if clk'event and clk='1' then
if cnt1=124 then
cnt1:=0;
if cnt2=199 then
cnt2:=0;
clk_1k<= not clk_1k;
else
cnt2:=cnt2+1;
end if;
else
cnt1:=cnt1+1;
end if;
end if;
end process;
--*****************汉字滚动进程***************************
process(p,clk_1k)
FUNCTION word(bcd8421:INTEGER RANGE 0 TO 23) RETURN STD_LOGIC_VECTOR IS
VARIABLE smg7: STD_LOGIC_VECTOR(7 DOWNTO 0);
BEGIN--汉字编码
CASE bcd8421 IS
when 0=>smg7:="00011000";
when 1=>smg7:="00100100";
when 2=>smg7:="01000010";
when 3=>smg7:="10000001";
when 4=>smg7:="10000001";
when 5=>smg7:="01000010";
when 6=>smg7:="00100100";
when 7=>smg7:="00011000";
when 8=>smg7:="00001110";
when 9=>smg7:="00111111";
when 10=>smg7:="01111111";
when 11=>smg7:="11111110";
when 12=>smg7:="11111110";
when 13=>smg7:="01111111";
when 14=>smg7:="00111111";
when 15=>smg7:="00001110";
when 16=>smg7:="00011000";
when 17=>smg7:="00011000";
when 18=>smg7:="00111100";
when 19=>smg7:="11100111";
when 20=>smg7:="11100111";
when 21=>smg7:="00111100";
when 22=>smg7:="00011000";
when 23=>smg7:="00011000";
END CASE;
RETURN smg7;
END word;
variable cnt : integer range 0 to 255;
begin
if clk_1k'event and clk_1k='1' then
p<=p+1;
if cnt=255 then
cnt:=0;
clk_1h<=not clk_1h;
else
cnt:=cnt+1;
end if;
end if;
case p is
when 0 => b<="11111110";l<=word(c);
when 1 => b<="11111101";l<=word(c+1);
when 2 => b<="11111011";l<=word(c+2);
when 3 => b<="11110111";l<=word(c+3);
when 4 => b<="11101111";l<=word(c+4);
when 5 => b<="11011111";l<=word(c+5);
when 6 => b<="10111111";l<=word(c+6);
when 7 => b<="01111111";l<=word(c+7);
end case;
end process;
process(clk_1h)
begin
if clk_1h'event and clk_1h='1' then
c<=c+1;--地址加
end if;
end process;
end led;
上面程序是一个8*8点阵从右向左显示三个图片,一个菱形,一个心形,一个十字型,可是问题是十字形刚刚显示完全就马上消失并显示完整的菱形...我想要的结果是十字形显示后慢慢移动到最左边,移动的时候菱形也就慢慢显示出来
不知道诸位明白不,就是最后一张图片显示完全后不要来瞬变显示到第一张图片,而是第一张接在最后一张后面徐徐显示出....
不知道诸位明白不................
烦.... 你的C范围 0--15,你的图形是24,你最好C=0--31,图形在扩展一个,24不好取模,或者最后一组是全灭,你四组图形----菱 心 十字 空白 看来只能这样了....谢谢老兄..
页:
[1]