It works.
Blasphemy alert: I've tested this on my i8088-based SBC.
Attachment:
File comment: BAT frame (0xAA) and 'A' make/break codes (0x1C, 0xF0+0x1C)
ps2working.jpg [ 171.37 KiB | Viewed 16205 times ]
Note 1. I've changed the pinout a bit:
Code:
GAL22V10
-------\___/-------
PS2 CLK | 1 24 | VCC
| |
PS2 DATA | 2 23 | IRQ
| |
A0 | 3 22 |
| |
/RD | 4 21 | /D0
| |
| 5 20 | /D1
| |
| 6 19 | /D2
| |
| 7 18 | /D3
| |
| 8 17 | /D4
| |
| 9 16 | /D5
| |
| 10 15 | /D6
| |
| 11 14 | /D7
| |
GND | 12 13 | /CS
-------------------
Note 2. I've inverted IRQ, since x86 interrupt lines are active-high (I've been bit by that more times that I'm willing to admit.) You have to change IRQ to /IRQ in line 4 if you're using this in a system with
proper active-low IRQ line, such as 6502.
Note 3. I eliminated the /RESET signal, so the registers needs to be reset by CPU by writing/reading A0=1. The reason is that we cannot have OR terms in asynchronous reset definition, so we cannot do `RESET + CS * A0`. I decided to drop /RESET whatsoever so that we can reset the controller ourselves.
Code:
GAL22V10
PS2
CLK DATA A0 /RD NC NC NC NC NC NC NC GND
/CS /Q7 /Q6 /Q5 /Q4 /Q3 /Q2 /Q1 /Q0 /START IRQ VCC
AR = CS * A0 ; Reset by accessing the chip with A0 = 1
SP = GND
/Q7.R = /DATA * START + /Q7 * /START
/Q6.R = /Q7 * START + /Q6 * /START
/Q5.R = /Q6 * START + /Q5 * /START
/Q4.R = /Q5 * START + /Q4 * /START
/Q3.R = /Q4 * START + /Q3 * /START
/Q2.R = /Q3 * START + /Q2 * /START
/Q1.R = /Q2 * START + /Q1 * /START
/Q0.R = /Q1 * START + /Q0 * /START
/Q0.E = CS * RD
/Q1.E = CS * RD
/Q2.E = CS * RD
/Q3.E = CS * RD
/Q4.E = CS * RD
/Q5.E = CS * RD
/Q6.E = CS * RD
/Q7.E = CS * RD
/START.R = /Q0
IRQ.R = /START
DESCRIPTION
Keyboard IC by Gregor
Converted from WinCUPL to GALasm by Andrew Dunai
Original thread: http://forum.6502.org/viewtopic.php?f=10&t=7833
GAL is initialized by reading/writing anything with A0=1:
Code:
init_kb:
out KB_PORT+1, al
Reading & resetting:
Code:
read_kb:
in al, KB_PORT ; read byte
xor al, 0xFF ; flip since it's inverted due to galasm bug
out KB_PORT, al ; reset buffer
_________________
/Andrew
deck65 - 6502 slab with screen and keyboard |
ПК-88 - SBC based on KM1810VM88 (Ukrainian i8088 clone) |
leo80 - simple Z80 SBC
nice65 - 6502 assembly linter |
My parts, footprints & 3D models for KiCad/FreeCAD