times New Roman">程序我觉得没啥问题,就是不出结果。小弟想做的事12864显示汉字。
CLK 2MHZ
LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_ARITH.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;ENTITY bishe1 IS PORT ( clk : IN std_logic; --全局时钟 reset : IN std_logic; --异步复位 -- LCD12864的接口 lcd_data : OUT std_logic_vector(7 DOWNTO 0); --数据总线 lcd_en : OUT std_logic; lcd_rs : OUT std_logic; --数据/指令 lcd_rw : OUT std_logic); --读/写END bishe1; architecture one of bishe1 is type statetype is(s1,s2,s3,s4,s5,s6,s7,s8,s9,s10); --定义一个有10个状态的状态机 signal state:statetype; signal count:integer range 0 to 7; --数据计数器 type datatype1 is array (0 to 11) of std_logic_vector(7 downto 0); type datatype2 is array (0 to 7) of std_logic_vector(7 downto 0); type datatype3 is array (0 to 13) of std_logic_vector(7 downto 0); type datatype4 is array (0 to 15) of std_logic_vector(7 downto 0); --自定义四个数据类型 constant hanzi1:datatype1:=("10110110","10111000","11000111","11101100","11010011","11001010","10110101","11100111", "10110100","10110011","11010001","10100111");-- constant hanzi2:datatype2:=("11001101","10101000","11010000","11000101","10110100","11110011","11010100","10111010"); --存储通信学院 constant hanzi3:datatype3:=("10100011","10110000","10100011","10111001","10110101","11100111","11010000","11000101", "11010110","11101100","10111111","10100001","10111110","11111100");-- constant hanzi4:datatype4:=("11010110","10111000","10110101","10111100","11000000","11001100","11001010","10100110", "10100001","10100011","11001100","10110111","10100111","10110101","10111010","11101010");-- signal rs:std_logic:='0'; signal rw:std_logic:='0'; signal data:std_logic_vector(7 downto 0); begin lcd_rw<=rw; lcd_rs<=rs; lcd_data<=data; lcd_en<=clk;process(clk,reset)begin if reset='1' then --未按下清屏按键 if clk'event and clk='1' then --在时钟的上升沿判断,进行状态选择与跳转 case state is when s1=>if count=0 then data<="00110100";count<=count+1;--功能设定 elsif count=1 then data<="00000110";count<=count+1;--点设定 elsif count=2 then data<="00001100";count<=count+1;--显示控制 else state<=s2;count<=0; end if; when s2=>data<="10000001";state<=s3;--设置第一行显示DDRAM地址 when s3=>rs<='1';--访问数据寄存器,显示第一行汉字 if count=11 then state<=s4;data<=hanzi1(count); else state<=s3;data<=hanzi1(count);count<=count+1; end if; when s4=>rs<='0';data<="10010010";count<=0;state<=s5; when s5=>rs<='1'; if count=7 then state<=s6;data<=hanzi2(count); else state<=s5;data<=hanzi2(count);count<=count+1; end if; when s6=>rs<='0';data<="10100000";count<=0;state<=s6; when s7=>rs<='1'; if count=13 then state<=s7;data<=hanzi3(count); else state<=s6;data<=hanzi3(count);count<=count+1; end if; when s8=>rs<='0';data<="10110000";count<=0;state<=s5; when s9=>rs<='1'; if count=15 then state<=s8;data<=hanzi2(count); else state<=s7;data<=hanzi4(count);count<=count+1; end if; when s10=>rs<='0';data<="00000010";count<=0;--光标归位 when others=>count<=0;state<=s1; end case; end if; else data<="00000001";state<=s1;--按下清屏键,清屏 end if; end process; end;
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>