Salamandra Netlist Manipulation Framework
Salamandra is an extensible Pythonic infrastructure for loading, analyzing, generating, and storing netlists. Developed by EnICS labs, it is currently at version 1.0.1 and is under active development. The library supports Python 3.5+ and is released under the Apache 2.0 open-source license.
Common errors
-
ModuleNotFoundError: No module named 'salamandra'
cause The Salamandra library is not installed in the current Python environment.fixRun `pip install salamandra` to install the library. -
TypeError: 'str' object is not callable
cause This error often indicates attempting to use Python 2-specific syntax or features, or incorrect object usage, with a Python 3-only library like Salamandra.fixVerify that you are running your code with Python 3.5+ and that your code adheres to Python 3 syntax. Consult the official Python 3 documentation for language differences if migrating from Python 2.
Warnings
- gotcha Salamandra is currently under development, and its documentation for the latest features may be incomplete or evolving. Users should expect potential API changes as the library matures.
- gotcha The Salamandra library exclusively supports Python 3 (specifically Python 3.5 and above). Attempting to use it with Python 2 will result in compatibility errors.
Install
-
pip install salamandra
Imports
- Component
from salamandra import Component
- Pin
from salamandra import Pin
- Input
from salamandra import Input
- Output
from salamandra import Output
- Inout
from salamandra import Inout
Quickstart
import salamandra as slm
# Create an NMOS component skeleton
nmos = slm.Component('nmos')
nmos.add_pin(slm.Pin('source'))
nmos.add_pin(slm.Pin('drain'))
nmos.add_pin(slm.Pin('gate'))
nmos.add_pin(slm.Pin('body'))
# Create an inverter component with subcomponents and connections
inv = slm.Component('inv')
# Add pins to the inverter
inv.add_pin(slm.Input('I'))
inv.add_pin(slm.Output('ZN'))
inv.add_pin(slm.Inout('VDD'))
inv.add_pin(slm.Inout('VSS'))
# Add subcomponents (instances of nmos and pmos - pmos would be defined similarly to nmos)
# For this example, let's assume 'pmos' is also a defined slm.Component object
pmos = slm.Component('pmos') # Define a dummy pmos for the example to be runnable
pmos.add_pin(slm.Pin('source'))
pmos.add_pin(slm.Pin('drain'))
pmos.add_pin(slm.Pin('gate'))
pmos.add_pin(slm.Pin('body'))
inv.add_subcomponent(nmos, 'n1')
inv.add_subcomponent(pmos, 'p1')
# Establish connections
inv.connect('I', 'n1.gate')
inv.connect('I', 'p1.gate')
inv.connect('ZN', 'n1.drain')
inv.connect('ZN', 'p1.drain')
inv.connect('VDD', 'p1.source')
inv.connect('VDD', 'p1.body')
print(f"Created component: {inv.name}")
print(f"Pins: {[p.name for p in inv.pins]}")
print(f"Subcomponents: {[s.name for s in inv.subcomponents]}")
# For full netlist export, one would typically call functions like inv.print_verilog()
# print("\nVerilog Netlist (example snippet):")
# inv.print_verilog()