Front-end to back-end interface

September 29, 2020 ยท View on GitHub

The front-end is responsible for fetching instructions and the back-end is responsible for executing them. This interface ensures that the back-end has instructions to execute and that the front-end is aware of any control flow in the program.

Front-end to back-end

SignalTypeDescription
fetch_validBooleanWhether fetch_instr is valid.
fetch_instrfetched_instr_tThe instruction to execute. (More details)

Back-end to front-end

SignalTypeDescription
satp64 bitsThe value of the SATP (Supervisor Address Translation and Protection) control register.
prvpriv_lvl_eThe current privilege level. (Available options)
statusstatus_tA collection of relevant information from the control registers. (More details)
redirect_validBooleanWhether a redirection (e.g. branch, jump) is currently being requested.
redirect_reasonif_reason_eThe reason for the requested redirection. (Available options)
redirect_pc64 bitsThe new memory address to begin fetching instructions from.
branch_infobranch_info_tNon-speculative information about executed branches, used (for example) to update the branch predictor. (More details)
fetch_readyBooleanWhether the back-end is ready to receive a new instruction.

fetched_instr_t

A fetched instruction and relevant metadata. A compound type consisting of:

FieldTypeDescription
pc64 bitsProgram counter.
if_reasonif_reason_eReason why the instruction was fetched (i.e. was it speculative?). (Available options)
instr_word32 bitsThe instruction that was fetched.
ex_validBooleanWhether an exception occurred during instruction fetch.
exceptionexception_tFurther information on the exception. (More details)

if_reason_e

Reasons for an instruction fetch taking place.

ValueDescription
IF_PREFETCHAn instruction prefetch that follows the previous instruction in program counter order.
IF_PREDICTAn instruction prefetch commanded by the branch predictor.
IF_MISPREDICTAn instruction fetch caused by misprediction.
IF_PROT_CHANGEDMemory protection bits, e.g. MSTATUS, PRV or SATP has been changed.
IF_SATP_CHANGEDThe SATP (Supervisor Address Translation and Protection) control register has been changed.
IF_FENCE_IThe FENCE.I instruction was executed.
IF_SFENCE_VMAThe SFENCE.VMA instruction was executed.

exception_t

Information about an exception. A compound type consisting of:

FieldTypeDescription
causeexc_cause_eThe cause of the exception. The only possible instruction fetch exceptions in Muntjac are EXC_CAUSE_INSTR_PAGE_FAULT and EXC_CAUSE_INSTR_ACCESS_FAULT.
tval64 bitsAddress being accessed when the exception occurred.

priv_lvl_e

Privilege levels.

ValueDescription
PRIV_LVL_MMachine mode.
PRIV_LVL_HHypervisor mode.
PRIV_LVL_SSupervisor mode.
PRIV_LVL_UUser mode.

status_t

A collection of information from the control registers consisting of:

FieldTypeDescription
tsrBooleanThe MSTATUS TSR bit (Trap Supervisor Return).
twBooleanThe MSTATUS TW bit (Timeout Wait).
tvmBooleanThe MSTATUS TVM bit (Trap Virtual Memory).
mxrBooleanThe MSTATUS MXR bit (Make eXecutable Readable).
sumBooleanThe MSTATUS SUM bit (permit Supervisor User Memory access).
mprvBooleanThe MSTATUS MPRV bit (Modify PRiVilege).
fs2 bitsThe MSTATUS FS bits (Floating-point State).
mpppriv_lvl_eThe MSTATUS MPP bits (Machine mode Previous Privilege).
sppBooleanThe MSTATUS SPP bit (Supervisor mode Previous Privilege).
mpieBooleanThe MSTATUS MPIE bit (Machine mode Previous Interrupt-Enable).
spieBooleanThe MSTATUS SPIE bit (Supervisor mode Previous Interrupt-Enable).
mieBooleanThe MSTATUS MIE bit (Machine mode Interrupt-Enable).
sieBooleanThe MSTATUS SIE bit (Supervisor mode Interrupt-Enable).

branch_info_t

Information about a branch operation. A compound type consisting of:

FieldTypeDescription
branch_typebranch_type_eThe type of branch. (Available options)
pc64 bitsThe address of the branch instruction (not the address being branched to).
compressedBooleanWhether the branch instruction is compressed.

branch_type_e

Types of branch operation.

ValueDescription
BRANCH_NONENot a branch instruction.
BRANCH_UNTAKENBranch not taken.
BRANCH_TAKENBranch taken.
BRANCH_JUMPUnconditional jump.
BRANCH_CALLEnvironment call: request additional privilege.
BRANCH_RETEnvironment return: return to previous privilege.
BRANCH_YIELDVoluntarily yield control of the core and trigger a thread switch.