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:

InsUsageDescriptionC
nopnopDoes nothing111
movmov rd, rsrd ← rs000
movmov rd, #value rd ← value000
addadd rd, ra, rbrd ← ra + rb001
subsub rd, ra, rbrd ← ra - rb010
andand rd, ra, rbrd ← ra & rb011
oror rd, ra, rbrd ← ra | rb100
sllsll rd, ra, rbrd ← ra << rb (logical)101
slasla rd, ra, rbrd ← 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: