devices module
Make devices and set device properties.
Used in the Logic Simulator project to make devices and ports and store their properties.
Classes
Device - stores device properties. Devices - makes and stores all the devices in the logic network.
- class devices.Device(device_id: int)
Bases:
object
Store device properties.
- Parameters
device_id – device ID.
- No public methods.
- class devices.Devices(names: names.Names)
Bases:
object
Make and store devices.
This class contains many functions for making devices and ports. It stores all the devices in a list.
- Parameters
names – instance of the names.Names() class.
- get_device(self, device_id):
Returns the Device object corresponding to the device ID.
- find_devices(self, device_kind=None):
Returns a list of device_ids of the specified device_kind.
- add_device(self, device_id, device_kind):
Adds the specified device to the network.
- add_input(self, device_id, input_id):
Adds the specified input to the specified device.
- add_output(self, device_id, output_id, signal=0):
Adds the specified output to the specified device.
- get_signal_name(self, device_id, output_id):
Returns the name string of the specified signal.
- get_signal_ids(self, signal_name):
Returns the device and output IDs of the specified signal.
- set_switch(self, device_id, signal):
Sets switch_state of specified device to signal.
- make_switch(self, device_id, initial_state):
Makes a switch device and sets its initial state.
- make_clock(self, device_id, clock_half_period):
Makes a clock device with the specified half period.
- make_gate(self, device_id, device_kind, no_of_inputs):
Makes logic gates with the specified number of inputs.
- make_d_type(self, device_id):
Makes a D-type device.
- cold_startup(self):
Simulates cold start-up of D-types and clocks.
- make_device(self, device_id, device_kind, device_property=None):
Creates the specified device and returns errors if unsuccessful.
- add_device(device_id, device_kind)
Add the specified device to the network.
- add_input(device_id, input_id)
Add the specified input to the specified device.
Return True if successful.
- add_output(device_id, output_id, signal=0)
Add the specified output to the specified device.
Return True if successful. The default output signal is LOW (0).
- cold_startup()
Simulate cold start-up of D-types and clocks.
Set the memory of the D-types to a random state and make the clocks begin from a random point in their cycles.
- find_devices(device_kind=None)
Return a list of device IDs of the specified device_kind.
Return a list of all device IDs in the network if no device_kind is specified.
- get_device(device_id: int)
Return the Device object corresponding to device_id.
- get_signal_ids(signal_name)
Return the device and output IDs of the specified signal.
- get_signal_name(device_id, port_id)
Return the name string of the specified signal.
The signal is specified by its device_id and port_id. Return None if either ID is invalid.
- make_clock(device_id, clock_half_period)
Make a clock device with the specified half period.
clock_half_period is an integer > 0. It is the number of simulation cycles before the clock switches state.
- make_d_type(device_id)
Make a D-type device.
- make_device(device_id, device_kind, device_property=None)
Create the specified device.
Return self.NO_ERROR if successful. Return corresponding error if not.
- make_gate(device_id, device_kind, no_of_inputs)
Make logic gates with the specified number of inputs.
- make_switch(device_id, initial_state)
Make a switch device and set its initial state.
- set_switch(device_id, signal)
Set the switch state of the specified device to signal.
Return True if successful.