In order to transfer the output signals from the runtime component to the GUI, the simulator module must retrieve all the signal values on each of the output netlists of the runtime component. As seen from Figure 5.9, this is accomplished by the member function show_outputs(), which Runtime_Component inherits from its base class Component. This member function simply iterates over all the output ports of the runtime component and sends each of the output ports the message show_signals(), which they inherit from the Port base class.
As with the get_signal() and send_signal() member functions described earlier, the show_signals() messages eventually reach the output ports' respective wires, causing the show_signals() member function of each of the wires to be invoked. This Wire member function is presented in Figure 5.10. The function simply sends, to standard output, the output stanza header, the id attribute followed by the identifier of the netlist as well as the values attribute.
Figure 5.10: The show_signals() Member
Function of the Wire Class
It then calls the member function display_signals() to
actually retrieve and display the values of the signals and the times
that they occurred during the simulation. This function is presented in
Figure 5.11 and simply amounts to a traversal of all
the signals on the wire. The output operator, <<
, has been
overloaded by the Signal class to output the signal time and
value enclosed in braces. Note that only the changes in the output
signals are sent to standard output by this method.
Figure 5.11: The display_signals()
Member Function of the Wire Class
In the context of our particular example, because the circuit had only one output signal, only one output stanza is sent to standard output by the simulator engine. The stanza representing this output waveform is presented in Figure 5.12. Note that the time and value of the first signal is {_ X}. This represents the initial time and initial value of the output signal. Because of the command pipeline established by the GUI, all the output signals that the simulator engine generates on standard output will be picked up by the GUI, parsed and then displayed graphically. This final step is described in the next subsection.
Figure 5.12: Sample Protocol for an Output Signal Waveform