📄 lcdmpddr.vhd
字号:
LIBRARY ieee,lpm;
USE lpm.lpm_components.all;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
USE ieee.std_logic_unsigned.all;
ENTITY lcdmpddr IS
PORT( sclk,start,clear :in std_logic;
prom_data :in std_logic_vector(8 downto 0);
sel :in std_logic_vector(1 downto 0);
en,r_w,d_i :out std_logic;
promadr :out std_logic_vector(7 downto 0);
db :out std_logic_vector(7 downto 0));
END lcdmpddr;
ARCHITECTURE lcdmpddr_arch OF lcdmpddr IS
signal stks :std_logic_vector(3 downto 0);
signal ssk :std_logic_vector(1 downto 0);
signal cntm :std_logic_vector(8 downto 0);
signal cntp :std_logic_vector(2 downto 0);
signal prom_q :std_logic_vector(8 downto 0);
signal dbnc,lcden :std_logic;
signal scount :std_logic_vector(26 downto 0);
signal clk,clkm :std_logic;
BEGIN
process(sclk)
begin
if (sclk'event and sclk='1') then
if clear='1' then scount<="000000000000000000000000000";
else scount <= scount +1;
end if;
end if;
end process;
clk <= scount(15); --20m/32768 =1.5ms 16
process(sel)
begin
case sel is
when "00" => clkm <= scount(18);--6ms
when "01" => clkm <= scount(19);
when "10" => clkm <= scount(20);
when "11" => clkm <= scount(21);
end case;
end process;
process (cntm)
begin
IF (cntm >= "001000101" and cntm < "101000110" )then
promadr <= "01000101"; lcden <= '0';
elsif (cntm >= "110001100" )then
promadr <= "10001100"; lcden <= '0';
else
promadr <= cntm(7 DOWNTO 0); lcden <= '1';
end if;
end process;
prom_q <= prom_data;
process(clk, clkm)
begin
if (clkm'event and clkm='1') then
if clear='1' then
cntm<="000000000";
elsif (cntp="101") then
if cntm ="111111111" then cntm<="000000000";
else cntm<=cntm+1;
end if;
else cntm<=cntm;
end if;
end if;
if clk'event and clk='1' then
if clear='1' then
stks<="0000";
cntp<="000";
ssk<="00";
else
dbnc<= (start or clkm or clear );
r_w<= not (stks(0) or stks(1) or stks(2));
en<=stks(1) and lcden ;
case ssk is
when "00" =>
if dbnc='1' then ssk<="01";
else ssk<="00";
end if;
when "01" => ssk<="10";
when "10" =>
if dbnc='0' then ssk<="00";
else ssk<="10";
end if;
when "11" => ssk<="00";
when others=>
end case;
case stks is
when "0000" =>
if ssk(0)='1' then stks<="0001";
else stks<="0000";
end if;
when "0001" => stks<="0010";
when "0010" => stks<="0100";
when "0100" => stks<="1000";
when "1000" =>
if (cntp(2)='0') then
stks<="0001";
elsif cntp="101" then stks<="0000";
else stks<="1000";
end if;
when others=> stks<="0000";
end case;
end if;
if (stks(3)='1' and cntp/="101") then
cntp<=cntp+1;
else cntp<=cntp;
end if;
if (cntp="101") and (prom_q(8)='0') then
d_i<='1';
else d_i<='0';
end if;
case cntp is
when "000" => db<="00111000"; -- LCD Initialization
when "001" => db<="00001110";
when "010" => db<="00000110";
when "011" => db<="00000001";
when "100" => db<="10000000";
when "101" => db<=prom_q(7 DOWNTO 0); -- Lcd Display
when others=>
end case;
end if;
end process;
END lcdmpddr_arch;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -