UCCE2053 Computer Organisation and Architecture Assignment Sample 2026

UCCE2053 Assignment Sample

Assignment Type : Practical Assignment
Pipeline Processor Design: Specification Development

1. Architecture Specification: Written Spec

1.1 Functionality / Feature

  • 32-bit MIPS ISA-compatible CPU processor.
  • System Verilog-based design.
  • Supports a 5-stage pipeline:
    o Instruction Fetch (IF)
    o Instruction Decode and Operand Fetch (ID)
    o Instruction Execute (EX)
    o Memory Access (MEM)
    o Register Write Back (WB)
  • Contains 32 general-purpose registers.
  • Supports Program Counter (PC) for instruction sequencing.
  • Supports instruction and data memory interfaces.
  • Supports Memory Read / Write Operations: lw, sw, lb, and sb.
  • Performs Arithmetic, Logical, Comparison and Address-Generation Operations.
  • Supports Branch Instructions: beq, and bne.
  • Supports Jump Instructions: j, and jal.
  • Supports the selected Group 3 instructions: l_inc and R-format lw variant.  Supports Pipeline Hazard Management.

1.2 Operating Procedure and Application

1.2.1 Programming Mode

  • MIPS assembly code is converted into machine code before execution.  The verification process follows the general flow:
  • Machine code is then stored in a file and loaded into instruction memory.

1.2.2 Normal Execution Mode

  1. The PC provides the instruction address.
  2. The instruction is fetched from instruction memory.
  3. The instruction is decoded and source operands are obtained.
  4. The ALU performs arithmetic, logical, comparison, shift, or address-generation operations.
  5. Memory access is performed when required.
  6. The selected result is written back to the register file.

1.3 Naming Convention

Item Naming Convention
General Naming
Program Counter PC
Next Program Counter PC_next
Instruction instruction
Register Source 1 rs
Register Source 2 rt
Destination Register rd
Immediate Value immediate
ALU Result alu_result
Memory Address data_addr
Memory Read Data data_rdata
Memory Write Data data_wdata
Register Write-Back Data write_back_data
Pipeline Register
IF/ID Register IF_ID
ID/EX Register ID_EX
EX/MEM Register EX_MEM
MEM/WB Register MEM_WB
Group 3 Signal
Incremented rs value rs_inc_value
RS increment rs value rs_inc_dest
RS write_enable flag reg_write_rs
Load with increment instruction flag is_l_inc
Register load word instruction flag is_r_lw

1.4 Pipeline Chip Interface and I/O Pin Description

1.4.1 Pipeline Chip Interface 

1.4.2 I/O Pin Description

Functional Group Signal Direction Width Description
System Control clk Input 1-bit System clock.
rst Input 1-bit Resets the processor and pipeline state.
Programming Mode Interface prog_en Input 1-bit Programming mode enable.
prog_addr Input 32-bit External programming address.
prog_data Input 32-bit External programming data.
prog_we Input 1-bit External programming write enable.
Instruction Memory Bus instr_addr Output 32-bit Instruction memory address.
instr_data Input 32-bit Instruction memory data.
Data Memory

Bus

data_addr Output 32-bit Data memory address.
data_wdata Output 32-bit Data memory write data.
data_rdata Input 32-bit Data memory read data.
data_we Output 1-bit Data memory write enable.
data_re Output 1-bit Data memory read enable.
Peripheral I/O io_in Input 32-bit Peripheral input data.
io_out Output 32-bit Peripheral output data.
Debug         and

Tracing

pc_out Output 32-bit Debug program counter.
halt Output 1-bit Processor halt status.

1.4.3 Timing Diagram  

1. Programming Mode Timing (prog_en = 1)
Setup Requirement: prog_addr and prog_data must be driven valid before the rising edge of clk.
Latch Timing: prog_we pulses high for one clock cycle to latch prog_data into Instruction Memory at address prog_addr.

2. Normal Execution Mode Timing (prog_en = 0)

Reset Sequence: On rst falling edge at T0, PC clears to 0x0000_0000 and outputs pc_out.

  • Instruction Fetch (IF): instr_addr matches pc_out. Instruction Memory returns instr_data within the same clock cycle.
  • Memory Read (MEM): During load instructions (lw) at T4, data_re asserts high, placing memory contents onto data_rdata.

1.5 Internal Operation

1.5.1 Instruction Fetch (IF)

  • Inputs and Control Signals: PC (Program Counter), clk, rst, PC Control/Stall flags.
  • Stage Operations: o Memory Fetch: Drives instr_addr with PC [31:0] to retrieve the 32-bit instruction word (instr_data) from Instruction Memory. o Next PC Calculation: Computes PC + 4 as the normal sequential instruction address (or selects branch/jump target addresses when branch control flags are asserted).
  • Output Pipeline Register (IF_ID): Latches instr_data and computed PC + 4 on the rising clock edge.

1.5.2 Instruction Decode and Operand Fetch (ID)

  • Input Pipeline Register: Incoming data from IF_ID (instr_data, PC + 4), Register File data outputs, Hazard/Stall control flags.
  • Stage Operations:
    • Instruction Decoding: Decodes opcode, funct, and register fields (rs, rt, rd).
    • Register File Read: Reads source operands (R[rs] and R[rt]) from the register file.
    • Immediate Extension and Control: Performs sign/zero extension on the 16-bit immediate field and generates execution, memory, hazard, and write_back control signals.
  • Output Pipeline Register: Latches control signals, read data (rs_data, rt_data), signextended immediate, target register indices, and PC + 4 into ID_EX.

 1.5.3 Instruction Execute (EX)

  • Inputs and Control Signals: Incoming data from ID_EX, hazard forwarding paths (forwardA, forwardB).
  • Stage Operations: o Standard Operations: Performs ALU arithmetic, logical, shift, and comparison operations using forwarding multiplexers. Calculates branch targets and standard base + offset memory addresses.
    • Group 3 l_inc Extension: Calculates effective memory address while simultaneously evaluating secondary base increment value R[rs] + 4.
      Address = R[rs] + SignExt(imm)
      R[rt]      = Memory[Address] R[rs]      = R[rs] + 4
    • Group 3 R-format lw Variant Extension: Calculate the effective memory address by using two register operands via the ALU.
      Address = R[rs] + R[rt]
      R[rd]     = Memory[Address]
  • Output Pipeline Register (EX_MEM): Latches ALU results, store data (R[rt]), secondary increment values (l_inc), target register indices, and memory/WB control signals into EX_MEM.

1.5.4 Memory Access (MEM)

  • Inputs and Pipeline Register: Incoming data from EX_MEM, memory read bus (data_rdata).
  • Stage Operations:
    o Memory Address and Control: Drives data_addr using the ALU execution result. Asserts data_re for load indtructions or data_we for store instructions.
    o Data Transfer: Passes store data (data_wdata) from the forwarded register value into Data Memory during stores and captures incoming read data (data_rdata) during loads.
  • Output Pipeline Register (MEM_WB): Latches data_rdata, ALU execution outputs, secondary increment values (l_inc), target register indices, and write-back control signals into MEM_WB.

1.5.5 Register Write Back (WB)

  • Inputs and Pipeline Register: Incoming data from MEM_WB, clk, rst.
  • Stage Operations: o Result Selection: Multiplexes the final write-back value from either the ALU execution result or memory read data (data_rdata).
    • Standard Write-Back: Writes the selected result to the destination register (rd or rt) on the falling clock edge.
    • Group 3 Dual Write-Back (l_inc): Updates destination register rt with loaded memory data while simultaneously updating base register rs with the secondary incremented value (R[rs] + 4).
  • State Update: Updates the Register File contents for subsequent instruction cycles.

1.6 Memory Map

Memory Region Access Address Range Function
Start  Address End Address
Text Segment Instruction Fetch/Read 0x0000_0040 0x0000_0FFF Stores application program instructions.
Data Segment Read/Write 0x0000_1000 0x0000_1FFF Stores program data accessed by load/store instructions.
Boot Rom Read 0x0000_0000 0x0000_003C Stores boot/reset program           and             initial instructions to provide the processor reset/start address.
Other/Reserved Reserved 0x0000_2000 TBD/ remaining Reserved for future expansion, memory-

mapped peripherals, or unused address space.

 Byte-to-Word Address Mapping Note

The Boot ROM occupies byte address range 0x0000_0000 through 0x0000_003C (64 bytes total) because the internal array structure stores 32-bit words, simulation initialization loaded via $readmemh targets word indices 0 through 15. The address conversion follows:

Word_Index = [Byte_Address / 4]

1.7 System Registers

The CPU contains the following main architectural registers.

Register Name Register Width/Number Description
Program

Counter (PC)

32-bit Stores the address of the current instruction.
IF_ID Implementation dependent Stores instruction       and      fetch-stage information.
ID_EX Implementation dependent Stores decoded operands, immediate values, register fields, and control signals.
EX_MEM Implementation dependent Stores ALU results, memory information, destination register, and control signals.
MEM_WB Implementation dependent Stores memory           data,    ALU             result, destination        register,             and      write-back control.
General-Purpose Registers 32 * 32-bit Stores operand and execution results.
General Purpose Registers
Register Name Register Width/Number Alternate Name Description
$zero 0 Constant Zero Always read as 0

(R[0] = 0).

$at 1 Assembler Temporary Reserved         for assembler use.
$v0-$v1 2-3 Value Function result/return value.
$a0-$a3 4-7 Argument Function argument.
$t0-$t7 8-15 Temporary Temporary register.
$s0-$s7 16-23 Saved Saved register.
$t8-$t9 24-25 Temporary Temporary register.
$k0-$k1 26-27 Kernel Reserved/system use.
$gp 28 Global Pointer Global data pointer.
$sp 29 Stack Pointer Stack pointer.
$fp 30 Frame pointer Frame pointer.
$ra 31 Return Address Stores return address for jal.

 Special Register Behaviour  $zero is hardwired to 32’b0.

  • Any attempt to write to $zero does not change its value.
  • $ra is automatically selected as the destination register for the jal instruction.
  • The remaining registers can be used as source or destination registers according to the supported instruction format.

1.8 Supported Instruction Description

Instruction Format Opcode Funct [5:0] Operation Addressing Mode
add $rd, $rs,

$rt

R 0x00 0x20 R[rd] <- R[rs] + R[rt] Register Direct
addi $rt, $rs, imm I 0x08 N/A R[rt]        <-      R[rs]       +

SignExt(imm)

Immediate
addu $rd, $rs,

$rt

R 0x00 0x21 R[rd] <- R[rs] + R[rt] Register Direct
addiu $rt, $rs, imm I 0x09 N/A R[rt]        <-      R[rs]       +

SignExt(imm)

Immediate
sub $rd, $rs,

$rt

R 0x00 0x22 R[rd] <- R[rs] – R[rt] Register Direct
and $rd, $rs,

$rt

R 0x00 0x24 R[rd] <- R[rs] AND

R[rt]

Register Direct
andi $rt, $rs, imm I 0x0c N/A R[rt] <- R[rs] AND

ZeroExt(imm)

Immediate
or $rd, $rs, $rt R 0x00 0x25 R[rd] <- R[rs] OR R[rt] Register Direct
ori      $rt,           $rs, imm I 0x0D N/A R[rt]       <-     R[rs]      OR

ZeroExt(imm)

Immediate
nor $rd, $rs,

$rt

R 0x00 0x27 R[rd] <- NOT(R[rs] OR

R[rt])

Register Direct
xor $rd, $rs,

$rt

R 0x00 0x26 R[rd] <- R[rs] XOR

R[rt]

Register Direct
lui $rt, imm I 0x0F N/A R[rt] <- {imm, 16’b0} Immediate
sll       $rd, shamt $rt, R 0x00 0x00 R[rd] <- R[rt] << shamt Register

Direct /

Immediate

Shift

srl      $rd, shamt $rt, R 0x00 0x02 R[rd] <- R[rt] >> shamt Register

Direct /

Immediate

Shift

sra      $rd, shamt $rt, R 0x00 0x03 R[rd] <-         R[rt]           >>> shamt Register

Direct /

Immediate

Shift

lw                  $rt,

offset($rs)

I 0x23 N/A R[rt] <- Mem[R[rs] + SignExt(imm)] Base

Addressing

sw                  $rt,

offset($rs)

I 0x2B N/A Mem[R[rs]                       +

SignExt(imm)] <- R[rt]

Base

Addressing

lb                   $rt,

offset($rs)

I 0x20 N/A R[rt]                                <-

SignExt(Mem[R[rs] + SignExt(imm)][7:0])

Base

Addressing

sb                   $rt,

offset($rs)

I 0x28 N/A Mem[R[rs]                       +

SignExt(imm)][7:0] <- R[rt][7:0]

Base

Addressing

beq $rs, $rt,

offset

I 0x04 N/A PC      <-    PC    +    4     +

(SignExt(imm) << 2) if

R[rs] == R[rt]

PC-relative
bne $rs, $rt,

offset

I 0x05 N/A PC      <-    PC    +    4     +

(SignExt(imm) << 2) if

R[rs] != R[rt]

PC-relative
j target J 0x02 N/A PC <- {(PC + 4)[31:28], target, 2’b00} Pseudo-direct
jal target J 0x03 N/A $ra <- PC+4; PC <-

{(PC + 4)[31:28], target,

2’b00}

Pseudo-direct
Jr $rs R 0x00 0x08 PC <- R[rs] Register Direct
slt $rd, $rs, $rt R 0x00 0x2A R[rd]       <-      (R[rs]      <

R[rt]) ? 1 : 0

Register Direct
slti       $rt,             $rs, imm I 0x0a N/A R[rt]        <-      (R[rs]       <

SignExt(imm)) ? 1 : 0

Immediate
l_inc              $rt,

offset($rs)

I 0x2C N/A R[rt] <- Mem[R[rs] + SignExt(imm)]; R[rs] <- R[rs] + 4 Base + AutoIncrement
lw $rt, $rd($rs) R 0x00 0x30 R[rt] <- Mem[R[rs] +

R[rd]]

Register Indexed
multu rs, rt R 0x00 0x19 {HI, LO} <- GPR[rs] *

GPR[rt]

Register Direct
mfhi rd R 0x00 0x10 GPR[rd] <- HI Register Direct
mflo rd R 0x00 0x12 GPR[rd] <- LO Register Direct

 1.9 Addressing Mode

Addressing Mode Target Usage Explanation
Register Direct R-format ALU instructions

(add, sub, and, etc.)

Operands fetched directly from register file (R[rs], R[rt]).
Immediate I-type     ALU       instructions

(addi, andi, ori, etc.)

Operand supplied directly by immediate field (SignExt(imm) or ZeroExt(imm)).
Base + Offset Load/Store instructions (lw, sw, lb, sb, l_inc) EA = R[rs] + SignExt(imm) and l_inc appends side effect R[rs] <- R[rs] + 4.
Register Indexed Group 3 R-format lw variant EA = R[rs] + R[rd].
PC-Relative Conditional branches (beq, bne) Target = PC + 4 + (SignExt(imm) << 2).
Pseudo-Direct Unconditional jumps (j, jal) Target = {(PC + 4) [31:28], target [25:0], 2’b00}.

 2. Micro-Architecture Specification

2.1 Design Hierarchy

1. Top Level

mips_cpu_top Connects all pipeline stages, hazard control, and memory interfaces.
Receives clk, rst, instr_data [31:0], data_rdata [31:0], and io_in [31:0].
Outputs instr_addr [31:0], data_addr [31:0], data_wdata [31:0], data_we, data_re, io_out [31:0], pc_out [31:0], and halt.
  1. Block Level
if_stage Fetches instructions from memory.
Holds and updates Program Counter (pc_reg).
Calculates sequential next address (pc_adder: PC + 4).
id_stage Decodes instructions and extracts bitfields (rs, rt, rd, imm).
Performs sign/zero extension (sign_extend).
Generates control signals and Group 3 flags (is_l_inc, is_l_lw, reg_write_rs).
ex_stage Performs arithmetic, logic, and shift operations (alu).
Computes Group 3 auto-incremented addition (rs_inc_adder: R[rs] + 4).
Calculates branch target addresses.
mem_stage Control data memory read/write requests (mem_interface).
Handles byte sign extension and alignment (byte_aligner).
Drives peripheral output signals (io_out).
wb_stage Selects final write-back source data for target registers (wb_muxes).
Routes dual write-back payloads to the register file.
reg_file Contains 32 * 32-bit architectural registers.
Provides dual read ports and dual write ports (Port 1 for standard result, Port 2 for rs_inc_value).
pipe_regs Registers intermediate state across stage boundaries (IF_ID,

ID_EX, EX_MEM, MEM_WB).

Propagates Group 3 payload signals (rs_inc_value, rs_inc_dest, reg_write_rs).
hazard_control Decodes main control matrix (control_unit).
Detects data hazards and controls forwarding multiplexers (forward_unit).
Resolves load-use hazards and issues pipeline stalls or flushes (hazard_unit)

2.2 Pre-Synthesis Unit Level Schematic

3. Architecture Specification: Verification Spec

1 Test Programmes and Binaries

3.1.1 Individual Instruction Test Program

Test ID Instruction Test

Description

Test Program Expected Output Status
Arithmetic Tests
T01 add Add             two

positive values

addi $t0, $zero,

5

addi $t1, $zero,

10

add $t2, $t0, $t1

$t2 = 15
T02 add Positive             and negative operands addi $t0, $zero, –

1

addi $t1, $zero,

1

add $t2, $t0, $t1

$t2 = 0
T03 addi Add immediate value addi $t0, $zero, 15 $t0 = 15
T04 addu Unsigned addition addiu $t0, $zero,

10

addiu $t1, $zero,

20

addu $t2, $t0,

$t1

$t2 = 30
T05 addiu Unsigned immediate addiu $t0, $zero, 25 $t0 = 25
T06 sub Subtract             two operands addi $t0, $zero,

0

addi $t1, $zero,

1

sub $t2, $t0, $t1

$t2 = -1
Logical Tests
T07 and Bitwise logical

AND

addi $t0, $zero,

0x0F

addi $t1, $zero,

0x33

and $t2, $t0, $t1

$t2 = 0x03
T08 or Bitwise logical

OR

addi $t0, $zero,

0x0F

addi $t1, $zero,

0x30

or $t2, $t0, $t1

$t2 = 0x3F
T09 nor Bitwise logical

NOR

addi $t0, $zero,

0x00

addi $t1, $zero,

0x00

nor $t2, $t0, $t1

$t2 = 0xFFFF_FFFF
T10 xor Bitwise logical addi $t0, $zero, $t2 = 0xAA
XOR 0x55

addi $t1, $zero,

0xFF

xor $t2, $t0, $t1

T11 andi Immediate bitwise AND addi $t0, $zero, 0xFFFF andi $t2, $t0, 0x00FF $t2 = 0x00FF
T12 ori Immediate bitwise OR addi $t0, $zero,

0x1000 ori             $t2,             $t0, 0x000F

$t2 = 0x100F
T13 lui    Load       upper

immediate

lui $t0, 0x1234 $t0 = 0x1234_0000
Shift Tests
T14 sll   Logical       left

shift

andi $t0, $zero,

4

sll $t1, $t0, 2

$t1 = 16
T15 srl   Logical     right

shift

addi $t0, $zero,

4

srl $t1, $t0, 2

$t1 = 4
T16 sra Arithmetic right shift addi $t0, $zero, –

16

sra $t1, $t0, 2

$t1 = -4 (sign preserved)
Memory Tests
T17 lw    Load        word

from memory

lw $t0, 0($s0) $t0 = Mem[$s0]
T18 sw Store word to memory addi $t0, $zero,

42

sw $t0, 0($s0)

Mem[$s0] = 42
T19 lb Load byte with sign extension lb $t0, 0($s0)   $t0                                 =

SignExt(MemByte[$s0])

T20 sb Store byte to memory addi $t0, $zero,

0xAB

sb $t0, 0($s0)

MemByte[$s0] = 0xAB
Comparison Tests 
T21 slt Signed comparison addi $t0, $zero,

5 addi $t1, $zero,

10

slt $t2, $t0, $t1

$t2 = 1
T22 slti Immediate comparison addi $t0, $zero,

15

slti $t2, $t0, 10

$t2 = 0
T23 slt Signed corner case addi $t0, $zero, –

5

addi $t1, $zero, 5

$t2 = 1
slt $t2, $t0, $t1
Branch and Jump Tests
T24 beq Equal operands (taken) addi $t0, $zero,

5

addi $t1, $zero,

5

beq       $t0,      $1,

target

Branch taken
T25 beq Unequal operands taken) (not addi $t0, $zero,

5

addi $t1, $zero,

8

beq       $t0,      $t1,

target

No branch (fallthrough)
T26 bne Unequal operands (taken) addi $t1, $zero,

5

addi $t1, $zero,

8

bne       $t0,      $t1,

target

Branch taken
T27 bne Equal operands (not taken) addi $t0, $zero,

5

addi $t1, $zero,

5

bne       $t0,      $t1,

target

No branch (fallthrough)
T28 j Jump to target address j target PC = target
T29 jal Jump and link jal target $ra = PC + 4,

PC = target

T30 jr Jump register jr $ra PC = $ra
Group 3 Tests
T31 l_inc Load memory and increment

rs

l_inc $t1, 0($t0) $t1 = Mem[$t0];

$t0 = $t0 + 4

T32 R-format lw Load memory with base +

index

lw $t2, $t0($t1) $t2 = Mem[$t0 + $t1]
Register Test
T33 $zero Attempt write to $zero addi              $zero,

$zero, 100

$zero remains 0

 3.1.2 Basic Building Block Tests

Test ID Building Block Test Description Input

Stimulus/Test Vector

Expected Result Status
BB-

01

reg_file Dual          port

read verification

raddr1 = 5’d2, raddr2 = 5’d3 rdata1 = Reg[2], rdata2 = Reg[3]
BB-

02

reg_file Standard write port 1 access wadr1 = 5’d4,

wdata1                  =

32’hA5A5_A5A5,

we1 = 1

Reg[4] updates to 32’hA5A5_A5A5 on next posedge clk.
BB-

03

reg_file Dual write ports (l_inc payload) wadr1 = 5’d4, wdata1 = 32’h11, wadr2 = 5’d5, wdata2 = 32’h22, we1 = 1, we2 =1 Reg[4] = 32’h11, Reg[5] = 32’h22

written simultaneously

BB-

04

reg_file Attempt to write to $zero (r0) wadr1 = 5’d0,

wdata1                  =

32’hFFFF_FFFF, we1 = 1

rdata1 remains 32’h0000_0000.
BB-

05

alu Arithmetic

ADD

Operation

Verifications

alu_ctrl = ADD, A

= 32d’15,

B = 32’d10

alu_out = 32’d25
BB-

06

alu Arithmetic

SUB

Operation

Verifications

alu_ctrl = SUB, A

= 32’h0000_0020,

B                           =

32’h0000_0005

alu_out                =

32’h0000_001B,

zero = 0

BB-

07

alu Bitwise AND

Operation

Verification

alu_ctrl = AND, A

= 32’hF0F0_F0F0, B = 32’HFFFF

_0000

alu_out                =

32’hF0F0_0000

BB-

08

alu Bitwise      OR

Operation

Verification

alu_ctrl = OR,

A                           =

32’h0F0F_0F0F, B

= 32’h5555_5555

alu_out                =

32’h5F5F_5F5F

BB-

09

alu Bitwise XOR

Operation

Verification

alu_ctrl = XOR, A

= 32’h0F0F_0F0F,

B                           =

32’h5555_5555

alu_out                =

32’h5A5A_5A5A

BB-

10

alu Bitwise NOR

Operation

Verification

alu_ctrl = NOR, A

= 32’h0F0F_0F0F,

B                           =

32’h5555_5555

alu_out                =

32’h0A0A_0A0A

BB-

11

alu Shift          Left

Logical

(SLL)

Verification

alu_ctrl = SLL,

A                           =

32’h0000_0001, shamt = 4

alu_out                =

32’h0000_0010

BB-

12

alu Shift        Right

Logical

alu_ctrl = SRL, A = 32’hF000_000F, alu_out                =

32’h0A0A_0A0A

(SRL) Verification shamt = 4
BB-

13

alu Shift        Right

Arithmetic

(SRA)

Verification

alu_ctrl = SRA, A = 32’hF000_000F, shamt = 4 alu_out =

32’h0F00_0000

(Zero fill)

BB-

14

alu Set on less than (slt) comparison alu_ctrl = SLT, A

= -32’d5,

B = 32’d2

alu_out = 32’d1
BB-

15

ex_stage Group            3

rs_inc_adder verification

rs_val                    =

32’h0000_10000

rs_inc_out           =

32’h0000_1004

BB-

16

mem_interface Memory read access mem_read = 1,

addr                       =

32’h0000_1000

data_rdata

outputs           word

stored at 0x1000

BB-

17

mem_interface Memory

write access

mem_write = 1,

addr                       =

32’h0000_1000,

w_data                  =

32’h1234_5678

Memory              at

0x1000 updates to

32’h1234_5678

BB-

18

control_unit Main opcode decoding matrix opcode                  =

6’b000_000,

funct                      =

6’b100_000 (ADD)

alu_src = 0, reg_write =1, mem_to_reg = 0
BB-

19

hazard_unit Load-use hazard detection id_ex_mem_read = 1, id_ex_rt = 5’d2, if_id_rs = 5’d2 pipeline_stall = 1, flush_id_ex = 1
BB-

20

forward_unit EX_MEM

and

MEM_WB

data     hazard forwarding

ex_mem_reg_write

= 1, ex_mem_rd =

5’d3, id_ex_rs =

5’d3

forward_a            =

2’b10 (Selectes EX_MEM result)

BB-

21

forward_unit Group 3 rs autoincrement forwarding ex_mem_is_l_inc = 1, ex_mem_rs =

5’d4, id_ex_rs =

5’d4

forward_rs_inc = 1

3.1.3 Data Hazard Test Program

Test Test Program Expected Result Status
RAW Dependency addi $t0, $zero, 5 add $t1, $t0, $t0 $t1 = 10. EX_MEM forwarding path supplies $t0 payload directly to ALU input.
Load-Use-Hand lw $t0, 0($t1) add $t2, $t0, $t0 $t2 = 2 * Mem[$t1]. hazard_unit inserts a 1cycle pipeline stall (IF_ID freeze, ID_EX bubble)
Forwarding      /       Stall

Verification

addi $t0, $zero, 5 add $t1, $t0, $t0 sub $t2, $t1, $t0 $t1 = 10 and $t2 = 5. Forwarding unit resolves hazards dynamically without unnecessary stalls.
Goup 3 l_inc RAW

Hazard

l_inc $t0, 0($s0) add $t1, $s0, $t2 $t1 = ($s0 + 4) + $t2. forward_unit detects write back to $s0 via Port 2 and forwards rs_inc_value.

3.2 Integration Test Program

The program is designed to verify that different processor functions operate correctly together in the five-stages pipeline.

Test ID Test

Function

Instructions / Features Assembly               Test

Sequence/Description

Expected

Verification Result

Status
INT01 Arithmetic and Logic addi,         add,

sub, and, or

addi $t0, $zero, 10 addi $t1, $zero, 20 add $t2, $t0, $t1 sub $t3, $t2, $t0 and $t4, $t3, $t1 or $t5, $t4, $t0 $t2 = 30

$t3 = 20

$t4 = 20

$t5 = 30

(Validates multi-

stage            ALU

dependency chain)

INT02 Memory

Write-Read

sw, lw addi       $s0,        $zero,

0x1000

addi       $t0,        $zero,

0xDEADBEEF

sw $t0, 0($s0) lw $t1, 0($s0)

Mem[0x1000] = 0xDEADBEEF

$t1                      =

0xDEADBEEF

(Validates

memory      write-

to-read sequence)

INT03 Comparison and Branch slt, beq, bne addi $t0, $zero, 5 addi $t1, $zero, 10 slt $t2, $t0, $t1 bne $t2, $zero, L1 addi $t3, $zero, 99 L1: beq $t0, $t1, L2 Branch L1 taken ($t3      remains unchanged).

Branch L2 not taken. Pipeline flush executes correctly.

INT04 Loop

Execution

Arithmetic + branch addi $t0, $zero, 0 addi $t1, $zero, 5 LOOP: addi $t0, $t0, 1 bne $t0, $t1, LOOP Loop    iterates exactly 5 times. Final $t0 = 5. Pipeline branch control             handles loop     iteration back_edges cleanly.
INT05 Subroutine

Call           and

Return

j, jal, jr jal FUNC addi $s0, $zero, 1 j END

FUNC:      addi       $v0,

$zero, 42 jr $ra

END: nop

$ra correctly saves return address (PC + 4). Execution jumps to FUNC, sets $v0 = 42, and jr $ra returns cleany.
INT06 Group          3:

l_inc Integration

L_inc, add addi       $s0,        $zero,

0x1000

l_inc $t0, 0($s0)

$t0                      =

Mem[0x1000].

$s0      increments

add $t1, $s0, $t0 to 0x1004. $t1 receives 0x1004 + Mem[0x1000] via dual write-

back     and forwarding.

INT07 Group 3: Rformat lw

Integration

R-format lw, add addi       $s0,        $zero,

0x1000

addi       $t0,        $zero,

0x0004 lw $t1, $s0($t0)

Memory        read

address

calculated as R[$s0] + R[$t0] = 0x1004. $t1 = Mem[0x1004].

INT08 Multi-Hazard Stress Test Full Pipeline and Group 3 lw $t0, 0($s0) l_inc $t1, 0($t0) add $t2, $t1, $t0 Tests consecutive load-use stall insertion, l_inc base-address forwarding, and dual write-back

timing simultaneously without             timing hazards

3.3 Boot Program and Program Loading Specification

3.3.1 Boot Program

Upon reset assertion (reset = 1), the Program Counter (PC) is initialized to 0x00000000 (Boot ROM address space) and all internal pipeline registers are flushed (IF_ID, ID_EX, EX_MEM, MEM_WB). The boot load clears pipeline registers and initializes stack pointers before jumping to 0x0000_0040 (Text Segment).

As shown in the boot sequence flow diagram, execution follows a deterministic initialization path:

  1. Reset State: Holds PC = 0x0000_0000 and forces control signals to zero.
  2. Boot ROM Fetch: Fetches setup instructions from the Boot ROM space (0x0000_0000 to 0x0000_003C).
  3. Pipeline and State Init: Clears hazard units, zeros register file register, and sets initial stack pointers.
  4. Application Handoff: Executes an unconditional jump (j 0x0000_0040) to transfer control to the user application program in the text segment.

 3.3.2 Program Loading Specification

  1. Memory Region Allocation
Memory Region Word Index Range Byte Address Range Function/Content
Boot ROM 0 to 15 0x0000_0000 –

0x0000_003C

Reset    routines    and      state

initialization

Instruction

Memory (.text)

16 to 1023 0x0000_0040 –

0x0000_0FFF

Assembled             application

binary machine code

Data         Memory

(.data)

0  to 1023 0x0000_1000 –

0x0000_1FFF

Global data, variables, and stack space

 2. HDL Memory Initialization

In SystemVerilog simulation, instruction memory (imem) is pre-loaded using $readmemh system tasks. The machine code generated by the assembler is formatted into standard ASCII 32-bit hexadecimal strings.

logic [31:0] instruction_memory [0:1023];  initial begin

$readmemh(“boot.hex”, instruction_memory, 0, 15);

$readmemh(“program.hex”, instruction_memory, 16, 1023);  end

 Execution Parameters and Rules

  • Address Translation: Array indices 0..1023 represent 32-bit word addresses indexed using word aligned addressing (PC [31:2]).
  • Simulation Requirements: boot.hex and program.hex must be placed in the simulator’s root working directory.
  • Format Specification: Hex files must contain raw 8-difit hexadecimal instructions (e.g., 20080005) separated by line breaks, without 0x prefixes.

 4. Micro-Architecture Secification: Unit And Block Levels

4.1 CPU Unit

4.1.1 Functionality / Feature

  • Maintains the Program Counter.
  • Fetches instructions from instruction memory.
  • Transfers instructions through the five-stages pipeline.
  • Reads source operands from the register file.
  • Selects ALU operands using multiplexers.
  • Performs execution and address-generation operations.
  • Transfers data between the processor and data memory.
  • Selects the appropriate write-back result.
  • Supports pipeline hazard handling.
  • Supports l_inc and R-format lw variant.

  4.1.2 CPU Unit Interface and I/O Pin Description

  1. CPU Unit Interface
  2. I/O Pin Description
Signal Direction Width Description
clk Input 1-bit System clock
rst Input 1-bit Resets CPU and pipeline state
instr_addr Output 32-bit Address of instruction to be fetched
instr_data Input 32-bit Instruction       supplied           by             instruction memory
data_addr Output 32-bit Effective address for data memory access
data_wdata Output 32-bit Data supplied for store operations
data_rdata Input 32-bit Data returned from data memory
data_re Output 1-bit Data memory read enable
data_we Output 1-bit Data memory write enable

 4.1.3 Internal Operation

Program Counter

  • Stores the current instruction address.
  • Normally updates to PC + 4.
  • Supports branch and jump target selection.
  • Updated on the active clock edge.
  • Pipeline Registers
Pipeline Register Main Function
IF_ID Stores fetched instruction and related information
ID_EX Stores decoded operands, immediate value and control information
EX_MEM Stores ALU    result, memory           information     and             destination information
MEM_WB Stores memory/ALU result and write-back information

Need a custom answer for your subject?

Share your module details and get fast, original academic support from our team.