use pin and net objects in connect_inst

This commit is contained in:
Sam Crow 2023-07-17 16:04:56 -07:00
parent d0339a90e6
commit 45b88889e4
3 changed files with 16 additions and 5 deletions

View File

@ -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

View File

@ -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

View File

@ -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