-
Notifications
You must be signed in to change notification settings - Fork 77
Module
A module is a functional unit comprising gates and their connected nets. Modules allow for hierarchization of the netlist and can be nested into each other, thus creating different levels of abstraction from the original netlist. Per design, modules only really contain gates and not nets. However, a module provides a set of functions to obtain all nets that are connected to gates within that module. By default, all gates of a netlist are contained in a single module called the "top_module" if no hierarchy is defined within the netlist file. Each module comes with a unique ID and a name. Additionally, a type may be assigned to a module if desired.
Within the GUI, modules can be managed using the Modules Widget. The user can create, manipulate, and remove modules from within the GUI using either GUI functionalities or the provided Python bindings.
TODO: widget and context menus, coloring
A module can be created by calling create_module
on the current netlist. When creating a new module, the user always needs to specify its parent module. In the example below, we simply use the "top_module" as a parent module. The ID cannot be changed by the user and may only be read by calling the get_id
function from C++ or Python. Read and write access to the name is provided by the get_name
and set_name
functions respectively. Similarly, the module's type can be accessed using get_type
and set_type
. Some example Python code is given below:
m = netlist.create_module("example_module", netlist.get_top_module()) # create a new module within the top module
print(m.get_name()) # print the name of the module
print(m.get_type()) # print the type of the module
print(m.get_id()) # print the ID of the module
To retrieve a module from the netlist that corresponds to a known ID, the get_module_by_id
command can be executed on the netlist. Furthermore, a module may be deleted using delete_module
as shown below. When deleting a module, all gates assigned to that module are handed over to its parent module.
g = netlist.get_module_by_id(3) # get the module with ID 3 from the netlist
netlist.delete_module(g) # delete the module
Gates can be added to a module by calling assign_gate
and removed by using remove_gate
. Furthermore, the user can check whether a gate or module is part of a module by resorting to contains_gate
and contains_module
. Finally, a list of contained gates and submodules is returned by the functions get_gates
and get_submodules
. A short example is given below:
m = netlist.create_module("example_module", netlist.get_top_module()) # create a new module within the top module
m.assign_gate(netlist.get_gate_by_id(1)) # assign gate with ID 1 to module
m.contains_gate(netlist.get_gate_by_id(4)) # return 'false'
gates = m.get_gates() # return a list containing only the gate with ID 1
g.remove_gate(gates[0]) # remove gate with ID 1 from module
TODO: get_input_nets, get_output_nets, get_internal_nets, get_gate_by_id TODO: add reference to Python Doc