Skip to content

Netlist Utilities

SJulianS edited this page Nov 12, 2022 · 10 revisions

The netlist utils class provides several utility functions that aid reverse engineering.

Get Subgraph Function

It is often desirable to generate a Boolean function that is made up of multiple interconnected combinational gates. For this purpose, get_subgraph_function can be used. It takes a list of gates and the output net that is determined by the Boolean function as an input, see the respective Python documentation. Note that the variables in the Boolean function are replaced by net_[id] with [id] being the net ID of the respective input net to the Boolean function. This is done as gate pin names are not unique among the gates of which the Boolean function is being generated. For example, the list of gates could contain multiple gates with an input pin A, but for each gate this input pin could be connected to a different sub-circuit input. Additionally, net names are not unique in HAL, hence we rely on their IDs for unique Boolean function variable names. The generated Boolean function is not yet simplified.

gate1 = netlist.get_gate_by_id(1)
gate2 = netlist.get_gate_by_id(2)

subgraph = [gate1, gate2]

output_net = netlist.get_net_by_id(10)

bf = hal_py.NetlistUtils.get_subgraph_function(output_net, subgraph)

This code might for example return the following Boolean function: net_3 & net_4 & net_5 & net_6.

Clone this wiki locally