The Instruction Decoder 4 component is a simple 4-bit instruction decoder. It allows you to enter an instruction from a small subset of instructions and configures the outputs appropriately for that instruction.
It is assumed that there are four registers r0-r3 and two buses A and B. The bus output Ae determines what register is enabled to bus A. The bus output Be determines what register is enabled to bus B or if the immediate output is enabled to bus B.
The supported instructions are:
There are five outputs:
The supported instructions are:
| Ins | Usage | Description | C |
|---|---|---|---|
| nop | nop | Does nothing | 111 |
| mov | mov rd, rs | rd ← rs | 000 |
| mov | mov rd, #value | rd ← value | 000 |
| add | add rd, ra, rb | rd ← ra + rb | 001 |
| sub | sub rd, ra, rb | rd ← ra - rb | 010 |
| and | and rd, ra, rb | rd ← ra & rb | 011 |
| or | or rd, ra, rb | rd ← ra | rb | 100 |
| sll | sll rd, ra, rb | rd ← ra << rb (logical) | 101 |
| sla | sla rd, ra, rb | rd ← ra << rb (arithmetic) | 110 |
The nop command has no arguments. The mov command has two arguments and all other commands have three arguments. The third argument (second for a mov) can be a register or immediate value (signed decimal, only).
Suppose you enter this instruction: add r1,r2,r3 The output pins for this instruction are set to:
For this instruction: sub r0,r2,#5, the outputs are set to: