求助EDA的VHDL语言的高手啊!!!这段程序是嘛意思啊???!!!越详细越好,不胜感激!!!!!!! 5
libraryIEEE;useIEEE.STD_LOGIC_1164.ALL;--显示magic!useIEEE.STD_LOGIC_ARITH.ALL;--与上面程序功...
library IEEE;
use IEEE.STD_LOGIC_1164.ALL; --显示magic!
use IEEE.STD_LOGIC_ARITH.ALL; --与上面程序功能相同,但显示速度很快,基本看不清光标的闪烁移位
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity lcd_display is
generic(N:integer:=4000;
delay:integer:=10000); --改了此延时,造成该情况发生!
Port ( clk : in std_logic;
reset:in std_logic; --定义一个拔盘
lcdda : out std_logic;
lcdrw : out std_logic;
lcden : out std_logic;
test : out std_logic_vector(7 downto 0)
);
end lcd_display;
architecture Behavioral of lcd_display is
type state is (set_dlnf1,set_dlnf2,home,clear_lcd1,clear_lcd2,set_mode,set_cursor,set_dcb,set_ddram,write_data);
signal current_state:state;
type rom is array(0 to 9) of std_logic_vector(7 downto 0);
constant datarom:rom:=(("00110000"),("00110001"),("00110010"),("00110011"),("00110100"),("00110101"),("00110110"),("00110111"),("00111000"),("00111001"));
signal clkk:std_logic;
signal data : std_logic_vector(7 downto 0);
begin
divider:process(clk,reset)
variable cnt:integer range 0 to 1000;
begin
if reset='1'then cnt:=0;clkk<='0';
elsif rising_edge(clk) then
cnt:=cnt+1;
if cnt=N then clkk<='1';
elsif cnt=2*N then cnt:=0;clkk<='0';
end if;
end if;
end process divider;
control:process(clkk,reset,current_state)
variable cntt,cnt2:integer;
begin
if reset='1'then --复位信号初始化
current_state<=set_dlnf1;
cntt:=0;
cnt2:=0;
elsif rising_edge(clkk)then
test<=data; --显示
case current_state is
when set_dlnf1=> --功能设置
lcden<='0';
lcdda<='0';
lcdrw<='0';
data<="00110000";
if cntt>delay and cntt<delay*500 then --delay=10000 延时10ms
lcden<='1';
cntt:=cntt+1;
else
lcden<='0'; cntt:=cntt+1;
end if;
if cntt=delay*500 then
current_state<=set_dlnf2;
cntt:=0;
end if;
when set_dlnf2=>
lcden<='0';
lcdda<='0';
lcdrw<='0';
data<="00110000";
if cntt>delay and cntt<delay*500 then --delay=10000 延时10ms
lcden<='1';cntt:=cntt+1;
else
lcden<='0';cntt:=cntt+1;
end if;
if cntt=delay*500 then
current_state<=set_cursor;
cntt:=0;
end if;
when set_dcb=>
lcden<='0';
lcdda<='0';
lcdrw<='0';
data<="00001100";
if cntt>delay and cntt<delay*500 then --delay=10000 延时10ms
lcden<='1';cntt:=cntt+1;
else
lcden<='0';cntt:=cntt+1;
end if;
if cntt=delay*500 then
current_state<=clear_lcd1;
cntt:=0;
end if; 展开
use IEEE.STD_LOGIC_1164.ALL; --显示magic!
use IEEE.STD_LOGIC_ARITH.ALL; --与上面程序功能相同,但显示速度很快,基本看不清光标的闪烁移位
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity lcd_display is
generic(N:integer:=4000;
delay:integer:=10000); --改了此延时,造成该情况发生!
Port ( clk : in std_logic;
reset:in std_logic; --定义一个拔盘
lcdda : out std_logic;
lcdrw : out std_logic;
lcden : out std_logic;
test : out std_logic_vector(7 downto 0)
);
end lcd_display;
architecture Behavioral of lcd_display is
type state is (set_dlnf1,set_dlnf2,home,clear_lcd1,clear_lcd2,set_mode,set_cursor,set_dcb,set_ddram,write_data);
signal current_state:state;
type rom is array(0 to 9) of std_logic_vector(7 downto 0);
constant datarom:rom:=(("00110000"),("00110001"),("00110010"),("00110011"),("00110100"),("00110101"),("00110110"),("00110111"),("00111000"),("00111001"));
signal clkk:std_logic;
signal data : std_logic_vector(7 downto 0);
begin
divider:process(clk,reset)
variable cnt:integer range 0 to 1000;
begin
if reset='1'then cnt:=0;clkk<='0';
elsif rising_edge(clk) then
cnt:=cnt+1;
if cnt=N then clkk<='1';
elsif cnt=2*N then cnt:=0;clkk<='0';
end if;
end if;
end process divider;
control:process(clkk,reset,current_state)
variable cntt,cnt2:integer;
begin
if reset='1'then --复位信号初始化
current_state<=set_dlnf1;
cntt:=0;
cnt2:=0;
elsif rising_edge(clkk)then
test<=data; --显示
case current_state is
when set_dlnf1=> --功能设置
lcden<='0';
lcdda<='0';
lcdrw<='0';
data<="00110000";
if cntt>delay and cntt<delay*500 then --delay=10000 延时10ms
lcden<='1';
cntt:=cntt+1;
else
lcden<='0'; cntt:=cntt+1;
end if;
if cntt=delay*500 then
current_state<=set_dlnf2;
cntt:=0;
end if;
when set_dlnf2=>
lcden<='0';
lcdda<='0';
lcdrw<='0';
data<="00110000";
if cntt>delay and cntt<delay*500 then --delay=10000 延时10ms
lcden<='1';cntt:=cntt+1;
else
lcden<='0';cntt:=cntt+1;
end if;
if cntt=delay*500 then
current_state<=set_cursor;
cntt:=0;
end if;
when set_dcb=>
lcden<='0';
lcdda<='0';
lcdrw<='0';
data<="00001100";
if cntt>delay and cntt<delay*500 then --delay=10000 延时10ms
lcden<='1';cntt:=cntt+1;
else
lcden<='0';cntt:=cntt+1;
end if;
if cntt=delay*500 then
current_state<=clear_lcd1;
cntt:=0;
end if; 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询