From 7ddb1a39dcb892fd251aea1c1d52ee1ddb104769 Mon Sep 17 00:00:00 2001 From: mrg Date: Mon, 12 Dec 2022 13:58:30 -0800 Subject: [PATCH] Line wrap output spice subckt and instance lines at 80 characters. --- compiler/base/hierarchy_spice.py | 34 +++++++++++++++++++------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/compiler/base/hierarchy_spice.py b/compiler/base/hierarchy_spice.py index ba2f5bb9..4beb7c2e 100644 --- a/compiler/base/hierarchy_spice.py +++ b/compiler/base/hierarchy_spice.py @@ -8,6 +8,7 @@ import os import re import math +import textwrap as tr from pprint import pformat from openram import debug from openram import tech @@ -338,19 +339,21 @@ class spice(): return # write out the first spice line (the subcircuit) - sp.write("\n.SUBCKT {0} {1}\n".format(self.cell_name, - " ".join(self.pins))) + wrapped_pins = "\n+ ".join(tr.wrap(" ".join(self.pins))) + sp.write("\n.SUBCKT {0}\n+ {1}\n".format(self.cell_name, + wrapped_pins)) # write a PININFO line - pin_info = "*.PININFO" - for pin in self.pins: - if self.pin_type[pin] == "INPUT": - pin_info += " {0}:I".format(pin) - elif self.pin_type[pin] == "OUTPUT": - pin_info += " {0}:O".format(pin) - else: - pin_info += " {0}:B".format(pin) - sp.write(pin_info + "\n") + if False: + pin_info = "*.PININFO" + for pin in self.pins: + if self.pin_type[pin] == "INPUT": + pin_info += " {0}:I".format(pin) + elif self.pin_type[pin] == "OUTPUT": + pin_info += " {0}:O".format(pin) + else: + pin_info += " {0}:B".format(pin) + sp.write(pin_info + "\n") # Also write pins as comments for pin in self.pins: @@ -391,9 +394,11 @@ class spice(): " ".join(self.conns[i]))) sp.write("\n") else: - sp.write("X{0} {1} {2}\n".format(self.insts[i].name, - " ".join(self.conns[i]), - self.insts[i].mod.cell_name)) + wrapped_connections = "\n+ ".join(tr.wrap(" ".join(self.conns[i]))) + + sp.write("X{0}\n+ {1}\n+ {2}\n".format(self.insts[i].name, + wrapped_connections, + self.insts[i].mod.cell_name)) sp.write(".ENDS {0}\n".format(self.cell_name)) @@ -409,6 +414,7 @@ class spice(): sp.write("\n") + def sp_write(self, spname, lvs=False, trim=False): """Writes the spice to files""" debug.info(3, "Writing to {0}".format(spname))