Skip to content

Commit

Permalink
Merge branch 'main' into xyce-and-ngspice-path-corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
nunobrum authored Feb 23, 2025
2 parents b044ac7 + 3c63510 commit a6d0f26
Show file tree
Hide file tree
Showing 16 changed files with 529 additions and 50 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -819,15 +819,17 @@ For support and improvement requests please open an Issue in [GitHub spicelib is

## History

* Version TBD
* Version 1.4.1
* Fixed Issue #158 - improve xyce path detection, improve runner switch parameter help texts
* Fixed Issue #154 - support embedded subcircuits in Qspice
* Fixed Issue #139 - support xyce raw files
* Added `get_all_parameter_names()` function to all editors (#159)
* Version 1.4.0 (Python 3.9+ only)
* Fixed Issue #152 - python version compatibility too limited on PyPi.
* Version 1.3.8
* Solving deprecation in GitHub artifact actions v3 -> v4
* Version 1.3.7
* Fixed Issue #143 - ltsteps example fixed
* Fixed Issue #143 - ltsteps example fixed
* Fixed Issue #141 - Raw file reader cannot handle complex values (AC analysis) in ASCII RAW files
* Fixed Issue #140 and #131 - Compatibility with LTspice 24+
* Fixed Issue #145 - Allow easy hiding of simulator's console message
Expand Down
63 changes: 63 additions & 0 deletions examples/testfiles/Qspice_bug_embedded_subckt.qsch
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
���۫schematic
�component (-6700,-2000) 0 0
�symbol V
�type: V�
�description: Independent Voltage Source�
�shorted pins: false�
�line (0,-130) (0,-200) 0 0 0x1000000 -1 -1�
�line (0,200) (0,130) 0 0 0x1000000 -1 -1�
�rect (-25,77) (25,73) 0 0 0 0x1000000 0x3000000 -1 0 -1�
�rect (-2,50) (2,100) 0 0 0 0x1000000 0x3000000 -1 0 -1�
�rect (-25,-73) (25,-77) 0 0 0 0x1000000 0x3000000 -1 0 -1�
�ellipse (-130,130) (130,-130) 0 0 0 0x1000000 0x1000000 -1 -1�
�text (100,150) 1 7 0 0x1000000 -1 -1 "V1"�
�text (100,-150) 1 7 0 0x1000000 -1 -1 "1"�
�pin (0,200) (0,0) 1 0 0 0x0 -1 "+"�
�pin (0,-200) (0,0) 1 0 0 0x0 -1 "-"�
�component (-3000,-1800) 0 0
�symbol R
�type: R�
�description: Resistor(USA Style Symbol)�
�shorted pins: false�
�line (0,200) (0,180) 0 0 0x1000000 -1 -1�
�line (0,-180) (0,-200) 0 0 0x1000000 -1 -1�
�zigzag (-80,180) (80,-180) 0 0 0 0x1000000 -1 -1�
�text (100,150) 1 7 0 0x1000000 -1 -1 "R1"�
�text (100,-150) 1 7 0 0x1000000 -1 -1 "1Meg"�
�pin (0,200) (0,0) 1 0 0 0x0 -1 "1"�
�pin (0,-200) (0,0) 1 0 0 0x0 -1 "2"�
�component (-4800,-1300) 0 0
�symbol Proportional
�type: X�
�description: Proportional�
�library file: |.subckt mycomp OUT IN\nE1 OUT 0 IN 0 {P}\n.ends mycomp�
�shorted pins: false�
�triangle (-100,200) (-100,-200) (300,0) 0 0 0x1000000 0x2000000 -1 -1�
�text (-100,250) 1 6 2 0x1000000 -1 -1 "X2"�
�text (0,0) 1 0 0 0x1000000 -1 -1 "mycomp"�
�text (0,-300) 1 0 0 0x1000000 -1 -1 "P=2"�
�pin (300,0) (30,150) 0.63 13 0 0x0 -1 "OUT"�
�pin (-100,0) (-100,10) 0.63 14 0 0x0 -1 "IN"�
�net (-6700,-2500) 1 13 0 "GND"�
�net (-6100,-1300) 1 14 0 "IN"�
�net (-3300,-1300) 1 14 0 "OUT"�
�junction (-6700,-2400)�
�wire (-6700,-2400) (-6700,-2200) "GND"�
�wire (-6700,-1800) (-6700,-1300) "IN"�
�wire (-3300,-1300) (-3000,-1300) "OUT"�
�wire (-3000,-2000) (-3000,-2400) "GND"�
�wire (-3000,-2400) (-6700,-2400) "GND"�
�wire (-6700,-2500) (-6700,-2400) "GND"�
�wire (-6700,-1300) (-6100,-1300) "IN"�
�wire (-3000,-1300) (-3000,-1600) "OUT"�
�wire (-4500,-1300) (-3300,-1300) "OUT"�
�wire (-6100,-1300) (-4900,-1300) "IN"�
�text (-9180,470) 1 7 0 0x1000000 -1 -1 ".tran 0 1m 0 100n uic"�

96 changes: 96 additions & 0 deletions examples/testfiles/Qspice_top.qsch
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
���۫schematic
�component (-1000,0) 0 0
�symbol V
�type: V�
�description: Independent Voltage Source�
�shorted pins: false�
�line (0,-130) (0,-200) 0 0 0x1000000 -1 -1�
�line (0,200) (0,130) 0 0 0x1000000 -1 -1�
�rect (-25,77) (25,73) 0 0 0 0x1000000 0x3000000 -1 0 -1�
�rect (-2,50) (2,100) 0 0 0 0x1000000 0x3000000 -1 0 -1�
�rect (-25,-73) (25,-77) 0 0 0 0x1000000 0x3000000 -1 0 -1�
�ellipse (-130,130) (130,-130) 0 0 0 0x1000000 0x1000000 -1 -1�
�text (100,150) 1 7 0 0x1000000 -1 -1 "V1"�
�text (100,-150) 1 7 0 0x1000000 -1 -1 "PWL 0 0 1m 5"�
�pin (0,200) (0,0) 1 0 0 0x0 -1 "+"�
�pin (0,-200) (0,0) 1 0 0 0x0 -1 "-"�
�component (1400,200) 0 0
�symbol R
�type: R�
�description: Resistor(USA Style Symbol)�
�shorted pins: false�
�line (0,200) (0,180) 0 0 0x1000000 -1 -1�
�line (0,-180) (0,-200) 0 0 0x1000000 -1 -1�
�zigzag (-80,180) (80,-180) 0 0 0 0x1000000 -1 -1�
�text (100,150) 1 7 0 0x1000000 -1 -1 "R1"�
�text (100,-150) 1 7 0 0x1000000 -1 -1 "10K"�
�pin (0,200) (0,0) 1 0 0 0x0 -1 "1"�
�pin (0,-200) (0,0) 1 0 0 0x0 -1 "2"�
�component (-800,800) 0 0
�symbol V
�type: V�
�description: Independent Voltage Source�
�shorted pins: false�
�line (0,-130) (0,-200) 0 0 0x1000000 -1 -1�
�line (0,200) (0,130) 0 0 0x1000000 -1 -1�
�rect (-25,77) (25,73) 0 0 0 0x1000000 0x3000000 -1 0 -1�
�rect (-2,50) (2,100) 0 0 0 0x1000000 0x3000000 -1 0 -1�
�rect (-25,-73) (25,-77) 0 0 0 0x1000000 0x3000000 -1 0 -1�
�ellipse (-130,130) (130,-130) 0 0 0 0x1000000 0x1000000 -1 -1�
�text (100,150) 1 7 0 0x1000000 -1 -1 "V2"�
�text (100,-150) 1 7 0 0x1000000 -1 -1 "5"�
�pin (0,200) (0,0) 1 0 0 0x0 -1 "+"�
�pin (0,-200) (0,0) 1 0 0 0x0 -1 "-"�
�component (300,400) 0 0
�symbol
�type: �
�description: MyDiff�
�shorted pins: false�
�rect (-500,-400) (500,400) 0 0 0 0xff0000 0xc8c8c8 -1 1 -1�
�text (-100,0) 1 12 0 0x1000000 -1 -1 "X2"�
�text (-300,-400) 0.681 13 0 0x1000000 -1 -1 "sub_circuit2"�
�pin (-500,-100) (0,0) 1 7 0 0x0 -1 "INP"�
�pin (-500,100) (0,0) 1 7 0 0x0 -1 "INN"�
�pin (0,400) (180,-190) 1 14 0 0x0 -1 "VDD"�
�pin (0,-400) (150,0) 1 14 0 0x0 -1 "VSS"�
�pin (500,0) (-150,0) 1 11 0 0x0 -1 "OUT"�
�component (-1700,300) 0 0
�symbol V
�type: V�
�description: Independent Voltage Source�
�shorted pins: false�
�line (0,-130) (0,-200) 0 0 0x1000000 -1 -1�
�line (0,200) (0,130) 0 0 0x1000000 -1 -1�
�rect (-25,77) (25,73) 0 0 0 0x1000000 0x3000000 -1 0 -1�
�rect (-2,50) (2,100) 0 0 0 0x1000000 0x3000000 -1 0 -1�
�rect (-25,-73) (25,-77) 0 0 0 0x1000000 0x3000000 -1 0 -1�
�ellipse (-130,130) (130,-130) 0 0 0 0x1000000 0x1000000 -1 -1�
�text (150,50) 1 7 0 0x1000000 -1 -1 "V3"�
�text (100,-150) 1 7 0 0x1000000 -1 -1 "1"�
�pin (0,200) (0,0) 1 0 0 0x0 -1 "+"�
�pin (0,-200) (0,0) 1 0 0 0x0 -1 "-"�
�net (-1000,-200) 1 13 0 "GND"�
�net (1400,0) 1 13 0 "GND"�
�net (-800,600) 1 13 0 "GND"�
�net (300,-500) 1 13 0 "GND"�
�net (-1700,100) 1 13 0 "GND"�
�wire (800,400) (1400,400) "N01"�
�wire (-800,1000) (300,1000) "N02"�
�wire (300,1000) (300,800) "N02"�
�wire (300,0) (300,-500) "GND"�
�wire (-200,500) (-1700,500) "N03"�
�wire (-1000,200) (-1000,300) "N04"�
�wire (-1000,300) (-200,300) "N04"�
�text (-1400,-350) 1 7 0 0x1000000 -1 -1 ".tran 1m"�

157 changes: 157 additions & 0 deletions examples/testfiles/sub_circuit2.qsch
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
���۫schematic
�component (-1300,200) 2 0
�symbol R
�type: R�
�description: Resistor(USA Style Symbol)�
�shorted pins: false�
�line (0,200) (0,180) 0 0 0x1000000 -1 -1�
�line (0,-180) (0,-200) 0 0 0x1000000 -1 -1�
�zigzag (-80,180) (80,-180) 0 0 0 0x1000000 -1 -1�
�text (30,350) 1 110 0 0x1000000 -1 -1 "R1"�
�text (320,0) 1 109 0 0x1000000 -1 -1 "10K"�
�pin (0,200) (0,0) 1 0 0 0x0 -1 "1"�
�pin (0,-200) (0,0) 1 0 0 0x0 -1 "2"�
�component (-1300,-200) 2 0
�symbol R
�type: R�
�description: Resistor(USA Style Symbol)�
�shorted pins: false�
�line (0,200) (0,180) 0 0 0x1000000 -1 -1�
�line (0,-180) (0,-200) 0 0 0x1000000 -1 -1�
�zigzag (-80,180) (80,-180) 0 0 0 0x1000000 -1 -1�
�text (30,350) 1 110 0 0x1000000 -1 -1 "R2"�
�text (-80,0) 1 109 0 0x1000000 -1 -1 "10K"�
�pin (0,200) (0,0) 1 0 0 0x0 -1 "1"�
�pin (0,-200) (0,0) 1 0 0 0x0 -1 "2"�
�component (-700,-600) 4 0
�symbol R
�type: R�
�description: Resistor(USA Style Symbol)�
�shorted pins: false�
�line (0,200) (0,180) 0 0 0x1000000 -1 -1�
�line (0,-180) (0,-200) 0 0 0x1000000 -1 -1�
�zigzag (-80,180) (80,-180) 0 0 0 0x1000000 -1 -1�
�text (130,-150) 1 75 0 0x1000000 -1 -1 "R3"�
�text (130,150) 1 75 0 0x1000000 -1 -1 "22K"�
�pin (0,200) (0,0) 1 0 0 0x0 -1 "1"�
�pin (0,-200) (0,0) 1 0 0 0x0 -1 "2"�
�component (100,1200) 6 0
�symbol R
�type: R�
�description: Resistor(USA Style Symbol)�
�shorted pins: false�
�line (0,200) (0,180) 0 0 0x1000000 -1 -1�
�line (0,-180) (0,-200) 0 0 0x1000000 -1 -1�
�zigzag (-80,180) (80,-180) 0 0 0 0x1000000 -1 -1�
�text (-80,0) 1 46 0 0x1000000 -1 -1 "R4"�
�text (80,0) 1 45 0 0x1000000 -1 -1 "22K"�
�pin (0,200) (0,0) 1 0 0 0x0 -1 "1"�
�pin (0,-200) (0,0) 1 0 0 0x0 -1 "2"�
�component (-200,0) 0 0
�symbol OpAmp
�type: û
�description: Generic Rail-to-Rail Output OpAmp�
�shorted pins: false�
�line (-100,450) (-100,-450) 0 0 0x1000000 -1 -1�
�line (500,0) (-100,450) 0 0 0x1000000 -1 -1�
�line (-50,200) (50,200) 0 0 0x1000000 -1 3�
�line (-50,-200) (50,-200) 0 0 0x1000000 -1 4�
�line (0,-250) (0,-150) 0 0 0x1000000 -1 4�
�line (500,0) (-100,-450) 0 0 0x1000000 -1 -1�
�text (202,300) 1 7 0 0x1000000 -1 -1 "�1"�
�text (200,0) 0.5 0 2 0x1000000 -1 -1 "RRopAmp"�
�text (454,-71) 0.5 7 0 0x1000000 -1 -1 "Avol=<100K>"�
�text (334,-151) 0.5 7 0 0x1000000 -1 -1 "GBW=<5Meg>"�
�text (244,-221) 0.5 7 0 0x1000000 -1 -1 "Slew=<5Meg>"�
�text (244,-321) 0.5 7 0 0x1000000 -1 -1 "Rload=<2K>"�
�text (244,-421) 0.5 7 0 0x1000000 -1 -1 "Phi=<60>"�
�pin (100,300) (0,0) 1 0 0 0x1000000 -1 "Vdd"�
�pin (100,-300) (0,0) 1 0 0 0x1000000 -1 "Vss"�
�pin (500,0) (0,0) 1 15 0 0x1000000 -1 "OUT"�
�pin (-100,200) (50,0) 1 15 0 0x1000000 -1 "IN-"�
�pin (-100,-200) (60,0) 1 15 0 0x1000000 -1 "IN+"�
�pin (0,100) (0,0) 1 15 0 0x1000000 -1 "MULT+" "�"�
�pin (0,-100) (0,0) 1 15 0 0x1000000 -1 "MULT-" "�"�
�pin (300,0) (60,0) 1 15 0 0x1000000 -1 "IN--" "�"�
�pin (400,0) (20,0) 0.794 15 0 0x1000000 -1 "IN++" "�"�
�pin (-100,0) (20,0) 0.794 7 0 0x1000000 -1 "EN" "�"�
�component (1500,1000) 0 0
�symbol Zener
�type: D�
�description: Zener Diode�
�library file: Zener.txt�
�shorted pins: false�
�line (80,80) (-80,80) 0 0 0x1000000 -1 -1�
�line (0,200) (0,80) 0 0 0x1000000 -1 -1�
�line (0,-200) (0,-70) 0 0 0x1000000 -1 -1�
�line (80,80) (130,130) 0 0 0x1000000 -1 -1�
�line (-130,30) (-80,80) 0 0 0x1000000 -1 -1�
�triangle (0,80) (100,-70) (-100,-70) 0 0 0x1000000 0x2000000 -1 -1�
�text (100,200) 1 7 0 0x1000000 -1 -1 "D1"�
�text (100,-200) 1 7 0 0x1000000 -1 -1 "MM3Z5V1T1G"�
�pin (0,-200) (0,0) 1 0 0 0x0 -1 "A"�
�pin (0,200) (0,0) 1 0 0 0x0 -1 "K"�
�component (1500,1700) 0 0
�symbol R
�type: R�
�description: Resistor(USA Style Symbol)�
�shorted pins: false�
�line (0,200) (0,180) 0 0 0x1000000 -1 -1�
�line (0,-180) (0,-200) 0 0 0x1000000 -1 -1�
�zigzag (-80,180) (80,-180) 0 0 0 0x1000000 -1 -1�
�text (100,150) 1 7 0 0x1000000 -1 -1 "R5"�
�text (100,-150) 1 7 0 0x1000000 -1 -1 "100"�
�pin (0,200) (0,0) 1 0 0 0x0 -1 "1"�
�pin (0,-200) (0,0) 1 0 0 0x0 -1 "2"�
�net (-2100,200) 1 11 1 "INN"�
�net (1500,2100) 1 14 1 "VDD"�
�net (-100,-1200) 1 13 1 "VSS"�
�net (1800,0) 1 7 1 "OUT"�
�net (-2100,-200) 1 11 1 "INP"�
�junction (1500,1300)�
�junction (800,0)�
�junction (-100,-1000)�
�junction (-700,200)�
�junction (-700,-200)�
�wire (800,0) (1800,0) "OUT"�
�wire (-100,-1000) (-100,-1200) "VSS"�
�wire (-1500,-200) (-2100,-200) "INP"�
�wire (-1500,200) (-2100,200) "INN"�
�wire (300,1200) (800,1200) "OUT"�
�wire (800,1200) (800,0) "OUT"�
�wire (300,0) (800,0) "OUT"�
�wire (-700,1200) (-700,200) "N01"�
�wire (-300,200) (-700,200) "N01"�
�wire (-700,-200) (-1100,-200) "N02"�
�wire (-700,200) (-1100,200) "N01"�
�wire (-700,1200) (-100,1200) "N01"�
�wire (-700,-400) (-700,-200) "N02"�
�wire (-300,-200) (-700,-200) "N02"�
�wire (-700,-800) (-700,-1000) "VSS"�
�wire (-100,-300) (-100,-1000) "VSS"�
�wire (-700,-1000) (-100,-1000) "VSS"�
�wire (-100,300) (-100,800) "N03"�
�wire (-100,800) (1100,800) "N03"�
�wire (-100,-1000) (1500,-1000) "VSS"�
�wire (1500,-1000) (1500,800) "VSS"�
�wire (1500,1900) (1500,2100) "VDD"�
�wire (1100,800) (1100,1300) "N03"�
�wire (1100,1300) (1500,1300) "N03"�
�wire (1500,1200) (1500,1300) "N03"�
�wire (1500,1300) (1500,1500) "N03"�

2 changes: 2 additions & 0 deletions spicelib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ def all_loggers():
"""
return [
"spicelib.AscEditor",
"spicelib.AscToQsch",
"spicelib.AsyReader",
"spicelib.BaseEditor",
"spicelib.BaseSchematic",
"spicelib.LTSpiceSimulator",
"spicelib.LTSteps",
"spicelib.NGSpiceSimulator",
"spicelib.QschEditor",
"spicelib.qspice_log_reader",
"spicelib.QSpiceSimulator",
"spicelib.RawRead",
Expand Down
18 changes: 16 additions & 2 deletions spicelib/editor/asc_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,9 @@ def _get_subcircuit(self, symbol: AsyReader) -> Union[SpiceEditor, 'AscEditor']:
def get_subcircuit(self, reference: str) -> 'AscEditor':
"""Returns an AscEditor file corresponding to the symbol"""
sub = self.get_component(reference)
return sub.attributes['_SUBCKT']
if '_SUBCKT' in sub.attributes:
return sub.attributes['_SUBCKT']
raise AttributeError(f"An associated subcircuit was not found for {reference}")

def get_component_info(self, reference) -> dict:
"""Returns the reference information as a dictionary"""
Expand Down Expand Up @@ -332,7 +334,19 @@ def _get_param_named(self, param_name):
if match.group("name").upper() == param_name_uppercase:
return match, directive
return None, None


def get_all_parameter_names(self) -> List[str]:
# docstring inherited from BaseEditor
param_names = []
search_expression = re.compile(PARAM_REGEX(r"\w+"), re.IGNORECASE)
for directive in self.directives:
if directive.text.upper().startswith(".PARAM"):
matches = search_expression.finditer(directive.text)
for match in matches:
param_name = match.group('name')
param_names.append(param_name.upper())
return sorted(param_names)

def get_parameter(self, param: str) -> str:
match, directive = self._get_param_named(param)
if match:
Expand Down
Loading

0 comments on commit a6d0f26

Please sign in to comment.