www.pudn.com > PS2_jianpanshibie_FPGA.rar > cmd_control.v, change:2010-12-03,size:751b


module cmd_control (clk,rstn,ps2_done_sig,ps2_data_f,ps2_data_s,ps2_data_t,data_out); 
input clk; 
input rstn; 
input ps2_done_sig; 
input [7:0] ps2_data_f,ps2_data_s,ps2_data_t; 
output [3:0] data_out; 
 
reg [3:0] rdata; 
always @(posedge clk or negedge rstn) 
	if(!rstn) 
		begin 
			rdata<=4'b0001; 
		end 
	else if(ps2_done_sig) 
		case (ps2_data_f) 
			8'h1c:		//键盘上的字母A 
				rdata<={rdata[2:0],rdata[3]}; 
			8'h23:		//键盘上的字母D 
				rdata<={rdata[0],rdata[3:1]}; 
			8'he0: 
				begin 
					case (ps2_data_s) 
						8'h6b:		//小键盘上的方向左键 
							rdata<={rdata[2:0],rdata[3]}; 
						8'h74:		//小键盘上的方向右键 
							rdata<={rdata[0],rdata[3:1]}; 
					endcase 
				end 
		endcase 
 
assign data_out = rdata; 
 
endmodule