|
<< Click to Display Table of Contents >> Navigation: ASA-EMulatR Reference Guide > Introduction > Architecture Overview > Chapter 4 - Functional Execution Domains ("Boxes) > 4.4 IBox - Instruction Box |
The IBox is the front-end intelligence of the processor. It is responsible for instruction fetch and decode, and nothing else. Once a grain is produced, IBox is no longer involved in that instruction's lifecycle.
•Instruction fetch coordination — reads the current PC, performs virtual-to-physical translation via the Ev6Translator, and fetches the 32-bit instruction word from GuestMemory
•Instruction decode — passes raw bits to GrainResolver::ResolveGrain() which extracts the opcode and function code, then looks up the cached grain in the InstructionGrainRegistry
•Decode cache management — maintains two levels of decode cache: PcDecodeCache (indexed by virtual PC, 64 entries) and PaDecodeCache (indexed by physical address, 64 entries). Cache hits bypass GuestMemory entirely.
•FetchResult generation — packages the DecodedInstruction, grain pointer, CALL_PAL detection, and prediction metadata into a FetchResult for pipeline consumption
•Branch target calculation — computes static branch targets for unconditional branches during fetch
•CALL_PAL detection — identifies PAL instructions early and extracts the function code for PalBox routing
•Does not execute instructions — all execution occurs in EX via Box dispatch
•Does not update registers — register writes are deferred to MEM/WB
•Does not change PC architecturally — PC commit occurs only in WB
•Does not handle memory translation for data — data translation is MBox's responsibility
•Does not handle faults beyond signaling decode failures (ILLEGAL_INSTRUCTION)
IBox is implemented as a final class (IBoxBase.h, 842 lines) with a two-phase fetch path: fetchNext() is the hot-path entry point that calls fetchAndDecode(). The fetch pipeline is: (1) try PC-based decode cache, (2) on miss try PA-based decode cache, (3) on miss fetch from GuestMemory, decode via GrainResolver, and populate both caches.
Dependencies: MBox (for instruction address translation), GuestMemory (physical memory fetch), GrainResolver (decode), CBox (branch prediction — not done in IBox directly).
Invariant: IBox never mutates architectural state.
See Also: 3.4 Fetch Stage (IF); IBoxLib/IBoxBase.h; grainFactoryLib/GrainResolver.h.