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

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

?? ps2_mouse.v

?? 本實驗實現PS/2接口與RS-232接口的數據傳輸
?? V
?? 第 1 頁 / 共 2 頁
字號:
//-------------------------------------------------------------------------------------
//
// Author: John Clayton
// Date  : April 30, 2001
// Update: 6/06/01 copied this file from ps2.v (pared down).
// Update: 6/07/01 Finished initial coding efforts.
// Update: 6/09/01 Made minor changes to state machines during debugging.
//                 Fixed errors in state transitions.  Added state to m2
//                 so that "reset" causes the mouse to be initialized.
//                 Removed debug port.
//
//
//
//
//
// Description
//-------------------------------------------------------------------------------------
// This is a state-machine driven serial-to-parallel and parallel-to-serial
// interface to the ps2 style mouse.  The state diagram for part of the
// m2 state machine was obtained from the work of Rob Chapman, as published
// at: 
// www.ee.ualberta.ca/~elliott/ee552/studentAppNotes/1998_w/mouse_notes.html
//
//
// Some aspects of the mouse interface are not implemented (e.g, verifying
// the FA response code from the mouse when enabling streaming mode.)
// However, the mouse interface was designed so that "hot plugging" a mouse
// into the connector should cause the interface to send the F4 code to the
// mouse in order to enable streaming.  By this means, the mouse begins to
// operate, and no reset pulse should be needed.
//
// Similarly, there is a "watchdog" timer implemented, so that during periods
// of inactivity, the bit_count is cleared to zero.  Therefore, the effects of
// a bad count value are corrected, and internal errors of that type are not
// propagated into subsequent packet receive operations.
//
// To enable the streaming mode, F4 is sent to the mouse.
// The mouse responds with FA to acknowledge the command, and then enters
// streaming mode at the default rate of 100 packets per second (transmission
// of packets ceases when the activity at the mouse is not longer sensed.)
//
// There are additional commands to change the sampling rate and resolution
// of the mouse reported data.  Those commands are not implemented here.
// (E8,XX = set resolution 0,1,2,3)
// (E7 = set scaling 2:1)
// (E6 = reset scaling)
// (F3,XX = set sampling rate to XX packets per second.)
//
// At this time I do not know any of the command related to using the
// wheel of a "wheel mouse." 
//
// The packets consists of three bytes transmitted in sequence.  The interval
// between these bytes has been measured on two different mice, and found to
// be different.  On the slower (older) mouse it was approximately 345
// microseconds, while on a newer "wheel" mouse it was approximately 125
// microseconds.  The watchdog timer is designed to cause processing of a
// complete packet when it expires.  Therefore, the watchdog timer must last
// for longer than the "inter-byte delay" between bytes of the packet.
// I have set the default timer value to 400 usec, for my 49.152 MHz clock.
// The timer value and size of the timer counter is settable by parameters,
// so that other clock frequencies and settings may be used.  The setting for
// the watchdog timeout is not critical -- it only needs to be greater than
// the inter-byte delay as data is transmitted from the mouse, and no less
// than 60usec.
//
// Each "byte" of the packet is transmitted from the mouse as follows:
//
// 1 start bit, 8 data bits, 1 odd parity bit, 1 stop bit. == 11 bits total.
// (The data bits are sent LSB first)
//
// The data bits are formatted as follows:
//
// byte 0: YV, XV, YS, XS, 1, 0, R, L
// byte 1: X7..X0
// byte 2: Y7..Y0
//
// Where YV, XV are set to indicate overflow conditions.
//       XS, YS are set to indicate negative quantities (sign bits).
//        R,  L are set to indicate buttons pressed, left and right.
// 
//
//
// The interface to the ps2 mouse (like the keyboard) uses clock rates of
// 30-40 kHz, dependent upon the mouse itself.  The mouse generates the
// clock.
// 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.
// 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 mouse
// the ps2_clk and ps2_data lines are used as inputs.  While writing to the
// mouse, however (which is done when a "packet" of less than 33 bits is
// received), both the ps2_clk and ps2_data lines are sometime pulled low by
// this interface.  As such, they are bidirectional, and pullups are used to
// return them to the "high" state, whenever the drivers are set to the
// high impedance state.
//
// 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 to configure the debounce timer for different
// clock frequencies.  2 or 3 microseconds of debounce should be plenty.
// You may possibly use much less, if your pullups are strong.
//
// A parameters is provided to configure a 60 microsecond period used while
// transmitting to the mouse.  The 60 microsecond period is guaranteed to be
// more than one period of the ps2_clk signal.
//
//
//-------------------------------------------------------------------------------------


`resetall
`timescale 1ns/100ps

`define TOTAL_BITS   33  // Number of bits in one full packet


module ps2_mouse_interface (
  clk,
  reset,
  ps2_clk,
  ps2_data,
  left_button,
  right_button,
  x_increment,
  y_increment,
  data_ready,       // rx_read_o
  read,             // rx_read_ack_i
  error_no_ack
  );

// Parameters

// The timer value can be up to (2^bits) inclusive.
parameter WATCHDOG_TIMER_VALUE_PP = 20000; // Number of sys_clks for 400usec.
parameter WATCHDOG_TIMER_BITS_PP  = 15;    // Number of bits needed for timer
parameter DEBOUNCE_TIMER_VALUE_PP = 186;   // Number of sys_clks for debounce
parameter DEBOUNCE_TIMER_BITS_PP  = 8;     // Number of bits needed for timer


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

// There are three state machines: m1, m2 and m3.
// States chosen as "default" states upon power-up and configuration:
//    "m1_clk_h"
//    "m2_wait"
//    "m3_data_ready_ack"

parameter m1_clk_h = 0;
parameter m1_falling_edge = 1;
parameter m1_falling_wait = 3;
parameter m1_clk_l = 2;
parameter m1_rising_edge = 6;
parameter m1_rising_wait = 4;

parameter m2_reset = 14;
parameter m2_wait = 0;
parameter m2_gather = 1;
parameter m2_verify = 3;
parameter m2_use = 2;
parameter m2_hold_clk_l = 6;
parameter m2_data_low_1 = 4;
parameter m2_data_high_1 = 5;
parameter m2_data_low_2 = 7;
parameter m2_data_high_2 = 8;
parameter m2_data_low_3 = 9;
parameter m2_data_high_3 = 11;
parameter m2_error_no_ack = 15;
parameter m2_await_response = 10;

parameter m3_data_ready = 1;
parameter m3_data_ready_ack = 0;

// I/O declarations
input clk;
input reset;
inout ps2_clk;
inout ps2_data;
output left_button;
output right_button;
output [8:0] x_increment;
output [8:0] y_increment;
output data_ready;
input read;
output error_no_ack;

reg left_button;
reg right_button;
reg [8:0] x_increment;
reg [8:0] y_increment;
reg data_ready;
reg error_no_ack;

// Internal signal declarations
wire watchdog_timer_done;
wire debounce_timer_done;
wire packet_good;

reg [`TOTAL_BITS-1:0] q;  // Shift register
reg [2:0] m1_state;
reg [2:0] m1_next_state;
reg [3:0] m2_state;
reg [3:0] m2_next_state;
reg m3_state;
reg m3_next_state;
reg [5:0] bit_count;      // Bit counter
reg [WATCHDOG_TIMER_BITS_PP-1:0] watchdog_timer_count;
reg [DEBOUNCE_TIMER_BITS_PP-1:0] debounce_timer_count;
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.
reg clean_clk;        // Debounced output from m1, follows ps2_clk.
reg rising_edge;      // Output from m1 state machine.
reg falling_edge;     // Output from m1 state machine.
reg output_strobe;    // Latches data data into the output registers

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

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

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

// State transition logic
always @(m1_state
         or ps2_clk
         or debounce_timer_done
         or watchdog_timer_done
         )
begin : m1_state_logic

  // Output signals default to this value, unless changed in a state condition.
  clean_clk <= 0;
  rising_edge <= 0;
  falling_edge <= 0;

  case (m1_state)
    m1_clk_h :
      begin
        clean_clk <= 1;
        if (~ps2_clk) m1_next_state <= m1_falling_edge;
        else m1_next_state <= m1_clk_h;
      end
      
    m1_falling_edge :
      begin
        falling_edge <= 1;
        m1_next_state <= m1_falling_wait;
      end
      
    m1_falling_wait :
      begin
        if (debounce_timer_done) m1_next_state <= m1_clk_l;
        else m1_next_state <= m1_falling_wait;
      end

    m1_clk_l :
      begin
        if (ps2_clk) m1_next_state <= m1_rising_edge;
        else m1_next_state <= m1_clk_l;
      end

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩亚洲丝袜制服| 久久久亚洲精品一区二区三区| 欧美亚洲综合色| 成人免费看的视频| 欧美在线免费播放| 国产午夜精品久久| 欧美电影免费观看高清完整版在| 中文av一区二区| 美女性感视频久久| 欧美男生操女生| 一区二区三区四区视频精品免费 | 日韩欧美www| 亚洲综合在线第一页| 成人在线综合网站| 久久欧美一区二区| 精品亚洲国内自在自线福利| 欧美三区在线观看| 一区二区三区欧美激情| 北岛玲一区二区三区四区| 久久综合久久久久88| 精品综合久久久久久8888| 69精品人人人人| 午夜国产不卡在线观看视频| 在线视频亚洲一区| 亚洲在线成人精品| 欧美三级中文字幕在线观看| √…a在线天堂一区| 国产99久久久国产精品| 久久久99精品免费观看| 国内精品在线播放| 久久久久久久性| 国产激情一区二区三区| 国产视频一区在线播放| 国产成人福利片| 中文一区在线播放| 白白色 亚洲乱淫| 国产精品国产三级国产有无不卡 | 日产欧产美韩系列久久99| 欧美人成免费网站| 调教+趴+乳夹+国产+精品| 欧美精品一二三区| 蜜臀av亚洲一区中文字幕| 欧美一区二区三区婷婷月色| 老司机精品视频一区二区三区| 这里只有精品电影| 久久91精品久久久久久秒播| 精品久久久久久久久久久院品网 | 96av麻豆蜜桃一区二区| 亚洲黄色在线视频| 欧美日韩一二三| 精品一区二区三区欧美| 久久久久久久久蜜桃| 成人激情图片网| 亚洲小少妇裸体bbw| 91精品国产色综合久久ai换脸| 免费观看一级欧美片| 国产性天天综合网| 色综合久久中文综合久久牛| 国产综合色精品一区二区三区| 久久这里只有精品6| 99riav久久精品riav| 午夜av一区二区三区| 久久久不卡影院| 一本高清dvd不卡在线观看| 天天爽夜夜爽夜夜爽精品视频| 日韩限制级电影在线观看| 国产乱色国产精品免费视频| 亚洲日本青草视频在线怡红院| 欧美精品一卡两卡| 粉嫩高潮美女一区二区三区| 亚洲电影一区二区三区| 2020国产成人综合网| 日本乱人伦一区| 久久国产尿小便嘘嘘| 亚洲九九爱视频| www国产亚洲精品久久麻豆| 色狠狠av一区二区三区| 国产美女娇喘av呻吟久久| 有码一区二区三区| 国产午夜亚洲精品羞羞网站| 欧美视频一二三区| 国产+成+人+亚洲欧洲自线| 偷偷要91色婷婷| 亚洲色大成网站www久久九九| 欧美成人国产一区二区| 在线视频中文字幕一区二区| 成人精品国产一区二区4080| 日本欧美韩国一区三区| 亚洲男人的天堂在线aⅴ视频| 精品国产91久久久久久久妲己| 欧美这里有精品| 大胆欧美人体老妇| 久久99久久99精品免视看婷婷| 一区二区三区四区激情| 中文字幕av一区二区三区高 | 麻豆91在线观看| 亚洲一区二区三区四区五区中文| 国产精品乱码久久久久久| 精品久久久久久无| 日韩午夜在线观看| 欧美丰满少妇xxxxx高潮对白 | 久久se这里有精品| 日本欧美韩国一区三区| 五月综合激情婷婷六月色窝| 亚洲免费观看高清完整版在线 | av欧美精品.com| 风间由美性色一区二区三区| 国产自产视频一区二区三区| 日本亚洲免费观看| 日韩制服丝袜av| 香港成人在线视频| 亚洲www啪成人一区二区麻豆| 亚洲另类在线制服丝袜| 亚洲激情六月丁香| 亚洲制服欧美中文字幕中文字幕| 亚洲天堂av老司机| 中文字幕在线一区二区三区| 国产精品成人一区二区三区夜夜夜| 国产色爱av资源综合区| 国产精品网站一区| 亚洲免费观看高清完整版在线| 亚洲天堂福利av| 玉足女爽爽91| 首页亚洲欧美制服丝腿| 男人操女人的视频在线观看欧美| 麻豆成人免费电影| 国产一区二三区| 成人精品gif动图一区| 91视频一区二区三区| 91极品视觉盛宴| 欧美久久高跟鞋激| 精品日韩欧美一区二区| 国产亚洲精品aa午夜观看| 国产精品久久久久久久久快鸭| 自拍偷拍国产精品| 午夜影视日本亚洲欧洲精品| 美美哒免费高清在线观看视频一区二区| 理论片日本一区| 成人av中文字幕| 欧美日韩小视频| 久久综合久色欧美综合狠狠| 国产精品二三区| 丝袜亚洲另类欧美| 国产一区二区日韩精品| 91在线视频免费观看| 91精品国产综合久久精品| 久久午夜羞羞影院免费观看| 亚洲免费高清视频在线| 日本不卡中文字幕| 粉嫩绯色av一区二区在线观看 | 欧美一卡二卡三卡| 国产精品午夜在线观看| 午夜精品一区二区三区电影天堂| 麻豆视频观看网址久久| www.欧美色图| 日韩欧美在线一区二区三区| 国产精品丝袜91| 奇米影视一区二区三区| 91视视频在线观看入口直接观看www | 丝袜美腿亚洲综合| 国产成人啪免费观看软件| 欧美日韩在线精品一区二区三区激情| 精品久久久久久久久久久久久久久久久 | 中文字幕一区免费在线观看| 亚洲成a人v欧美综合天堂下载| 麻豆国产精品官网| 欧美亚洲国产一区二区三区va| 久久精品在这里| 性做久久久久久久免费看| 成人性生交大片免费看视频在线| 7777精品伊人久久久大香线蕉超级流畅 | 精品一区二区三区免费| 在线日韩av片| 国产精品网站在线播放| 久久66热re国产| 欧美精品一二三四| 一区二区在线观看不卡| 国产成人在线视频网站| 日韩一级黄色大片| 午夜精品久久久久久久蜜桃app| 不卡在线观看av| 国产亚洲一区二区在线观看| 麻豆91免费看| 欧美精品亚洲一区二区在线播放| 最新欧美精品一区二区三区| 国产91丝袜在线18| 2023国产一二三区日本精品2022| 欧美aaaaa成人免费观看视频| 欧美做爰猛烈大尺度电影无法无天| 中文字幕不卡的av| 成人av手机在线观看| 国产欧美视频一区二区| 国产精品影视网| 久久久亚洲精品石原莉奈| 韩国女主播成人在线| 精品福利一二区| 国产中文字幕一区| 久久久久久久久久久久久久久99 | 欧美成人高清电影在线| 蜜臀av亚洲一区中文字幕|