亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ps2_keyboard.v

?? PS2的程序
?? V
?? 第 1 頁 / 共 2 頁
字號:
//-------------------------------------------------------------------------------------
//
// Author: John Clayton
// Date  : April 30, 2001
// Update: 4/30/01 copied this file from lcd_2.v (pared down).
// Update: 5/24/01 changed the first module from "ps2_keyboard_receiver"
//                 to "ps2_keyboard_interface"
// Update: 5/29/01 Added input synchronizing flip-flops.  Changed state
//                 encoding (m1) for good operation after part config.
// Update: 5/31/01 Added low drive strength and slow transitions to ps2_clk
//                 and ps2_data in the constraints file.  Added the signal
//                 "tx_shifting_done" as distinguished from "rx_shifting_done."
//                 Debugged the transmitter portion in the lab.
// Update: 6/01/01 Added horizontal tab to the ascii output.
// Update: 6/01/01 Added parameter TRAP_SHIFT_KEYS.
// Update: 6/05/01 Debugged the "debounce" timer functionality.
//                 Used 60usec timer as a "watchdog" timeout during
//                 receive from the keyboard.  This means that a keyboard
//                 can now be "hot plugged" into the interface, without
//                 messing up the bit_count, since the bit_count is reset
//                 to zero during periods of inactivity anyway.  This was
//                 difficult to debug.  I ended up using the logic analyzer,
//                 and had to scratch my head quite a bit.
// Update: 6/06/01 Removed extra comments before the input synchronizing
//                 flip-flops.  Used the correct parameter to size the
//                 5usec_timer_count.  Changed the name of this file from
//                 ps2.v to ps2_keyboard.v
// Update: 6/06/01 Removed "&& q[7:0]" in output_strobe logic.  Removed extra
//                 commented out "else" condition in the shift register and
//                 bit counter.
// Update: 6/07/01 Changed default values for 60usec timer parameters so that
//                 they correspond to 60usec for a 49.152MHz clock.
//
//
//
//
//
// Description
//-------------------------------------------------------------------------------------
// This is a state-machine driven serial-to-parallel and parallel-to-serial
// interface to the ps2 style keyboard interface.  The details of the operation
// of the keyboard interface were obtained from the following website:
//
//   http://www.beyondlogic.org/keyboard/keybrd.htm
//
// Some aspects of the keyboard interface are not implemented (e.g, parity
// checking for the receive side, and recognition of the various commands
// which the keyboard sends out, such as "power on selt test passed," "Error"
// and "Resend.")  However, if the user wishes to recognize these reply
// messages, the scan code output can always be used to extend functionality
// as desired.
//
// Note that the "Extended" (0xE0) and "Released" (0xF0) codes are recognized.
// The rx interface provides separate indicator flags for these two conditions
// with every valid character scan code which it provides.  The shift keys are
// also trapped by the interface, in order to provide correct uppercase ASCII
// characters at the ascii output, although the scan codes for the shift keys
// are still provided at the scan code output.  So, the left/right ALT keys
// can be differentiated by the presence of the rx_entended signal, while the
// left/right shift keys are differentiable by the different scan codes
// received.
//
// The interface to the ps2 keyboard uses ps2_clk clock rates of
// 30-40 kHz, dependent upon the keyboard itself.  The rate at which the state
// machine runs should be at least twice the rate of the ps2_clk, so that the
// states can accurately follow the clock signal itself.  Four times 
// oversampling is better.  Say 200kHz at least.  The upper limit for clocking
// the state machine will undoubtedly be determined by delays in the logic 
// which decodes the scan codes into ASCII equivalents.  The maximum speed
// will be most likely many megahertz, depending upon target technology.
// In order to run the state machine extremely fast, synchronizing flip-flops
// have been added to the ps2_clk and ps2_data inputs of the state machine.
// This avoids poor performance related to slow transitions of the inputs.
// 
// Because this is a bi-directional interface, while reading from the keyboard
// the ps2_clk and ps2_data lines are used as inputs.  While writing to the
// keyboard, however (which may be done at any time.  If writing interrupts a
// read from the keyboard, the keyboard will buffer up its data, and send
// it later) both the ps2_clk and ps2_data lines are occasionally pulled low,
// and pullup resistors are used to bring the lines high again, by setting
// the drivers to high impedance state.
//
// The tx interface, for writing to the keyboard, does not provide any special
// pre-processing.  It simply transmits the 8-bit command value to the
// keyboard.
//
// Pullups MUST BE USED on the ps2_clk and ps2_data lines for this design,
// whether they be internal to an FPGA I/O pad, or externally placed.
// If internal pullups are used, they may be fairly weak, causing bounces
// due to crosstalk, etc.  There is a "debounce timer" implemented in order
// to eliminate erroneous state transitions which would occur based on bounce.
// 
// Parameters are provided in order to configure and appropriately size the
// counter of a 60 microsecond timer used in the transmitter, depending on
// the clock frequency used.  The 60 microsecond period is guaranteed to be
// more than one period of the ps2_clk_s signal.
//
// Also, a smaller 5 microsecond timer has been included for "debounce".
// This is used because, with internal pullups on the ps2_clk and ps2_data
// lines, there is some bouncing around which occurs
//
// A parameter TRAP_SHIFT_KEYS allows the user to eliminate shift keypresses
// from producing scan codes (along with their "undefined" ASCII equivalents)
// at the output of the interface.  If TRAP_SHIFT_KEYS is non-zero, the shift
// key status will only be reported by rx_shift_key_on.  No ascii or scan
// codes will be reported for the shift keys.  This is useful for those who
// wish to use the ASCII data stream, and who don't want to have to "filter
// out" the shift key codes.
//
//-------------------------------------------------------------------------------------


`resetall
`timescale 1ns/100ps

`define TOTAL_BITS   11
`define EXTEND_CODE  16'hE0
`define RELEASE_CODE 16'hF0
`define LEFT_SHIFT   16'h12
`define RIGHT_SHIFT  16'h59


module ps2_keyboard_interface (
  clk,
  reset,
  ps2_clk,
  ps2_data,
  rx_extended,
  rx_released,
  rx_shift_key_on,
  rx_scan_code,
  rx_ascii,
  rx_data_ready,       // rx_read_o
  rx_read,             // rx_read_ack_i
  tx_data,
  tx_write,
  tx_write_ack_o,
  tx_error_no_keyboard_ack
  );

// Parameters

// The timer value can be up to (2^bits) inclusive.
parameter TIMER_60USEC_VALUE_PP = 2950; // Number of sys_clks for 60usec.
parameter TIMER_60USEC_BITS_PP  = 12;   // Number of bits needed for timer
parameter TIMER_5USEC_VALUE_PP = 186;   // Number of sys_clks for debounce
parameter TIMER_5USEC_BITS_PP  = 8;     // Number of bits needed for timer
parameter TRAP_SHIFT_KEYS_PP = 0;       // Default: No shift key trap.

// State encodings, provided as parameters
// for flexibility to the one instantiating the module.
// In general, the default values need not be changed.

// State "m1_rx_clk_l" has been chosen on purpose.  Since the input
// synchronizing flip-flops initially contain zero, it takes one clk
// for them to update to reflect the actual (idle = high) status of
// the I/O lines from the keyboard.  Therefore, choosing 0 for m1_rx_clk_l
// allows the state machine to transition to m1_rx_clk_h when the true
// values of the input signals become present at the outputs of the
// synchronizing flip-flops.  This initial transition is harmless, and it
// eliminates the need for a "reset" pulse before the interface can operate.

parameter m1_rx_clk_h = 1;
parameter m1_rx_clk_l = 0;
parameter m1_rx_falling_edge_marker = 13;
parameter m1_rx_rising_edge_marker = 14;
parameter m1_tx_force_clk_l = 3;
parameter m1_tx_first_wait_clk_h = 10;
parameter m1_tx_first_wait_clk_l = 11;
parameter m1_tx_reset_timer = 12;
parameter m1_tx_wait_clk_h = 2;
parameter m1_tx_clk_h = 4;
parameter m1_tx_clk_l = 5;
parameter m1_tx_wait_keyboard_ack = 6;
parameter m1_tx_done_recovery = 7;
parameter m1_tx_error_no_keyboard_ack = 8;
parameter m1_tx_rising_edge_marker = 9;
parameter m2_rx_data_ready = 1;
parameter m2_rx_data_ready_ack = 0;

  
// I/O declarations
input clk;
input reset;
inout ps2_clk;
inout ps2_data;
output rx_extended;
output rx_released;
output rx_shift_key_on;
output [7:0] rx_scan_code;
output [7:0] rx_ascii;
output rx_data_ready;
input rx_read;
input [7:0] tx_data;
input tx_write;
output tx_write_ack_o;
output tx_error_no_keyboard_ack;

reg rx_extended;
reg rx_released;
reg [7:0] rx_scan_code;
reg [7:0] rx_ascii;
reg rx_data_ready;
reg tx_error_no_keyboard_ack;

// Internal signal declarations
wire timer_60usec_done;
wire timer_5usec_done;
wire extended;
wire released;
wire shift_key_on;

                         // NOTE: These two signals used to be one.  They
                         //       were split into two signals because of
                         //       shift key trapping.  With shift key
                         //       trapping, no event is generated externally,
                         //       but the "hold" data must still be cleared
                         //       anyway regardless, in preparation for the
                         //       next scan codes.
wire rx_output_event;    // Used only to clear: hold_released, hold_extended
wire rx_output_strobe;   // Used to produce the actual output.

wire tx_parity_bit;
wire rx_shifting_done;
wire tx_shifting_done;
wire [11:0] shift_key_plus_code;

reg [`TOTAL_BITS-1:0] q;
reg [3:0] m1_state;
reg [3:0] m1_next_state;
reg m2_state;
reg m2_next_state;
reg [3:0] bit_count;
reg enable_timer_60usec;
reg enable_timer_5usec;
reg [TIMER_60USEC_BITS_PP-1:0] timer_60usec_count;
reg [TIMER_5USEC_BITS_PP-1:0] timer_5usec_count;
reg [7:0] ascii;      // "REG" type only because a case statement is used.
reg left_shift_key;
reg right_shift_key;
reg hold_extended;    // Holds prior value, cleared at rx_output_strobe
reg hold_released;    // Holds prior value, cleared at rx_output_strobe
reg ps2_clk_s;        // Synchronous version of this input
reg ps2_data_s;       // Synchronous version of this input
reg ps2_clk_hi_z;     // Without keyboard, high Z equals 1 due to pullups.
reg ps2_data_hi_z;    // Without keyboard, high Z equals 1 due to pullups.

//--------------------------------------------------------------------------
// Module code

assign ps2_clk = ps2_clk_hi_z?1'bZ:1'b0;
assign ps2_data = ps2_data_hi_z?1'bZ:1'b0;

// Input "synchronizing" logic -- synchronizes the inputs to the state
// machine clock, thus avoiding errors related to
// spurious state machine transitions.
always @(posedge clk)
begin
  ps2_clk_s <= ps2_clk;
  ps2_data_s <= ps2_data;
end

// State register
always @(posedge clk)
begin : m1_state_register
  if (reset) m1_state <= m1_rx_clk_h;
  else m1_state <= m1_next_state;
end

// State transition logic
always @(m1_state
         or q
         or tx_shifting_done
         or tx_write
         or ps2_clk_s
         or ps2_data_s
         or timer_60usec_done
         or timer_5usec_done
         )
begin : m1_state_logic

  // Output signals default to this value, unless changed in a state condition.
  ps2_clk_hi_z <= 1;
  ps2_data_hi_z <= 1;
  tx_error_no_keyboard_ack <= 0;
  enable_timer_60usec <= 0;
  enable_timer_5usec <= 0;

  case (m1_state)

    m1_rx_clk_h :
      begin
        enable_timer_60usec <= 1;
        if (tx_write) m1_next_state <= m1_tx_reset_timer;
        else if (~ps2_clk_s) m1_next_state <= m1_rx_falling_edge_marker;
        else m1_next_state <= m1_rx_clk_h;
      end
      
    m1_rx_falling_edge_marker :
      begin
        enable_timer_60usec <= 0;
        m1_next_state <= m1_rx_clk_l;
      end

    m1_rx_rising_edge_marker :
      begin
        enable_timer_60usec <= 0;
        m1_next_state <= m1_rx_clk_h;
      end


    m1_rx_clk_l :
      begin
        enable_timer_60usec <= 1;
        if (tx_write) m1_next_state <= m1_tx_reset_timer;
        else if (ps2_clk_s) m1_next_state <= m1_rx_rising_edge_marker;
        else m1_next_state <= m1_rx_clk_l;
      end

    m1_tx_reset_timer:
      begin
        enable_timer_60usec <= 0;
        m1_next_state <= m1_tx_force_clk_l;
      end

    m1_tx_force_clk_l :
      begin
        enable_timer_60usec <= 1;
        ps2_clk_hi_z <= 0;  // Force the ps2_clk line low.
        if (timer_60usec_done) m1_next_state <= m1_tx_first_wait_clk_h;
        else m1_next_state <= m1_tx_force_clk_l;
      end

    m1_tx_first_wait_clk_h :
      begin
        enable_timer_5usec <= 1;
        ps2_data_hi_z <= 0;        // Start bit.
        if (~ps2_clk_s && timer_5usec_done)
          m1_next_state <= m1_tx_clk_l;
        else
          m1_next_state <= m1_tx_first_wait_clk_h;
      end
      
    // This state must be included because the device might possibly
    // delay for up to 10 milliseconds before beginning its clock pulses.
    // During that waiting time, we cannot drive the data (q[0]) because it
    // is possibly 1, which would cause the keyboard to abort its receive
    // and the expected clocks would then never be generated.
    m1_tx_first_wait_clk_l :
      begin

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩午夜在线观看| 亚洲人成网站影音先锋播放| 国产精品欧美一区喷水| 首页综合国产亚洲丝袜| 国产二区国产一区在线观看| 欧美精品一二三四| 亚洲欧美另类小说视频| 国产精品1区二区.| 日韩欧美中文一区| 亚洲国产精品欧美一二99| 99久精品国产| 国产精品国模大尺度视频| 精品午夜久久福利影院| 欧美人伦禁忌dvd放荡欲情| 亚洲乱码日产精品bd| 成人综合在线视频| 欧美经典一区二区三区| 久草精品在线观看| 精品欧美一区二区在线观看| 日韩专区在线视频| 欧美精品九九99久久| 亚洲精品写真福利| 一本一道综合狠狠老| 亚洲欧美电影院| 91欧美一区二区| 国产精品理伦片| 丁香婷婷深情五月亚洲| 中文一区二区完整视频在线观看| 精品亚洲成av人在线观看| 欧美精品一区二区久久久| 日韩综合小视频| 欧美一区在线视频| 久久99日本精品| 久久久国产精品麻豆 | 久久久亚洲国产美女国产盗摄| 日日夜夜免费精品| 日韩欧美一卡二卡| 国产在线精品不卡| 国产精品嫩草影院av蜜臀| 成人一级片网址| 中文字幕亚洲一区二区va在线| youjizz国产精品| 亚洲精品久久7777| 欧美日韩一级二级| 精品一区二区三区在线播放| 久久久久一区二区三区四区| 99久久精品免费看| 亚洲成av人在线观看| 91精品国产免费| 国产成人丝袜美腿| 亚洲精品水蜜桃| 日韩欧美一区二区三区在线| 国产伦精品一区二区三区免费| 国产亚洲精品aa| 一本色道**综合亚洲精品蜜桃冫| 亚洲一区二区三区精品在线| 日韩一级高清毛片| av高清不卡在线| 欧美a级理论片| 国产精品视频一二三区 | 国产成人精品影视| 亚洲精品国产a久久久久久| 欧美丰满少妇xxxxx高潮对白| 精品一区二区三区免费毛片爱| 日本一区二区三区视频视频| 欧洲生活片亚洲生活在线观看| 免费不卡在线视频| 亚洲视频在线一区| 精品久久人人做人人爰| 色婷婷久久一区二区三区麻豆| 麻豆精品在线播放| 伊人婷婷欧美激情| 国产日产精品1区| 欧美久久久久免费| 91在线国产福利| 另类综合日韩欧美亚洲| 亚洲欧美视频在线观看| 精品久久久久久久一区二区蜜臀| 91麻豆免费视频| 国产精品一区二区黑丝| 五月天国产精品| 亚洲日本va午夜在线影院| 欧美videofree性高清杂交| 一本大道久久精品懂色aⅴ| 久久精品国产精品亚洲精品| 亚洲一区在线电影| 中文字幕一区二区三区蜜月| 日韩精品一区二区三区视频| 欧美体内she精视频| 成人av影视在线观看| 老司机精品视频线观看86| 亚洲电影一区二区三区| 亚洲欧美怡红院| 中文av一区二区| 久久久亚洲午夜电影| 日韩免费性生活视频播放| 欧美日韩午夜精品| 欧美日韩一区二区三区视频| 91黄色免费网站| 国产成人综合在线播放| 久久精品噜噜噜成人88aⅴ| 亚洲v日本v欧美v久久精品| 一区二区三区在线高清| 亚洲人成在线观看一区二区| 国产精品美女久久久久久久久久久 | 日韩和欧美一区二区三区| 亚洲精品福利视频网站| 日韩一区欧美小说| 亚洲人成网站影音先锋播放| 国产精品福利一区二区三区| 亚洲国产精品成人综合| 欧美激情在线免费观看| 中文字幕 久热精品 视频在线| 国产三级一区二区三区| 国产亚洲精品久| 国产亚洲精品精华液| 国产精品毛片a∨一区二区三区| 日本一区二区电影| 亚洲欧美综合色| 亚洲一区二区三区不卡国产欧美| 亚洲色图欧洲色图婷婷| 亚洲激情综合网| 婷婷激情综合网| 精久久久久久久久久久| 国产乱码精品1区2区3区| 国产91精品精华液一区二区三区 | 国产精品国产三级国产普通话三级| 欧美国产97人人爽人人喊| 国产精品成人免费| 夜夜嗨av一区二区三区中文字幕 | 亚洲欧洲精品天堂一级| 亚洲欧美日韩国产一区二区三区| 一级日本不卡的影视| 亚洲成a人片在线不卡一二三区 | 99re在线精品| 欧美日韩mp4| www国产亚洲精品久久麻豆| 欧美极品另类videosde| 一区二区三区不卡视频在线观看 | av网站一区二区三区| 欧美中文字幕一区二区三区亚洲| 欧美精品欧美精品系列| 久久综合久久综合久久综合| 亚洲天堂免费看| 亚洲不卡一区二区三区| 国产成人午夜99999| 欧美亚洲日本国产| wwww国产精品欧美| 亚洲国产综合人成综合网站| 韩国欧美国产一区| 色婷婷综合久久久久中文一区二区| 91精品在线一区二区| 欧美激情在线观看视频免费| 亚洲午夜久久久久久久久电影网 | 国产精品美女久久久久av爽李琼| 亚洲午夜在线电影| 国产成人免费视频 | 在线精品亚洲一区二区不卡| 欧美成人国产一区二区| 亚洲成人免费电影| 成人激情免费电影网址| 日韩午夜激情免费电影| 亚洲免费观看高清完整版在线观看熊| 日av在线不卡| 日本韩国一区二区| 国产精品久久久久9999吃药| 蜜桃av噜噜一区二区三区小说| 97久久精品人人做人人爽| 精品国产第一区二区三区观看体验 | 日本一区二区三区四区| 美女精品一区二区| 91国偷自产一区二区三区成为亚洲经典 | 欧美日韩国产精品成人| 中文字幕一区在线观看| 麻豆国产精品一区二区三区| 欧美性大战xxxxx久久久| 国产精品美女久久久久av爽李琼| 精品午夜一区二区三区在线观看| 欧美色老头old∨ideo| 亚洲色图欧美偷拍| 99re视频精品| 国产精品区一区二区三区| 激情综合色播激情啊| 91精品中文字幕一区二区三区| 一个色综合av| 色美美综合视频| 亚洲欧美电影一区二区| 99精品欧美一区二区三区综合在线| 久久色.com| 国产东北露脸精品视频| 2023国产精品| 国产精品自在在线| 久久久蜜桃精品| 国产精品 欧美精品| 国产偷国产偷亚洲高清人白洁| 久久se这里有精品| 久久精品欧美日韩精品| 丁香婷婷深情五月亚洲| 国产精品欧美极品| 91女人视频在线观看|