-
Notifications
You must be signed in to change notification settings - Fork 76
Net
A net may either be a connection of at least two gates or a global input or output to the entire netlist. A net connects to a gate via the pins provided by the gate. The association of a net to a pin and its gate is stored within a so called endpoint.
A new net can be created using the create_net
function on the netlist. Each net has a unique ID and a name and may be part of a grouping. All these information are accessible using the get_id
, set_name
, get_name
, and get_grouping
functions.
net = netlist.create_net("example_net") # create a net with name "example_net"
net.get_id() # get the ID of the net
net.get_name() # get the name of the net
net.get_grouping() # get the grouping of the net
A net can be accessed by ID using the get_net_by_id
function and may be deleted from the netlist using delete_net
:
net = netlist.get_net_by_id(3)
netlist.delete_net(net)
Each net keeps track of its source (gate output) and destination (gate input) endpoints. Such endpoints may be added using add_source
and add_destination
. A list of source and destination endpoints can be retrieved using get_sources
and get_destinations
. Endpoints may also be removes from a net using remove_source
and remove_destination
.
net = netlist.create_net("example_net") # create a new net
gate = netlist.get_gate_by_id(3) # get gate with ID 3 (assumed to have a pin called "A")
net.add_destination(gate, "A") # add pin "A" of gate with ID 3 as destination of net
dest = net.get_destinations()[0] # get first (and in this case only) destination
net.remove_destination(dest) # remove the destination again
Additional commands allow to determine whether an endpoint is a source or a destination of a net and to get the total number of sources and destinations. These are given by is_a_source
, is_a_destination
, get_num_of_sources
, and get_num_of_destinations
.
All nets that have no source and no destination should be marked as global input or output nets. This can be done using mark_global_input_net
and mark_global_output_net
and can be reversed using unmark_global_input_net
and unmark_global_output_net
. The current status of a net in that regard can be checked using is_global_input_net
and is_global_output_net
.
net = netlist.get_net_by_id(3) # get net with ID 3
net.mark_global_input_net() # mark net as global input net
net.is_global_input_net() # return True
net.unmark_global_input_net() # unmark net
By providing the net as input, all these functions can also be executed on the netlist itself. In addition, calling get_global_input_nets
or get_global_output_nets
on the netlist returns a list of all global input or output nets respectively.
net = netlist.get_net_by_id(3) # get net with ID 3
netlist.mark_global_input_net(net) # mark net as global input net
netlist.is_global_input_net(net) # return True
netlist.unmark_global_input_net(net) # unmark net
netlist.get_global_output_nets() # return all global output nets