RISC V ISS SystemC Interface Propsal
RISC V ISS SystemC Interface Propsal
IP – Architectural Team
RISC V ISS SysctemC Interface (Wrapper) Proposal
Shehadeh, J under Team Lead Hroub(CTO), A and Nasir,N (CEO)
Proposal
Below is a SystemC module wrapper for a C++ based RISC-V Instruction Set Simulator. The
module includes ports for clock, reset, and an output port. Inside the module there is a
RISCVSIM object which is instantiated in the constructor.
Blocking method is also implemented to allow sending and receiving data using a blocking
mechanism. This shall be helpful for out TLM module.
The simulation Thread waits for the positive edge of the clock and checks if reset is asserted then
if yes it loads the program and run the simulation. It also checks if an interrupt has occurred by
calling the interrupt_occured function, if yes it puts the value true on the interrupt output to be
handled by another module in the systemC environment. The simulation thread also retrieves
data from the ISS by calling get_data() function of the ISS object and writing it to the "data_bus"
port. Then it read the data from "data_bus" port and set it to the ISS object by calling set_data()
function of the ISS object. In this way the data is exchanged between the ISS and the systemc
environment (Note that this step may be unnecessary if we are only interested in the final output)
The step() function is responsible for the cycle accurate simulation. It is called eached cycle to
pass the next instruction with the updated line number.
Note that this code is in a dirty stage as it’s running time can be cut shorter
Note that this module is not time accurate as it will issue a new instruction on every clock cycle.
#include "systemc.h"
#include simulator library header
SC_MODULE(ISS_WRAPPER) {
sc_in<bool> clk;
sc_in<bool> reset;
sc_out<bool> done; //for status check
sc_out<bool> interrupt; //for interrupts (manual)
sc_inout_rv<32> data_bus; // inout port for data bus
Spike_ISS *iss;
void iss_thread() {
while (true) {
if (reset.read() == true) {
iss->load_program("program.bin");
iss->run();
done.write(true);
}
if (iss->interrupt_occured()) {
interrupt.write(true);
} else {
interrupt.write(false);
}
SC_THREAD(iss_thread);
sensitive << clk.pos();
}
~ISS_WRAPPER() {
delete iss;
}
};
#include <iostream>
#include <fstream>
#include <string>