⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 plcdmdr.v

📁 128×64单色点阵LCD的quartus工程文件
💻 V
字号:
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 lcdmpdr IS
PORT(	clk,clkm,start,clear,mode	:in		std_logic;
		datai,prom_data	:in 	std_logic_vector(7 downto 0);
		en,r_w,d_i,tmdt	:out	std_logic;
		promadr			:out 	std_logic_vector(6 downto 0);
		db				:out	std_logic_vector(7 downto 0)
);
END lcdmpdr;

ARCHITECTURE lcdmpdr_arch OF lcdmpdr IS
signal stks			:std_logic_vector(3 downto 0);
signal ssk,d,c		:std_logic_vector(1 downto 0);
signal cntd			:std_logic_vector(4 downto 0);
signal cntm			:std_logic_vector(6 downto 0);
signal cntp			:std_logic_vector(2 downto 0);
signal prom_q		:std_logic_vector(7 downto 0);
signal dbnc,b,a		:std_logic;
BEGIN
    promadr <= cntm ;
    prom_q  <= prom_data;
	
	process(clk,clkm)
	begin
	if (clkm'event and clkm='1')  then
		if clear='1' then
			cntm<="0000000";
		elsif   (mode = '0' and cntp="101") then 
			if cntm="0111001" then cntm<="0000000";
			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";
			d<="00";
			cntd<="00000";
		else
			cntd(2 downto 0)<=cntd(2 downto 0)+1;
			cntd(3)<=cntd(2);
			cntd(4)<=cntd(3);
			tmdt<=cntd(2) and (not cntd(4));
			d(0)<= (start or clkm or clear);
			d(1)<= d(0);
			dbnc<=((d(0) and d(1)) or dbnc) and (d(0) or d(1));
			r_w<= not (stks(0) or stks(1) or stks(2));
			en<=stks(1);
			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="000" or cntp="001" or cntp="010" or cntp="011") then
						stks<="0001";
					elsif cntp="101" then stks<="0000";
					else stks<="1000";
					end if;
				when others=> stks<="0000";
			end case;
		
			if (stks(3)='1' and cntp/="101") then 
				cntp<=cntp+1;
			else cntp<=cntp;
			end if;
			
			
			if (cntp="101") or (mode='1' and datai(7)='0') or (mode='1' and prom_q(7)='0') then 
				d_i<=(stks(0) or stks(1) or stks(2));
			else  d_i<=not (stks(0) or stks(1) or stks(2));
			end if;
			
			case cntp is
				when "000" => db<="00111000";
				when "001" => db<="00001110";
				when "010" => db<="00000110";
				when "011" => db<="00000001";
				when "100" => db<="10000000";
				when "101" => 
							if mode='0' then
								if prom_q(7 downto 6)="11" then
									db(7)<=prom_q(7);
									db(6)<='0';
									db(5 downto 0)<=prom_q(5 downto 0);
								elsif prom_q(7 downto 6)="10" then
									db(7)<='0';
									db(6 downto 0)<=prom_q(6 downto 0);
								else db<=prom_q;
								end if;
							else db<=datai;
							end if;
							
				when others=> 
			end case;
		end if;
	end if;
	end process;
	
END lcdmpdr_arch; 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -