3.7 Execute Stage (EX)

<< Click to Display Table of Contents >>

Navigation:  ASA-EMulatR Reference Guide > Introduction > Architecture Overview > Chapter 3 - Pipeline Architecture >

3.7 Execute Stage (EX)

Central Execution Principle

 

All architectural work happens in the Execute stage. This is the single most important pipeline invariant. The EX stage invokes execution through the grain's virtual execute() method, which dispatches to the appropriate Box:

 

slot.grain->execute(slot);

 

Work performed in EX includes:

Integer arithmetic and logic (EBox)

Floating-point operations (FBox) — execute synchronously, stalling the pipeline until completion

Address calculation and memory access — loads and stores via MBox, DTB translation

Branch condition evaluation

Barrier setup and serialization requests (CBox)

LL/SC reservation handling

PAL instruction execution (PalBox)

 

The grain produces results into the slot: payLoad (result value), ra_value (register A value), branchTaken/branchTarget (branch outcome), and fault metadata (faultPending, trapCode, faultVA) if an exception was detected.

 


 

Early Exit Conditions

 

Before executing the grain, EX checks for early exit conditions:

Invalid slot — return immediately

Stalled slot — return without execution

Fault already pending — do not re-execute

Null grain pointer — raise ILLEGAL_INSTRUCTION fault

 


 

Floating-Point Execution Policy

 

Floating-point operations execute synchronously in EX. The pipeline stalls in the EX stage until the FP operation completes. No asynchronous FP completion tracking is used. This design favors simplicity, correctness, and debuggability over throughput.

 


 

Memory Operations in EX

 

All memory accesses occur during EX via the MBox:

Loads retrieve data and store it in slot.payLoad

Stores compute the address (slot.va, slot.pa) in EX; the actual memory write is deferred to stage_WB

DTB translation is performed here

Memory faults (TLB miss, access violation, alignment) are detected here and recorded in slot.faultPending

 

The MEM stage does not perform memory access — this is a deliberate simplification.

 


 

Pipeline Flush from EX

 

If the grain sets slot.flushPipeline during execution (e.g., for PAL side-effects), younger stages (IF, DE, IS) are immediately cleared:

 

if (stage(STAGEEX).flushPipeline) {

 for (int i = 0; i < STAGEEX; i++) {

 stage(i).valid = false;

 stage(i).clear();

 }

 stage(STAGEEX).flushPipeline = false;

}

 

See Also: Chapter 4 - Functional Execution Domains ("Boxes); 3.12 Stalls and Serialization; 3.14 Precise Exceptions.