Simplest possible I/O for Homebrew 8-bit CPU

The "simplest possible I/O" depends on what your I/O requirements are. It would be very simple, if you're in control of the CPU design, to implement a couple of special instructions to input and output a few bits of parallel I/O.

But since you mention keyboard and video, it seems that your requirement is to be able to interact with your system that way - and the dead simplest way to do that is to incorporate a fixed baud-rate serial port, and use a PC & terminal program to supply the keyboard and video. Using 9600 bps is fine for human console purposes, or if you expect to transfer binary, 115200 could handle 64K bytes in around 6 seconds.

An off-the-shelf UART chip like the 6850 or 8250 (well, out of the junk-box anyway) will need only 2 to 8 registers for a complete stdin/stdout solution. This is a tiny footprint compared to trying to implement a keyboard and video interface directly. You can probably drive a keyboard matrix with just a single 8-bit output port and a single 8-bit input port, but video will need 2K addresses just to supply the frame buffer for an 80x25 character display. If you consider so-called LSI solutions like the 8250 to be cheating, I would counter that constructing a UART from 74xx would probably be easier than constructing a video generator from the same technology.

That said, the down-side of the UART is that you are likely to lose input unless you either (a) poll it frequently enough, or (b) implement interrupts. For a simple proof-of-concept for your CPU, just polling should suffice - unless you're also trying to prove out interrupt capabilities of your CPU (if/when it has them), in which case, keeping up with serial input by using UART interrupts would be a fine test case.


Apart from standard parallel I/O ports you'll definitely want serial I/O, like U(S)ART, as well. We'll need it in a minute.

Input
For the input I would build an interface for a common PC keyboard (the so called PS/2). This uses a synchronous serial protocol; that's what you'll need the serial interface for. That means SIPO (Serial In/Parallel Out) and PISO (Parallel In/Serial Out). A synchronous protocol like the PS/2 keyboard's has the advantage that there's also a clock signal, which makes the conversion easier than for instance a UART. (You'll soon want a UART too)

Display
Most of the TRS-80 home computer was, apart from CPU (Z80) and memory, built with TTL ICs, including the 16 lines x 64 characters video, so the schematics may help you to get started.
But this may already be a big step, and I would start with something simpler, so that you can focus on the CPU, which most likely will need some debugging before it works properly. And it would be nice to have something of a display for that. (You don't want to debug the CPU and the video logic at the same time. Take one step at a time.)
I would suggest to use a common 4x20 character LCD (bigger is OK too). This is easy to interface and can display already a lot of (debug) information.
Another option is that you create a UART interface. It's standard on most microcontrollers and you'll need it sooner or later anyway. The UART will allow you to connect to a PC, and with a simple protocol you can use the PC's display to show a virtual display of your own computer in a window.

Interrupts
Mike comments that interrupts aren't that hard to implement, but I think it's a good idea to leave them out for the moment. They do add a level of complexity, and a risk of instability (more on a software than a hardware level); safety-critical microprocessors usually don't have interrupts. I recall the old Viper, which was used in fighter planes.
To make sure you don't lose incoming data you'll have to buffer it. The usual solution is a FIFO. This one is a building block from the 74HC series, so you can simply use that, or you can roll your own. (I don't know what your make or buy criteria are.)


Further reading
TRS-80 Technical Manual

Tags:

Cpu

Input

Output