Services and Modeling for Embedded Software Development
Embecosm divider strip
Prev  Next

6.3.3.  Extended Or1ksim Wrapper Module Class Implementation

The constructor just passes its arguments to its base class

Or1ksimExtSC::Or1ksimExtSC ( sc_core::sc_module_name  name,
                             const char              *configFile,
                             const char              *imageFile ) :
  Or1ksimSC( name, configFile, imageFile )
{
 }      // Or1ksimExtSC()
	  

isLittleEndian is a simple wrapper for the underlying Or1ksim ISS library function[3].

bool
Or1ksimExtSC::isLittleEndian()
{
  return (1 == or1ksim_is_le());

}	// or1ksimIsLe()
	  

The majority of the code for doTrans is unchanged from its implementation in Or1ksimSC. The addition is a wait for zero time immediately after the transaction has completed. This allows the SystemC thread to yield, so that any other threads that are ready can take a turn.

  wait( sc_core::SC_ZERO_TIME );
	  
[Caution]Caution

The call to wait is essential. SystemC is not preemptive. Other threads are only considered for execution when the currently executing thread yields. If the code were to return here, control would pass back to the underlying Or1ksim ISS until its next upcall, with no opportunity for another SystemC thread (such as that for the UART or terminal) to execute.

The implementation currently is untimed, so a zero delay wait is perfectly acceptable. That just gives all the other untimed threads a turn at execution.

The logger described in Chapter 5 worked without this call to wait, because it had no thread—all its functionality was in the blocking transaction callback function. This is part of the same thread as the original transport call from the initiator port in the Or1ksim wrapper.

The extended Or1ksim wrapper module class, Or1ksimExtSC implementation may be found in sys-models/simple-soc/Or1ksimExtSC.cpp in the distribution.



[3] A technicality is that the Or1ksim library function, is_little_endian returns an int, since C does not have a bool type. A C++ compiler would automatically convert one to the other, but making the comparison explicit is good for clarity. The same code will be generated, so there is no loss of performance.

Embecosm divider strip