hammer: Run Spike in lock step (co-simulation) mode

337 views
Skip to first unread message

Jerin Joy

unread,
Sep 21, 2022, 8:12:05 PM9/21/22
to RISC-V SW Dev
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. 

The source is available here:
https://github.com/rivosinc/hammer

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.

For examples on how to use hammer, check out tests/ and pytests/.

hammer is in active development and we plan to push out updates regularly. 
We're happy to accept PRs for fixes and enhancements.

Jerin
Reply all
Reply to author
Forward
0 new messages