Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
Fix: Exporter: PCB: PCB net numbers (#95)
Browse files Browse the repository at this point in the history
* Replicate bug example

* Revert changes to example

* Fix net number gap

* Sort the list of nets
  • Loading branch information
ruben-iteng authored Oct 21, 2024
1 parent 0dd5df1 commit 44ca526
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/faebryk/exporters/pcb/kicad/pcb.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,10 @@ def apply_netlist(pcb_path: Path, netlist_path: Path):

# Remove nets ------------------------------------------------------------------
logger.debug(f"Removed nets: {nets_removed}")
removed_net_numbers = list[int]()
for net_name in nets_removed:
pcb_net, pads = pcb_nets[net_name]
removed_net_numbers.append(pcb_net.number)
pcb.kicad_pcb.nets.remove(pcb_net)
for pad in pads:
assert pad.net
Expand Down Expand Up @@ -166,12 +168,17 @@ def apply_netlist(pcb_path: Path, netlist_path: Path):
logger.debug(f"New nets: {nets_added}")
for net_name in nets_added:
# nl_net = nl_nets[net_name]
if removed_net_numbers:
net_number = removed_net_numbers.pop()
else:
net_number = len(pcb.kicad_pcb.nets)
pcb_net = C_kicad_pcb_file.C_kicad_pcb.C_net(
name=net_name,
number=len(pcb.kicad_pcb.nets),
number=net_number,
)
pcb.kicad_pcb.nets.append(pcb_net)
pcb_nets[net_name] = (pcb_net, [])
pcb.kicad_pcb.nets.sort(key=lambda x: x.number)

# Components ===================================================================
pcb_comps = {
Expand Down

0 comments on commit 44ca526

Please sign in to comment.