Introduction to SystemC AMS and Models of Computation
An overview of the SystemC Analog/Mixed-Signal (AMS) extensions and its three primary Models of Computation (MoCs).
Introduction to SystemC AMS and Models of Computation
Welcome to the SystemC Analog/Mixed-Signal (AMS) extensions. Standard SystemC models hardware using a Discrete-Event (DE) simulation kernel, which is excellent for digital logic. However, modern systems—such as RF communication interfaces, automotive engine controllers, and power management ICs—tightly interweave digital control logic with continuous-time analog behavior.
The SystemC AMS extensions (IEEE 1666.1) bridge this gap by enabling the co-simulation of discrete-event digital behavior alongside continuous-time and discrete-time analog equations.
Why SystemC AMS?
Traditional SPICE simulators calculate voltages and currents at the transistor level, which is far too slow for system-level verification where a digital firmware boot might take millions of clock cycles. SystemC AMS abstracts the analog behavior into higher-level mathematical models, allowing execution speeds that are orders of magnitude faster than SPICE, while maintaining accuracy appropriate for architectural exploration and software bring-up.
The Three Models of Computation (MoCs)
To handle the diverse requirements of analog modeling, the SystemC AMS standard defines three distinct Models of Computation (MoCs).
1. Timed Data Flow (TDF)
The Timed Data Flow (TDF) MoC is the workhorse of SystemC AMS. It models systems using discrete-time sampled signals. TDF is incredibly fast because it relies on static scheduling. Before the simulation starts, the TDF solver analyzes the data rates, timesteps, and delays of all connected TDF modules and creates a fixed mathematical execution schedule.
- Use Case: Digital Signal Processing (DSP), baseband communications, and abstract control loops.
2. Linear Signal Flow (LSF)
The Linear Signal Flow (LSF) MoC defines behavior through continuous-time mathematical relations (differential and algebraic equations). You build an LSF model by connecting predefined primitive blocks like adders, integrators, and differentiators. The AMS linear solver evaluates these equations dynamically.
- Use Case: Analog control systems, Laplace-domain transfer functions, and abstract filters.
3. Electrical Linear Networks (ELN)
The Electrical Linear Networks (ELN) MoC provides a traditional node-based electrical modeling approach. It uses conservative continuous-time equations based on Kirchhoff's Voltage and Current Laws. You connect electrical primitives like resistors, capacitors, inductors, and voltage/current sources via terminals.
- Use Case: Modeling electrical loads, power drivers, and basic RLC circuits.
Clusters and Solvers
SystemC AMS introduces the concept of a cluster. When you instantiate and connect AMS modules, the AMS kernel traverses the netlist during elaboration and groups connected modules of the same MoC into clusters. Each cluster is assigned its own mathematical solver (e.g., a Linear Solver for ELN/LSF, or a Static Scheduler for TDF).
These solvers run synchronously with the standard SystemC DE kernel, ensuring that time progresses accurately across both the digital and analog domains.
Complete Example: Your First AMS Simulation
The following complete, compilable example demonstrates how to set up a basic SystemC AMS simulation. It uses the TDF MoC to generate a sine wave, scales it by a constant, and traces the output to a file that can be viewed in a waveform viewer (like GTKWave).
#include <systemc>
#include <systemc-ams.h>
#include <cmath>
// 1. A TDF Source Module generating a Sine Wave
SCA_TDF_MODULE(SineSource) {
sca_tdf::sca_out<double> out;
double amplitude;
double frequency;
SCA_CTOR(SineSource) : amplitude(1.0), frequency(1000.0) {}
// set_attributes is called by the solver during elaboration
void set_attributes() {
// Define the sampling period (timestep)
set_timestep(10.0, sc_core::SC_US);
}
// processing is called at every timestep according to the static schedule
void processing() {
double t = get_time().to_seconds(); // Get current simulation time
double val = amplitude * std::sin(2.0 * M_PI * frequency * t);
out.write(val);
}
};
// 2. A TDF Sink Module acting as an amplifier
SCA_TDF_MODULE(Amplifier) {
sca_tdf::sca_in<double> in;
sca_tdf::sca_out<double> out;
double gain;
SCA_CTOR(Amplifier) : gain(2.5) {}
void set_attributes() {
// TDF automatically propagates timesteps.
// We do not strictly need to set the timestep here because it will
// inherit the 10us timestep from the SineSource through the connected signal.
}
void processing() {
// Read the input, apply gain, write to output
out.write(in.read() * gain);
}
};
int sc_main(int argc, char* argv[]) {
// 3. Declare AMS Signals to connect the modules
sca_tdf::sca_signal<double> sig_sine("sig_sine");
sca_tdf::sca_signal<double> sig_amp("sig_amp");
// 4. Instantiate modules
SineSource src("src");
src.out(sig_sine);
Amplifier amp("amp");
amp.in(sig_sine);
amp.out(sig_amp);
// 5. Setup Tracing
// SystemC AMS provides specialized tracing functions for analog waveforms.
// This creates a standard VCD (Value Change Dump) file.
sca_util::sca_trace_file* tf = sca_util::sca_create_vcd_trace_file("ams_waveforms");
// Trace the signals
sca_util::sca_trace(tf, sig_sine, "SineWave");
sca_util::sca_trace(tf, sig_amp, "AmplifiedWave");
// 6. Start the simulation
std::cout << "Starting AMS Simulation...\n";
sc_core::sc_start(2.0, sc_core::SC_MS); // Simulate for 2 milliseconds
std::cout << "Simulation Complete.\n";
// 7. Cleanup
sca_util::sca_close_vcd_trace_file(tf);
return 0;
}In the next tutorial, we will dive deeper into the rules and advanced callbacks of the Timed Data Flow (TDF) model.
Comments and Corrections