GNU Octave and Circuit Simulation

I’m a mathematics graduate and for the past two weeks I’ve been an intern with Embecosm, charged with looking into open source alternatives to Matlab and Simulink, particularly for silicon chip modeling.

About GNU Octave

GNU Octave is an open source Matlab alternative, however, it lacks a Simulink-like companion program. Octave is of particular interest as it is made to be similar to Matlab, to allow for easy porting between them.

Candidates as alternatives to Simulink

There are a number of packages that offer open source Simulink-like functionality outside of Octave. Here is a brief outline of the ones that I came across:

  • Scilab is another Matlab analogue but unlike Octave it already has a Simulink like package Xcos;
  • Qucs is a circuit simulator, that whilst still a work in progress, is a good tool for many circuit based applications;
  • The gEDA suite is a collection of compatible programs for electronic design and simulation it operates by producing a schematic with gschem and exporting it to ngspice via gnelist and gspiceui. Each of these programs have their own strengths and weaknesses but for an open source Simulink-like Scilab’s Xcos is the clear favorite at this time.

Octave Simulation

GNU Octave has powerful numerical tools, so hypothetically it is able to run simulations, but is impractical to do so as it would require the end user to write large new scripts for each simulation.

There are three main requirements of a Simulink-like for Octave: firstly it has to have an intuitive user interface to allow for easy editing and good readability; secondly the information contained in the block diagram need to be sent to Octave in a way that it can understand; and finally, a library of blocks and corresponding functions.

The modularity of the gEDA suite allows the possibility to co-opt some of its functionality to provide the first two requirements. Gschem already allows users to create custom circuit symbols and as it uses information light symbols, we can add Octave-specific information and still get the netlist via gnetlist. Once the netlist is obtained, it then remains for it to be able to be interpreted by Octave via a function. This last requirement has no easy solution and will mean manually writing the function library.

Basic gEDA Suite Simulation

In order to demonstrate why I think that gEDA provides a good starting point for a GNU Octave-based Simulink-like solution, I shall use a simple example.

First, I created a circuit schematic using gschem and went for a simple RC circuit with a 5 volt power supply. The 1 picoOhm resistor is required to ensure that the capacitor doesn’t produce unexpected errors.


This produces the netlist:

R1 2 3 1p
R2 1 4 10K
C1 3 4 100n
V1 2 1 5

There are multiple ways to input the simulation parameters, but my preferred method is with gspiceui.


This produces the following:

* Component Definitions
C1 3 4 100n
R1 2 3 1p
R2 1 4 10K
V1 2 1 5

* NG-Spice Simulation Commands
.TRAN 100.00u 8.00m 0.00m UIC


This is where I feel that the Octave interface would be best placed as we have all of the parameters set up, but none of the actual simulation has been done.

The simulation is then run with ngspice (by clicking on the cog icon). In order to plot the results I imported them into Octave using the load command (the filename should be Using the plot command the following figure was produced:


This is a as expected.

In conclusion

There are a good number of alternatives for Simulink especially in the area of low level circuit design but of the ones I have tried Scilab/Xcos have functionality closest to Simulink. Octave remains an area of interest but there is a lot of work to do to get a working Simulink-like for it.