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

Chapter 7.  Adding a Terminal as a Test Bench

7.1. Overall Design of the Simple SoC Model
7.1.1. Class Structure
7.1.2. Behavioral Diagrams
7.2. SystemC Terminal Module Design
7.3. Terminal Module Class Definition
7.3.1. Mapping Signals to Class Instances
7.3.2. The SystemC Class
7.3.3. Setting up the xterm
7.3.4. Signal and event handling
7.4. Terminal Module Class Implementation
7.4.1. SystemC Processes
7.4.2. Signal and event handling
7.5. The Complete SoC
7.5.1. The Model Main Program
7.5.2. Test Program to Run on the Or1ksim ISS
7.5.3. Compiling and Running the Model
7.5.4. Model Timing

The Or1ksim ISS described in Chapter 4 and the UART described in described in Chapter 6 can be put together as a minimal SoC. However a test bench is needed to exercise that SoC

The usual way of exercising a SoC with a UART is to connect a terminal to the UART. This section describes a suitable SystemC model of a terminal and how to connect it to create the complete SoC.

This is not a TLM 2.0 component—the interfaces are standard SystemC buffers, so the description is less detailed. However it serves to illustrate an important general technique when using SystemC—how to interact with the operating system functions.

The problem is that many operating system calls block. Consider modeling the terminal as a thread which reads characters from a console window. This will block until characters are typed. However the block does not use the SystemC wait call, so SystemC is not aware that the thread has yielded. The simulation will hang until characters are received.

This implementation of the terminal will show how to wrap non-blocking versions of operating system functions with SystemC events, to give versions that block correctly using SystemC wait, so allowing the thread to yield.

The code for the terminal module (TermSC.cpp and TermSC.h) and the main program (simpleSocMainSC.cpp may be found with the UART module and extended Or1ksim ISS wrapper code in the sysc-models/simple-soc directory of the distribution.

Embecosm divider strip