Microcoding and Testing the Add Instruction

Microcode for the Add instruction

Here's the microcode for the short-word version of the Add instruction.
# OPCODE L STAT : FETCH MASEL SHS EOI RFA1 WRF1 XSEL YSEL CMX AND CY1 CYP
# A - Add
11100 0 0001 : 0 1 0 1 110 1 01 10 0 0 0 0
MASEL = 1 selects the address field of the instruction as the main memory address. RFA1 = 011 (remember the data bits are backwards inb the microcode source) selects the most significant short word of the accumulator. XSEL = 10 and YSEL = 01 route data read from main memory and register file 1 to the ALU, which is set up for addition with carry in = 0. WRF1 = 1 writes the output from the ALU into register file 1. EOI = 1 indicates that this is the last microinstruction for this instruction.

Test Loader

I wrote a Python program to generate memory images for loading into Logisim. It accepts a subset of the EDSAC Initial Orders 2 input format, with a few extensions.

Here's an example for testing the Add instruction.
0: A 2 F
1: A 3 F
2: 123
3: 456
The numbers on the left are memory addresses, in decimal. Lines starting with a letter represent instructions, and consist of an opcode, a memory address, and a length indicator (F for short word, D for long word). A line can also contain a number to be stored in memory, written in decimal, hex (prefixed by $) or binary (prefixed by %).

Assuming the accumulator starts out containing zero, if the test is successful it should end with the accumulator containing 579 decimal (10 0100 0011).

Add Test Video

Here's a video of the Add test running in Logisim. Note that the numbers appear LSB first in Logisim's memory display windows.