Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework register file's "zero" register #298

Merged
merged 4 commits into from
Apr 10, 2022
Merged

Rework register file's "zero" register #298

merged 4 commits into from
Apr 10, 2022

Conversation

stnolting
Copy link
Owner

@stnolting stnolting commented Apr 10, 2022

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 register x0 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 register x0 is a physical register. We do not want to rely on BRAM initialization to ensure that x0 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 code crt0.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 setting reset_x0_c := false (VHDL constant in neorv32_package.vhd).


This PR also fixes a synthesis/simulation warning regarding unconnected pmp_* signals.

register x0 (zero) is now explicitly initialized (set to zero) by the CPU control
-> shortens critical path (regfile -> ALU -> regfile)
@stnolting stnolting added the HW hardware-related label Apr 10, 2022
@stnolting stnolting self-assigned this Apr 10, 2022
first instruction is not required to write to x0 anymore
@stnolting stnolting changed the title Rework register file's zero register Rework register file's "zero" register Apr 10, 2022
@stnolting stnolting marked this pull request as ready for review April 10, 2022 19:24
@stnolting stnolting merged commit f142d74 into main Apr 10, 2022
@stnolting stnolting deleted the rework_regfile_zero branch April 10, 2022 19:24
@stnolting stnolting added the optimization Make things faster, smaller and more efficient label Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
HW hardware-related optimization Make things faster, smaller and more efficient
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant