-
Notifications
You must be signed in to change notification settings - Fork 76
Gate
A (logical) gate is an electronic component comprising multiple in- and outputs that implements one or more Boolean fucntion(s). It is connected to a number of nets via its pins and can thus be used in larger circuits to implement complex logic operations. Such a circuit on gate-level is usually referred to as a netlist.
Similar to all other netlist components in HAL, a gate comprises basic information such as an ID, a name, and a gate type that can be read and sometimes written using dedicated commands such as get_id
, get_name
, set_name
, and get_type
. A gate can be created by using create_gate
on the netlist while specifying its gate type and name. Furthermore, a gate can return the module and the grouping is is assigned to using get_module
and get_grouping
.
gt = GateType("example_type") # create an empty gate type
g = netlist.create_gate(gt, "example_gate") # create a new gate
id = g.get_id() # get the gate's ID
name = g.get_name() # get the gate's name
grouping = g.get_grouping() # get the gate's grouping
Additionally, a gate can be retrieved from the netlist by ID using get_gate_by_id
and may be deleted using delete_gate
. Deleting a gate may result in dangling wires.
g = netlist.get_gate_by_id(3) # get the gate with ID 3 from the netlist
netlist.delete_gate(g) # delete the gate
Each gate offers functions has multiple input and output pins that are potentially connected to a variety of nets. The user can retrieve the names of the in- and output pins by using get_input_pins
or get_output_pins
respectively. Furthermore, the net connected to such a pin can be retrieved using get_fan_in_net
and get_fan_out_net
. If required, even the whole endpoint of a pin is accessible via get_fan_in_endpoint
and get_fan_out_endpoint
. A list of all connected nets or endpoints is also available via get_fan_in_nets', 'get_fan_out_nets
, get_fan_in_endpoints
and get_fan_out_endpoints
.
out_pins = g.get_output_pins() # get all output pins
out_net = g.get_fan_out_net(out_pins[0]) # get net connected to first output pin
out_ep = g.get_fan_out_endpoint(out_pins[0]) # get endpoint of first output pin
in_eps = g.get_fan_in_endpoints() # get all endpoints at input pins
Easy access to the predecessors and successors of a gate is provided by the functions get_predecessors
, get_unique_predecessors
, get_successors
, and get_unique_successors
. The functions retrieving unique predecessors or successors return a list of gates while all remaining function return a list of endpoints of the predecessor or successor gate.
pred = g.get_predecessors() # get all predecessor endpoints
unique_succ = g.get_unique_successors() # get all unique successor gates