Rework register file's "zero" register #298
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR reworks the handling of register
x0
(= "zero"), which is always returns zero.We do not want to implement AND-gates to set the register source operands (
rs1
&rs2
) to zero when reading from registerx0
since this would cost ~64 LUTs and would also increase the critical path. Hence, register zero is part of the register file and will also be mapped to the register file-absorbing block RAM - so registerx0
is a physical register. We do not want to rely on BRAM initialization to ensure thatx0
is always zero. Thus, a special logic is required.Pre-PR
The current register file checks all write accesses if they target register zero. For any write access to this register, the actual read data is set to zero. This increases the critical path (register file -> ALU -> register file) as an additional logic level is required. Furthermore, the very first instruction of a program has to write to
x0
to make sure it is cleared. Currently, this is ensured by the CPU start-up codecrt0.S
. However, this is not portable as users might use custom start-up codes.Post-Pr
The CPU control ensures that register
x0
is set to zero by forcing a zero-write to this register. The additional logic to flush the register file write data to zero is removed. This shortens the critical path and also reduces area costs.ℹ️ For implementations using a custom register file architecture (where
x0
is actually hardwired to zero) the hardware-based initialization can be disabled by settingreset_x0_c := false
(VHDL constant inneorv32_package.vhd
).This PR also fixes a synthesis/simulation warning regarding unconnected
pmp_*
signals.