This website uses cookies. By using this site, you consent to the use of cookies. For more information, please take a look at our Privacy Policy.
Home > FPGA Technical Tutorials > Design Recipes for FPGAs Using Verilog and VHDL > PS/2 Mouse Interface > Basic PS/2 Mouse Handler in Verilog

TABLE OF CONTENTS

Xilinx FPGA FPGA Forum

Basic PS/2 Mouse Handler in Verilog

FONT SIZE : AAA

The simplest form of the Verilog handler could use the keyboard clock signal as the system clock and then monitor the data coming from the keyboard. This is shown here:

1 module psmouse (

2 clk, / clock input

3 data / data input

4 );

5

6 input clk;

7 input data;

8

9 wire clk;

10 wire data;

11

12 reg [4:0] index = 5’b10111;

13 reg [23:0] d;

14 reg [7:0] byte1;

15 reg [7:0] byte2;

16 reg [7:0] byte3;

17

18 always @ (negedge clk)

19 begin : count

20 d[index] <= data;

21 if (index > 0) begin

22 index <= index − 1;

23 end

24 else begin

25 index <= 23;

26 byte1 <= d[23:16];

27 byte2 <= d[15:8];

28 byte3 <= d[7:0]

29 end

30 end

31

32 endmodule

This Verilog is very simple: on each falling edge of the clock the current value of the data is read into the next element of the data array (d) and when the complete 24-bits packet has been read in (and index has counted down to zero) then the three bytes are transcribed from the packet. 

A modified handler could also be implemented in Verilog, either using the same approach as described for the VHDL model, but also the approach could be taken to simply divide down the clock from a higher frequency reference. 

  • XC5VLX110T-3FF1136C

    Manufacturer:Xilinx

  • FPGA Virtex-5 LXT Family 110592 Cells 65nm Technology 1V 1136-Pin FCBGA
  • Product Categories: Special equipment devices and IC

    Lifecycle:Active Active

    RoHS: No RoHS

  • XC5VLX155-1FF1153I

    Manufacturer:Xilinx

  • FPGA Virtex-5 LX Family 65nm Technology 1V 1153-Pin FCBGA
  • Product Categories: FPGAs (Field Programmable Gate Array)

    Lifecycle:Active Active

    RoHS: No RoHS

  • XC5VLX155-1FFG1153I

    Manufacturer:Xilinx

  • FPGA Virtex-5 LX Family 65nm Technology 1V 1153-Pin FCBGA
  • Product Categories: FPGAs (Field Programmable Gate Array)

    Lifecycle:Active Active

    RoHS:

  • XC3090A-7PQ160C

    Manufacturer:Xilinx

  • FPGA XC3000 Family 6K Gates 320 Cells 113MHz 5V 160-Pin PQFP
  • Product Categories: FPGAs

    Lifecycle:Obsolete -

    RoHS: No RoHS

  • XC4028XLA-09BG256C

    Manufacturer:Xilinx

  • FPGA XC4000XLA Family 28K Gates 2432 Cells 227MHz 0.35um Technology 3.3V 256-Pin BGA
  • Product Categories:

    Lifecycle:Obsolete -

    RoHS: No RoHS

Need Help?

Support

If you have any questions about the product and related issues, Please contact us.