import re
with open("boardloaf-he/netlist_fixed.xml", "r") as f:
    content = f.read()

# Find the (net ...) blocks
nets = re.findall(r'\(net\s+\(code\s+"[^"]+"\)\s+\(name\s+"([^"]+)"\)(.*?)\)', content, re.DOTALL)

print("MCU Pins:")
for net_name, nodes in nets:
    # Find nodes connected to MCU
    if '(ref "MCU")' in nodes:
        pins = re.findall(r'\(node\s+\(ref\s+"MCU"\)\s+\(pin\s+"([^"]+)"\)', nodes)
        for pin in pins:
            print(f"Pin {pin} -> Net {net_name}")

print("\nConnections to MUXes:")
for net_name, nodes in nets:
    if '74HC4051' in nodes or 'U' in nodes: # We need a better way to check if node is mux. Let's just print all nodes for key nets
        pass

