Languages

CommunityCategory: XMODELSimulating the AC transfer function characteristics of a circuit model

XMODEL

Simulating the AC transfer function characteristics of a circuit model

SA Support Team Staff 2019-04-02

Is there a way to measure the AC transfer characteristics of a circuit model in XMODEL?

1 Answers
Best Answer
SA Support Team Staff 2019-04-02

Yes! With the new 'probe_ac' primitive introduced since the 2019.04 release, it is very easy to measure the AC transfer characteristics of a given circuit model and plot its AC transfer function in frequency domain. I will explain the steps using a simple RC filter shown below.
First, connect the 'stim' output of the 'probe_ac' primitive to the circuit's input and connect the circuit's output to the 'resp' input of the 'probe_ac' primitive. And set the values of the 'freq_start' and 'freq_stop' parameters of the 'probe_ac' primitive instance to specify the frequency range, and set the values of the 'delay' and 'period' parameters to specify the start time and duration of the frequency sweeping period, respectively. Also, you can set the 'stim_dc' and 'stim_ac' parameters to specify the offset and amplitude of the small-signal AC stimulus, respectively.

When the XMODEL simulation starts, the 'probe_ac' primitive produces a sinusoidal stimulus of which frequency increases gradually within the specified range and for the specified duration. And the circuit model may respond differently to this stimulus input depending on the frequency value at each time point, as shown below. The 'probe_ac' primitive analyzes this response collected through its 'resp' input and stores the resulting AC transfer function data to the output file in a table format. Note that the simulation must run longer than the sum of 'delay' and 'period' values in order for the primitive to collect the entire transfer function.

You can also plot the measured AC transfer function in XWAVE by configuring an XMODEL testbench cellview using the 'meas_ac' script. To create a new testbench view, first select the "Open Testbench Editor" item under the GLISTER pull-down menu on the schematic editor window displaying the aforementioned RC filter testbench. When the XMODEL Testbench Editor window shows up, click the "Create New Testbench" icon button on the top right corner and give a name for the new testbench cellview (say, 'tb_ac'). And setup this new testbench cellview using the following steps.
On the first tab named "Simulation", make sure the simulation time is longer than the 'delay' + 'period' value of the 'probe_ac' primitive. Since the 'probe_ac' primitive automatically terminates the simulation when it finishes the measurement, the simulation time may be longer than necessary. Set the rest of the parameters properly for the circuit model being characterized.

On the second tab named "Design", leave the testbench schematic cellview as the only dependent cellview and set its cell name as the "Top-level Module". By default, the XMODEL Testbench Editor automatically adds a top-level testbench file for you (e.g. tb_ac.sv) when it creates a new testbench cellview. However, in this case, you need to delete that file and rename the top-level module as we are using the schematic cellview as the top-level testbench module.

Finally, on the third tab named "Commands", redefine the commands for running simulation and for plotting simulation results using the 'meas_ac' script instead of the default 'xmodel' launcher script. Particularly, the command 'meas_ac --plotwave' displays the AC transfer function plot in XWAVE when you press the 'Plot Waveforms' icon button located on the bottom right corner.

You are all set! Now you can run the XMODEL simulation by pressing the 'Run Simulation' icon button and plot the resulting AC transfer function in frequency domain by pressing the 'Plot Waveforms' icon button. When you do, XWAVE will display a plot as shown below.

For your information, you can also perform this AC analysis while sweeping a parameter value over a specified range. For instructions on how to perform parameter sweeps, please refer to "Sweeping parameter values in XMODEL simulations". The source code of the 'meas_ac' script is located in $XMODEL_HOME/example/bin/meas_ac.py in case you want to extend it and add more functionalities.