cana.io.cnet module

BNS / Cell Collective .cnet (BLIF-like) import and export.

cana.io.cnet.parse_cnet(text)[source]

Parse BNS / Cell Collective .cnet text into a node list.

Format sketch:

.v <N>
.l <id> <name>
.n <id> <k> <in1> ... <ink>
<binstate> <out>   # don't-care bits are ``-`` (legacy ``2`` also accepted)
.e

Per-node heuristic: if any logic line uses don’t-care -/2, store that node’s cover as one_symbol_schemata only; otherwise import as a dense bit_lut (including ON-only minterm listings with implied 0s).

Import is faithful: missing peer representations are not filled. Call BooleanNetwork.fill_function_representation(...) (or the node helper) when you need the other slot.

Parameters:

text (str)

Return type:

List[BooleanNode]

cana.io.cnet.nodes_to_cnet(nodes, *, adjust_no_input=False, one_symbol_schemata=False)[source]

Export a node list to BNS / Cell Collective .cnet text.

Parameters:
  • nodes (Sequence[BooleanNode]) – Dense list[BooleanNode] hub (nodes[i].id == i).

  • adjust_no_input (bool) – If True, rewrite empty-input nodes as self-loops with identity LUT [0, 1] (BNS compatibility).

  • one_symbol_schemata (bool) – If True, export one-symbol (wildcard) covers; if False (default), export dense 2**k LUT rows.

Return type:

str

Dense export materializes bit_lut via BooleanFunction.get_bit_lut() when only expression/schemata are present. Schemata export materializes one_symbol_schemata similarly. If a representation cannot be derived, raises ValueError.