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

📄 ps2keyboard.v

📁 Verilog, c and asm source codes of the Minimig system, a fpga implementation of the Amiga computer.
💻 V
📖 第 1 页 / 共 3 页
字号:
	if(reset)		kbdrststatus[1]<=1;	else if (valid && aleft)		kbdrststatus[1]<=keydat[7];	//latch status of right alt key	if(reset)		kbdrststatus[0]<=1;	else if (valid && aright)		kbdrststatus[0]<=keydat[7];endassign kbdrst=~(kbdrststatus[2]|kbdrststatus[1]|kbdrststatus[0]);//reset if all 3 keys downendmodule//-------------------------------------------------------------------------------------------------//-------------------------------------------------------------------------------------------------//-------------------------------------------------------------------------------------------------//ps2 key to amiga key mapper using blockram//this module also handles the osdctrl signalsmodule ps2keyboardmap(	input 	clk,		    	//clock	input	reset,				//reset	input	enable,				//enable	input 	[7:0]ps2key,		//ps2 key code input	output	valid,				//amiga key code valid (strobed when new valid keycode at output) 	output	[7:0]akey,		//amiga key code output	output	ctrl,	  			//amiga control key	output	aleft, 				//amiga left alt key	output	aright,	   			//amiga right alt key	output	caps,	   			//amiga capslock key	output	reg[5:0]osdctrl	//osd menu control);//local signalsreg		[15:0]keyrom;			//rom outputreg		enable2;				//enable signal delayed by one clockreg		upstroke;				//upstroke key statusreg		extended;				//extended key status			//generate delayed enable signal (needed because of blockram pipelining)always @(posedge clk)	enable2<=enable;//latch special ps2 keycodes//keyrom[7] is used together with [0], [1] and [2] for ps2 special codes decoding//these are needed for complete decoding of the ps2 codesalways @(posedge clk)	if(reset)//reset	begin		upstroke<=0;		extended<=0;	end	else if(enable2 && keyrom[7] && keyrom[0])//extended key identifier found		extended<=1;	else if(enable2 && keyrom[7] && keyrom[1])//upstroke identifier found		upstroke<=1;	else if(enable2 && !(keyrom[7]&&keyrom[2]))//other key found and it was not an ack, reset both status bits	begin		upstroke<=0;		extended<=0;	end//assign all output signals//keyrom[6:0]=amiga keycodeassign valid=keyrom[15]&enable2;assign ctrl=keyrom[14];assign aleft=keyrom[13];assign aright=keyrom[12];assign caps=keyrom[11];assign akey[7:0]={upstroke,keyrom[6:0]};//osd control handling//keyrom[8] is used together with [0],[1],[2] and [3] for osd key decodingalways @(posedge clk)begin	if(reset)		osdctrl[5:0] <= 0;	else if(enable2 && keyrom[8])		osdctrl[5:0] <= keyrom[5:0] & {6{~upstroke}};end//-------------------------------------------------------------------------------------------------//here follows the ps2 to Amiga key romtable://standard decodes//[6:0]=amiga key code//[15]=valid amiga key (present in rom)//decodes for special function keys ://[14]=control key//[13]=left alt key//[12]=right alt key//[11]=capslock key//PS2 specific decodes://[7]&[0]=PS2 EXTENDED KEY//[7]&[1]=PS2 UPSTROKE IDENTIFIER//[7]&[2]=PS2 ACKNOWLEDGE//OSD control decodes//[8]&([0] or [1] or [2] or [3])always @(posedge clk)begin	if(enable)	begin		case({extended,ps2key[7:0]})			9'h000:		keyrom[15:0]<=16'h0000;			9'h001:		keyrom[15:0]<=16'h8058;//F9			9'h002:		keyrom[15:0]<=16'h0000;			9'h003:		keyrom[15:0]<=16'h8054;//F5			9'h004:		keyrom[15:0]<=16'h8052;//F3			9'h005:		keyrom[15:0]<=16'h8050;//F1			9'h006:		keyrom[15:0]<=16'h8051;//F2			9'h007:		keyrom[15:0]<=16'h0108;//F12 <OSD MENU> MENU			9'h008:		keyrom[15:0]<=16'h0000;			9'h009:		keyrom[15:0]<=16'h8059;//F10			9'h00a:		keyrom[15:0]<=16'h8057;//F8			9'h00b:		keyrom[15:0]<=16'h8055;//F6			9'h00c:		keyrom[15:0]<=16'h8053;//F4			9'h00d:		keyrom[15:0]<=16'h8042;//TAB			9'h00e:		keyrom[15:0]<=16'h8000;//~			9'h00f:		keyrom[15:0]<=16'h0000;			9'h010:		keyrom[15:0]<=16'h0000;			9'h011:		keyrom[15:0]<=16'ha064;//LEFT ALT			9'h012:		keyrom[15:0]<=16'h8060;//LEFT SHIFT			9'h013:		keyrom[15:0]<=16'h0000;			9'h014:		keyrom[15:0]<=16'hc063;//CTRL			9'h015:		keyrom[15:0]<=16'h8010;//q			9'h016:		keyrom[15:0]<=16'h8001;//1			9'h017:		keyrom[15:0]<=16'h0000;			9'h018:		keyrom[15:0]<=16'h0000;			9'h019:		keyrom[15:0]<=16'h0000;			9'h01a:		keyrom[15:0]<=16'h8031;//z			9'h01b:		keyrom[15:0]<=16'h8021;//s			9'h01c:		keyrom[15:0]<=16'h8020;//a			9'h01d:		keyrom[15:0]<=16'h8011;//w			9'h01e:		keyrom[15:0]<=16'h8002;//2			9'h01f:		keyrom[15:0]<=16'h0000;			9'h020:		keyrom[15:0]<=16'h0000;			9'h021:		keyrom[15:0]<=16'h8033;//c			9'h022:		keyrom[15:0]<=16'h8032;//x			9'h023:		keyrom[15:0]<=16'h8022;//d			9'h024:		keyrom[15:0]<=16'h8012;//e			9'h025:		keyrom[15:0]<=16'h8004;//4			9'h026:		keyrom[15:0]<=16'h8003;//3			9'h027:		keyrom[15:0]<=16'h0000;			9'h028:		keyrom[15:0]<=16'h0000;			9'h029:		keyrom[15:0]<=16'h8040;//SPACE			9'h02a:		keyrom[15:0]<=16'h8034;//v			9'h02b:		keyrom[15:0]<=16'h8023;//f			9'h02c:		keyrom[15:0]<=16'h8014;//t			9'h02d:		keyrom[15:0]<=16'h8013;//t			9'h02e:		keyrom[15:0]<=16'h8005;//5			9'h02f:		keyrom[15:0]<=16'h0000;			9'h030:		keyrom[15:0]<=16'h0000;			9'h031:		keyrom[15:0]<=16'h8036;//n			9'h032:		keyrom[15:0]<=16'h8035;//b			9'h033:		keyrom[15:0]<=16'h8025;//h			9'h034:		keyrom[15:0]<=16'h8024;//g			9'h035:		keyrom[15:0]<=16'h8015;//y			9'h036:		keyrom[15:0]<=16'h8006;//6			9'h037:		keyrom[15:0]<=16'h0000;			9'h038:		keyrom[15:0]<=16'h0000;			9'h039:		keyrom[15:0]<=16'h0000;			9'h03a:		keyrom[15:0]<=16'h8037;//m			9'h03b:		keyrom[15:0]<=16'h8026;//j			9'h03c:		keyrom[15:0]<=16'h8016;//u			9'h03d:		keyrom[15:0]<=16'h8007;//7			9'h03e:		keyrom[15:0]<=16'h8008;//8			9'h03f:		keyrom[15:0]<=16'h0000;			9'h040:		keyrom[15:0]<=16'h0000;			9'h041:		keyrom[15:0]<=16'h8038;//<			9'h042:		keyrom[15:0]<=16'h8027;//k			9'h043:		keyrom[15:0]<=16'h8017;//i			9'h044:		keyrom[15:0]<=16'h8018;//o			9'h045:		keyrom[15:0]<=16'h800a;//0			9'h046:		keyrom[15:0]<=16'h8009;//9			9'h047:		keyrom[15:0]<=16'h0000;			9'h048:		keyrom[15:0]<=16'h0000;			9'h049:		keyrom[15:0]<=16'h8039;//>			9'h04a:		keyrom[15:0]<=16'h803a;//FORWARD SLASH			9'h04b:		keyrom[15:0]<=16'h8028;//l			9'h04c:		keyrom[15:0]<=16'h8029;//;			9'h04d:		keyrom[15:0]<=16'h8019;//p			9'h04e:		keyrom[15:0]<=16'h800b;//-			9'h04f:		keyrom[15:0]<=16'h0000;			9'h050:		keyrom[15:0]<=16'h0000;			9'h051:		keyrom[15:0]<=16'h0000;			9'h052:		keyrom[15:0]<=16'h802a;//"			9'h053:		keyrom[15:0]<=16'h0000;			9'h054:		keyrom[15:0]<=16'h801a;//[			9'h055:		keyrom[15:0]<=16'h800c;//=			9'h056:		keyrom[15:0]<=16'h0000;			9'h057:		keyrom[15:0]<=16'h0000;			9'h058:		keyrom[15:0]<=16'h8862;//CAPSLOCK			9'h059:		keyrom[15:0]<=16'h8061;//RIGHT SHIFT			9'h05a:		keyrom[15:0]<=16'h8044;//ENTER			9'h05b:		keyrom[15:0]<=16'h801b;//]			9'h05c:		keyrom[15:0]<=16'h0000;			9'h05d:		keyrom[15:0]<=16'h800d;//BACKSLASH			9'h05e:		keyrom[15:0]<=16'h0000;			9'h05f:		keyrom[15:0]<=16'h0000;			9'h060:		keyrom[15:0]<=16'h0000;			9'h061:		keyrom[15:0]<=16'h0000;			9'h062:		keyrom[15:0]<=16'h0000;			9'h063:		keyrom[15:0]<=16'h0000;			9'h064:		keyrom[15:0]<=16'h0000;			9'h065:		keyrom[15:0]<=16'h0000;			9'h066:		keyrom[15:0]<=16'h8041;//BACKSPACE			9'h067:		keyrom[15:0]<=16'h0000;			9'h068:		keyrom[15:0]<=16'h0000;			9'h069:		keyrom[15:0]<=16'h801d;//KP 1			9'h06a:		keyrom[15:0]<=16'h0000;			9'h06b:		keyrom[15:0]<=16'h802d;//KP 4			9'h06c:		keyrom[15:0]<=16'h803d;//KP 7			9'h06d:		keyrom[15:0]<=16'h0000;			9'h06e:		keyrom[15:0]<=16'h0000;			9'h06f:		keyrom[15:0]<=16'h0000;			9'h070:		keyrom[15:0]<=16'h800f;//KP 0			9'h071:		keyrom[15:0]<=16'h803c;//KP .			9'h072:		keyrom[15:0]<=16'h801e;//KP 2			9'h073:		keyrom[15:0]<=16'h802e;//KP 5			9'h074:		keyrom[15:0]<=16'h802f;//KP 6			9'h075:		keyrom[15:0]<=16'h803e;//KP 8			9'h076:		keyrom[15:0]<=16'h8045;//ESCAPE			9'h077:		keyrom[15:0]<=16'h805a;//NUM LOCK / KP (			9'h078:		keyrom[15:0]<=16'h805f;//HELP (F11)			9'h079:		keyrom[15:0]<=16'h805e;//KP +			9'h07a:		keyrom[15:0]<=16'h801f;//KP 3			9'h07b:		keyrom[15:0]<=16'h804a;//KP -			9'h07c:		keyrom[15:0]<=16'h805d;//KP *			9'h07d:		keyrom[15:0]<=16'h803f;//KP 9			9'h07e:		keyrom[15:0]<=16'h805b;//SCROLL LOCK / KP )			9'h07f:		keyrom[15:0]<=16'h0000;			9'h080:		keyrom[15:0]<=16'h0000;			9'h081:		keyrom[15:0]<=16'h0000;			9'h082:		keyrom[15:0]<=16'h0000;			9'h083:		keyrom[15:0]<=16'h8056;//F7			9'h084:		keyrom[15:0]<=16'h0000;			9'h085:		keyrom[15:0]<=16'h0000;			9'h086:		keyrom[15:0]<=16'h0000;			9'h087:		keyrom[15:0]<=16'h0000;			9'h088:		keyrom[15:0]<=16'h0000;			9'h089:		keyrom[15:0]<=16'h0000;			9'h08a:		keyrom[15:0]<=16'h0000;			9'h08b:		keyrom[15:0]<=16'h0000;			9'h08c:		keyrom[15:0]<=16'h0000;			9'h08d:		keyrom[15:0]<=16'h0000;			9'h08e:		keyrom[15:0]<=16'h0000;			9'h08f:		keyrom[15:0]<=16'h0000;			9'h090:		keyrom[15:0]<=16'h0000;			9'h091:		keyrom[15:0]<=16'h0000;			9'h092:		keyrom[15:0]<=16'h0000;			9'h093:		keyrom[15:0]<=16'h0000;			9'h094:		keyrom[15:0]<=16'h0000;			9'h095:		keyrom[15:0]<=16'h0000;			9'h096:		keyrom[15:0]<=16'h0000;			9'h097:		keyrom[15:0]<=16'h0000;			9'h098:		keyrom[15:0]<=16'h0000;			9'h099:		keyrom[15:0]<=16'h0000;			9'h09a:		keyrom[15:0]<=16'h0000;			9'h09b:		keyrom[15:0]<=16'h0000;			9'h09c:		keyrom[15:0]<=16'h0000;			9'h09d:		keyrom[15:0]<=16'h0000;			9'h09e:		keyrom[15:0]<=16'h0000;			9'h09f:		keyrom[15:0]<=16'h0000;			9'h0a0:		keyrom[15:0]<=16'h0000;			9'h0a1:		keyrom[15:0]<=16'h0000;			9'h0a2:		keyrom[15:0]<=16'h0000;			9'h0a3:		keyrom[15:0]<=16'h0000;			9'h0a4:		keyrom[15:0]<=16'h0000;			9'h0a5:		keyrom[15:0]<=16'h0000;			9'h0a6:		keyrom[15:0]<=16'h0000;			9'h0a7:		keyrom[15:0]<=16'h0000;			9'h0a8:		keyrom[15:0]<=16'h0000;			9'h0a9:		keyrom[15:0]<=16'h0000;			9'h0aa:		keyrom[15:0]<=16'h0000;			9'h0ab:		keyrom[15:0]<=16'h0000;			9'h0ac:		keyrom[15:0]<=16'h0000;			9'h0ad:		keyrom[15:0]<=16'h0000;			9'h0ae:		keyrom[15:0]<=16'h0000;			9'h0af:		keyrom[15:0]<=16'h0000;			9'h0b0:		keyrom[15:0]<=16'h0000;			9'h0b1:		keyrom[15:0]<=16'h0000;			9'h0b2:		keyrom[15:0]<=16'h0000;			9'h0b3:		keyrom[15:0]<=16'h0000;			9'h0b4:		keyrom[15:0]<=16'h0000;			9'h0b5:		keyrom[15:0]<=16'h0000;			9'h0b6:		keyrom[15:0]<=16'h0000;			9'h0b7:		keyrom[15:0]<=16'h0000;			9'h0b8:		keyrom[15:0]<=16'h0000;			9'h0b9:		keyrom[15:0]<=16'h0000;			9'h0ba:		keyrom[15:0]<=16'h0000;			9'h0bb:		keyrom[15:0]<=16'h0000;			9'h0bc:		keyrom[15:0]<=16'h0000;			9'h0bd:		keyrom[15:0]<=16'h0000;			9'h0be:		keyrom[15:0]<=16'h0000;			9'h0bf:		keyrom[15:0]<=16'h0000;			9'h0c0:		keyrom[15:0]<=16'h0000;			9'h0c1:		keyrom[15:0]<=16'h0000;			9'h0c2:		keyrom[15:0]<=16'h0000;			9'h0c3:		keyrom[15:0]<=16'h0000;			9'h0c4:		keyrom[15:0]<=16'h0000;			9'h0c5:		keyrom[15:0]<=16'h0000;			9'h0c6:		keyrom[15:0]<=16'h0000;			9'h0c7:		keyrom[15:0]<=16'h0000;			9'h0c8:		keyrom[15:0]<=16'h0000;			9'h0c9:		keyrom[15:0]<=16'h0000;			9'h0ca:		keyrom[15:0]<=16'h0000;			9'h0cb:		keyrom[15:0]<=16'h0000;			9'h0cc:		keyrom[15:0]<=16'h0000;			9'h0cd:		keyrom[15:0]<=16'h0000;

⌨️ 快捷键说明

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