MCPcopy Create free account
hub / github.com/SLiCAP/SLiCAP_python / _parseNetlist

Function _parseNetlist

SLiCAP/SLiCAPyacc.py:175–278  ·  view source on GitHub ↗

Netlist parser: converts a netlist to the active circuit object. The name of the active circuit object is the last name in the global _CIRCUITNAMES: _CIRCUITNAMES[-1]. The circuit object itself is stored in a dictionary that depends on the variable cirType. :param netlist: Netl

(netlist, name, cirType)

Source from the content-addressed store, hash-verified

173 _checkReferences(_USERCIRCUITS[cir])
174
175def _parseNetlist(netlist, name, cirType):
176 """
177 Netlist parser: converts a netlist to the active circuit object.
178 The name of the active circuit object is the last name in the global
179 _CIRCUITNAMES: _CIRCUITNAMES[-1]. The circuit object itself is stored in a
180 dictionary that depends on the variable cirType.
181
182 :param netlist: Netlist of the circuit
183 :type netlist: String
184
185 :param name: Name of the (sub)circuit, defaults to 'main'
186 :type name: String (no whitespace characters)
187
188 :param cirType: pointer to the dictionary to which the circuit elements
189 and commands will be written.
190 :type cirType: str
191
192 :return: None
193
194 :rtype: Nonetype
195 """
196 global _CIRCUITNAMES
197 _CIRCUITNAMES.append(name)
198 _createCircuit(name, cirType)
199 lines, errors = _tokenize(netlist)
200 if errors == 0:
201 if name == 'main' and lines[0][0].type in _TITLE:
202 title = lines[0][0].value
203 if lines[0][0].type == 'QSTRING':
204 # Remove the double quotes, this conflicts with HTML files
205 title = title[1:-1]
206 _addTitle(name, cirType, title)
207 lines = lines[1:]
208 for line in lines:
209 #print("NAMES:", _CIRCUITNAMES, name, cirType, list(_CIRCUITS.keys()))
210 if line[0].type == "ID":
211 deviceType = line[0].value[0].upper()
212 if deviceType != 'X':
213 _parseElement(line, name, cirType)
214 else:
215 _parseSubcircuitElement(line, name, cirType)
216 elif line[0].type == "CMD":
217 cmdType = line[0].value.upper()
218 if cmdType == "SUBCKT":
219 if len(line) > 1:
220 if line[1].type == "ID":
221 cirName = line[1].value
222 if cirName not in _CIRCUITNAMES:
223 _createSubCKT(line, cirName, cirType)
224 _CIRCUITNAMES.append(cirName)
225 name = cirName
226 else:
227 _printError("Error: Hierarchical loop involving '" + line[1].value + "'.", line[1])
228 _addErrors(name, cirType, 1)
229 else:
230 _printError("Error: Expected a circuit title.", line[1])
231 _addErrors(name, cirType, 1)
232 else:

Callers 3

_compileSLiCAPLibrariesFunction · 0.85
_compileUSERLibraryFunction · 0.85
_checkCircuitFunction · 0.85

Calls 12

_tokenizeFunction · 0.90
_printErrorFunction · 0.90
_createCircuitFunction · 0.85
_addTitleFunction · 0.85
_parseElementFunction · 0.85
_parseSubcircuitElementFunction · 0.85
_createSubCKTFunction · 0.85
_addErrorsFunction · 0.85
_addSourceFunction · 0.85
_addDetectorFunction · 0.85
_addLGrefFunction · 0.85
_parseCommandFunction · 0.85

Tested by

no test coverage detected