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:
orpsoc_fpga_top.or1200_top.or1200_cpu.or1200_ctrl.wb_freeze orpsoc_fpga_top.or1200_top.or1200_cpu.or1200_ctrl.wb_insn orpsoc_fpga_top.or1200_top.or1200_cpu.or1200_fr.rf_a
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:
uint32_t OrpsocAccess::getWbInsn () { return (or1200_ctrl->get_wb_insn) (); }