riscv-software-src / riscv-isa-sim

Spike, a RISC-V ISA Simulator
Other
2.36k stars 826 forks source link

Provide C API for Spike Integration with Other Languages #1616

Open Clo91eaf opened 6 months ago

Clo91eaf commented 6 months ago

Background:

Spike, being a fundamental component within the RISC-V ecosystem, possesses extensive capabilities in simulation and emulation. To broaden its accessibility and interoperability with various programming languages, it's imperative to develop a C API for Spike, enabling seamless integration with other language environments. A preliminary effort has been made in the libspike-interfaces project, demonstrating a basic Rust binding usage.

Proposal:

  1. Development of a C API for Spike: In order to facilitate integration with different programming languages, it's essential to define and expose certain Spike objects via a C API. This API will serve as a bridge for communication between Spike and other language environments, enabling developers to leverage Spike's functionalities across diverse platforms.

  2. Additional Usage Scenarios:

    • RISC-V Bus Behavior Model
    • Trace-based Performance Model
    • Co-simulation for Verification

Roadmap:

jerryz123 commented 6 months ago

Most of what you describe would be best implemented in a separate library that links to Spike. Recent work has made using spike as-a-library easier, there are even regressions now to test that this works.

Do you have concrete examples of changes/improvements that would improve the usability of Spike in these ways?

Co-simulation for Verification

There are already a number of projects which link Spike in the RTL simulator to provide functional co-simulation for verification.

Custom Instruction Support Hooks

This is already supported, but the APIs are not well documented.