How medwatt/gmid works
Main Components
• Lookup Table Generator: This module (located under src/mosplot/lookup_table_generator) is responsible for running SPICE simulations, reading model files, and building lookup tables. Note that it wraps simulator-specific modules (for both ngspice and hspice) and corresponding parsers.
• Simulator Abstraction & Parsers: Inside the lookup table generator, the simulators folder abstracts the simulation back-end. It has base simulator classes (base_simulator.py) and concrete implementations (hspice_simulator.py and ngspice_simulator.py) with dedicated sub-modules for parsing simulation outputs.
• Plotting Module: Under src/mosplot/plot, this module processes data stored in the lookup tables, evaluates expressions (via the Expression classes), and generates various plots (including handling interpolation, twin-axis plots, and quick plot methods). It also pulls in utility routines (in the plot/util subfolder) for data extraction and manipulation.
• Optimization Module: Located in src/mosplot/optimizer, this module focuses on optimizing circuit parameters given target specifications and uses the lookup table data. It includes data type definitions (datatypes.py), the optimizer engine (optimizer.py), and design report generation (design_report.py).
• Tests: The tests folder shows examples such as sample designs and lookup table testing, which are essential for validating inter-module interactions.
Out the Interactions
• Data Flow: The Lookup Table Generator uses SPICE simulators (via their respective modules) to produce simulation results that are parsed and stored as lookup tables (Python dictionaries). These tables then serve as the common data source for both the Plotting and Optimization modules.
• Util Functions: Shared helper code (under plot/util and similar utility parts) helps in extracting and formatting data consistently for plotting/analysis.
Architectural Patterns and Principles
• Modular Design: Each main functionality (lookup, plotting, optimization) is encapsulated in its own sub-package, reflecting a clear separation of concerns.
• Abstraction Layers: The simulator interface abstracts differences between ngspice and hspice, and the use of parsers for each keeps simulation-specific details separate from the high-level lookup table generation code.
• Reusability & Extensibility: The architecture supports easy extension (for instance, adding new simulators or plotting expressions) because each component communicates through defined interfaces and shared data structures (lookup tables as dictionaries).
Relevant Technologies
• Python 3.9+ as the runtime
• Libraries such as numpy, scipy, and matplotlib support numerical computations and plotting.
• External SPICE simulators (ngspice/hspice) are critical to generating simulation data.
• The system also includes standard Python packaging via setup.py and integration test cases.