Pipeline
Describes the main processing pipeline of the CPU.
-
The pipeline is 3 stages long:
-
Fetch
-
Decode + Execute
-
Writeback
Fetch
-
64-bit wide memory bus -
128-bit fetch buffer.128bits =64bits (memory bus width) *2(largest instruction size). -
The fetch buffer also tracks bus error bits. Each 16-bit halfword in the buffer is tagged with a "is this data associated with an instruction bus error?" bit.
-
It maintains it's own copy of the program counter, and a separate register containing the instruction fetch address.
-
It makes the following data fields available to the decode and operand gather stage:
Bits Name Description 32 s1_instr32-bit instruction word ready for decoding. 1 s1_ferrFetch error associated with these s1_instrbits?1 s1_i16bits1_instrcontains 16-bit instruction.1 s1_i32bits1_instrcontains 32-bit instruction.1 s1_eat_2Eat 2 bytes from the buffer. 1 s1_eat_4Eat 4 bytes from the buffer.
Note that s1_eat_[2,4] are driven by the decode stage, other signals
are driven by the fetch stage.
-
The control flow change bus is driven from either execute or writeback, and communicates all interrupts, exceptions, branches and jumps to the fetch stage. The writeback stage takes priority in the event of contention.
Bits Name Dir Description 1 cf_validin Control flow change request valid 1 cf_ackout Control flow change acknowledged. 64 cf_targetin Target address of the control flow change. 4 cf_causein Cause of the control flow change.
Decode / Execute
-
Decodes instructions and selects inputs to functional units.
-
Computes data memory & branch target addresses using the ALU.
-
Non-trap control flow changes take place here.
-
The pipeline register data fields presented to writeback are:
Bits Name Description 1 s3_validExecute has instruction ready for writeback 1 s3_readyWriteback ready for new instruction 2 s3_fullInstruction in writeback stage 5 s3_rdDestination GPR XLEN s3_wdataWrite data for CSRs / GPRs XLEN s3_npcNext program counter - for jump and link. XLEN s3_pcProgram counter for instruction 3 s3_csr_opControl & Status Register operation 4 s3_cfu_opControl flow change operations: mret/ebreak etc 5 s3_lsu_opLoad/store unit operation 2 s3_wb_opWriteback data sourcing 1 s3_trapRaise trap.
Writeback
- This stage writes back data to the register file, accesses CSRs, finalises control flow changes and finishes memory accesses.