Skip to content

Commit

Permalink
net name prefix for panelization
Browse files Browse the repository at this point in the history
  • Loading branch information
ducky64 committed Aug 16, 2023
1 parent 86eeb17 commit c933b56
Show file tree
Hide file tree
Showing 14 changed files with 3,988 additions and 3,983 deletions.
12 changes: 9 additions & 3 deletions electronics_model/NetlistGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def visit_linkarray(self, context: TransformUtil.TransformContext, link: edgir.L
self.process_blocklike(context.path, link)

@staticmethod
def name_net(net: Iterable[TransformUtil.Path]) -> str:
def name_net(net: Iterable[TransformUtil.Path], net_prefix: str) -> str:
"""Names a net based on all the paths of ports and links that are part of the net."""
def pin_name_goodness(pin1: TransformUtil.Path, pin2: TransformUtil.Path) -> int:
assert not pin1.params and not pin2.params
Expand Down Expand Up @@ -281,7 +281,8 @@ def pin_name_goodness(pin1: TransformUtil.Path, pin2: TransformUtil.Path) -> int
else: # prefer shorter pin paths
return len(pin1.ports) - len(pin2.ports)
best_path = sorted(net, key=cmp_to_key(pin_name_goodness))[0]
return str(best_path)

return net_prefix + str(best_path)

def run(self) -> Netlist:
self.transform_design(self.design.design)
Expand Down Expand Up @@ -323,7 +324,12 @@ def name_pin(pin: TransformUtil.Path) -> TransformUtil.Path:
else:
return pin

named_nets = {self.name_net([name_pin(pin) for pin in net]): net
board_refdes_prefix = self.design.get_value(('refdes_prefix',))
if board_refdes_prefix is not None:
net_prefix = board_refdes_prefix
else:
net_prefix = ''
named_nets = {self.name_net([name_pin(pin) for pin in net], net_prefix): net
for net in nets}

netlist_blocks = {str(self.names[block_path]): block
Expand Down
48 changes: 24 additions & 24 deletions examples/EspProgrammer/EspProgrammer.net
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@
(sheetpath (names "/led_en/") (tstamps "/086c0268/"))
(tstamps "0296014b")))
(nets
(net (code 1) (name "vusb")
(net (code 1) (name "Uvusb")
(node (ref usb_uart.conn) (pin A4))
(node (ref usb_uart.conn) (pin B9))
(node (ref usb_uart.conn) (pin B4))
Expand All @@ -278,7 +278,7 @@
(node (ref usbconv.regin_cap0) (pin 1))
(node (ref usbconv.regin_cap1) (pin 1))
(node (ref reg_3v3.in_cap) (pin 1)))
(net (code 2) (name "gnd")
(net (code 2) (name "Ugnd")
(node (ref usb_esd) (pin 3))
(node (ref usb_uart.conn) (pin A1))
(node (ref usb_uart.conn) (pin B12))
Expand All @@ -297,76 +297,76 @@
(node (ref reg_3v3.out_cap) (pin 2))
(node (ref usb_uart.cc_pull.cc1) (pin 1))
(node (ref usb_uart.cc_pull.cc2) (pin 1)))
(net (code 3) (name "v3v3")
(net (code 3) (name "Uv3v3")
(node (ref reg_3v3.ic) (pin 5))
(node (ref out) (pin 1))
(node (ref led.package) (pin 2))
(node (ref led_en.package) (pin 2))
(node (ref reg_3v3.out_cap) (pin 1)))
(net (code 4) (name "usb_chain_0.d_P")
(net (code 4) (name "Uusb_chain_0.d_P")
(node (ref usb_uart.conn) (pin A6))
(node (ref usb_uart.conn) (pin B6))
(node (ref usb_esd) (pin 2))
(node (ref usbconv.ic) (pin 4)))
(net (code 5) (name "usb_chain_0.d_N")
(net (code 5) (name "Uusb_chain_0.d_N")
(node (ref usb_uart.conn) (pin A7))
(node (ref usb_uart.conn) (pin B7))
(node (ref usb_esd) (pin 1))
(node (ref usbconv.ic) (pin 5)))
(net (code 6) (name "usbconv.uart.tx")
(net (code 6) (name "Uusbconv.uart.tx")
(node (ref usbconv.ic) (pin 26))
(node (ref out) (pin 4)))
(net (code 7) (name "usbconv.uart.rx")
(net (code 7) (name "Uusbconv.uart.rx")
(node (ref usbconv.ic) (pin 25))
(node (ref out) (pin 3)))
(net (code 8) (name "usbconv.dtr")
(net (code 8) (name "Uusbconv.dtr")
(node (ref usbconv.ic) (pin 28))
(node (ref auto.dtr_res) (pin 1))
(node (ref auto.q_boot) (pin 2)))
(net (code 9) (name "usbconv.rts")
(net (code 9) (name "Uusbconv.rts")
(node (ref usbconv.ic) (pin 24))
(node (ref led_en.res) (pin 2))
(node (ref auto.rts_res) (pin 1))
(node (ref auto.q_en) (pin 2)))
(net (code 10) (name "auto.en")
(net (code 10) (name "Uauto.en")
(node (ref auto.q_en) (pin 3))
(node (ref out) (pin 6)))
(net (code 11) (name "auto.boot")
(net (code 11) (name "Uauto.boot")
(node (ref auto.q_boot) (pin 3))
(node (ref out) (pin 2)))
(net (code 12) (name "usbconv.suspend")
(net (code 12) (name "Uusbconv.suspend")
(node (ref usbconv.ic) (pin 12))
(node (ref led.res) (pin 2)))
(net (code 13) (name "usb_uart.conn.A5")
(net (code 13) (name "Uusb_uart.conn.A5")
(node (ref usb_uart.conn) (pin A5))
(node (ref usb_uart.cc_pull.cc1) (pin 2)))
(net (code 14) (name "usb_uart.conn.B5")
(net (code 14) (name "Uusb_uart.conn.B5")
(node (ref usb_uart.conn) (pin B5))
(node (ref usb_uart.cc_pull.cc2) (pin 2)))
(net (code 15) (name "usbconv.nsuspend")
(net (code 15) (name "Uusbconv.nsuspend")
(node (ref usbconv.ic) (pin 11)))
(net (code 16) (name "usbconv.ri")
(net (code 16) (name "Uusbconv.ri")
(node (ref usbconv.ic) (pin 2)))
(net (code 17) (name "usbconv.dcd")
(net (code 17) (name "Uusbconv.dcd")
(node (ref usbconv.ic) (pin 1)))
(net (code 18) (name "usbconv.dsr")
(net (code 18) (name "Uusbconv.dsr")
(node (ref usbconv.ic) (pin 27)))
(net (code 19) (name "usbconv.cts")
(net (code 19) (name "Uusbconv.cts")
(node (ref usbconv.ic) (pin 23)))
(net (code 20) (name "usbconv.ic.vdd")
(net (code 20) (name "Uusbconv.ic.vdd")
(node (ref usbconv.ic) (pin 6))
(node (ref usbconv.ic) (pin 9))
(node (ref usbconv.vdd_cap) (pin 1)))
(net (code 21) (name "auto.dtr_res.b")
(net (code 21) (name "Uauto.dtr_res.b")
(node (ref auto.dtr_res) (pin 2))
(node (ref auto.q_en) (pin 1)))
(net (code 22) (name "auto.rts_res.b")
(net (code 22) (name "Uauto.rts_res.b")
(node (ref auto.rts_res) (pin 2))
(node (ref auto.q_boot) (pin 1)))
(net (code 23) (name "led.res.a")
(net (code 23) (name "Uled.res.a")
(node (ref led.res) (pin 1))
(node (ref led.package) (pin 1)))
(net (code 24) (name "led_en.res.a")
(net (code 24) (name "Uled_en.res.a")
(node (ref led_en.res) (pin 1))
(node (ref led_en.package) (pin 1))))
)
Loading

0 comments on commit c933b56

Please sign in to comment.