https://open-source-silicon.dev logo
#analog-design
Title
# analog-design
p

Pepijn de Vos

11/09/2021, 12:16 PM
Is there a way to parse the spice files and get metadata? Some ngspice command or something, or maybe even PySpice.
t

Tim Edwards

11/09/2021, 2:57 PM
What kind of metadata are you looking for?
p

Pepijn de Vos

11/09/2021, 3:34 PM
Hm, to begin with just a list of all the models and maybe their ports/parameters.
s

Stefan Schippers

11/09/2021, 4:45 PM
you can leverage the ngspice parser and issue this command:
listing deck expand > some_file
to get a flattened spice netlist with all includes (all models) and parameter passing resolved. the file format is a spice syntax netlist, but with no more subcircuits, so just primitive elements with numeric parameters (resistors, capacitors, mos transistors, I/V sources etc) and .model lines.
Consider that if you do this on sky130 netlist the listing is huge due to the model complexity.
p

Pepijn de Vos

11/09/2021, 4:47 PM
Hm, but in sky130 the "models" are actually subcircuits right?
s

Stefan Schippers

11/09/2021, 4:47 PM
yes, these get flattened as well, down to the spice primitives
p

Pepijn de Vos

11/09/2021, 4:49 PM
Okay maybe I should have been clearer, what I actually want is the user-facing "models" ie subcircuits. So that command does help resolving the includes, but doesn't get me much closer to getting the the "stuff that you can use"
Like, when you made the sky130 xschem library, did you just manually add the right models?
s

Stefan Schippers

11/09/2021, 4:55 PM
no, the produced netlist will just have a
.lib /path/to/sky130A/libs.tech/ngspice/sky130.lib.spice tt
all components in library reference the spice model by its name (for example nfet_01v8_lvt), the definition of these model is in above file which is included with a .lib
btw the listing expand on ngspice is not a good way to go if you want to parse a big netlist, since ngspice code base is full of fixed sized arrays, in particular line length for listing is hardcoded as 4096 (it was 512, incremented after user complaining, still gets overrun in sky130), this limit easily truncated when dumping a flattened netlist on sky130.
anyway flattening a netlist (if you want to remove hierarchy and parameter passing) and including all the files (sky130 is a pile of files including files including...) is not extremely difficult.