skidl.bus module¶
Handles buses.
- class skidl.bus.Bus(*args, **attribs)[source]¶
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'])
- connect(*pins_nets_buses)[source]¶
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].
- copy(num_copies=None, **attribs)[source]¶
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.
- classmethod fetch(name, *args, **attribs)[source]¶
Get the bus with the given name from a circuit, or create it if not found.
- classmethod get(name, circuit=None)[source]¶
Get the bus with the given name from a circuit, or return None.
- is_movable()[source]¶
Return true if the bus is movable to another circuit.
A bus is movable if all the nets in it are movable.
- 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.