Friday, February 28, 2014

Modifying the SAP-1 Control Matrix

Extending the instruction set and capabilities of the SAP-1 using the original control matrix design allows you to avoid having to purchase an EEPROM/Flash programmer.  However adding more than a few new opcodes can quickly become very complicated.  As an example, the accumulator will be modified to support left and right shifting of the data.  This modification was described in the post SAP-1 with Shift Register and Microcoded ROM.  The design of the accumulator here is identical.

Two new instructions need to be added: SL (opcode 3h) for Shift Left and SR (opcode 4h) for Shift Right.  To execute these the control word needs to be modified.  The /La control signal is replaced with two signals, Asl and Asr, which connect to the mode select inputs of the shift registers.

To support the new instructions, two extra decoding gates have to be added to the instruction register.  Recall that the purpose of the instruction decoder is to convert the 4-bit opcode in to a single active signal.

For example, when the instruction register is loaded with ADD (opcode 0h) then only the LDA line is active, ADD, SUB, OUT, SL, SR and /HLT will be inactive.  To further simplify the circuit, this part of the controller sequencer can be replaced with a 3-bit to 1-of-8 line decoder such as the 74HC238.

The ring counter circuit remains unchanged.  Again, its output is such that only 1 of the 6 lines is active during a clock cycle.

Together these two groups of signals drive the control matrix, which outputs the control word: the collection of signals which activate the individual components of the computer.  A series of control words (micro-instructions) execute the function represented by the opcode.

Next, much like with the microcode ROM design, the microcode for each instruction is mapped out.  Once this is done the logical equation that describes each bit of the control word can be derived. 

Note: the Excel spreadsheet is found in the file linked at the end of this post.

From this table, a logic equation can be written for each control signal.  From this the configuration of the control matrix will be derived.  For example: Asl = (T4 & SL) + (T5 & LDA) + (T6 & ADD) + (T6 & SUB).  [Note: & is boolean AND, + is boolean OR]. Asl is active during T4 when the opcode is SL or during T5 when the opcode is LDA or during T6 when the opcode is ADD or during T6 when the opcode is SUB.  Check the spreadsheet for a breakdown of all the control signal decoding.

Some patterns should start to reveal themselves.  The T1, T2 and T3 states are always the same because they are part of the Fetch cycle.  Ep and /Lm are always active during T1, Cp is always active during T2 and /CE and /Li are always active during T3.

Now map out the equation in to the actual logic gates.  The original SAP-1 design mostly uses NAND gates in the control matrix.  Replacing the lower NAND with its DeMorgan equivalent reveals the true logic.  This circuit could be replaced with an equivalent configuration of AND and OR gates (or AND and NOR gates for active low output).

Each bit of the control word will need a similar set of gates.  A program such as Logic Friday can assist with converting the equations to logic gates. Here is another configuration of the Asl control line:

As another example, here is the /Lm control signal:

Link to a RAR file containing the schematic and full description of the control matrix.

No comments:

Post a Comment