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

6.2.4.  Good Coding Practice when Accessing Verilator Signals

With the need to include many headers and use several depths of indirection, accessing Verilator signals can make for very cluttered code.

The solution is to define a separate C++ accessor class, which provides this access functionality, and makes the signals required available through concisely named accessor functions.

This is the purpose of the OrpsocAccess in this application note. The SystemC model needs access to two signals (wb_freeze and wb_insn) and the CPU register file, whose hierarchical references are:


The OrpsocAccess provides accessors for each of these. Its constructor is passed a pointer to the top level SystemC module and saves pointers to the C++ modules:

OrpsocAccess::OrpsocAccess (Vorpsoc_fpga_top *orpsoc_fpga_top)
  or1200_ctrl = orpsoc_fpga_top->v->or1200_top->or1200_cpu->or1200_ctrl;
  rf_a        = orpsoc_fpga_top->v->or1200_top->or1200_cpu->or1200_rf->rf_a;


The accessor functions, getWbFreeze, getWbInsn and getGpr then use these. For example:

OrpsocAccess::getWbInsn ()
  return  (or1200_ctrl->get_wb_insn) ();

Embecosm divider strip