Input Instruction
Output Hardware Modification
I made a small change to the output interface. I realised it was
probably a bad idea to connect the OBSY signal from the output device
directly to the ubranch multiplexer, because glitches could occur if it
changes near a clock edge, so I added a flip-flop to synchronise it
with the bit clock.
Input Hardware
The Input instruction reads a character from an input device
(originally a paper tape reader) and stores it in the lower 5 bits of a
memory location. To support this, I designed the following input
interface. It consists of a 5-bit parallel-in serial-out shift
register, and some logic to manage a pair of handshaking signals. INPUT
RDY is asserted by the input device when there is data present, and
INPUT ACK is pulsed by the CPU once the data has been accepted. The
device is then expected to remove INPUT RDY and start reading the next
character.
Reading the input data is a two-step process: first the data is loaded
into the input register in parallel, then it is shifted out serially
and written to memory. Rather than use up two MISC values for this, I
allocated one MISC value called INPT and used WMEM to distinguish
between loading and shifting. This effectively gives me two control
signals for the price of one.
The INPUT RDY signal is synchronised with RUNCLK to produce IRDY, which
is connected to an input of the microcode branch multiplexer. The
serial output from the input register is connected to an input of the X
multiplexer.
For testing purposes, I connected INPUT RDY to a flip-flop that emulates the handshaking action of an input device.
Other changes to the main circuit:
Input Microcode
INPT = 011 # Load/shift input register depending on WMEM
BIBSY = 011 # Input data not available
# I - Input
01000 0 0001 : - - -- --- - -- -- -- - - - - - - - --- - BIBSY 1000 # Loop until input data available
01000 0 0010 : - - -- --- - -- -- -- - - - - - - - INPT - --- ---- # Load data into input register
01000 0 0011 : - EOI -- XIN - -- -- -- - - - - - - WMEM INPT - --- ---- # Write input register to memory