Introduction to the SpectreNetlistParser

When working with netlists or creating EDA workflows, engineers and designers frequently encounter the need to manipulate or analyze circuit designs expressed in netlist files. Spectre and/or SPICE format netlists define the components and connections of a circuit in a text format. The SpectreNetlistParser is a specialized tool designed to parse these netlist files into an Abstract Syntax Tree (AST), transforming raw netlist data into a structured and easily navigable format.

Why Use SpectreNetlistParser?

The SpectreNetlistParser enhances the efficiency and accuracy of circuit design and simulation processes in several key ways:

  • Ease of Use: It automates the conversion of text-based netlist files into ASTs, which accurately represent the hierarchical structure of a circuit, including its components and connectivity.
  • Accuracy: The parsed netlist accurately maintains the original netlist structure including all comments and whitespace in a structured format.
  • Integration and Flexibility: The parser seamlessly integrates with Julia, enabling it to be used in a wide range of applications.

By using SpectreNetlistParser, users can avoid the error-prone process of manually parsing complex netlist syntax and can directly interact with the structure of the netlist programmatically. This leads to more robust design practices and can significantly speed up the development cycle in electronic design projects.

Getting Started with SpectreNetlistParser

To utilize SpectreNetlistParser in your projects, ensure Julia is installed on your system along with CedarSim. This tool is designed to fit smoothly into any Julia-based project or script where handling Spectre netlist files is required.

Basic Usage

The following example illustrates the basic usage of the SpectreNetlistParser:

To read in a Spectre format netlist:

using CedarSim: SpectreNetlistParser
# Parse the netlist file
ast = SpectreNetlistParser.parsefile("inverter.scs")

# Now `ast` holds the abstract syntax tree of the netlist

or in SPICE format:

using CedarSim.SpectreNetlistParser: SPICENetlistParser
# Parse the netlist file
ast = SPICENetlistParser.parsefile("inverter.spice")

# Now `ast` holds the abstract syntax tree of the netlist

In this example, parsefile is a function that reads a netlist file named inverter.scs (or inverter.spice) and parses it into an abstract syntax tree. The ast object can then be used to explore, analyze the circuit described in the netlist.

SPICE Syntax Support

SPICE defines the connections between circuit elements, hence the files being referred to as "netlists". CedarEDA supports the following syntax elements in SPICE, please file an issue on our public issue tracker for SPICE features that are important to you, but are not yet implemented.

SPICE Elements

TypeElementSupported Arguments
Voltage SourceVDC, SIN, PULSE, PWL
Current SourceIDC, SIN, PULSE, PWL
Ideal ResistorR
Ideal CapacitorC
Ideal InductorL
MOSFETM
Subcircuit CallXInstance parameter values

SPICE Commands

Supported CommandsExample
.ac.AC DEC 10 fmin fmax
.dc.NOISE V(vout) v0 0
.end.end
.global.global 0
.include.include "file.sp"
.lib.lib "models.lib" tt
.model.model nmos nmos ...
.op.op
.option.option RELTOL=1e-5
.options.options RELTOL=1e-5
.param.param c1 = 1p
.parameter.parameter rl = 10k
.parameters.parameters a=10 b=12
.print.print vin vout
.subckt, .ends.subckt foo n1 n2 n3 x=1 y=10 ...
.tran.tran 1p 1u

SPICE Numbers

Numbers in SPICE are case insensitive and support the following scaling suffixes:

SuffixScale
T10^12
G10^9
MEG10^6
k10^3
m10^-3
mil25.4u
u10^-6
n10^-9
p10^-12
f10^-15
a10^-18

SPICE Equations

The following mathematical operators are supported:

OperatorMeaning
+Addition
-Subtraction
*Multiplication
/Division
**Exponent

The following mathematical functions are supported:

FunctionDescription
min(x, y)Minimum of x and y
max(x, y)Maximum of x and y
abs(x)Absolute value of x
log(x)Logarithm of x to base ℯ
log10(x)Logarithm of x to base 10
sgn(x)Sign of x: x>0 = 1, x<0 = 1, x==0 = 0
sign(x, y)Magnitude of x with the sign of y: sgn(y)*abs(x)
exp(x)ℯ^x
pow(x,y)x to the power of y
pwr(x,y)Signed power: sgn(x)*(abs(x)^y)
sqrt(x)Square root of x
sinh(x)Hyperbolic sine of x
cosh(x)Hyperbolic cosine of x
tanh(x)Hyperbolic tangent of x
sin(x)Sine of x (in radians)
cos(x)Cosine of x (in radians)
tan(x)Tangent of x (in radians)
atan(x)Inverse tangent of x
arctan(x)Inverse tangent of x
asinh(x)Inverse hyperbolic sine of x
acosh(x)Inverse hyperbolic cosine of x
atanh(x)Inverse hyperbolic tangent of x
int(x)Integer portion of x
nint(x)Round to nearest integer to x
floor(x)Integer value less than or equal to x
ceil(x)Integer value greater than or equal to x

Supported Spectre Syntax

Spectre refers to the netlist language used by the Spectre Circuit Simulator and is closely related to SPICE. SpectreNetlistParser supports the following syntax elements in Spectre, please file an issue on our public issue tracker for Spectre features that are important to you, but are not yet implemented.

Spectre Elements

TypeSpectre Element
Voltage Sourcevsource
Current Sourceisource
Ideal Resistorresistor
Ideal Capacitorcapactor
Ideal Inductorinductor
Behavioral Sourcebsource

Spectre Numbers

Numbers in Spectre support the following scaling suffixes:

SuffixScale
T10^12
G10^9
M10^6
K10^3
k10^3
_1
%10^-2
c10^-2
m10^-3
u10^-6
n10^-9
p10^-12
f10^-15
a10^-18

Spectre Equations

The following mathematical operators are supported:

OperatorMeaning
+Addition
-Subtraction
*Multiplication
/Division
^Exponentiation
!Boolean not
==Boolean equal
!=Boolean not equal
>Greater than
<Less than
<=Less than or equal
>=Greater than or equal

The following mathematical functions are supported

FunctionDescription
max(x, y)Maximum of x and y
min(x, y)Minimum of x and y
abs(x)Absolute value of x
ln(x)Logarithm of x to base ℯ
log(x)Logarithm of x to base ℯ
log10(x)Logarithm of x to base 10
exp(x)ℯ^x
pow(x,y)x to the power of y
sqrt(x)Square root of x
sinh(x)Hyperbolic sine of x
cosh(x)Hyperbolic cosine of x
tanh(x)Hyperbolic tangent of x
sin(x)Sine of x (in radians)
cos(x)Cosine of x (in radians)
tan(x)Tangent of x (in radians)
atan(x)Inverse tangent of x
arctan(x)Inverse tangent of x
asinh(x)Inverse hyperbolic sine of x
acosh(x)Inverse hyperbolic cosine of x
atanh(x)Inverse hyperbolic tangent of x
int(x)Integer value less than or equal to x
floor(x)Integer value less than or equal to x
ceil(x)Integer value greater than or equal to x

Spectre Commands

Supported CommandsExample
ahdl_includeahdl_include "opamp.va"
dcdcOp dc write="spectre.dc"
globalglobal 0
includeinclude "inverter.scs"
infofinalTimeOP info what=oppoint where=rawfile
inline subcktinline subckt pfet (d g s x) ...
modelmodel mnfet bsimcmg type=n ...
noisenoise noise start=10Hz stop=10M dec=1k
optionssaveOptions options save=allpub
parametersparameters rl=10k freq=1M
pnoisepnoise pnoise start=10Hz stop=10M dec=1k
psspss pss fund=100k maxacfreq=4M
spsp sp ports=[PORT0] start=1G stop=9G lin=101
subckt, endssubckt dff A CLK OUT VCC ...
savesave VOUT
trantran tran stop=1u start=0 step=1p

Conclusion

The SpectreNetlistParser provides a powerful, efficient way to handle Spectre netlists, transforming them from simple text files into structured, programmatically manageable data. This capability is crucial for accelerating development cycles and enhancing the accuracy and flexibility of circuit design and analysis. Whether for basic modifications, in-depth analyses, or comprehensive reporting, SpectreNetlistParser is an essential tool in the electronic design automation toolkit.