大家好,最近编写了一个程序。在试验版的led点阵屏上一次显示字符。我是先把每个要显示的字符设为常量,当时钟信号clk8(8HZ)第16个周期上升沿时,开始输出下一个字符。(先设矢量q,对q计数,16后清零)当时钟clk2(2MHZ)上升沿时,行信号row 加一,开始扫下一行,同时输出对应字符的第row行。 程序如下:library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity xianshi is port( clk8,clk2:in std_logic; row:buffer std_logic_vector(2 downto 0); lineut std_logic_vector(7 downto 0)); end xianshi; architecture Behavioral of xianshi is signal q:std_logic_vector(6 downto 0); signal qq:std_logic_vector(2 downto 0); type romtable is array (0 to 7) of std_logic_vector (7 downto 0); constant word0:romtable:=romtable'( "11111111", --word0~word6定义为常量,是二维数组,每次输出一行 "10000001", -- "10000001", -- "11111111", "10000000", "10000000", "10000000", "10000000"); constant word1:romtable:=romtable'( "10000000", "10000000", "10000000", "10000000", "10000000", "10000000", "10000000", "11111111"); constant word2:romtable:=romtable'( "11110000", "10001000", "10000100", "10000010", "10000010", "10000100", "10001000", "11110000"); constant word3:romtable:=romtable'( "11101111", "00000001", "01101101", "00000001", "01101101", "00000001", "11101111", "11100001"); constant word4:romtable:=romtable'( "00000000", "11111101", "11111011", "00000000", "11110111", "11110111", "11110111", "11100111"); constant word5:romtable:=romtable'( "01000100", "01000100", "01001111", "11111111", "01100110", "01000110", "11001001", "01010001"); constant word6:romtable:=romtable'( "00010100", "00010010", "00010001", "11111111", "00111000", "01010100", "10010010", "10010001"); begin qq<=q(6)&q(5)&q(4); p1:process(clk8,qq) begin if(qq<=6) then if rising_edge(clk8) then q<=q+'1'; end if; else q<="0000000"; end if; end process p1;
p2:process (clk2) begin if rising_edge(clk2) then row<=row+'1'; end if; end process p2; p3:process (row,qq)
begin if (qq=0) then line<=word0(conv_integer (row)); elsif (qq=1) then line<=word1(conv_integer(row)); elsif (qq=2) then line<=word2(conv_integer(row)); elsif(qq=3) then line<=word3(conv_integer(row)); elsif (qq=4) then line<=word4(conv_integer(row)); elsif (qq=5) then line<=word5(conv_integer(row)); else line<=word6(conv_integer(row));
end if; end process p3; end Behavioral;
此程序在仿真时,row 信号是红颜色,大小是xxx,为不定态,为什么,哪个地方出错了? 冥思苦想好久,也找不到答案,请各位赐教,万分感谢 |