Add support for per-hart start PCs (--pc-harts) #2199
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.
Summary
This PR introduces a new command-line argument
--pc-hartsto allow specifying different start addresses (PCs) for different harts. This feature is particularly valuable for RTL co-simulation workflows, where the simulator must exactly match the behavior of the RTL design. In these scenarios, the Boot ROM is often bypassed or disabled, and each hart is released from reset at a specific entry point defined by the hardware configuration.Problem
Currently, Spike defaults to setting the PC for all harts to the ELF entry point or the address specified by
--pc.However, in many bare-metal verification environments and Asymmetric Multi-Processing (AMP) configurations, harts often have distinct reset vectors. For example, a dual-core system might require:
0x20000x4000Achieving this previously required modifying the C++ source code or relying on a complex bootloader/bootrom to diverge the harts.
Solution
I have added the
--pc-hartsflag which parses a comma-separated list ofHartID:Addresspairs.Usage Example:
spike -p2 --pc-harts=0:0x0,1:0x200 my_program.elfImplementation Details
--pc-hartsinspike_main/spike.cc.processor_tstates after simulation initialization but before the run loop begins.Testing
Verified using a dual-core bare-metal assembly test (with the boot ROM disabled) where Hart 0 and Hart 1 must execute distinct code sections located at
0x0and0x200respectively. Confirmed that both harts start at the correct overridden addresses.