Rivos is releasing the source for hammer - a library that instantiates Spike and can be used to run Spike in lock-step and allows Spike state to be read and written. This is useful to run Spike in co-simulation with another model for verification.
hammer instantiates Spike and provides a C++ and Python API to interact with it.
Example:
Hammer hammer = Hammer("RV64GCV", "MSU", "vlen:512,elen:32", hart_ids, memory_layout,
target_binary, std::nullopt);
..
..
uint32_t flen = hammer.get_flen(0);
uint32_t vlen = hammer.get_vlen(0);
..
for (uint32_t i = 0; i < 8; ++i) {
hammer.single_step(0);
}
uint64_t current_pc = hammer.get_PC(0);
uint64_t current_x1 = hammer.get_gpr(0, 1);
uint64_t current_x2 = hammer.get_gpr(0, 2);
uint64_t current_x3 = hammer.get_gpr(0, 3);
..
uint64_t next_PC = current_PC + (4 * 8);
hammer.set_PC(0, next_PC);
hammer requires a few changes to Spike to run. The repo contains a patch that has to be applied to Spike to build for hammer.
hammer is in active development and we plan to push out updates regularly.
We're happy to accept PRs for fixes and enhancements.
Jerin