Due: 5:00pm, Friday, October 21. Value: 50 pts. Submit to Sauron.
Using Logisim, design a circuit implementing the MINIAC
computer described below.
You may use any built-in Logisim components in completing this
assignment.
The following table lists useful files for your work;
to download them, you may need to right-click the link and select Save
Link As…
.
| circuit-miniac.circ: | Logisim starter circuit including clock, registers, ROM, and RAM. |
| miniac.py: | Python script for assembling and executing MINIAC assembly language files. Documentation is at top of the Python file. |
| miniac-halve.s: | MINIAC assembly language for halving a number. |
| miniac-mult.s: | MINIAC assembly language for multiplying two numbers. |
The MINIAC instruction set was designed for the purpose of this assignment. It uses two one-byte registers, known as PC (program counter) and AC (accumulator). It includes a program memory containing 256 bytes implemented as read-only memory (ROM), and it has a data memory containing 32 bytes implemented as random-access memory (RAM).
Every MINIAC instruction is encoded in one byte: The top three bits give the operation to be performed, and the bottom five bits are an argument supporting the operation. Each of the three-bit combinations are tabulated below.
| 000xxxxx | BZ x | Branch if Zero | |
| if AC = 0 then PC ← PC + signed(x) else PC ← PC + 1 | |||
| 001xxxxx | BN x | Branch if Negative | |
| if AC < 0 then PC ← PC + signed(x) else PC ← PC + 1 | |||
| 010xxxxx | ST x | STore | |
| RAM[x] ← AC; PC ← PC + 1 | |||
| 011xxxxx | RL x | Rotate Left | |
| AC ← AC rotated left by distance given in lower 3 bits of x; PC ← PC + 1 | |||
| 100xxxxx | LI x | Load Immediate | |
| AC ← signed(x); PC ← PC + 1 | |||
| 101xxxxx | LM x | Load from Memory | |
| AC ← RAM[x]; PC ← PC + 1 | |||
| 110xxxxx | AD x | ADd | |
| AC ← AC + RAM[x]; PC ← PC + 1 | |||
| 111xxxxx | SB x | SuBtract | |
| AC ← AC − RAM[x]; PC ← PC + 1 | |||
Here is an example program fragment that takes a value n from RAM[1] and places n / 2 into RAM[0]. This is essentially the code found in the miniac-halve.s file.
hex binary assembly comment 0xA1 101 00001 LM 1 # Load number to be halved, 0x67 011 00111 RL 7 # rotate it right once, 0x40 010 00000 ST 0 # and store result. 0x23 001 00011 BN 3 # Go to (b) if top bit is 1 (1's bit before rotation) 0x80 100 00000 LI 0 # Stop computer. 0x00 000 00000 BZ 0 0x81 100 00001 LI 1 # (b): Set AC to 0x80. 0x67 011 00111 RL 7 0xC0 110 00000 AD 0 # Add 0x80 to result to clear top bit. 0x40 010 00000 ST 0 0x80 100 00000 LI 0 # Stop computer. 0x00 000 00000 BZ 0
To test your circuit, you will want to load a program into
the MINIAC's ROM memory.
I suggest using the provided Python script for this.
The script has two options: The -s
option
produces hexadecimal output corresponding to the machine code, and the
-v
option traces what happens as a MINIAC computer
executes the machine code. The hexadecimal output of the
-s
option is in a format that Logisim accepts
for its ROM circuits.
You'll want to save the Python script's hexadecimal output into a file. You can do this using output redirection.
linux% python miniac.py -s assem-filename.s > machine-filename.hex
Once you save into the file, go your circuit in
Logisim, right-click (or control-click) the ROM, select Load
Image…, and select the name of the file containing the
hexadecimal code (machine-filename.hex in the
above command). You will then want to start the clock ticking,
either manually by clicking the clock component repeatedly or by
selecting Enable Ticks
from the Simulate menu.