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

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? ps2_keyboard.v

?? 本實(shí)驗(yàn)實(shí)現(xiàn)PS/2接口與RS-232接口的數(shù)據(jù)傳輸
?? V
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
//-------------------------------------------------------------------------------------
//
// 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

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色综合中文综合网| 日韩小视频在线观看专区| 9191久久久久久久久久久| 日韩欧美123| 国产精品美女久久久久aⅴ | 欧美三级电影网| 精品少妇一区二区三区免费观看 | 色国产精品一区在线观看| 538在线一区二区精品国产| 精品成人一区二区三区四区| 亚洲欧洲日韩女同| 秋霞午夜鲁丝一区二区老狼| 成人avav影音| 欧美高清hd18日本| 国产女主播视频一区二区| 夜色激情一区二区| 国产乱人伦精品一区二区在线观看| 91在线播放网址| 精品美女一区二区| 夜夜精品视频一区二区| 国产高清不卡二三区| 欧美日韩免费观看一区二区三区| 久久久久久久久岛国免费| 伊人性伊人情综合网| 狠狠色丁香久久婷婷综合丁香| 91免费看`日韩一区二区| 精品国产成人系列| 亚洲在线免费播放| 国产91富婆露脸刺激对白| 91精品黄色片免费大全| 亚洲女性喷水在线观看一区| 国产美女在线观看一区| 7777精品伊人久久久大香线蕉| 中文字幕一区免费在线观看| 激情偷乱视频一区二区三区| 7777精品伊人久久久大香线蕉的 | 欧美日精品一区视频| 国产日韩欧美精品综合| 另类的小说在线视频另类成人小视频在线 | 欧美理论电影在线| 中文字幕在线不卡一区| 国产在线播精品第三| 91精品国产综合久久福利| 有码一区二区三区| 99麻豆久久久国产精品免费| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 久久99精品久久久| 欧美日韩国产高清一区二区| 亚洲精选一二三| 成人免费av网站| 久久综合九色欧美综合狠狠 | 久久精品一区二区三区不卡牛牛 | 国产婷婷色一区二区三区| 美脚の诱脚舐め脚责91| 欧美精品自拍偷拍动漫精品| 亚洲自拍偷拍网站| 91福利国产成人精品照片| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆| 国产精品1区2区| 久久日韩精品一区二区五区| 精品亚洲aⅴ乱码一区二区三区| 7777精品伊人久久久大香线蕉的 | 欧美va日韩va| 美女精品一区二区| 91精品国产综合久久久久久久| 午夜精品久久久久久久| 欧美日韩在线不卡| 亚洲国产另类av| 欧美视频在线一区二区三区| 亚洲影视资源网| 欧美性猛片xxxx免费看久爱| 亚洲成人av电影在线| 欧美日韩国产一级| 天天操天天干天天综合网| 欧美久久免费观看| 日韩高清在线电影| 欧美一区在线视频| 久久精品国产亚洲一区二区三区| 日韩欧美成人激情| 国产精品一区三区| 国产精品国产精品国产专区不片 | 一区二区三区av电影| 日本久久一区二区| 亚洲二区视频在线| 日韩欧美久久一区| 国产精品99久久久久久似苏梦涵| 国产日产欧美精品一区二区三区| 成人免费毛片app| 一区二区免费在线播放| 欧美久久一区二区| 久久精品国产**网站演员| 久久综合狠狠综合久久激情| 成人午夜av影视| 亚洲精品久久久蜜桃| 欧美性一级生活| 蜜桃av一区二区| 国产精品五月天| 欧美影视一区二区三区| 青青国产91久久久久久| 久久精品亚洲一区二区三区浴池| av资源网一区| 三级在线观看一区二区| 精品成人一区二区三区四区| 99久久精品情趣| 五月激情六月综合| 26uuuu精品一区二区| 99re这里都是精品| 日韩高清不卡一区二区三区| 国产日产精品一区| 日本精品一区二区三区高清| 毛片基地黄久久久久久天堂| 国产精品天天看| 欧美精品丝袜久久久中文字幕| 国产精品自产自拍| 一区二区三区免费网站| 日韩欧美一级二级三级| av中文字幕一区| 免费高清视频精品| 日韩美女视频一区| 欧美成人乱码一区二区三区| www.视频一区| 久久99国产精品麻豆| 亚洲欧洲日韩一区二区三区| 日韩一级黄色片| 91色.com| 国产精品资源在线观看| 亚洲超碰97人人做人人爱| 久久精品亚洲一区二区三区浴池| 欧美日韩一区中文字幕| 高清不卡在线观看| 免费人成在线不卡| 亚洲黄网站在线观看| 久久综合狠狠综合久久综合88| 欧美在线观看一二区| 国产91在线观看| 蜜臀av性久久久久蜜臀aⅴ流畅| 亚洲美女电影在线| 久久久久久久久蜜桃| 91精品国产91久久综合桃花| 99久久精品一区二区| 国产伦精品一区二区三区视频青涩| 一区二区在线免费观看| 欧美激情在线观看视频免费| 欧美一区2区视频在线观看| 色婷婷综合激情| 成人精品高清在线| 国产制服丝袜一区| 全国精品久久少妇| 亚洲电影第三页| 亚洲美女精品一区| 国产精品久久久久影院色老大| 精品第一国产综合精品aⅴ| 欧美巨大另类极品videosbest | 亚洲成人在线观看视频| 国产精品人人做人人爽人人添| 精品久久久久久久人人人人传媒| 欧美伊人久久大香线蕉综合69 | 一区二区三区欧美日韩| 国产精品久久久久久久久免费桃花| 精品国产一区二区精华| 7878成人国产在线观看| 在线看一区二区| 94色蜜桃网一区二区三区| 成人短视频下载| 国产精品白丝jk白祙喷水网站| 极品少妇一区二区| 奇米在线7777在线精品| 日韩高清不卡一区二区三区| 亚洲bt欧美bt精品| 亚洲高清免费观看| 亚洲午夜久久久久中文字幕久| 亚洲色大成网站www久久九九| 中文字幕视频一区二区三区久| 国产偷国产偷精品高清尤物 | 99视频一区二区三区| 成人免费视频一区| 成人久久视频在线观看| 成人精品免费看| 99天天综合性| 色综合久久99| 欧美在线一二三四区| 欧美吻胸吃奶大尺度电影 | 日韩电影一二三区| 性做久久久久久| 奇米色777欧美一区二区| 麻豆精品视频在线观看| 国精品**一区二区三区在线蜜桃| 国内精品国产成人国产三级粉色 | 国产午夜亚洲精品羞羞网站| 国产日本欧美一区二区| 中文字幕第一区| 亚洲免费资源在线播放| 一区二区三区.www| 天堂成人国产精品一区| 蜜臀a∨国产成人精品| 精品一区二区三区在线观看国产| 黄色精品一二区| 成人av网站在线| 色呦呦一区二区三区| 欧美日韩国产综合视频在线观看 |