From 45b88889e4e03648ac718c15b6066dadb3219b0c Mon Sep 17 00:00:00 2001 From: Sam Crow Date: Mon, 17 Jul 2023 16:04:56 -0700 Subject: [PATCH] use pin and net objects in connect_inst --- compiler/base/geometry.py | 14 +++++++++++--- compiler/base/hierarchy_spice.py | 2 +- compiler/base/pin_spice.py | 5 ++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/compiler/base/geometry.py b/compiler/base/geometry.py index 29093a2d..a8ac89cb 100644 --- a/compiler/base/geometry.py +++ b/compiler/base/geometry.py @@ -285,9 +285,17 @@ class instance(geometry): return new_pins def connect_spice_pins(self, nets_list): - for i in range(len(self.pins)): - self.pins[i].set_inst_net(nets_list[i]) - nets_list[i].connect_pin(self.pins[i]) + """ + add the connection between instance pins and module nets + to both of their respective objects + nets_list must be the same length as self.spice_pins + """ + debug.check(len(self.spice_pins) == len(nets_list), + "must provide list of nets the same length as pin list\ + when connecting an instance") + for i in range(len(self.spice_pins)): + self.spice_pins[i].set_inst_net(nets_list[i]) + nets_list[i].connect_pin(self.spice_pins[i]) def calculate_transform(self, node): #set up the rotation matrix diff --git a/compiler/base/hierarchy_spice.py b/compiler/base/hierarchy_spice.py index b03fa4ef..e0d4f573 100644 --- a/compiler/base/hierarchy_spice.py +++ b/compiler/base/hierarchy_spice.py @@ -192,7 +192,7 @@ class spice(): # Order the arguments if the hard cell has a custom port order ordered_args = self.get_ordered_inputs(args) - if (check and num_pins != num_args): + if (num_pins != num_args): if num_pins < num_args: mod_pins = spice_pins + [""] * (num_args - num_pins) arg_pins = ordered_args diff --git a/compiler/base/pin_spice.py b/compiler/base/pin_spice.py index 0d2d2342..1b101bfd 100644 --- a/compiler/base/pin_spice.py +++ b/compiler/base/pin_spice.py @@ -13,7 +13,7 @@ class pin_spice: """ A class to represent a spice netlist pin. mod is the parent module that created this pin. - mod_net is the net object of this pin's parent module. + mod_net is the net object of this pin's parent module. It must have the same name as the pin. inst is the instance this pin is a part of, if any. inst_net is the net object from mod's nets which connects to this pin. """ @@ -45,6 +45,9 @@ class pin_spice: self.inst = inst def set_inst_net(self, net): + debug.check(self.inst_net is None, + "pin {} is already connected to net {} so it cannot also be connected to net {}\ + ".format(self.name, self.inst_net.name, net.name)) debug.check(isinstance(net, net_spice), "net must be a net_spice object") self.inst_net = net