Procedure

  1. Enter the assembly code in the code box provided or copy the example code.
  2. Click 'Generate Trace' to generate the execution trace for the program.
  3. Select the number of history bits you wish to use.
  4. Click on the 'Run Simulation' button to see the predictor's performance.
  5. You can reset the simulation at any time by clicking the 'Reset' button.

Allowed Instructions

  • ADD Rdest, Rsrc1, Rsrc2 — add two registers
  • SUB Rdest, Rsrc1, Rsrc2 — subtract two registers
  • AND Rdest, Rsrc1, Rsrc2 — bitwise AND two registers
  • MOV Rdest, constant — load immediate into a register
  • BEQ R1, R2, label — branch if equal
  • BNE R1, R2, label — branch if not equal

Example 1: For Loop

MOV R0, 0
MOV R1, 5
MOV R2, 3
MOV R3, 1
LOOP:
ADD R0, R0, R3
BEQ R0, R1, END
ADD R2, R2, R3
BNE R1, R0, LOOP
END:
NOP

Trace: B0:N, B1:T, B0:N, B1:T, B0:N, B1:T, B0:N, B1:T, B0:T

Example 2: For Loop with if statement

MOV R0, 0
MOV R1, 0
MOV R2, 10
MOV R3, 1
LOOP:
AND R4, R0, R3
BNE R4, R3, CONT
ADD R1, R1, R3
CONT:
ADD R0, R0, R3
BNE R0, R2, LOOP
END:
NOP

Trace: B0:T, B1:T, B0:N, B1:T, B0:T, B1:T, B0:N, B1:T, B0:T, B1:T, B0:N, B1:T, B0:T, B1:T, B0:N, B1:T, B0:T, B1:T, B0:N, B1:N

Example 3: Multiple Iterations

MOV R0, 0
MOV R1, 5
MOV R2, 3
MOV R3, 1
LOOP:
ADD R0, R0, R3
BEQ R0, R1, END
ADD R2, R2, R3
BNE R1, R0, LOOP
END:
NOP

Trace: B0:N, B1:T, B0:N, B1:T, B0:N, B1:T, B0:N, B1:T, B0:T

Enter Assembly Program

Predictor Configuration

Format: B{id}:{T|N} separated by commas (T=Taken, N=Not Taken)

Simulation Results