Coder Social home page Coder Social logo

zarkobabic / ps2-keyboard-protocol-implementation-in-systemverilog Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 7.28 MB

Implementation of the ps2 protocol for the keyboard, where the device is a keyboard with a ps2 serial port, and the host is an Altera Cyclone® V FPGA board.

Verilog 4.35% SystemVerilog 1.13% Tcl 0.31% Stata 0.11% Makefile 2.05% Shell 73.86% C 13.09% C++ 3.43% Objective-C 0.02% Fortran 0.03% Roff 1.63%
verilog fpga-board ps2-controller ps2-keyboard ps2-protocol synthesis verification

ps2-keyboard-protocol-implementation-in-systemverilog's Introduction

PS2-keyboard-protocol-implementation-in-SystemVerilog


Banner18

Abstract


Implementation of the ps2 protocol for the keyboard, where the device is a keyboard with a ps2 serial port, and the host is an Altera Cyclone® V FPGA board.

Implementation involves going through all stages of software development for hardware:

  1. Simulation using Verilog and Altera ModelSim
  2. Synthesis using Verilog and Quartus II
  3. Verification using SystemVerilog and QuestaSim

Navigation


In the folder

  src/simulation

there are source files used for the simulation. In the subfolder modules there are implementations of the used module written in Verilog.
In addition, there is a file testbench_uvm, which represents the source code for verification, written in SystemVerilog using the standard library UVM (Universal Verification Methodology library).

The

  src/synthesis

path contains files relevant to synthesis on the Altera Cyclone® V FPGA board.
The path

  src/synthesis/modules

contains the implemented modules:

  1. deb.v which is a debouncer for the keyboard clock signal
  2. hex.v which is a module for reading hex values on the seven-segment display of the FPGA board
  3. ps2.v which represents the main module in which the logic of the protocol is implemented

On the path src/syntesis/ there is also the file DEO_TOP0.v which represents the file in which things are instantiated and from which the program for the FPGA board will be synthesized.

Starting up


Before starting, make sure you have pre-installed Altera ModelSim, Quartus II and QuestaSim as well as connected Altera Cyclone® V FPGA board.

In order to start one of the development phases, it is necessary to use the makefile located in the path:

  src/tooling/xpack/makefile

If it is started from the Windows operating system, it is necessary to install and run Cygwin in order to simulate linux functions on windows from the terminal.

Inside the makefile, with the:

  help

command, we get a list of possible commands for starting phases.


The command:
  simul_run

starts the verification, while the command:

  synth_pgm

starts the tools of the synthesis program and puts program to the connected FPGA board.

Implementation


The goal of the project was to implement this protocol so that the last two bytes of pressed and released keyboard codes (make and break codes) are displayed on the seven-segment display of an Altera Cyclone® V FPGA board. I wrote the software for this board so that the board and the keyboard can communicate via ps2 protocol and send values that will be shown on the display.

Specification:

  • PS/2 protocol is a serial protocol for communication between devices and keyboards.
  • Communication is performed using two signals:
    1. PS2_KBCLK which represents the keyboard clock signal (10-16.7kH) to which data is sent.
    2. PS2_KBDAT through which data from the keyboard is sent serially.
  • Data is sent on the falling edge of the keyboard clock signal.
  • When no data is sent, the PS2_KBDAT signal has a value of one.
  • Sending data starts with the START bit (value 0), followed by 8 DATA bits (sent first the lowest bit), followed by the ODD_PARITY bit (odd parity), and finally the STOP bit is sent (value 1).
  • If a key whose make code has more than one byte is pressed, older bytes are sent first, using the same principle as sending from the lowest bits
  • When a button on the keyboard is pressed or released, the keyboard sends a code over the protocol pressed (make code) or released (break code) button.
  • The code can be of different lengths (1B, 2B, 4B, ...).
  • The code of the released button is formed by adding F0 to the code of the pressed button the two highest bytes.
  • If a button whose make code is larger than one byte is released, then a break code is created by adding F0 between the first and second byte.

PS2 protocol

ps2-keyboard-protocol-implementation-in-systemverilog's People

Contributors

zarkobabic avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.