Languages

CommunityCategory: XMODELCan XMODEL handle systems containing feedback loops?

XMODEL

Can XMODEL handle systems containing feedback loops?

SA Support Team Staff 2019-03-15

Many behavioral simulators I’ve seen cannot properly handle systems with feedbacks. For instance, the naïve Real-Number Verilog code below modeling an operational amplifier with resistive feedback (i.e. inverting amplifier) shows two problems. First, the simulation is very slow due to a large number of events being triggered and second, the output value diverges to infinity due to the numerical instability of computing the responses in a forward-Euler manner. Can XMODEL handle systems with feedback loops?

module invamp;

real Vin, Vout, Vx;

parameter real R1 = 1000.0;
parameter real R2 = 2000.0;
parameter real Av = 10.0;
parameter real Vos = 0.1;

initial begin
    Vin = 1.0;
    Vout = 0.0;
end

always begin
    #1;
    Vx = (R1 * Vout + R2 * Vin) / (R1 + R2);
    Vout = Av * (0 - Vx - Vos);
    $display("Vout = ", Vout);
end

endmodule
1 Answers
Best Answer
SA Support Team Staff 2019-03-15

Yes, XMODEL can handle circuits and systems with feedbacks. The problems you described are in fact very common ones when simulating circuits or systems using forward Euler method. When you compute each signal value in the order of propagation using the past values of the other signals, you can encounter many situations where the simulated results are unstable even though the system itself is known to be stable (refer to https://en.wikipedia.org/wiki/Euler_method). For this reason, SPICE simulators use trapezoidal rule.

There are two ways you can model analog circuits/systems in XMODEL: one is to model them as signal-flow models using 'function' primitives in which the signals propagate in only one direction, and the other is model them as conservative-system models using 'circuit' primitives in which the voltages and currents are determined simultaneously to satisfy the Kirchhoff Voltage/Current Laws. The signal-flow models using the former method may suffer from the same problems with the example Real-Number Verilog model since the system is being simulated in the forward-Euler fashion. However, the conservative-system models using the circuit primitives are capable of fast and accurate event-driven simulation since XMODEL basically treats the whole circuit with the feedback as a single system.

Simply put, if you have a circuit enclosed within a continuous-time feedback as this inverting amplifier example, it is best to model the components within the feedback loop using circuit primitives. And XMODEL is the only solution that offers circuit primitives in SystemVerilog.