As with the untimed SoC (see Section 7.5.1), the main program includes the headers for TLM 2.0 and the component modules, but this time using the synchronously timed versions.
#include "tlm.h" #include "Or1ksimSyncSC.h" #include "UartSyncSC.h" #include "TermSyncSC.h"
The baud rate for the terminal is defined as a constant for convenience.
#define BAUD_RATE 9600
As before the main program (sc_main
) takes as
arguments the Or1ksim configuration file and OpenRISC 1000 image. Instances
of the three modules are declared, but now have additional
arguments. The UART requires an input clock rate—obtained from
the ISS via the Or1ksimSyncSC
public utility
function, getClockRate
(see Section 8.3.3). The Terminal requires its baud
rate to be set.
Or1ksimSyncSC iss( "or1ksim", argv[1], argv[2] ); UartSyncSC uart( "uart", iss.getClockRate(), iss.isLittleEndian() ); TermSyncSC term( "terminal", BAUD_RATE );
The remainder of the program, connecting components and starting the simulation is identical to the untimed version.
The implementation of the main program for the SoC model with
synchronized timing may be found in
sys-models/sync-soc/syncSocMainSC.cpp
in the
distribution.