SLiCAPyacc.py¶
SLiCAP netlist parser: functions for converting a netlist into a circuit object.
Tokenizes the netlist and creates a ‘flattened’ circuit object.
Imported by the module SLiCAPexecute.py.
-
addGlobals(parDefs, par)¶ Adds value or expression of the parameter ‘par’ as well as the parameters in this expression given in the library to the parameter definitions in the dict ‘parDefs’.
Parameters: - parDefs (dict) – Dictionary with key-value pair of parameters to which the definition of the parameter ‘par’ needs to added.
- par (sympy.core.symbol.Symbol) – Parameter of which the definition needs to be added to the dict ‘parDefs’.
Returns: parDefs: dict with added parameter definitions
Return type: dict
-
addUserLibs(fileNames)¶ Adds pre compiled user libraries to LIB.
Overwrites existing keys in LIB.
Parameters: fileNames (list) – List with file names (str) of user libraries.
-
checkCircuit(fileName)¶ Checks a netlist and converts it into a circuit object.
Parameters: fileName – Name of the netlist file, relative to the circuit directory. Returns: cir Return type: SLiCAPprotos.circuit
-
expandCircuit(elmt, parentCircuit, childCircuit)¶ Expands an element ‘elmt’ of ‘parentCircuit’ based on the prototype ‘childCircuit’.
After expansion the element ‘elmt’ will be removed from ‘parentCircuit’.
This proceeds as follows:
- New circuit elements
- Each element of the child circuit will be added to the parent.
- The name (refdes) of this element childID_parentID, where ‘childID’ is the name of the element of the child circuit and ‘parentID is the name of the element of the parent circuit that needed to be expanded (e.g. Xnnn or Mnnn).
- Node names
- If a node ID of the child element is found in the connecting nodes of the child circuit, the corresponding node of the new element obtains this node ID.
- If the node of the child element is the global ground node: ‘0’, the corresponding node of the new element is also ‘0’.
- In other case we have a local node. The corresponding node of the new element will then be the node ID of the element of the child circuit with added suffix: ‘_parentID.
- Reference names
- References to other elements are always local. The names of referenced elements will obtain the suffix: ‘_parentID’.
- Parameter names
- Parameter definitions used in ‘elmt’ will be passed tho parameters of the child circuit
- All other parameter names used in both element definitions and parameter definitions of the child circuit will obtain the suffix ‘_parentID’.
Parameters: - elmt – Element of the parent circuit that requires expansion
- parentCircuit (SLiCAP.protos.circuit) – Circuit object of the circuit with the element ‘elmt’
- childCircuit (SLiCAP.protos.circuit) – Prototype circuit used for expansion of ‘elmt’
Returns: parentCircuit Circuit in which ‘elmt’ is replaced with elements of the child circuit.
Return type: - New circuit elements
-
expandModelsCircuits(circuitObject)¶ Expands the subcircuits and the models that require expansion.
This proceeds as follows:
- Check if models and model parameters used with element definitions can be found in built-in models, models defined with the circuit, or in precompiled libraries.
- If element models are not ‘stamp’ models, expand them by using their prototype subcircuit.
- If element models refer to sub circuits, check for a hierarchical loop and if this does not exists, expand them by using their prototype subcircuit.
Parameters: circuitObject (SLiCAPprotos.circuit) – Circuit object to which the data will be added. Returns: circuitObject with expanded circuits or models Return type: SLiCAPprotos.circuit
-
makeCircuit(cir)¶ Creates a nested circuit object from the tokens in cir.lexer.
Called by: checkCircuit()
Parameters: cir (SLiCAP.protos.circuit) – Circuit object with lexer data in cir.lexer to which data will be added Returns: cir: circuit object with all data of the ‘flattened’ circuit. Return type: SLiCAPprotos.circuit
-
makeLibraries()¶ Compiles the library ‘lib/SLiCAPmodels.lib’.
Returns a circuit object with subcircuits, model definitions and parameter definitions from this library.
Returns: LIB: circuit object with subcircuits, model definitions and parameter definitions from ‘lib/SLiCAPmodels.lib’. Return type: SLiCAPprotos.circuit
-
sortDepVars(mainCircuit)¶ Sort the dependent variables. This controls the construction of the matrix such that the number of zero entries per column decreases from left to right.
Parameters: mainCircuit (SLiCAP.protos.circuit) – Main (fully expanded) circuit object. Returns: mainCircuit: Main circuit with updated attributes depVars and varIndex. Return type: SLiCAPprotos.circuit
-
updateCirData(mainCircuit)¶ Updates circuit data required for instructions.
- Updates the lists with dependent variables (detectors), sources (independent variables) and controlled sources (possible loop gain references).
- If global parameters are used in the circuit, their definition is added to the ‘.parDefs’ attribute of the circuit.
- Checks if the global ground node ‘0’ is used in the circuit.
- Checks if the circuit has at least two nodes.
- Checks if the referenced elements exist.
Parameters: mainCircuit (SLiCAP.protos.circuit) – Main (fully expanded) circuit object. Returns: mainCircuit: Main circuit with updated circuit information for instructions. Return type: SLiCAPprotos.circuit