The Or1ksim main
function first initializes
the ISS, then sits in a loop executing instructions. This
main
function is replaced by a series of
functions which form the interface to the library. The interface
functions needed are:
int or1ksim_init (const char *config_file, const char *image_file, void *class_ptr, int (*upr) (void *class_ptr, unsigned long int addr, unsigned char mask[], unsigned char rdata[], int data_len), int (*upw) (void *class_ptr, unsigned long int addr, unsigned char mask[], unsigned char wdata[], int data_len));
or1ksim_init
initializes the
simulator. For Or1ksim, configuration data is read from a
file, which is passed as the first argument,
config_file
. The program image is passed as
a second argument, image_file
.
Or1ksim also needs to be able to call up to the SystemC
model of which it is part—to read and write from the
peripheral address space. These are provided as the fourth
and fifth arguments, upr
and
upw
. More explanation of the upcall
mechanism can be found in Section 4.2.6.
Function calls between C and C++ can be awkward. The upcall
functions form part of the SystemC module object, but are
written as static functions with C linkage. To enable these
functions to invoke functions in the SystemC module, they are
passed a pointer to the module class instance to use as a
handle. This pointer forms the third argument,
class_ptr
.
int or1ksim_run( double duration );
or1ksim_run
runs the simulator for the
specified time in seconds.
These functions are a standard part of the Or1ksim 0.3.0 and Or1ksim 0.4.0 libraries.