Services - tools - models - for embedded software development
Embecosm divider strip
Prev  Next

5.1.2.  Or1200MonitorSC

The functionality of this class is identical to that of its Verilog counterpart. On each positive clock edge, the freeze signal for the write back pipeline stage in the CPU control unit is checked. If the value is clear, the current instruction being executed is read. If the instruction is a special l.nop instruction, the appropriate behavior is implemented.

The class has a single port, clk of type sc_in<bool>, which is connected to the system clock.

Constructor

Access to signals within the Verilator ORPSoC model is provided by the OrpsocAccess class, an instance of which is passed to the constructor.

The implementation of OrpsocAccess is covered in the chapter on Verilator modeling Chapter 6. It provides a number of methods to access signals in the model. Those of particular interest here are:

getWbFreeze

Gives the bool value of the CPU control unit write back freeze signal, wb_freeze.

getWbInsn

Gives the uint32_t value of the CPU control unit write back instruction, wb_insn.

getGpr (regNum)

Get the value of the ORPSoC GPR regNum from the CPU register file in rf_a.

The constructor declares a SystemC method, checkInstruction, which will check for a l.nop instruction on the positive edge of each clock.

checkInstruction

This function is called on the positive edge of each clock cycle. It uses the accessor class getWbFreeze and getWbInsn functions to check for special l.nop instructions. It implements behavior as follows:

l.nop 1

Gets the value in GPR 3 using the accessor getGpr function, which is the return code from the function. Prints out a time stamp (using the SystemC function, sc_time_stamp) followed by a message that the simulation is exiting with the return code obtained. Then calls the SystemC function, sc_stop to terminate model execution.

l.nop 2

Gets the value in GPR 3 using the accessor getGpr function. Prints out a time stamp (using the SystemC function, sc_time_stamp) followed by a message reporting the value found in GPR 3.

l.nop 3

This is the printf function, but is not implemented. Prints out a time stamp (using the SystemC function, sc_time_stamp) followed by the text "printf".

l.nop 4

Gets the value in GPR 3 using the accessor getGpr function, the bottom 8 bits of which are the character to print. Prints the character to standard output, and then flushes it. This avoids any issues with C++ library buffering if redirecting the output during a slow run.

Embecosm divider strip