This is a really, really bad API document. I’m working to make Sphinx generate a better one but, right now, the description on the homepage about how to use SKiDL is much better than this.
SKiDL API¶
Overview of How SKiDL Works¶
This is an overview of how SKiDL works.
skidl¶
skidl package¶
Subpackages¶
skidl.tools package¶
Submodules¶
skidl.tools.kicad module¶
Handler for reading Kicad libraries and generating netlists.
-
class
skidl.tools.kicad.
DrawDef
(name, ref, zero, name_offset, show_nums, show_names, num_units, lock_units, power_symbol)¶ Bases:
tuple
Create new instance of DrawDef(name, ref, zero, name_offset, show_nums, show_names, num_units, lock_units, power_symbol)
-
lock_units
¶ Alias for field number 7
-
name
¶ Alias for field number 0
-
name_offset
¶ Alias for field number 3
-
num_units
¶ Alias for field number 6
-
power_symbol
¶ Alias for field number 8
-
ref
¶ Alias for field number 1
-
show_names
¶ Alias for field number 5
-
show_nums
¶ Alias for field number 4
-
zero
¶ Alias for field number 2
-
-
class
skidl.tools.kicad.
DrawF0
(ref, x, y, size, orientation, visibility, halign, valign)¶ Bases:
tuple
Create new instance of DrawF0(ref, x, y, size, orientation, visibility, halign, valign)
-
halign
¶ Alias for field number 6
-
orientation
¶ Alias for field number 4
-
ref
¶ Alias for field number 0
-
size
¶ Alias for field number 3
-
valign
¶ Alias for field number 7
-
visibility
¶ Alias for field number 5
-
x
¶ Alias for field number 1
-
y
¶ Alias for field number 2
-
-
class
skidl.tools.kicad.
DrawF1
(name, x, y, size, orientation, visibility, halign, valign, fieldname)¶ Bases:
tuple
Create new instance of DrawF1(name, x, y, size, orientation, visibility, halign, valign, fieldname)
-
fieldname
¶ Alias for field number 8
-
halign
¶ Alias for field number 6
-
name
¶ Alias for field number 0
-
orientation
¶ Alias for field number 4
-
size
¶ Alias for field number 3
-
valign
¶ Alias for field number 7
-
visibility
¶ Alias for field number 5
-
x
¶ Alias for field number 1
-
y
¶ Alias for field number 2
-
-
class
skidl.tools.kicad.
DrawArc
(cx, cy, radius, start_angle, end_angle, unit, dmg, thickness, fill, startx, starty, endx, endy)¶ Bases:
tuple
Create new instance of DrawArc(cx, cy, radius, start_angle, end_angle, unit, dmg, thickness, fill, startx, starty, endx, endy)
-
cx
¶ Alias for field number 0
-
cy
¶ Alias for field number 1
-
dmg
¶ Alias for field number 6
-
end_angle
¶ Alias for field number 4
-
endx
¶ Alias for field number 11
-
endy
¶ Alias for field number 12
-
fill
¶ Alias for field number 8
-
radius
¶ Alias for field number 2
-
start_angle
¶ Alias for field number 3
-
startx
¶ Alias for field number 9
-
starty
¶ Alias for field number 10
-
thickness
¶ Alias for field number 7
-
unit
¶ Alias for field number 5
-
-
class
skidl.tools.kicad.
DrawCircle
(cx, cy, radius, unit, dmg, thickness, fill)¶ Bases:
tuple
Create new instance of DrawCircle(cx, cy, radius, unit, dmg, thickness, fill)
-
cx
¶ Alias for field number 0
-
cy
¶ Alias for field number 1
-
dmg
¶ Alias for field number 4
-
fill
¶ Alias for field number 6
-
radius
¶ Alias for field number 2
-
thickness
¶ Alias for field number 5
-
unit
¶ Alias for field number 3
-
-
class
skidl.tools.kicad.
DrawPoly
(point_count, unit, dmg, thickness, points, fill)¶ Bases:
tuple
Create new instance of DrawPoly(point_count, unit, dmg, thickness, points, fill)
-
dmg
¶ Alias for field number 2
-
fill
¶ Alias for field number 5
-
point_count
¶ Alias for field number 0
-
points
¶ Alias for field number 4
-
thickness
¶ Alias for field number 3
-
unit
¶ Alias for field number 1
-
-
class
skidl.tools.kicad.
DrawRect
(x1, y1, x2, y2, unit, dmg, thickness, fill)¶ Bases:
tuple
Create new instance of DrawRect(x1, y1, x2, y2, unit, dmg, thickness, fill)
-
dmg
¶ Alias for field number 5
-
fill
¶ Alias for field number 7
-
thickness
¶ Alias for field number 6
-
unit
¶ Alias for field number 4
-
x1
¶ Alias for field number 0
-
x2
¶ Alias for field number 2
-
y1
¶ Alias for field number 1
-
y2
¶ Alias for field number 3
-
-
class
skidl.tools.kicad.
DrawText
(angle, x, y, size, hidden, unit, dmg, text, italic, bold, halign, valign)¶ Bases:
tuple
Create new instance of DrawText(angle, x, y, size, hidden, unit, dmg, text, italic, bold, halign, valign)
-
angle
¶ Alias for field number 0
-
bold
¶ Alias for field number 9
-
dmg
¶ Alias for field number 6
-
halign
¶ Alias for field number 10
Alias for field number 4
-
italic
¶ Alias for field number 8
-
size
¶ Alias for field number 3
-
text
¶ Alias for field number 7
-
unit
¶ Alias for field number 5
-
valign
¶ Alias for field number 11
-
x
¶ Alias for field number 1
-
y
¶ Alias for field number 2
-
-
class
skidl.tools.kicad.
DrawPin
(name, num, x, y, length, orientation, num_size, name_size, unit, dmg, electrical_type, shape)¶ Bases:
tuple
Create new instance of DrawPin(name, num, x, y, length, orientation, num_size, name_size, unit, dmg, electrical_type, shape)
-
dmg
¶ Alias for field number 9
-
electrical_type
¶ Alias for field number 10
-
length
¶ Alias for field number 4
-
name
¶ Alias for field number 0
-
name_size
¶ Alias for field number 7
-
num
¶ Alias for field number 1
-
num_size
¶ Alias for field number 6
-
orientation
¶ Alias for field number 5
-
shape
¶ Alias for field number 11
-
unit
¶ Alias for field number 8
-
x
¶ Alias for field number 2
-
y
¶ Alias for field number 3
-
skidl.tools.skidl module¶
Handler for reading SKiDL libraries and generating netlists.
skidl.tools.spice module¶
Handler for reading SPICE libraries.
-
class
skidl.tools.spice.
XspiceModel
(*args, **kwargs)¶ Bases:
object
Object to hold the parameters for an XSPICE model.
-
skidl.tools.spice.
DeviceModel
¶ alias of
skidl.tools.spice.XspiceModel
-
skidl.tools.spice.
node
(net_pin_part)¶
-
skidl.tools.spice.
not_implemented
(part, circuit)¶ Unable to add a particular SPICE part to a circuit.
-
skidl.tools.spice.
add_part_to_circuit
(part, circuit)¶ Add a part to a PySpice Circuit object.
- Parameters
part – SKiDL Part object.
circuit – PySpice Circuit object.
-
class
skidl.tools.spice.
Parameters
(**params)¶ Bases:
dict
Class for holding Spice subcircuit parameters.
-
skidl.tools.spice.
add_subcircuit_to_circuit
(part, circuit)¶ Add a .SUBCKT part to a PySpice Circuit object.
- Parameters
part – SKiDL Part object.
circuit – PySpice Circuit object.
-
skidl.tools.spice.
add_xspice_to_circuit
(part, circuit)¶ Add an XSPICE part to a PySpice Circuit object.
- Parameters
part – SKiDL Part object.
circuit – PySpice Circuit object.
Module contents¶
This package contains the handler functions for various EDA tools.
Submodules¶
skidl.alias module¶
Handles aliases for Circuit, Part, Pin, Net, Bus, Interface objects.
skidl.arrange module¶
Arrange part units for best schematic wiring.
-
class
skidl.arrange.
Region
(x, y)¶ Bases:
skidl.coord.Point
Stores an (x,y) coord and a list of the parts stored within it.
-
clear
()¶
-
add
(part)¶
-
rmv
(part)¶
-
cost
()¶
-
-
class
skidl.arrange.
PartNet
(net)¶ Bases:
object
Stores the parts attached to a particular net.
-
calc_bbox
()¶
-
cost
(regions)¶
-
-
class
skidl.arrange.
Arranger
(circuit, grid_hgt=3, grid_wid=3)¶ Bases:
object
Create a W x H array of regions to store arrangement of circuit parts.
-
clear
()¶ Clear the parts from the regions.
-
cost
()¶ Compute the cost of the arrangement of parts to regions.
-
apply
()¶ Apply an assignment stored in regions to parts.
-
prearranged
()¶ Apply the (x,y) position of parts to update the regions.
-
arrange_randomly
()¶ Arrange the parts randomly across the regions.
-
expand_grid
(mul_hgt, mul_wid)¶ Expand the number of rows/columns in the grid of regions.
-
arrange_kl
()¶ Optimally arrange the parts across regions using Kernighan-Lin.
-
skidl.bus module¶
Handles buses.
-
class
skidl.bus.
Bus
(*args, **attribs)¶ Bases:
skidl.skidlbaseobj.SkidlBaseObject
This class collects one or more nets into a group that can be indexed.
- Parameters
name – A string with the name of the bus.
args – A list of ints, pins, nets, buses to attach to the net.
- Keyword Arguments
attribs – A dictionary of attributes and values to attach to the Net object.
Example
n = Net() led1 = Part("Device", 'LED') b = Bus('B', 8, n, led1['K'])
-
classmethod
get
(name, circuit=None)¶ Get the bus with the given name from a circuit, or return None.
-
classmethod
fetch
(name, *args, **attribs)¶ Get the bus with the given name from a circuit, or create it if not found.
-
extend
(*objects)¶ Extend bus by appending objects to the end (MSB).
-
insert
(index, *objects)¶ Insert objects into bus starting at indexed position.
-
get_nets
()¶ Return the list of nets contained in this bus.
-
get_pins
()¶ It’s an error to get the list of pins attached to all bus lines.
-
copy
(num_copies=None, **attribs)¶ Make zero or more copies of this bus.
- Parameters
num_copies – Number of copies to make of this bus.
- Keyword Arguments
attribs – Name/value pairs for setting attributes for the copy.
- Returns
A list of Bus copies or a Bus if num_copies==1.
- Raises
Exception if the requested number of copies is a non-integer or negative. –
Notes
An instance of a bus can be copied just by calling it like so:
b = Bus('A', 8) # Create a bus. b_copy = b(2) # Get two copies of the bus.
You can also use the multiplication operator to make copies:
b = 10 * Bus('A', 8) # Create an array of buses.
-
is_movable
()¶ Return true if the bus is movable to another circuit.
A bus is movable if all the nets in it are movable.
-
is_implicit
()¶ Return true if the bus name is implicit.
-
connect
(*pins_nets_buses)¶ Return the bus after connecting one or more nets, pins, or buses.
- Parameters
pins_nets_buses – One or more Pin, Net or Bus objects or lists/tuples of them.
- Returns
The updated bus with the new connections.
Notes
You can connect nets or pins to a bus like so:
p = Pin() # Create a pin. n = Net() # Create a net. b = Bus('B', 2) # Create a two-wire bus. b += p,n # Connect pin and net to B[0] and B[1].
-
property
name
¶ Get, set and delete the name of the bus.
When setting the bus name, if another bus with the same name is found, the name for this bus is adjusted to make it unique.
-
property
width
¶ Return width of a Bus, which is the same as using the len() operator.
skidl.circuit module¶
Handles complete circuits made of parts and nets.
-
class
skidl.circuit.
Circuit
(**kwargs)¶ Bases:
skidl.skidlbaseobj.SkidlBaseObject
Class object that holds the entire netlist of parts and nets.
-
parts
¶ List of all the schematic parts as Part objects.
-
nets
¶ List of all the schematic nets as Net objects.
-
buses
¶ List of all the buses as Bus objects.
-
hierarchy
¶ A ‘.’-separated concatenation of the names of nested SubCircuits at the current time it is read.
-
level
¶ The current level in the schematic hierarchy.
-
context
¶ Stack of contexts for each level in the hierarchy.
-
erc_list
= [<function dflt_circuit_erc>]¶
-
reset
(init=False)¶ Clear any circuitry and cached part libraries and start over.
-
mini_reset
(init=False)¶ Clear any circuitry but don’t erase any loaded part libraries.
-
add_hierarchical_name
(name)¶ Record a new hierarchical name. Throw an error if it is a duplicate.
-
rmv_hierarchical_name
(name)¶ Remove an existing hierarchical name. Throw an error if non-existent.
-
add_parts
(*parts)¶ Add some Part objects to the circuit.
-
rmv_parts
(*parts)¶ Remove some Part objects from the circuit.
-
add_nets
(*nets)¶ Add some Net objects to the circuit. Assign a net name if necessary.
-
rmv_nets
(*nets)¶ Remove some Net objects from the circuit.
-
add_buses
(*buses)¶ Add some Bus objects to the circuit. Assign a bus name if necessary.
-
rmv_buses
(*buses)¶ Remove some buses from the circuit.
-
add_packages
(*packages)¶
-
rmv_packages
(*packages)¶
-
add_stuff
(*stuff)¶ Add Parts, Nets, Buses, and Interfaces to the circuit.
-
rmv_stuff
(*stuff)¶ Remove Parts, Nets, Buses, and Interfaces from the circuit.
-
get_nets
()¶ Get all the distinct nets for the circuit.
-
instantiate_packages
()¶ Run the package executables to instantiate their circuitry.
-
ERC
(*args, **kwargs)¶ Run class-wide and local ERC functions on this circuit.
-
generate_netlist
(**kwargs)¶ Return a netlist and also write it to a file/stream.
- Parameters
file – Either a file object that can be written to, or a string containing a file name, or None.
tool – The EDA tool the netlist will be generated for.
do_backup – If true, create a library with all the parts in the circuit.
- Returns
A netlist.
-
generate_xml
(file_=None, tool=None)¶ Return netlist as an XML string and also write it to a file/stream.
- Parameters
file – Either a file object that can be written to, or a string containing a file name, or None.
- Returns
A string containing the netlist.
-
generate_netlistsvg_skin
(net_stubs)¶ Generate the skin file of symbols for use by netlistsvg.
-
generate_svg
(file_=None, tool=None)¶ Create an SVG file displaying the circuit schematic and return the dictionary that can be displayed by netlistsvg.
-
generate_schematic
(file_=None, tool=None)¶ Create a schematic file. THIS DOES NOT WORK!
-
generate_dot
(file_=None, engine='neato', rankdir='LR', part_shape='rectangle', net_shape='point', splines=None, show_values=True, show_anon=False, split_nets=['GND'], split_parts_ref=[])¶ Returns a graphviz graph as graphviz object and can also write it to a file/stream. When used in ipython the graphviz object will drawn as an SVG in the output.
See https://graphviz.readthedocs.io/en/stable/ and http://graphviz.org/doc/info/attrs.html
- Parameters
file – A string containing a file name, or None.
engine – See graphviz documentation
rankdir – See graphviz documentation
part_shape – Shape of the part nodes
net_shape – Shape of the net nodes
splines – Style for the edges, try ‘ortho’ for a schematic like feel
show_values – Show values as external labels on part nodes
show_anon – Show anonymous net names
split_nets – splits up the plot for the given list of net names
split_parts_ref – splits up the plot for all pins for the given list of part refs
- Returns
graphviz.Digraph
-
generate_graph
(file_=None, engine='neato', rankdir='LR', part_shape='rectangle', net_shape='point', splines=None, show_values=True, show_anon=False, split_nets=['GND'], split_parts_ref=[])¶ Returns a graphviz graph as graphviz object and can also write it to a file/stream. When used in ipython the graphviz object will drawn as an SVG in the output.
See https://graphviz.readthedocs.io/en/stable/ and http://graphviz.org/doc/info/attrs.html
- Parameters
file – A string containing a file name, or None.
engine – See graphviz documentation
rankdir – See graphviz documentation
part_shape – Shape of the part nodes
net_shape – Shape of the net nodes
splines – Style for the edges, try ‘ortho’ for a schematic like feel
show_values – Show values as external labels on part nodes
show_anon – Show anonymous net names
split_nets – splits up the plot for the given list of net names
split_parts_ref – splits up the plot for all pins for the given list of part refs
- Returns
graphviz.Digraph
-
backup_parts
(file_=None)¶ Saves parts in circuit as a SKiDL library in a file.
- Parameters
file – Either a file object that can be written to, or a string containing a file name, or None. If None, a standard library file will be used.
- Returns
Nothing.
-
-
skidl.circuit.
SubCircuit
(f)¶ A @SubCircuit decorator is used to create hierarchical circuits.
- Parameters
f – The function containing SKiDL statements that represents a subcircuit.
-
skidl.circuit.
subcircuit
(f)¶ A @SubCircuit decorator is used to create hierarchical circuits.
- Parameters
f – The function containing SKiDL statements that represents a subcircuit.
skidl.common module¶
Stuff everyone needs.
skidl.coord module¶
skidl.defines module¶
Definitions used everywhere.
skidl.erc module¶
ERC functions for Circuit, Part, Pin, Net, Bus, Interface objects.
-
skidl.erc.
dflt_circuit_erc
(circuit)¶ Do an electrical rules check on a circuit.
-
skidl.erc.
dflt_part_erc
(part)¶ Do an electrical rules check on a part in the schematic.
-
skidl.erc.
dflt_net_erc
(net)¶ Do electrical rules check on a net in the schematic.
skidl.interface module¶
Handles interfaces for subsystems with complicated I/O.
-
class
skidl.interface.
Interface
(*args, **kwargs)¶ Bases:
dict
,skidl.skidlbaseobj.SkidlBaseObject
An Interface bundles a group of nets/buses into a single entity with each net/bus becoming an attribute. An Interface is also usable as a dict where the attribute names serve as keys. This means the ** operator works on an Interface.
-
erc_list
= []¶
-
get_io
(*io_ids)¶ Return list of I/O selected by names.
- Parameters
io_ids – A list of strings containing names, numbers, regular expressions, slices, lists or tuples. If empty, then it will select all pins.
- Returns
A list of ios matching the given IDs, or just a single object if only a single match was found. Or None if no match was found.
-
skidl.logger module¶
Logging for generic messages and ERC.
-
class
skidl.logger.
CountCalls
(func)¶ Bases:
object
Decorator for counting the number of times a function is called.
This is used for counting errors and warnings passed to logging functions, making it easy to track if and how many errors/warnings were issued.
-
reset
()¶
-
-
class
skidl.logger.
SkidlLogFileHandler
(*args, **kwargs)¶ Bases:
logging.FileHandler
Logger that outputs messages to a file.
Open the specified file and use it as the stream for logging.
-
remove_log_file
()¶
-
-
class
skidl.logger.
SkidlLogger
(*args, **kwargs)¶ Bases:
logging.Logger
SKiDL logger that can stop output to log files and delete them.
Initialize the logger with a name and an optional level.
-
addHandler
(handler)¶ Add the specified handler to this logger.
-
removeHandler
(handler)¶ Remove the specified handler from this logger.
-
stop_file_output
()¶
-
skidl.net module¶
Handles nets.
-
class
skidl.net.
Traversal
(nets, pins)¶ Bases:
tuple
Create new instance of Traversal(nets, pins)
-
nets
¶ Alias for field number 0
-
pins
¶ Alias for field number 1
-
-
class
skidl.net.
Net
(name=None, circuit=None, *pins_nets_buses, **attribs)¶ Bases:
skidl.skidlbaseobj.SkidlBaseObject
Lists of connected pins are stored as nets using this class.
- Parameters
name – A string with the name of the net. If None or ‘’, then a unique net name will be assigned.
circuit – The Circuit object this net belongs to.
*pins_nets_buses – One or more Pin, Net, or Bus objects or lists/tuples of them to be connected to this net.
- Keyword Arguments
attribs – A dictionary of attributes and values to attach to the Net object.
-
erc_list
= [<function dflt_net_erc>]¶
-
classmethod
get
(name, circuit=None)¶ Get the net with the given name from a circuit, or return None.
-
classmethod
fetch
(name, *args, **attribs)¶ Get the net with the given name from a circuit, or create it if not found.
-
get_pins
()¶ Return a list of pins attached to this net.
-
get_nets
()¶ Return a list of nets attached to this net, including this net.
-
is_attached
(pin_net_bus)¶ Return true if the pin, net or bus is attached to this one.
-
is_movable
()¶ Return true if the net is movable to another circuit.
A net is movable if it’s not part of a Circuit or if there are no pins attached to it.
-
copy
(num_copies=None, circuit=None, **attribs)¶ Make zero or more copies of this net.
- Parameters
num_copies – Number of copies to make of this net.
- Keyword Arguments
attribs – Name/value pairs for setting attributes for the copy.
- Returns
A list of Net copies or a Net if num_copies==1.
- Raises
Exception if the requested number of copies is a non-integer or negative. –
Notes
An instance of a net can be copied just by calling it like so:
n = Net('A') # Create a net. n_copy = n() # Copy the net.
You can also use the multiplication operator to make copies:
n = 10 * Net('A') # Create an array of nets.
-
is_implicit
()¶ Return true if the net name is implicit.
-
connect
(*pins_nets_buses)¶ Return the net after connecting other pins, nets, and buses to it.
- Parameters
*pins_nets_buses – One or more Pin, Net, or Bus objects or lists/tuples of them to be connected to this net.
- Returns
The updated net with the new connections.
Notes
Connections to nets can also be made using the += operator like so:
atmega = Part('atmel', 'ATMEGA16U2') net = Net() net += atmega[1] # Connects pin 1 of chip to the net.
-
disconnect
(pin)¶ Remove the pin from this net but not any other nets it’s attached to.
-
merge_names
()¶ For multi-segment nets, select a common name for all the segments.
-
create_network
()¶ Create a network from a single net.
-
generate_netlist_net
(tool=None)¶ Generate the net information for inclusion in a netlist.
- Parameters
tool – The format for the netlist file (e.g., KICAD).
-
generate_xml_net
(tool=None)¶ Generate the net information for inclusion in an XML file.
- Parameters
tool – The format for the XML file (e.g., KICAD).
-
replace_spec_chars_in_name
()¶
-
property
width
¶ Return width of a Net, which is always 1.
-
property
name
¶ Get, set and delete the name of this net.
When setting the net name, if another net with the same name is found, the name for this net is adjusted to make it unique.
-
property
netclass
¶ Get, set and delete the net class assigned to this net.
If not net class is set, then reading the net class returns None.
You can’t overwrite the net class of a net once it’s set. You’ll have to delete it and then set it to a new value.
Also, assigning a net class of None will have no affect on the existing net class of a net.
-
property
drive
¶ Get, set and delete the drive strength of this net.
The drive strength cannot be set to a value less than its current value. So as pins are added to a net, the drive strength reflects the maximum drive value of the pins currently on the net.
-
property
valid
¶
-
test_validity
()¶
-
class
skidl.net.
NCNet
(name=None, circuit=None, *pins_nets_buses, **attribs)¶ Bases:
skidl.net.Net
Lists of unconnected pins are stored using this Net subclass.
This is a netlist subclass used for storing lists of pins which are explicitly specified as not being connected. This means the ERC won’t flag these pins as floating, but no net connections for these pins will be placed in the netlist so there will actually be no connections to these pins in the physical circuit.
- Parameters
name – A string with the name of the net. If None or ‘’, then a unique net name will be assigned.
*pins_nets_buses – One or more Pin, Net, or Bus objects or lists/tuples of them to be connected to this net.
- Keyword Arguments
attribs – A dictionary of attributes and values to attach to the object.
-
generate_netlist_net
(tool=None)¶ NO_CONNECT nets don’t generate anything for netlists.
-
property
drive
¶ Get the drive strength of this net.
The drive strength is always NOCONNECT_DRIVE. It can’t be changed. The drive strength cannot be deleted.
skidl.netclass module¶
Class for PCBNEW net classes.
-
class
skidl.netclass.
NetClass
(name, **attribs)¶ Bases:
object
skidl.netlist_to_skidl module¶
Convert a netlist into an equivalent SKiDL program.
-
skidl.netlist_to_skidl.
netlist_to_skidl
(netlist_src)¶
skidl.netlist_to_skidl_main module¶
Command-line program to convert a netlist into an equivalent SKiDL program.
-
skidl.netlist_to_skidl_main.
main
()¶
skidl.netpinlist module¶
Specialized list for handling nets, pins, and buses.
skidl.network module¶
Object for for handling series and parallel networks of two-pin parts, nets, and pins.
-
class
skidl.network.
Network
(*objs)¶ Bases:
list
Create a Network object from a list of pins, nets, and parts.
-
create_network
()¶ Creating a network from a network just returns the original network.
-
-
skidl.network.
tee
(ntwk)¶ Create a network “tee” by returning the first terminal of a Network object. Then you can create tee’ed networks like so: vi & r1 & r2 & tee(r3 & r4 & gnd) & r5 & gnd which becomes: vi—r1—r2-+-r5—gnd
r3—r4—gnd
skidl.note module¶
Supports user-specified notes that can be attached to other SKiDL objects.
-
class
skidl.note.
Note
(*notes)¶ Bases:
list
Stores one or more strings as notes.
Create a note.
- Parameters
notes – Either a string or an iterable containing multiple strings.
- Returns
A Note object containing note strings.
skidl.package module¶
Package a subcircuit so it can be used like a Part.
-
class
skidl.package.
Package
(**kwargs)¶ Bases:
skidl.interface.Interface
-
is_movable
()¶
-
-
skidl.package.
package
(subcirc_func)¶ Decorator that creates a package for a subcircuit routine.
skidl.part module¶
Handles parts.
-
class
skidl.part.
PinNumberSearch
(part)¶ Bases:
object
A class for restricting part pin indexing to only pin numbers while ignoring pin names.
-
get_pins
(*pin_ids, **criteria)¶
-
-
class
skidl.part.
PinNameSearch
(part)¶ Bases:
object
A class for restricting part pin indexing to only pin names while ignoring pin numbers.
-
get_pins
(*pin_ids, **criteria)¶
-
-
class
skidl.part.
Part
(lib=None, name=None, dest='NETLIST', tool=None, connections=None, part_defn=None, circuit=None, **kwargs)¶ Bases:
skidl.skidlbaseobj.SkidlBaseObject
A class for storing a definition of a schematic part.
-
ref
¶ String storing the reference of a part within a schematic (e.g., ‘R5’).
-
value
¶ String storing the part value (e.g., ‘3K3’).
-
footprint
¶ String storing the PCB footprint associated with a part (e.g., SOIC-8).
-
pins
¶ List of Pin objects for this part.
-
tag
¶ A tag string to link a part to its footprint in a pcb editor.
- Parameters
lib – Either a SchLib object or a schematic part library file name.
name – A string with name of the part to find in the library, or to assign to the part defined by the part definition.
dest – String that indicates where the part is destined for (e.g., LIBRARY).
tool – The format for the library file or part definition (e.g., KICAD).
connections – A dictionary with part pin names/numbers as keys and the nets to which they will be connected as values. For example: { ‘IN-‘:a_in, ‘IN+’:gnd, ‘1’:AMPED_OUTPUT, ‘14’:vcc, ‘7’:gnd }
part_defn – A list of strings that define the part (usually read from a schematic library file).
circuit – The Circuit object this Part belongs to.
- Keyword Arguments
kwargs – Name/value pairs for setting attributes for the part. For example, manf_num=’LM4808MP-8’ would create an attribute named ‘manf_num’ for the part and assign it the value ‘LM4808MP-8’.
- Raises
* Exception if the part library and definition are both missing. –
* Exception if an unknown file format is requested. –
-
erc_list
= [<function dflt_part_erc>]¶
-
add_xspice_io
(io)¶ Add XSPICE I/O to the pins of a part.
-
classmethod
get
(text, circuit=None)¶ Get the part with the given text from a circuit, or return None.
- Parameters
text – A text string that will be searched for in the list of parts.
- Keyword Arguments
circuit – The circuit whose parts will be searched. If set to None, then the parts in the default_circuit will be searched.
- Returns
A list of parts or a single part that match the text string with either their reference, name, alias, or their description.
-
parse
(get_name_only=False)¶ Create a part from its stored part definition.
- Parameters
get_name_only – When true, just get the name and aliases for the part. Leave the rest unparsed.
-
associate_pins
()¶ Make sure all the pins in a part have valid references to the part.
-
copy
(num_copies=None, dest='NETLIST', circuit=None, io=None, **attribs)¶ Make zero or more copies of this part while maintaining all pin/net connections.
- Parameters
num_copies – Number of copies to make of this part.
dest – Indicates where the copy is destined for (e.g., NETLIST).
circuit – The circuit this part should be added to.
io – XSPICE I/O names.
- Keyword Arguments
attribs – Name/value pairs for setting attributes for the copy.
- Returns
A list of Part copies or a single Part if num_copies==1.
- Raises
Exception if the requested number of copies is a non-integer or negative. –
Notes
An instance of a part can be copied just by calling it like so:
res = Part("Device",'R') # Get a resistor. res_copy = res(value='1K') # Copy the resistor and set resistance value.
You can also use the multiplication operator to make copies:
cap = Part("Device", 'C') # Get a capacitor caps = 10 * cap # Make an array with 10 copies of it.
-
validate
()¶ Check that pins and units reference the correct part that owns them.
-
copy_units
(src)¶ Make copies of the units from the source part.
-
add_pins
(*pins)¶ Add one or more pins to a part.
-
rmv_pins
(*pin_ids)¶ Remove one or more pins from a part.
-
swap_pins
(pin_id1, pin_id2)¶ Swap pin name/number between two pins of a part.
-
rename_pin
(pin_id, new_pin_name)¶ Assign a new name to a pin of a part.
-
renumber_pin
(pin_id, new_pin_num)¶ Assign a new number to a pin of a part.
-
get_pins
(*pin_ids, **criteria)¶ Return list of part pins selected by pin numbers or names.
- Parameters
pin_ids – A list of strings containing pin names, numbers, regular expressions, slices, lists or tuples. If empty, then it will select all pins.
- Keyword Arguments
criteria – Key/value pairs that specify attribute values the pins must have in order to be selected.
- Returns
A list of pins matching the given IDs and satisfying all the criteria, or just a single Pin object if only a single match was found. Or None if no match was found.
Notes
Pins can be selected from a part by using brackets like so:
atmega = Part('atmel', 'ATMEGA16U2') net = Net() atmega[1] += net # Connects pin 1 of chip to the net. net += atmega['RESET'] # Connects reset pin to the net.
-
is_connected
()¶ Return T/F depending upon whether a part is connected in a netlist.
If a part has pins but none of them are connected to nets, then this method will return False. Otherwise, it will return True even if the part has no pins (which can be the case for mechanical parts, silkscreen logos, or other non-electrical schematic elements).
-
attached_to
(nets=None)¶ Return True if any part pin is connected to a net in the list.
-
is_movable
()¶ Return T/F if the part can be moved from one circuit into another.
- This method returns true if:
the part is not in a circuit, or
the part has pins but none of them are connected to nets, or
the part has no pins (which can be the case for mechanical parts, silkscreen logos, or other non-electrical schematic elements).
-
set_pin_alias
(alias, *pin_ids, **criteria)¶ Set the alias for a part pin.
- Parameters
alias – The alias for the pin.
pin_ids – A list of strings containing pin names, numbers, regular expressions, slices, lists or tuples.
- Keyword Arguments
criteria – Key/value pairs that specify attribute values the pin must have in order to be selected.
- Returns
Nothing.
-
pin_aliases_to_attributes
()¶ Make each pin alias into an attribute of the part.
-
split_pin_names
(delimiters)¶ Use chars in delimiters to split pin names and add as aliases to each pin.
-
make_unit
(label, *pin_ids, **criteria)¶ Create a PartUnit from a set of pins in a Part object.
Parts can be organized into smaller pieces called PartUnits. A PartUnit acts like a Part but contains only a subset of the pins of the Part.
- Parameters
label – The label used to identify the PartUnit.
pin_ids – A list of strings containing pin names, numbers, regular expressions, slices, lists or tuples.
- Keyword Arguments
criteria – Key/value pairs that specify attribute values the pin must have in order to be selected.
- Returns
The PartUnit.
-
create_network
()¶ Create a network from the pins of a part.
-
generate_netlist_component
(tool=None)¶ Generate the part information for inclusion in a netlist.
- Parameters
tool – The format for the netlist file (e.g., KICAD).
-
generate_xml_component
(tool=None)¶ Generate the part information for inclusion in an XML file.
- Parameters
tool – The format for the XML file (e.g., KICAD).
-
generate_svg_component
(symtx='', tool=None, net_stubs=None)¶ Generate the SVG for displaying a part in an SVG schematic.
-
generate_pinboxes
(tool=None)¶ Generate the pinboxes for arranging parts in a schematic.
-
erc_desc
()¶ Create description of part for ERC and other error reporting.
-
export
()¶ Return a string to recreate a Part object.
-
property
hierarchical_name
¶
-
property
tag
¶ Return the part’s tag.
-
property
ref
¶ Get, set and delete the part reference.
When setting the part reference, if another part with the same reference is found, the reference for this part is adjusted to make it unique.
-
property
value
¶ Get, set and delete the part value.
-
property
foot
¶ Get, set and delete the part footprint.
-
property
match_pin_regex
¶ Get, set and delete the enable/disable of pin regular-expression matching.
-
-
class
skidl.part.
SkidlPart
(lib=None, name=None, dest='TEMPLATE', tool='skidl', connections=None, **attribs)¶ Bases:
skidl.part.Part
A class for storing a SKiDL definition of a schematic part. It’s identical to its Part superclass except:
The tool defaults to SKIDL.
- The destination defaults to TEMPLATE so that it’s easier to start
a part and then add pins to it without it being added to the netlist.
-
SKIDL
= 'skidl'¶
-
TEMPLATE
= 'TEMPLATE'¶
-
class
skidl.part.
PartUnit
(parent, label, *pin_ids, **criteria)¶ Bases:
skidl.part.Part
Create a PartUnit from a set of pins in a Part object.
Parts can be organized into smaller pieces called PartUnits. A PartUnit acts like a Part but contains only a subset of the pins of the Part.
- Parameters
part – This is the parent Part whose pins the PartUnit is built from.
pin_ids – A list of strings containing pin names, numbers, regular expressions, slices, lists or tuples. If empty, it will match every pin of the part.
- Keyword Arguments
criteria – Key/value pairs that specify attribute values the pin must have in order to be selected.
Examples
This will return unit 1 from a part:
lm358 = Part('linear','lm358') lm358a = PartUnit(lm358, unit=1)
Or you can specify the pins directly:
lm358a = PartUnit(lm358, 1, 2, 3)
-
add_pins_from_parent
(*pin_ids, **criteria)¶ Add selected pins from the parent to the part unit.
-
validate
()¶ Check that unit pins point to the parent part.
-
property
ref
¶ Get, set and delete the part reference.
When setting the part reference, if another part with the same reference is found, the reference for this part is adjusted to make it unique.
skidl.part_query module¶
Functions for finding/displaying parts and footprints.
-
skidl.part_query.
parse_search_terms
(terms)¶ Return a regular expression for a sequence of search terms.
Substitute a zero-width lookahead assertion (?= ) for each term. Thus, the “abc def” would become “(?=.*(abc))(?=.*(def))” and would match any string containing both “abc” and “def”. Or “abc (def|ghi)” would become “(?=.*(abc))((?=.*(def|ghi))” and would match any string containing “abc” and “def” or “ghi”. Quoted terms can be used for phrases containing whitespace.
-
skidl.part_query.
search_parts_iter
(terms, tool=None)¶ Return a list of (lib, part) sequences that match a regex term.
-
skidl.part_query.
search_parts
(terms, tool=None)¶ Print a list of parts with the regex terms within their name, alias, description or keywords.
-
skidl.part_query.
show_part
(lib, part_name, tool=None)¶ Print the I/O pins for a given part in a library.
- Parameters
lib – Either a SchLib object or the name of a library.
part_name – The name of the part in the library.
tool – The ECAD tool format for the library.
- Returns
A Part object.
-
class
skidl.part_query.
FootprintCache
(*args, **kwargs)¶ Bases:
dict
Dict for storing footprints from all directories.
-
reset
()¶
-
load
(path)¶ Load cache with footprints from libraries in fp-lib-table file.
-
-
skidl.part_query.
search_footprints_iter
(terms, tool=None)¶ Return a list of (lib, footprint) sequences that match a regex term.
-
skidl.part_query.
search_footprints
(terms, tool=None)¶ Print a list of footprints with the regex term within their description/tags.
-
skidl.part_query.
show_footprint
(lib, module_name, tool=None)¶ Print the pads for a given module in a library.
- Parameters
lib – The name of a library.
module_name – The name of the footprint in the library.
tool – The ECAD tool format for the library.
- Returns
A Part object.
-
skidl.part_query.
search
(terms, tool=None)¶ Print a list of parts with the regex terms within their name, alias, description or keywords.
-
skidl.part_query.
show
(lib, part_name, tool=None)¶ Print the I/O pins for a given part in a library.
- Parameters
lib – Either a SchLib object or the name of a library.
part_name – The name of the part in the library.
tool – The ECAD tool format for the library.
- Returns
A Part object.
skidl.pckg_info module¶
skidl.pin module¶
Handles part pins.
-
class
skidl.pin.
Pin
(**attribs)¶ Bases:
skidl.skidlbaseobj.SkidlBaseObject
A class for storing data about pins for a part.
- Parameters
attribs – Key/value pairs of attributes to add to the library.
-
nets
¶ The electrical nets this pin is connected to (can be >1).
-
part
¶ Link to the Part object this pin belongs to.
-
func
¶ Pin function such as PinType.types.INPUT.
-
do_erc
¶ When false, the pin is not checked for ERC violations.
-
class
types
(value)¶ Bases:
enum.IntEnum
An enumeration.
-
INPUT
= 1¶
-
OUTPUT
= 2¶
-
BIDIR
= 3¶
-
TRISTATE
= 4¶
-
PASSIVE
= 5¶
-
UNSPEC
= 6¶
-
PWRIN
= 7¶
-
PWROUT
= 8¶
-
OPENCOLL
= 9¶
-
OPENEMIT
= 10¶
-
PULLUP
= 11¶
-
PULLDN
= 12¶
-
NOCONNECT
= 13¶
-
-
classmethod
add_type
(*pin_types)¶ Add new pin type identifiers to the list of pin types.
- Parameters
pin_types – Strings identifying zero or more pin types.
-
class
drives
(value)¶ Bases:
enum.IntEnum
An enumeration.
-
NOCONNECT
= 1¶
-
NONE
= 2¶
-
PASSIVE
= 3¶
-
PULLUPDN
= 4¶
-
ONESIDE
= 5¶
-
TRISTATE
= 6¶
-
PUSHPULL
= 7¶
-
POWER
= 8¶
-
-
pin_info
= {<types.INPUT: 1>: {'drive': <drives.NONE: 2>, 'func_str': 'INPUT', 'function': 'INPUT', 'max_rcv': <drives.POWER: 8>, 'min_rcv': <drives.PASSIVE: 3>}, <types.OUTPUT: 2>: {'drive': <drives.PUSHPULL: 7>, 'func_str': 'OUTPUT', 'function': 'OUTPUT', 'max_rcv': <drives.PASSIVE: 3>, 'min_rcv': <drives.NONE: 2>}, <types.BIDIR: 3>: {'drive': <drives.TRISTATE: 6>, 'func_str': 'BIDIR', 'function': 'BIDIRECTIONAL', 'max_rcv': <drives.POWER: 8>, 'min_rcv': <drives.NONE: 2>}, <types.TRISTATE: 4>: {'drive': <drives.TRISTATE: 6>, 'func_str': 'TRISTATE', 'function': 'TRISTATE', 'max_rcv': <drives.TRISTATE: 6>, 'min_rcv': <drives.NONE: 2>}, <types.PASSIVE: 5>: {'drive': <drives.PASSIVE: 3>, 'func_str': 'PASSIVE', 'function': 'PASSIVE', 'max_rcv': <drives.POWER: 8>, 'min_rcv': <drives.NONE: 2>}, <types.UNSPEC: 6>: {'drive': <drives.NONE: 2>, 'func_str': 'UNSPEC', 'function': 'UNSPECIFIED', 'max_rcv': <drives.POWER: 8>, 'min_rcv': <drives.NONE: 2>}, <types.PWRIN: 7>: {'drive': <drives.NONE: 2>, 'func_str': 'PWRIN', 'function': 'POWER-IN', 'max_rcv': <drives.POWER: 8>, 'min_rcv': <drives.POWER: 8>}, <types.PWROUT: 8>: {'drive': <drives.POWER: 8>, 'func_str': 'PWROUT', 'function': 'POWER-OUT', 'max_rcv': <drives.PASSIVE: 3>, 'min_rcv': <drives.NONE: 2>}, <types.OPENCOLL: 9>: {'drive': <drives.ONESIDE: 5>, 'func_str': 'OPENCOLL', 'function': 'OPEN-COLLECTOR', 'max_rcv': <drives.TRISTATE: 6>, 'min_rcv': <drives.NONE: 2>}, <types.OPENEMIT: 10>: {'drive': <drives.ONESIDE: 5>, 'func_str': 'OPENEMIT', 'function': 'OPEN-EMITTER', 'max_rcv': <drives.TRISTATE: 6>, 'min_rcv': <drives.NONE: 2>}, <types.PULLUP: 11>: {'drive': <drives.PULLUPDN: 4>, 'func_str': 'PULLUP', 'function': 'PULLUP', 'max_rcv': <drives.POWER: 8>, 'min_rcv': <drives.NONE: 2>}, <types.PULLDN: 12>: {'drive': <drives.PULLUPDN: 4>, 'func_str': 'PULLDN', 'function': 'PULLDN', 'max_rcv': <drives.POWER: 8>, 'min_rcv': <drives.NONE: 2>}, <types.NOCONNECT: 13>: {'drive': <drives.NOCONNECT: 1>, 'func_str': 'NOCONNECT', 'function': 'NO-CONNECT', 'max_rcv': <drives.NOCONNECT: 1>, 'min_rcv': <drives.NOCONNECT: 1>}}¶
-
copy
(num_copies=None, **attribs)¶ Return copy or list of copies of a pin including any net connection.
- Parameters
num_copies – Number of copies to make of pin.
- Keyword Arguments
attribs – Name/value pairs for setting attributes for the pin.
Notes
An instance of a pin can be copied just by calling it like so:
p = Pin() # Create a pin. p_copy = p() # This is a copy of the pin.
-
is_connected
()¶ Return true if a pin is connected to a net (but not a no-connect net).
-
is_attached
(pin_net_bus)¶ Return true if this pin is attached to the given pin, net or bus.
-
split_name
(delimiters)¶ Use chars in divider to split a pin name and add substrings to aliases.
-
connect
(*pins_nets_buses)¶ Return the pin after connecting it to one or more nets or pins.
- Parameters
pins_nets_buses – One or more Pin, Net or Bus objects or lists/tuples of them.
- Returns
The updated pin with the new connections.
Notes
You can connect nets or pins to a pin like so:
p = Pin() # Create a pin. n = Net() # Create a net. p += net # Connect the net to the pin.
-
disconnect
()¶ Disconnect this pin from all nets.
-
get_nets
()¶ Return a list containing the Net objects connected to this pin.
-
get_pins
()¶ Return a list containing this pin.
-
create_network
()¶ Create a network from a single pin.
-
chk_conflict
(other_pin)¶ Check for electrical rule conflicts between this pin and another.
-
erc_desc
()¶ Return a string describing this pin for ERC.
-
get_pin_info
()¶
-
export
()¶ Return a string to recreate a Pin object.
-
property
net
¶ Return one of the nets the pin is connected to.
-
property
width
¶ Return width of a Pin, which is always 1.
-
property
drive
¶ Get, set and delete the drive strength of this pin.
-
BIDIR
= 3¶
-
INPUT
= 1¶
-
NOCONNECT
= 13¶
-
OPENCOLL
= 9¶
-
OPENEMIT
= 10¶
-
OUTPUT
= 2¶
-
PASSIVE
= 5¶
-
PULLDN
= 12¶
-
PULLUP
= 11¶
-
PWRIN
= 7¶
-
PWROUT
= 8¶
-
TRISTATE
= 4¶
-
UNSPEC
= 6¶
-
class
skidl.pin.
PhantomPin
(**attribs)¶ Bases:
skidl.pin.Pin
A pin type that exists solely to tie two pinless nets together. It will not participate in generating any netlists.
-
class
skidl.pin.
PinList
(num, name, part)¶ Bases:
list
A list of Pin objects that’s meant to look something like a Pin to a Part. This is used for vector I/O of XSPICE parts.
-
copy
()¶ Return a copy of a PinList for use when a Part is copied.
-
disconnect
()¶ Disconnect all the pins in the list.
-
is_connected
()¶
-
skidl.protonet module¶
Prototype of a net which can become a Net or a Bus depending upon what is connected to it.
-
class
skidl.protonet.
ProtoNet
(name=None, circuit=None)¶ Bases:
skidl.skidlbaseobj.SkidlBaseObject
-
create_network
()¶ Create a network from a single ProtoNet.
-
is_movable
()¶
-
skidl.pyspice module¶
Import this file to reconfigure SKiDL for doing SPICE simulations.
skidl.schlib module¶
Handles schematic libraries for various ECAD tools.
-
class
skidl.schlib.
SchLib
(filename=None, tool=None, lib_section=None, **attribs)¶ Bases:
object
A class for storing parts from a schematic component library file.
-
filename
¶ The name of the file from which the parts were read.
-
parts
¶ The list of parts (composed of Part objects).
- Parameters
filename – The name of the library file.
tool – The format of the library file (e.g., KICAD).
- Keyword Arguments
attribs – Key/value pairs of attributes to add to the library.
Load the parts from a library file.
-
classmethod
reset
()¶ Clear the cache of processed library files.
-
add_parts
(*parts)¶ Add one or more parts to a library.
-
get_parts
(use_backup_lib=True, **criteria)¶ Return parts from a library that match all the given criteria.
- Keyword Arguments
criteria – One or more keyword-argument pairs. The keyword specifies the attribute name while the argument contains the desired value of the attribute.
- Returns
A single Part or a list of Parts that match all the criteria.
-
get_part_by_name
(name, allow_multiples=False, silent=False, get_name_only=False)¶ Return a Part with the given name or alias from the part list.
- Parameters
name – The part name or alias to search for in the library.
allow_multiples – If true, return a list of parts matching the name. If false, return only the first matching part and issue a warning if there were more than one.
silent – If true, don’t issue errors or warnings.
- Returns
A single Part or a list of Parts that match all the criteria.
-
export
(libname, file_=None, tool=None)¶ Export a library into a file.
- Parameters
libname – A string containing the name of the library.
file – The file the library will be exported to. It can either be a file object or a string or None. If None, the file will be the same as the library name with the library suffix appended.
tool – The CAD tool library format to be used. Currently, this can only be SKIDL.
-
skidl.scriptinfo module¶
Routines for getting information about a script.
-
skidl.scriptinfo.
scriptinfo
()¶ Returns a dictionary with information about the running top level Python script: ————————————————————————— dir: directory containing script or compiled executable name: name of script or executable source: name of source code file ————————————————————————— name and source are identical if and only if running interpreted code. When running code compiled by py2exe or cx_freeze, source contains the name of the originating Python script. If compiled by PyInstaller, source contains no meaningful information.
Downloaded from: http://code.activestate.com/recipes/579018-python-determine-name-and-directory-of-the-top-lev/
-
skidl.scriptinfo.
get_script_name
()¶ Return the name of the top-level script.
-
skidl.scriptinfo.
get_skidl_trace
()¶ Return a string containing the source line trace where a SKiDL object was instantiated.
skidl.skidl module¶
-
class
skidl.skidl.
SkidlCfg
(*dirs)¶ Bases:
dict
Class for holding SKiDL configuration.
-
CFG_FILE_NAME
= '.skidlcfg'¶
-
load
(*dirs)¶ Load SKiDL configuration from JSON files in given dirs.
-
store
(dir='.')¶ Store SKiDL configuration as JSON in directory as .skidlcfg file.
-
-
skidl.skidl.
get_kicad_lib_tbl_dir
()¶ Get the path to where the global fp-lib-table file is found.
-
skidl.skidl.
invalidate_footprint_cache
(self, k, v)¶
-
skidl.skidl.
set_default_tool
(tool)¶ Set the ECAD tool that will be used by default.
-
skidl.skidl.
get_default_tool
()¶
-
skidl.skidl.
set_query_backup_lib
(val)¶ Set the boolean that controls searching for the backup library.
-
skidl.skidl.
get_query_backup_lib
()¶
-
skidl.skidl.
set_backup_lib
(lib)¶ Set the backup library.
-
skidl.skidl.
get_backup_lib
()¶
-
skidl.skidl.
no_files
(circuit=<skidl.circuit.Circuit object>)¶ Prevent creation of output files (netlists, ERC, logs) by this Circuit object.
skidl.skidlbaseobj module¶
Base object for Circuit, Interface, Package, Part, Net, Bus, Pin objects.
-
class
skidl.skidlbaseobj.
SkidlBaseObject
¶ Bases:
object
-
erc_list
= []¶
-
erc_assertion_list
= []¶
-
property
aliases
¶
-
property
notes
¶
-
copy
()¶
-
ERC
(*args, **kwargs)¶ Run ERC on this object.
-
add_erc_function
(func)¶ Add an ERC function to a class or class instance.
-
add_erc_assertion
(assertion, fail_msg='FAILED', severity=2)¶ Add an ERC assertion to a class or class instance.
-
skidl.utilities module¶
Utility functions used by the rest of SKiDL.
-
skidl.utilities.
norecurse
(f)¶ Decorator that keeps a function from recursively calling itself.
- Parameters
f (function) –
-
class
skidl.utilities.
TriggerDict
(*args, **kwargs)¶ Bases:
dict
This dict triggers a function when one of its entries changes.
-
skidl.utilities.
is_binary_file
(filename)¶ Return true if a file contains binary (non-text) characters.
-
skidl.utilities.
merge_dicts
(dct, merge_dct)¶ Dict merge that recurses through both dicts and updates keys.
- Parameters
dct – The dict that will be updated.
merge_dct – The dict whose values will be inserted into dct.
- Returns
Nothing.
-
skidl.utilities.
find_and_open_file
(filename, paths=None, ext=None, allow_failure=False, exclude_binary=False, descend=0)¶ Search for a file in list of paths, open it and return file pointer and full file name.
- Parameters
filename – Base file name (e.g., “my_file”).
paths – List of paths to search for the file.
ext – The extension for the file (e.g., “.txt”).
allow_failure – If false, failure to find file raises and exception.
exclude_binary – If true, skip files that contain binary data.
descend – If 0, don’t search lower-level directories. If positive, search that many levels down for the file. If negative, descend into subdirectories withcurrent_level limit.
-
skidl.utilities.
add_unique_attr
(obj, name, value, check_dup=False)¶ Create an attribute if the attribute name isn’t already used.
-
skidl.utilities.
num_to_chars
(num)¶ Return a string like ‘AB’ when given a number like 28.
-
skidl.utilities.
rmv_quotes
(s)¶ Remove starting and ending quotes from a string.
-
skidl.utilities.
add_quotes
(s)¶ Return string with added quotes if it contains whitespace or parens.
-
skidl.utilities.
is_iterable
(x)¶ Return True if x is iterable (but not a string).
-
skidl.utilities.
to_list
(x)¶ Return x if it is already a list, or return a list if x is a scalar.
-
skidl.utilities.
cnvt_to_var_name
(s)¶ Convert a string to a legal Python variable name and return it.
-
skidl.utilities.
list_or_scalar
(lst)¶ Return a list if passed a multi-element list, otherwise return a single scalar.
- Parameters
lst – Either a list or a scalar.
- Returns
A list if passed a multi-element list.
The list element if passed a single-element list.
None if passed an empty list.
A scalar if passed a scalar.
-
skidl.utilities.
flatten
(nested_list)¶ Return a flattened list of items from a nested list.
-
skidl.utilities.
rmv_attr
(objs, attr)¶ Remove an attribute from a list of objects.
-
skidl.utilities.
from_iadd
(objs)¶ Return True if one or more objects have attribute iadd_flag set to True.
-
skidl.utilities.
clr_iadd
(objs)¶ Delete iadd_flag attribute from a list of objects.
-
skidl.utilities.
reset_get_unique_name
()¶ Reset the heaps that store previously-assigned names.
-
skidl.utilities.
get_unique_name
(lst, attrib, prefix, initial=None)¶ Return a name that doesn’t collide with another in a list.
This subrcurrent_leveline is used to generate unique part references (e.g., “R12”) or unique net names (e.g., “N$5”).
- Parameters
lst – The list of objects containing names.
attrib – The attribute in each object containing the name.
prefix – The prefix attached to each name.
initial – The initial setting of the name (can be None or empty string).
- Returns
A string containing the unique name.
-
skidl.utilities.
fullmatch
(regex, string, flags=0)¶ Emulate python-3.4 re.fullmatch().
-
skidl.utilities.
filter_list
(lst, **criteria)¶ Return a list of objects whose attributes match a set of criteria.
Return a list of objects extracted from a list whose attributes match a set of criteria. The match is done using regular expressions. Example: filter_list(pins, name=’io[0-9]+’, direction=’bidir’) will return all the bidirectional pins of the component that have pin names starting with ‘io’ followed by a number (e.g., ‘IO45’).
If an attribute of the lst object is a list or tuple, each entry in the list/tuple will be checked for a match. Only one entry needs to match to consider the entire attribute a match. This feature is useful when searching for objects that contain a list of aliases, such as Part objects.
- Parameters
lst – The list from which objects will be extracted.
- Keywords Args:
- criteria: Keyword-argument pairs. The keyword specifies the attribute
name while the argument contains the desired value of the attribute. Regardless of what type the argument is, it is always compared as if it was a string. The argument can also be a regular expression that must match the entire string created from the attribute of the list object.
- Returns
A list of objects whose attributes match all the criteria.
-
skidl.utilities.
expand_indices
(slice_min, slice_max, match_regex, *indices)¶ Expand a list of indices into a list of integers and strings.
This function takes the indices used to select pins of parts and lines of buses and returns a flat list of numbers and strings. String and integer indices are put in the list unchanged, but slices are expanded into a list of integers before entering the final list.
- Parameters
slice_min – The minimum possible index.
slice_max – The maximum possible index (used for slice indices).
match_regex – If true,
indices – A list of indices made up of numbers, slices, text strings.
- Returns
A linear list of all the indices made up only of numbers and strings.
-
skidl.utilities.
find_num_copies
(**attribs)¶ Return the number of copies to make based on the number of attribute values.
- Keyword Arguments
attribs – Dict of Keyword/Value pairs for setting object attributes. If the value is a scalar, then the number of copies is one. If the value is a list/tuple, the number of copies is the length of the list/tuple.
- Returns
The length of the longest value in the dict of attributes.
- Raises
Exception if there are two or more list/tuple values with different –
lengths that are greater than 1. (All attribute values must be scalars –
or lists/tuples of the same length.) –
-
skidl.utilities.
opened
(f_or_fn, mode)¶ Yields an opened file or file-like object.
- Parameters
file_or_filename – Either an already opened file or file-like object, or a filename to open.
mode – The mode to open the file in.
-
skidl.utilities.
expand_buses
(pins_nets_buses)¶ Take list of pins, nets, and buses and return a list of only pins and nets.
-
skidl.utilities.
log_and_raise
(logger_in, exc_class, message)¶
-
skidl.utilities.
parse_sexp
(sexp, allow_underflow=False)¶ Parse an S-expression and return a nested list.
Module contents¶
SKiDL: A Python-Based Schematic Design Language
This module extends Python with the ability to design electronic circuits. It provides classes for working with:
Electronic parts (
Part
),Collections of part terminals (
Pin
) connected via wires (Net
), andGroups of related nets (
Bus
).
Using these classes, you can concisely describe the interconnection of parts using a flat or hierarchical structure. A resulting Python script outputs a netlist that can be imported into a PCB layout tool or Spice simulator. The script can also check the resulting circuitry for electrical rule violations.