Simulation Fundamentals: Simulation in NI Multisim

Publish Date: Apr 13, 2012 | 24 Ratings | 3.75 out of 5 | Print


Circuit simulation is widely regarded as a critical step in the design flow. SPICE simulation is the de facto standard for analog circuit simulation. Over the years, many enhancements and additions to SPICE have extended its functionality and range of applicability. NI Multisim adds to the versatility of SPICE by incorporating a mixed-mode simulator, allowing fast simulation of both analog and digital components together. The purpose of this document is to highlight the fundamental concept of mixed-mode simulation in NI Multisim. Mixed-mode simulation is built upon analog and digital simulation technology which co-exist and allow seamless, complete circuit design and simulation.

Table of Contents

  1. SPICE-based Analog Simulation
  2. Event based Digital Simulation
  3. The NI Multisim Approach
  4. Mixed-Mode Simulation
  5. Conclusion

1. SPICE-based Analog Simulation

Multisim’s analog simulation engine is based on SPICE version 3F5, the latest version of the world’s most popular public domain analog circuit simulator. SPICE originated from the University of California at Berkeley.

Although the Multisim development team has made many enhancements to the overall SPICE engine, the core algorithms remain intact. This section will briefly define analog simulation and describe how the core algorithms work.  

Basic Simulation

The analog circuit world is concerned about the knowledge of two quantities: voltage and current. Finding these quantities is the primary objective for SPICE. At its core, the SPICE simulator solves basic resistive circuits using Kirchoff’s Current Law (KCL) in much the same way a student in a circuits class would. Consider the purely resistive circuit shown below in Figure 1.

Figure 1 - Resistive Circuit

To solve the circuit, the simulator systematically forms a matrix in accordance with KCL and then proceeds to solve for the unknown quantities using various algebraic techniques such as Gaussian elimination and sparse matrix techniques.

One major complication with analog circuits becomes obvious when we consider adding another resistor to the existing circuit. It is not possible to directly use the solution of the original circuit to obtain a new solution. Therefore, a fundamental problem of solving analog circuits is that the addition of every component to the design represents a load to the circuit and affects all nodal voltages and currents.


Non-linear components, such as the diode shown in the circuit below, present another problem when solving analog circuits.

Figure 2 - Diode Circuit


It is impossible to solve the KCL nodal equations for the above circuit using basic algebraic techniques. This is a result of the diode’s non-linear voltage/current equation ( I=Is(e^(qV/NkT) ). In fact because of the use of a transcendental function in the equation (i.e. the function e^x), an exact solution does not even exist. In this situation an engineer must approximate the solution by making an initial guess at an answer and then improving the solution with successive calculations built upon this guess. This is called an iterative process.

SPICE simulation uses the Newton-Raphson iterative algorithm to solve circuits with non-linear I/V relationships.

For example, consider the Newton-Raphson process of solving the diode-resistor circuit shown in Figure 3 below.

Figure 3 - Newton-Raphson Solution

The solution to the circuit is found at the intersection of the Load line and the Diode’s I/V line. To find this intersection, SPICE begins by making a guess at the initial diode voltage. The diode is then linearized about this “guessed” value using the derivative of I/V curve. Hence, the linearization of the diode’s behavior effectively models the diode as a resistor in series with a voltage source.

With this new diode model, a KCL matrix is formed and the linear circuit can easily be solved. The solution becomes the entry point to the next iteration of the Newton-Raphson algorithm and the process continues until the difference in successive solutions becomes very small. When this occurs, the circuit solution is said to converge.

Non-convergence has always been one of the biggest hurdles in analog simulation. This inability for a circuit to converge means that the Newton-Raphson algorithm output cannot settle to a consistent set of values after numerous iterations. This is generally a result of strong non-linearity and discontinuity in the equations that describe analog parts

Reactive Elements

The final complication in solving analog circuits comes from reactive elements, namely capacitors and inductors, whose I/V relationships are described by differential equations. The simulator uses numeric integration methods to approximate the state of the reactive elements as a function of time.

For example, the Backward Euler approximation for a capacitor uses the time step, previous voltage, and present current to approximate the present voltage, as shown by the relationship below.

This approximation allows for the discretization of the capacitor using the following linear companion mode in Figure 4.

Figure 4 - Discretization of a Capacitor

Local Truncation Error (LTE) is an important measure of the accuracy of a numerical integration method. LTE is the first discarded term of the Taylor series expansion of an integration formula. If the LTE is measured to be too large, SPICE will decrease ∆t (the time step) to place LTE back within limits. In addition to accuracy, numerical integration algorithms have the property of stability. However, measuring stability is impossible because the simulator cannot distinguish between regular and irregular circuit behavior.

SPICE offers the Gear and Trapezoidal integration methods to approximate the state of the reactive elements. Although for most circuits, both methods will provide almost identical results, it is generally regarded that the Gear method is more stable, but trapezoidal method is faster and more accurate.

In general, time step control is an essential part of the SPICE simulation process. The time step not only determines the accuracy, but also the simulation speed and the ability of a circuit to converge.

Consider a case when quantities in a circuit begin moving very fast. With an excessively large time step the simulator may end up in a vastly changed circuit state which may cause convergence problems. The SPICE simulator contains sophisticated algorithms to dynamically control the time steps. 

To summarize the SPICE analog simulation process, the following flow chart in Figure 5 below shows the states that the simulator traverses when performing a transient analysis. This is the most complicated analysis SPICE can perform because complications from both non-linear elements and numerical integration of reactive elements must be dealt with.

Figure 5 - Analog SPICE simulation process

Back to Top

2. Event based Digital Simulation

Digital circuit simulation is vastly different from analog circuit simulation. Analog simulation refers to the core SPICE concepts such as solving matrices, linearization, and numerical integration. In Multisim digital circuit simulation occurs at a more abstract level.

In digital simulations, there is no concept of KCL nodal equations, nor voltage nor current. Discrete states are determined by the current states, previous states, inputs, and timing constraints. Also, a distinction exists between an input and an output port in a digital component whereas analog components exhibit forward and reverse transmission properties. The most popular digital simulation method, which is used by Multisim, is event-driven. As the name implies, this type of simulator only processes functional evaluation when an event occurs at the input of a component.

All events are successive in the digital simulator’s time-line. For each event, a routine inside the appropriate component executes and a resulting state may be stored and a new event may be scheduled. When no more events are scheduled, the simulation is finished.

Digital simulation can therefore be viewed as being composed of three parts:

  1. Event scheduler and caller - The scheduler maintains a queue of digital events and makes calls to routines of a digital device
  2. I/O state controller - The state controller controls nodes connecting digital devices.
  3. Functional description interpreter - The interpreter parses and compiles functional behavior of logic   

Back to Top

3. The NI Multisim Approach

A group at Georgia Tech enhanced SPICE to include an event-driven algorithm and add code modeling ability. The resultant simulation technology was named XSPICE. Multisim includes XSPICE, and makes use of these enhancements, particularly for digital simulation.

The XSPICE event-driven algorithm is what constitutes parts 1 and 2 (Event Scheduler and I/O State Controller) of Multisim’s digital simulator. The I/O nodes of digital devices may be in one of 12 digital states which are defined by:

  • Separate levels (3): HI, LO, UNKNOWN 
  • Each of the above levels is further distinguished by drive strengths: STRONG, RESISTIVE, HI-IMPEDANCE, UNDETERMINED

XSPICE does not support a functional description interpreter which is a traditional part of a digital simulator. The creators of XSPICE created an environment that allows for the creation of devices (both analog and digital) in the form of code models which are written in the C programming language. The code models contain XSPICE Macros and APIs to link to the simulation kernel, as well as contain a functional description of a device’s behavior. It is the third party C-compiler (used to compile these code models) that acts as the functional description interpreter. Creating devices using this low level approach requires significant knowledge about XSPICE.

Multisim has enhanced the digital simulator by adding three special modules which work to simplify the creation of digital devices. These modules communicate with the XSPICE event-driven algorithm through special shell code model devices. Each of the modules supports a different digital behavior description that is open to users.


  1. Digital table HDL module – interprets Multisim’s proprietary tabular format HDL syntax. The HDL is convenient for describing simple combinational and sequential logic.
  2. VHDL module – interprets a specially compiled VHDL file, called a .vx file. The compiler is included with MultiVHDL. 
  3. Multisim MCU module – emulates the behavior of PIC and 8051 microcontroller architectures using instructions supplied in a .hex file. An Assembly and C compiler is included with the Multisim MCU module.

Back to Top

4. Mixed-Mode Simulation

When both the analog simulator and the digital simulator are active in the same circuit, the overall simulation is termed mixed-mode simulation.

At a circuit level, analog devices are interfaced to digital devices using special hybrid elements called bridges which translate digital states to analog voltage values, and vice versa.

This bridge is also responsible for scheduling new analog solve steps and digital events. 

Consider the following simple example below in Figure 6, the case of a Digital-to-Analog (D/A) bridge:

Figure 6 - Simple Digital-to-Analog Example

Now consider the following schedule of simulation events in Figure 7.

Figure 7 - Event Scheduler

Assume that the SPICE time-step control algorithm has scheduled an analog solve event at time t3 and the digital simulator has an event scheduled at time t1 for the NOT gate (U1). After the NOT gate evaluates at time t1 (as a digital event), an event is generated for the bridge at time t2 to account for the digital delay. This means that just after time t2, the voltage value at the gates of the transistors will change, requiring an analog solve. The D/A bridge schedules this analog solve event at the time that it drives the transistors with the new voltage value.

The diagram in Figure 8 below shows the interconnection of important parts in Multisim’s mixed-mode simulation. With the exception of connections running from code model to code model, all were covered in this document.

Figure 8 - Mixed-mode simulation

Back to Top

5. Conclusion

NI Multisim is a SPICE-based simulator that provides many custom extensions to the language. These extensions allow mixed-mode simulation with digital, analog, MCU, and VHDL models all co-existing. By providing powerful bridging technology to enable such diversity in simulation, engineers now have an exceptional ability to simulate unique and niche applications. 

Multisim for free for 30 days Multisim with an Interactive Demo
Free Courseware for Circuits About the NI Electronics Education Platform

Back to Top

Bookmark & Share


Rate this document

Answered Your Question?
Yes No