Line wrap output spice subckt and instance lines at 80 characters.

This commit is contained in:
mrg 2022-12-12 13:58:30 -08:00
parent 1a621cf41d
commit 7ddb1a39dc
1 changed files with 20 additions and 14 deletions

View File

@ -8,6 +8,7 @@
import os import os
import re import re
import math import math
import textwrap as tr
from pprint import pformat from pprint import pformat
from openram import debug from openram import debug
from openram import tech from openram import tech
@ -338,19 +339,21 @@ class spice():
return return
# write out the first spice line (the subcircuit) # write out the first spice line (the subcircuit)
sp.write("\n.SUBCKT {0} {1}\n".format(self.cell_name, wrapped_pins = "\n+ ".join(tr.wrap(" ".join(self.pins)))
" ".join(self.pins))) sp.write("\n.SUBCKT {0}\n+ {1}\n".format(self.cell_name,
wrapped_pins))
# write a PININFO line # write a PININFO line
pin_info = "*.PININFO" if False:
for pin in self.pins: pin_info = "*.PININFO"
if self.pin_type[pin] == "INPUT": for pin in self.pins:
pin_info += " {0}:I".format(pin) if self.pin_type[pin] == "INPUT":
elif self.pin_type[pin] == "OUTPUT": pin_info += " {0}:I".format(pin)
pin_info += " {0}:O".format(pin) elif self.pin_type[pin] == "OUTPUT":
else: pin_info += " {0}:O".format(pin)
pin_info += " {0}:B".format(pin) else:
sp.write(pin_info + "\n") pin_info += " {0}:B".format(pin)
sp.write(pin_info + "\n")
# Also write pins as comments # Also write pins as comments
for pin in self.pins: for pin in self.pins:
@ -391,9 +394,11 @@ class spice():
" ".join(self.conns[i]))) " ".join(self.conns[i])))
sp.write("\n") sp.write("\n")
else: else:
sp.write("X{0} {1} {2}\n".format(self.insts[i].name, wrapped_connections = "\n+ ".join(tr.wrap(" ".join(self.conns[i])))
" ".join(self.conns[i]),
self.insts[i].mod.cell_name)) 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)) sp.write(".ENDS {0}\n".format(self.cell_name))
@ -409,6 +414,7 @@ class spice():
sp.write("\n") sp.write("\n")
def sp_write(self, spname, lvs=False, trim=False): def sp_write(self, spname, lvs=False, trim=False):
"""Writes the spice to files""" """Writes the spice to files"""
debug.info(3, "Writing to {0}".format(spname)) debug.info(3, "Writing to {0}".format(spname))