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

📄 scandispled.vhd

📁 many application on kit SP-3: VGA, digital clock, counter, interface PS2....
💻 VHD
📖 第 1 页 / 共 3 页
字号:
library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;use IEEE.NUMERIC_STD.all;entity displed is   Port ( ps2clk,ps2data,clk50: in  STD_LOGIC;			 ledout0,ledout1,ledout2,ledout3,ledout4,ledout5:in STD_LOGIC_vector(7 downto 0);			 ledoutsp0,ledoutsp1,ledoutsp2,ledoutsp3:in STD_LOGIC_vector(7 downto 0);			 ledtay0,ledtay1,ledtay2,ledtay3:in STD_LOGIC_vector(7 downto 0); 			 AN: inout  STD_LOGIC_vector(3 downto 0);			 SW0,SW1,SW2,SW3: in STD_LOGIC;					 HS : out STD_LOGIC;			 VS : out STD_LOGIC;			 RGB_out : out std_logic_vector (2 downto 0);			 Tx:out STD_LOGIC;						 Rx:in STD_LOGIC;			 display:out STD_LOGIC_vector(7 downto 0)); end displed;architecture Behavioral of displed is-- khai bao linh kien Keyboard	component keyTx		generic(FREQ : natural := 50000  );		port( clk    : in  std_logic;  		-- main clock				rdy    : buffer  std_logic; 				ps2_clk  : in  std_logic;           -- keyboard clock				ps2_data : in  std_logic;           -- keyboard data				s        : buffer std_logic_vector(7 downto 0);				sccode  : out std_logic_vector(7 downto 0));	end component;		component Vga 		Port ( CLK : in STD_LOGIC;			RGB_in : in std_logic_vector (2 downto 0);			HS : out STD_LOGIC;			VS : out STD_LOGIC;			CntH : out std_logic_vector (9 downto 0);			CntV : out std_logic_vector (9 downto 0);			RGB_out : out std_logic_vector (2 downto 0));	end component;		component  ComTx 		port(clk : in  std_logic;			 enaTx : in std_logic;			 DataIn : in std_logic_vector(7 downto 0);   			 bitout : out std_logic);	end component;				component ComRx 		port( clk : in  std_logic;			   			   din : in std_logic;
				Red_out : out std_logic;				Green_out : out std_logic;				Blue_out : out std_logic;				hs_out : out std_logic;				vs_out : out std_logic;				Bytesc1: out std_logic_vector(7 downto 0);				byteOut: out std_logic_vector(7 downto 0));  				  	end component;		component TopKBVGAchar 		Port(clk,ps2_data,ps2_clk : in  STD_LOGIC;			hs,vs : out  STD_LOGIC;          RGB : out  STD_LOGIC_VECTOR (2 downto 0));	end component;			SUBTYPE byte IS STD_LOGIC_VECTOR(7 DOWNTO 0);	TYPE memory_type IS ARRAY(1 TO 20) OF byte;	SIGNAL a,s: memory_type;		signal dispKB,dispKB1,dispKB2,dispRx,scancode :STD_LOGIC_vector(7 downto 0);	signal ctr :STD_LOGIC_vector(12 downto 0);	CONSTANT max: INTEGER := 400000000;	SIGNAL count: INTEGER RANGE 0 TO max;	CONSTANT max1: INTEGER := 950000000;	SIGNAL count1: INTEGER RANGE 0 TO max1;	CONSTANT max2: INTEGER := 20;	SIGNAL count2 : INTEGER RANGE 0 TO max2 ;		signal RGB,RGBVga,RGBRx :STD_LOGIC_vector(2 downto 0);		signal enaTx,ready,HS1,VS1,HS2,VS2,HS3,VS3: STD_LOGIC;	signal scRx: STD_LOGIC_vector(7 downto 0);				signal cntH, cntV:STD_LOGIC_vector(9 downto 0);			begin	U40: keyTx port map(clk50,ready,ps2clk,ps2data,dispKB,scancode);	U41: Vga port map (clk50,RGB,HS2,VS2,CntH,cntV,RGB_out);	U42: ComTx port map(clk50,enaTx,scancode,Tx);	U44: ComRx port map (clk50,Rx,RGBRx(0),RGBRx(1),RGBRx(2),HS3,VS3,scRx,dispRx);	U6 : TopKBVGAchar port map (clk50,ps2data,ps2clk,HS1,VS1,RGBVga); Process (clk50,SW0,SW1,SW2,SW3)begin	if rising_edge(clk50) then			if SW0= '0' and SW1='0' and SW2='0' then				if SW3='0' then
				AN<= "1110";				display <= dispRx;				HS <=HS2;				VS <=VS2;				CASE dispRx is 						when	"10000011" =>	RGB <= "001";--b						when	"10010000" =>	RGB <= "010";--G						when	"11000110" =>	RGB <= "011";--Cyan= xanh nhat								when	"10101111" =>	RGB <= "100";--R								when	"11001000" =>	RGB <= "101";--Magenta = hong nhat						when	"10010001" =>	RGB <= "110";--Y						when	"11000001" =>	RGB <= "111";--w-U						when	others     =>  							if (CntH >= 0)and(CntH < 91 )then 																RGB <= "001";							elsif (CntH >= 91)and(CntH < 182 )then	--CntH >= 92: pixel white=91										RGB <= "010";							elsif (CntH >= 182)and(CntH < 274 )then --CntH >= 183: pixel white=182										RGB <= "011";							elsif (CntH >= 274)and(CntH < 366 )then --CntH >= 275: pixel white=274										RGB <= "100";							elsif (CntH >= 366)and(CntH < 458 )then 										RGB <= "101";							elsif (CntH >= 458)and(CntH < 550 )then 										RGB <= "110";							else										RGB <= "111";	-- con lai la white							end if;					end case;					else
					AN<= "1110";					display <= dispRx;
					HS <=HS2;					VS <=VS2;
					RGB <= RGBRx;	--------VGAChar	
				end if;
						elsif  SW0= '0' and SW1='0' and SW2='1' then	-- Tx+VGACkar_LEDChar--			if rising_edge(clk50) then							dispKB1 <= dispKB;	--LEDCHAR					HS <= HS1;		--------VGAChar					VS <= VS1;		--------VGAChar					RGB <= RGBvga;	--------VGAChar								if ready='1' then	-- co 1 phim duoc an						enaTx <='1';		--TxChar						if count2 < max2 then --dem so ky tu cho phep hien thi , 20 ky tu								count2 <= count2 + 1;										else							count2 <= 1;						end if;					end if;						if dispKB1 /= "11110110" then	-- kiem tra khong phai la ky tu Tab						if  dispKB1 /= "01111111" then	--  kiem tra khong phai la ky tu ENter + cho phep hien thi ky tu									if (CTR = "0000000000000") then															if count2 = 1 then	-- hien thi ky tu thu 1									s(1) <= dispKB1;									if (AN(0)='0') then 												AN <= "1111";										display <= "11111111";										AN(1) <= '0';											elsif (AN(1)='0') then 												AN(1) <= '1';										display <= s(1);										AN(0) <= '0';											end if;									end if;										if count2 = 2 then	-- hien thi ky tu thu 2											s(2) <= dispKB1;									if (AN(0)='0') then 												AN(0) <= '1';										display <= s(1);												AN(1) <= '0';									elsif (AN(1)='0') then 											AN(1) <= '1';										display <= s(2);												AN(0) <= '0';									end if;	 								end if;								if count2 = 3 then -- hien thi ky tu thu 3											s(3) <= dispKB1;									if (AN(0)='0') then 												AN(0) <= '1';										display <= s(2);												AN(1) <= '0';									elsif (AN(1)='0') then 											AN(1) <= '1';										display <= s(1);												AN(2) <= '0';									elsif (AN(2)='0') then 											AN(2) <= '1';										display <= s(3);												AN(0) <= '0';										end if;	 								end if;											if count2 = 4 then -- hien thi ky tu thu 4										s(4) <= dispKB1;									if (AN(0)='0') then 											AN(0) <= '1';										display <= s(3);												AN(1) <= '0';									elsif (AN(1)='0') then 											AN(1) <= '1';										display <= s(2);												AN(2) <= '0';										elsif (AN(2)='0') then 											AN(2) <= '1';										display <= s(1);												AN(3) <= '0';										elsif (AN(3)='0') then 												AN(3) <= '1';										display <= s(4)	;											AN(0) <= '0';										 end if;	 								end if;								if count2 = 5 then -- hien thi ky tu thu 5										s(5) <= dispKB1;									if (AN(0)='0') then 											AN(0) <= '1';										display <= s(4);												AN(1) <= '0';									elsif (AN(1)='0') then 											AN(1) <= '1';										display <= s(3);												AN(2) <= '0';										elsif (AN(2)='0') then 											AN(2) <= '1';										display <= s(2);												AN(3) <= '0';										elsif (AN(3)='0') then 												AN(3) <= '1';										display <= s(5)	;											AN(0) <= '0';										end if;	 								end if;								if count2 = 6 then -- hien thi ky tu thu 6										s(6) <= dispKB1;						 									if (AN(0)='0') then 											AN(0) <= '1';										display <= s(5);												AN(1) <= '0';									elsif (AN(1)='0') then 											AN(1) <= '1';										display <= s(4);												AN(2) <= '0';										elsif (AN(2)='0') then 											AN(2) <= '1';										display <= s(3);												AN(3) <= '0';										elsif (AN(3)='0') then 												AN(3) <= '1';										display <= s(6)	;											AN(0) <= '0';										end if;	 								end if;													if count2 = 7 then -- hien thi ky tu thu 7										s(7) <= dispKB1;									if (AN(0)='0') then 											AN(0) <= '1';										display <= s(6);												AN(1) <= '0';									elsif (AN(1)='0') then 											AN(1) <= '1';										display <= s(5);												AN(2) <= '0';										elsif (AN(2)='0') then 											AN(2) <= '1';										display <= s(4);												AN(3) <= '0';										elsif (AN(3)='0') then 												AN(3) <= '1';										display <= s(7);											AN(0) <= '0';										 end if;	 								end if;								if count2 = 8 then -- hien thi ky tu thu 8																s(8) <= dispKB1;									if (AN(0)='0') then 											AN(0) <= '1';										display <= s(7);												AN(1) <= '0';									elsif (AN(1)='0') then 											AN(1) <= '1';										display <= s(6);												AN(2) <= '0';										elsif (AN(2)='0') then 											AN(2) <= '1';										display <= s(5);												AN(3) <= '0';										elsif (AN(3)='0') then 												AN(3) <= '1';										display <= s(8);											AN(0) <= '0';										end if;	 								end if;				 								if count2 = 9 then									s(9) <= dispKB1;									if (AN(0)='0') then 											AN(0) <= '1';										display <= s(8);												AN(1) <= '0';									elsif (AN(1)='0') then 											AN(1) <= '1';										display <= s(7);												AN(2) <= '0';										elsif (AN(2)='0') then 											AN(2) <= '1';										display <= s(6);												AN(3) <= '0';										elsif (AN(3)='0') then 												AN(3) <= '1';										display <= s(9);											AN(0) <= '0';										end if;	 								end if;				 								if count2 = 10 then									s(10) <= dispKB1;									if (AN(0)='0') then 											AN(0) <= '1';										display <= s(9);												AN(1) <= '0';									elsif (AN(1)='0') then 											AN(1) <= '1';										display <= s(8);												AN(2) <= '0';										elsif (AN(2)='0') then 											AN(2) <= '1';										display <= s(7);												AN(3) <= '0';										elsif (AN(3)='0') then 												AN(3) <= '1';										display <= s(10);											AN(0) <= '0';										end if;	 								end if;			 								if count2 = 11 then									s(11) <= dispKB1;									if (AN(0)='0') then 											AN(0) <= '1';										display <= s(10);												AN(1) <= '0';									elsif (AN(1)='0') then 											AN(1) <= '1';										display <= s(9);												AN(2) <= '0';										elsif (AN(2)='0') then 											AN(2) <= '1';										display <= s(8);												AN(3) <= '0';										elsif (AN(3)='0') then 												AN(3) <= '1';										display <= s(11)	;											AN(0) <= '0';										end if;	 								end if;			--count2									if count2 = 12 then									s(12) <= dispKB1;									if (AN(0)='0') then 											AN(0) <= '1';										display <= s(11);												AN(1) <= '0';									elsif (AN(1)='0') then 											AN(1) <= '1';										display <= s(10);												AN(2) <= '0';										elsif (AN(2)='0') then 											AN(2) <= '1';										display <= s(9);												AN(3) <= '0';										elsif (AN(3)='0') then 												AN(3) <= '1';										display <= s(12)	;											AN(0) <= '0';										end if;	 								end if;			--count2									if count2 = 13 then									s(13) <= dispKB1;									if (AN(0)='0') then 											AN(0) <= '1';										display <= s(12);												AN(1) <= '0';									elsif (AN(1)='0') then 											AN(1) <= '1';										display <= s(11);												AN(2) <= '0';										elsif (AN(2)='0') then 											AN(2) <= '1';										display <= s(10);												AN(3) <= '0';										elsif (AN(3)='0') then 												AN(3) <= '1';										display <= s(13)	;											AN(0) <= '0';										end if;	 								end if;			--count2									if count2 = 14 then									s(14) <= dispKB1;									if (AN(0)='0') then 											AN(0) <= '1';										display <= s(13);												AN(1) <= '0';									elsif (AN(1)='0') then 											AN(1) <= '1';										display <= s(12);												AN(2) <= '0';										elsif (AN(2)='0') then 											AN(2) <= '1';										display <= s(11);												AN(3) <= '0';										elsif (AN(3)='0') then 												AN(3) <= '1';										display <= s(14)	;											AN(0) <= '0';										end if;	 								end if;			--								if count2 = 15 then									s(15) <= dispKB1;									if (AN(0)='0') then 											AN(0) <= '1';										display <= s(14);												AN(1) <= '0';									elsif (AN(1)='0') then 											AN(1) <= '1';

⌨️ 快捷键说明

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