Three additional functions are needed in the Or1ksim library to
support synchronized timing. The UART will need to know the clock
rate of the model (to work out the baud rate from the value of the
divisor latch). The Or1ksimSyncSC
class
itself will need a pair of functions, one to set a timing point in
the ISS the second to return the amount of time since the last
timing point. This the amount of time the underlying ISS has used
when synchronizing with SystemC.
The three additional functions are simple additions. The clock rate is a configuration parameter, while a run time count of instructions executed is already maintained. An extra record in the run-time structure allows a time to be recorded (in seconds through dividing the count by the clock rate), which can be compared in subsequent calls to give the ISS time used since the last time point[6].
unsigned long int or1ksim_clock_rate();
or1ksim_clock_rate
returns the Or1ksim
ISS clock rate in Hz. This information will be used by the
UART to allow it to set its baud rate.
void or1ksim_set_time_point();
or1ksim_set_time_point
records the current
ISS simulation time (clock cycles divided by clock rate) in
the run-time data structure.
double or1ksim_get_time_period();
or1ksim_get_time_period
returns the time
in seconds since the last time point was set. This function is
needed to keep the SystemC model of time due to instruction set
processing accurate, both in the synchronous SoC and when
temporal decoupling is added later (see Chapter 9.
These functions are a standard part of the Or1ksim 0.3.0 and Or1ksim 0.4.0 libraries.
[6] This is a loosely timed model. The timing from the ISS is approximate—it does not model the microarchitecture in detail. Cycle estimates will not be exact—that requires a fully cycle accurate model.