The custom constructor calls the base class constructor to set the module name. The body of the constructor calculates the delay due to the baud rate. There is no configurability (this terminal supports 1 start, 8 data, 0 parity and 1 stop bits only), so this is a one off calculation.
TermSyncSC::TermSyncSC( sc_core::sc_module_name name, unsigned long int baudRate ) : TermSC( name ) { charDelay = sc_core::sc_time( 10.0 / (double)baudRate, sc_core::SC_SEC ); } /* TermSyncSC() */
The xtermThread
thread is almost identical to
the base class version. A single line is added after the character
is read from the xterm and before it is written to the port
to add the modeled baud rate delay.
int ch = xtermRead(); // Should not block wait( charDelay ); // Model baud rate delay tx.write( (unsigned char)ch ); // Send it
The implementation of the terminal module class with synchronized
timing, TermSyncSC
may be found in
sys-models/sync-soc/TermSyncSC.cpp
in the
distribution.