# keyboard interface in VHDL

#### m75allen

Joined Nov 20, 2006
11
Hi am trying to write a code in VHDL to interface keyboard in a vending machine to be downloaded in a virtex 4 board but i am stuck. Anyone who has an idea how to go about it i will appreciate very much. Thanks

#### n9352527

Joined Oct 14, 2005
1,198
What kind of keyboard? Standard PS2 PC keyboard?

#### Dave

Joined Nov 17, 2003
6,970
You need to give a few more details in addition to what n9352527 has asked:

1) What is the proposed configuration? Keyboard (for input) to virtex 4 (hardware interface) to what?

2) What exactly would you like to obtain from the interface implementation? i.e. What should it do?

3) Have you any idea what signal types to need to exchange over the interface? Control signals, data signals - what are the format of these signals?

Dave

#### m75allen

Joined Nov 20, 2006
11
The iam of the vending machine project is to use ps2 keyboard to input coin value via interfacing the ps2 with virtex 4. Secondly display out put values on a VGA monitor thus i requre code for keyboard and VGA. The keyboard signal will be basicaly controll signals for example key "A" can signify $1 and VGA will out put change value of 25 cents if the item chosen was 75 cents. Any idea???? Thanks #### n9352527 Joined Oct 14, 2005 1,198 This site has an explanation on how to interface a PS2 keyboard. Just follow the signals and timing diagrams and re-create them with your Virtex. Pay special attention to the timing and signal level and make sure you follow the initialisation protocol. VGA is quite simple, you need to establish the VGA/res mode first to obtain the signal timing and then create each RGB signals and put HV synch signals. Have a look at this page for a simple example. Notice that without any DAC you'd get only 8 primary colours. If you need any kind of colour shade, then go with a dedicated VGA DAC chip. The timing would still be the same. Is this an exercise or a project? It seems to be an overkill for a virtex4 #### Dave Joined Nov 17, 2003 6,970 The iam of the vending machine project is to use ps2 keyboard to input coin value via interfacing the ps2 with virtex 4. Secondly display out put values on a VGA monitor thus i requre code for keyboard and VGA. The keyboard signal will be basicaly controll signals for example key "A" can signify$1 and VGA will out put change value of 25 cents if the item chosen was 75 cents. Any idea???? Thanks
I assume you mean "you require code for the Virtex 4 FPGA to VGA" not "you require code for keyboard to VGA".

As with all FPGAs there are many possible implementations for interface and it is up to you to make the choice of which one suits your needs. See here for a range of VHDL implementations that you could use (linked from here). You may need to ensure that the on-chip clock on the Virtex 4 is converted to 1MHz for the operation - you can achieve this through a design of counters and flip-flops. This should be fairly straight forward to implement.

You may also be interested in looking at this tutorial from the LULEÅ University of Techonolgy in Sweden. There should be some reasonable information for the interfacing of devices in your system. I assume you have already written the code for processing the transaction?

Also if you have not done so already, familiarise yourself with the official Virtex 4 FPGA documentation over at Xilinx's website.

Dave

#### m75allen

Joined Nov 20, 2006
11
Thanks guys the links were helpfull. I might need more help from you guys. I am designing a vending machine which you can buy five different thing. You can use different combination of money, example $5,$1, 25 cents, 10 cents, and 5 cents. I need to come up with three modules in VHDL, coin module, change module and dispenser module. Any help??? Thanks

#### Dave

Joined Nov 17, 2003
6,970
Do you have a operative decription of what you propose each module to do? From the little information I cannot see why you wouldn't want to integrate the coin and change module into a single entity, I would assume that you could look at designing a state-machine that integrates both coin transactions and change deduction. Can you explain why you need these to be seperate?

Dave

#### Happyone

Joined Mar 7, 2007
1
pay attention that the keyboard gives you a scancode and not ASCII code!
so, after you understand the ps2 keyboard protocol (http://www.computer-engineering.org/ps2protocol/) see http://www.barcodeman.com/altek/mule/scandoc.php there you can find the correlation between the scancode and the key that pressed on the keybaord (pay attention again to the break code that generate while you release a key in the keyborad, use the Keyboard Emulator for more undersanding). now you have a scancode and a letter, make a metch by the ASCII table between scancode and ASCII code. you can use a ROM that the address is the scancode (8 bit) and the data is the ASCII code (also 8 bit). that could be your ps2 interface in the FGPA (you can see sample to the .mif file for the ROM in: http://users.ece.gatech.edu/~hamblen/ALTERA/onedge/gatech/ps2keyboard.html

#### avijitjena

Joined Mar 23, 2007
1
Hi am trying to write a code in VHDL to interface keyboard in a vending machine to be downloaded in a virtex 4 board but i am stuck. Anyone who has an idea how to go about it i will appreciate very much. Thanks
please provide me the VHDL code for keyboard interface to FPGA.