If we simulate any circuit and the open the plot window and press ‘ctrl+A’ we get a generic variable called ‘Time’. is this variable somehow accessible inside the C++ code block as well?
Hi, Sud.
Yes, the “t” parameter to the evaluation function is the current simulation timepoint being evaluated. This should match the waveform time axis exactly.
–robert
Anyway, please note that C block is executed at each timestep after Qspice finished solving the circuit.
Then, the output of Cblock will be sent out to the circuit at the following Timestep (aka, there is 1 Timestep delay between the input and out of C block
This is an example to explain @physicboy’s reply. The fundamental concept is that a native device in SPICE solves equations (e.g. Diode, Resistor etc…) and establishes input/output relationships at that simulation time. However, for a C++ block, its output can only be updated at the next simulation step (not during equation solving) [i.e. all device based on C++ block with this nature, including ¥-, €- and £-Device].
Therefore, within the C++ block, calculations are done exactly at that simulation time, but the output can only be updated at the next simulation time step. Generally, this explanation goes a bit beyond your initial question. In most cases, not being aware of this is not an issue, but it is crucial information to understand.
TimeInC.qsch (19.9 KB)
timeinc_x1.cpp (1.1 KB)
This is a reference
What triggers a C-block to run? - QSPICE - Qorvo Tech Forum
