← Back

Hardware Architecture

Y86-64 Processor Implementation

A complete implementation of the Y86-64 instruction set, developed first as a sequential processor and then extended into a five-stage pipelined architecture with forwarding, selective stalls, and precise control-hazard handling.

Source code Verilog HDL

System Specifications

  • ISAY86-64
  • Pipeline5 Stages
  • ControlStall & Bubble
  • HazardsForwarded
PIPELINE
F-D-E-M-W
Fetch, Decode, Execute, Memory, Write-back
HAZARDS
Hazard-Aware
Load/use stalls, ret stalls, branch bubbles
EXECUTION
Pipelined
Early PC update & overlap

The Challenge

Implementing a correct Y86-64 processor required precise handling of data hazards, control hazards, and architectural corner cases such as return instructions and conditionally executed moves — all while maintaining pipeline throughput.

Design Evolution

The project was developed in two phases: a fully functional sequential processor, followed by a pipelined implementation. Pipeline registers (F, D, E, M, W) were introduced, PC update was moved to the start of each cycle, and a clocked register file enabled visibility into architectural state across cycles.

Pipeline Architecture

Y86-64 five-stage pipeline datapath
FIG — PIPELINE DATA PATHRTL LEVEL

Each pipeline stage mirrors its sequential counterpart, with clocked registers isolating combinational logic. Mispredicted branches redirect fetch from the M stage, while return instructions source the PC from the W stage.

Hazard Detection & Forwarding

The pipeline distinguishes between load/use hazards, return hazards, and mispredicted branches. Load/use hazards trigger selective stalls, return instructions stall fetch, and branch mispredictions introduce bubbles to squash incorrect instructions.

pipe_control.v — Hazard & Bubble Control
// Load/use hazard
wire load_use_hazard =
  (E_icode == IMRMOVQ || E_icode == IPOPQ) &&
  (E_dstM == d_srcA || E_dstM == d_srcB);

// Return hazard
wire ret_hazard =
  (D_icode == IRET || E_icode == IRET || M_icode == IRET);

assign F_stall = load_use_hazard || ret_hazard;
assign D_stall = load_use_hazard;
assign D_bubble = (E_icode == IJXX && !e_Cnd) || ret_hazard;

Validation & Results

A Y86-64 assembly program computing the summation from 1 to 100 was used to validate correctness. GTKWave traces confirm correct instruction flow, forwarding behavior, and hazard resolution. The final value stored in the register %rax was 0x13BA (5050 decimal).