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

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

?? ps2_mouse_interface.v

?? 利用FPGA控制PS2
?? 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一区二区三区免费野_久草精品视频
裸体在线国模精品偷拍| 亚洲欧美日韩在线播放| 欧美探花视频资源| 国产盗摄女厕一区二区三区| 亚洲视频一二三| 精品国产成人系列| 在线观看中文字幕不卡| 成人黄页毛片网站| 韩国一区二区视频| 男人操女人的视频在线观看欧美| 欧美激情一区在线观看| 欧美tk—视频vk| 欧美日韩成人综合天天影院| 国产精品一区二区在线观看网站| 首页国产欧美日韩丝袜| 亚洲一级不卡视频| 亚洲一区二区av电影| 国产三级久久久| 日韩欧美国产一区二区在线播放| 日韩一区二区三区在线观看| 精品久久久久久最新网址| 欧美mv日韩mv亚洲| 国产亚洲精品7777| 午夜精品久久久久久久久久久| 国产精品久久久久久久久快鸭| 中文字幕一区二区在线播放| 亚洲区小说区图片区qvod| 亚洲综合成人在线视频| 免费成人在线视频观看| 国产传媒一区在线| 99热这里都是精品| 制服丝袜中文字幕亚洲| 国产欧美日韩在线视频| 亚洲黄色小视频| 国产永久精品大片wwwapp| 97久久精品人人做人人爽50路| 色伊人久久综合中文字幕| 日韩视频免费观看高清完整版在线观看 | 中文字幕制服丝袜成人av| 亚洲综合色区另类av| 麻豆国产欧美日韩综合精品二区| 国产成人一区在线| 中文字幕中文在线不卡住| 婷婷久久综合九色综合伊人色| 欧美色网一区二区| 亚洲欧美自拍偷拍色图| 国产一区二区三区免费在线观看 | 色综合天天性综合| 日韩你懂的电影在线观看| 亚洲同性gay激情无套| 国产精品一二三四五| 欧美videossexotv100| 午夜伊人狠狠久久| 91黄色免费网站| 亚洲欧美日韩一区二区三区在线观看 | 在线视频亚洲一区| 亚洲国产精品t66y| 日本高清视频一区二区| 亚洲精品国产a久久久久久| 久久99久久精品| 亚洲成人午夜电影| 成人av电影在线网| 欧美极品少妇xxxxⅹ高跟鞋| 国产一区二区三区香蕉| 日韩午夜在线播放| 蜜臀精品一区二区三区在线观看| 欧美日韩在线电影| 亚洲国产cao| 在线播放一区二区三区| 麻豆精品国产传媒mv男同| 欧美一二三四区在线| 蓝色福利精品导航| 国产亚洲精久久久久久| 国产91丝袜在线播放| 欧美激情在线观看视频免费| av电影在线不卡| 天天做天天摸天天爽国产一区 | 国产成人av一区二区三区在线| 日本一区二区三区dvd视频在线 | 欧美少妇一区二区| 日本欧美在线观看| 久久人人97超碰com| 成人精品免费看| 夜夜夜精品看看| 日韩情涩欧美日韩视频| 成人中文字幕合集| 天天色天天操综合| 日本一二三不卡| 7777精品久久久大香线蕉| 粉嫩av一区二区三区粉嫩| 亚洲影院免费观看| 久久蜜桃av一区二区天堂| 91美女视频网站| 国产一区免费电影| 亚洲在线视频一区| 久久亚洲欧美国产精品乐播| 欧美在线观看视频在线| 国产一区二区三区国产| 三级不卡在线观看| 国产精品不卡视频| 久久午夜电影网| 日韩欧美在线影院| 欧美视频在线一区二区三区| 国产.欧美.日韩| 狠狠色丁香婷婷综合| 日韩国产欧美在线观看| 亚洲精品久久久蜜桃| 亚洲国产精品成人综合色在线婷婷| 欧美一级理论片| 欧美美女直播网站| 欧美色图免费看| 欧美色图片你懂的| 欧美精品一二三区| 4hu四虎永久在线影院成人| 欧美主播一区二区三区| 色狠狠色噜噜噜综合网| 色综合一个色综合亚洲| 色综合久久久久网| 91成人在线观看喷潮| 日本国产一区二区| 欧美亚洲国产一卡| 欧美日韩另类一区| 日韩欧美国产一区二区三区| 日韩精品一区二区三区四区视频| 日韩欧美视频一区| 日韩精品自拍偷拍| 欧美激情在线观看视频免费| 亚洲欧洲日韩女同| 一级特黄大欧美久久久| 亚洲成人三级小说| 麻豆国产欧美日韩综合精品二区| 国产一区高清在线| 99久精品国产| 欧美一区二区福利在线| 久久精品亚洲精品国产欧美kt∨| 国产精品国产三级国产普通话99 | 日韩精品专区在线影院观看| 欧美国产视频在线| 午夜免费久久看| 极品瑜伽女神91| 色成年激情久久综合| 欧美老肥妇做.爰bbww| 国产亚洲精品bt天堂精选| 伊人色综合久久天天| 韩国理伦片一区二区三区在线播放| 国产精品一二三区在线| 欧美综合视频在线观看| 久久天堂av综合合色蜜桃网| 亚洲午夜精品在线| aaa欧美色吧激情视频| 精品精品国产高清a毛片牛牛| 亚洲精品国产a久久久久久| 国产在线精品一区二区不卡了| 在线观看www91| 国产精品视频九色porn| 六月丁香综合在线视频| 欧美亚洲免费在线一区| 亚洲美女屁股眼交3| 成人免费不卡视频| 久久久久国产精品厨房| 激情小说亚洲一区| 精品少妇一区二区三区日产乱码 | 在线观看日韩电影| 中文久久乱码一区二区| 国产激情偷乱视频一区二区三区 | 久久一留热品黄| 狠狠色综合日日| 久久久久久久久久久久久久久99| 日日骚欧美日韩| 91精品啪在线观看国产60岁| 日韩电影一二三区| 91精品国产一区二区| 久久精工是国产品牌吗| 精品毛片乱码1区2区3区| 久久99精品一区二区三区| 欧美sm极限捆绑bd| 国产乱码一区二区三区| 久久精品亚洲国产奇米99| 成人深夜福利app| 亚洲精品日日夜夜| 欧美日韩国产欧美日美国产精品| 视频一区二区中文字幕| 欧美成人精精品一区二区频| 国产高清成人在线| 亚洲美女淫视频| 精品国产免费人成在线观看| 国产一区在线观看麻豆| 亚洲欧美日本韩国| 日韩欧美一区二区视频| 成人一道本在线| 亚洲嫩草精品久久| 精品区一区二区| 日本精品视频一区二区| 另类中文字幕网| 亚洲制服丝袜av| 国产日本亚洲高清| 91小视频在线免费看| 国产精品久久久久天堂| 制服.丝袜.亚洲.另类.中文 | 91看片淫黄大片一级在线观看|