An Implementation of DLX

This unpipelined implementation is not the most economical or the highest-performance implementation without pipelining. Instead, it is designed to lead naturally to a pipelined implementation.
Implementing the instruction set requires the introduction of several temporary registers that are not part of the architecture.
Every DLX instruction can be implemented in at most five clock cycles. The five clock cycles are
Instruction fetch cycle (IF)
Instruction decode/register fetch (ID)
Execution/Effective address cycle (EX)
Memory access/branch completion cycle (MEM)
Write-back cycle (WB)

You can see what is done on each cycle using the following applet. Selecting "all cycles" will process the whole instruction from IF to WB cycle ("Cycle" is disabled in this case and has no effect). If it appears like nothing has changed on the picture it means that the cycle is not active for the instruction type.

Detailed description of each follows:
Instruction fetch cycle (IF):

IR       <- MEM[PC]
NPC  <- PC +4
Operation:
- Send out the PC and fetch the instruction from memory into the instruction register (IR)
- increment the PC by 4 to address the next sequential instruction
- the IR is used to hold the instruction that will be needed on subsequent clock cycles
- the NPC is used to hold the next sequential PC (program counter)

Instruction decode/register fetch (ID):

A <- Regs[IR6..10]
B <- Regs[IR11..15]
Imm <- ((IR16)16##IR16..31)
Operation:
- Decode the instruction and access the register file to read the registers.
- the output of the general-purpose registers are read into two temporary registers (A and B) for use in later clock cycles.
- the lower 16 bits of the IR are also sign-extended and stored into the temporary register IMM, for use in the next cycle.
- decoding is done in parallel with reading registers, which is possible because these fields are at a fixed location in the DLX instruction format. This technique is known as fixed-field decoding.

Execution/Effective address cycle (EX):
The ALU operates on the operand prepared in the prior cycle, performing one of four functions depending on the DLX instruction type

Memory reference:
ALUOutput <- A +Imm
Operation: The ALU adds the operands to form the effective address and places the result into the register ALUOutput
Register-Register ALU instruction:
ALUOutput <- A op B
Operation: The ALU performs the operation specified by the opcode on the value in register A and on the value in register B. The result is placed in   the register ALUOutput.
Register- Immediate ALU instruction:
ALUOutput <- A op Imm
Operation: The ALU performs the operation specified by the opcode on the value in register A and on the value in register Imm. The result is placed in   the register ALUOutput.
Branch:
ALUOutput <- NPC + Imm
Cond <- ( A op 0 )
Operation:
-The ALU adds the NPC to the sign-extended immediate value in Imm to compute the address of the branch target.
-Register A, which has been read in the prior cycle, is checked to determine whether the branch is taken.
- the comparison operation op is the relational operator determined by the branch opcode (e.g. op is "==" for the instruction BEQZ)
Memory access/branch completion cycle (MEM):
The only DLX instructions active in this cycle are loads, stores, and branches.
Memory reference:
LMD <- Mem[ALUOutput]                or               Mem[ALUOutput] <- B
Operation:
-Access memory if needed
- If the instruction is load , data returns from memory and is placed in the LMD (load memory data) register
- If the instruction is store, data from the B register is written into memory.
- In either case the address used is the one computed during the prior cycle and stored in the register ALUOutput
Branch:
if (cond) PC <- ALUOutput
else PC <- NPC
Operation:
- If the instruction branches, the PC is replaced with branch destination address in the register ALUOutput
- Otherwise, PC is replaced with the incremented PC in the register NPC
Write-back cycle (WB):
Register-Register ALU instruction:
Regs[IR16..20] <- ALUOutput
Register-Immediate ALU instruction:
Regs[IR11..15] <- ALUOutput
Load instruction:
Regs[IR11..15] <- LMD
Operation:
- Write the result into the register file, whether it comes from the memory(LMD) or from ALU (ALUOutput)
- the register destination field is in one of two positions depending on the opcode