Dept. Logo
Lab Home page
Department of Microelectronic Systems, Faculty of Electronics, Telecommunications and Informatics, Gdansk University of Technology Logo Wydziału
Flaga PL Polska wersja

Simple calculator with PS/2 keyboard

Task: Design and implement a simple integer calculator with addition and subtraction operations. The designed circuit should work as similarly as possible to the traditional calculator. Arguments and operators should be entered using PS/2 keyboard, input data and the result should be displayed on LED display of prototype board.

An example of operation 1234+96=1330:
Key (PS2) Display
0000
1 0001
2 0012
3 0123
4 1234
+ 1234
9 0009
6 0096
= 1330
ESC. 0000

UCF file, Digilent Spartan-3, Spartan-3 3S200 FT256-4:
#########################################################################################
# Clock:
NET "clk_i" LOC = "T9" ; # 50 MHz clock
#########################################################################################

#########################################################################################
# Seven-segment LED display:
NET "led7_an_o<3>" LOC = "E13" ; # leftmost digit, active low
NET "led7_an_o<2>" LOC = "F14" ; # active low
NET "led7_an_o<1>" LOC = "G14" ; # active low
NET "led7_an_o<0>" LOC = "d14" ; # rightmost digit, active low
#
NET "led7_seg_o<7>" LOC = "E14" ; # segment 'a', active low
NET "led7_seg_o<6>" LOC = "G13" ; # segment 'b', active low
NET "led7_seg_o<5>" LOC = "N15" ; # segment 'c', active low
NET "led7_seg_o<4>" LOC = "P15" ; # segment 'd', active low
NET "led7_seg_o<3>" LOC = "R16" ; # segment 'e', active low
NET "led7_seg_o<2>" LOC = "F13" ; # segment 'f', active low
NET "led7_seg_o<1>" LOC = "N16" ; # segment 'g', active low
NET "led7_seg_o<0>" LOC = "P16" ; # segment 'dp', active low
#########################################################################################

#########################################################################################
# Push-buttons:
NET "rst_i" LOC = "L14" ; # BTN3 active high
#########################################################################################

#########################################################################################
# PS2 port:
NET "ps2_clk_i" LOC = "M16" ; #clock from PS/2
NET "ps2_data_i" LOC = "M15" ; #PS/2 data
#########################################################################################

Wyświetlacz LED
Fig.1 Description of LED display connectors. Example of displaying digit '2'


Additional information on reading PS/2 keyboard