mirror of
https://github.com/VLSIDA/OpenRAM.git
synced 2026-09-04 08:44:12 +02:00
Move verify into a module. Make characterizer a module. Move exe searching to modules.
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
"""
|
||||
This is a module that will import the correct DRC/LVS/PEX
|
||||
module based on what tools are found. It is a layer of indirection
|
||||
to enable multiple verification tool support.
|
||||
|
||||
Each DRC/LVS/PEX tool should implement the functions run_drc, run_lvs, and
|
||||
run_pex, repsectively. If there is an error, they should abort and report the errors.
|
||||
If not, OpenRAM will continue as if nothing happened!
|
||||
"""
|
||||
|
||||
import os
|
||||
import debug
|
||||
from globals import OPTS,find_exe,get_tool
|
||||
|
||||
|
||||
debug.info(2,"Initializing verify...")
|
||||
|
||||
if not OPTS.check_lvsdrc:
|
||||
debug.info(1,"LVS/DRC/PEX disabled.")
|
||||
drc_exe = None
|
||||
lvs_exe = None
|
||||
pex_exe = None
|
||||
else:
|
||||
drc_exe = get_tool("DRC",["calibre","assura","magic"])
|
||||
lvs_exe = get_tool("LVS",["calibre","assura","netgen"])
|
||||
pex_exe = get_tool("PEX",["calibre","magic"])
|
||||
|
||||
|
||||
if drc_exe == None:
|
||||
pass
|
||||
elif "calibre" in drc_exe:
|
||||
from calibre import run_drc
|
||||
elif "assura" in drc_exe:
|
||||
from assura import run_drc
|
||||
elif "magic" in drc_exe:
|
||||
from magic import run_drc
|
||||
else:
|
||||
debug.warning("Did not find a supported DRC tool.")
|
||||
|
||||
if lvs_exe == None:
|
||||
pass
|
||||
elif "calibre" in lvs_exe:
|
||||
from calibre import run_lvs
|
||||
elif "assura" in lvs_exe:
|
||||
from assura import run_lvs
|
||||
elif "netgen" in lvs_exe:
|
||||
from magic import run_lvs
|
||||
else:
|
||||
debug.warning("Did not find a supported LVS tool.")
|
||||
|
||||
|
||||
if pex_exe == None:
|
||||
pass
|
||||
elif "calibre" in pex_exe:
|
||||
from calibre import run_pex
|
||||
elif "magic" in pex_exe:
|
||||
from magic import run_pex
|
||||
else:
|
||||
debug.warning("Did not find a supported PEX tool.")
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
"""
|
||||
This is a DRC/LVS interface for Assura. It implements completely
|
||||
independently two functions: run_drc and run_lvs, that perform these
|
||||
functions in batch mode and will return true/false if the result
|
||||
passes. All of the setup (the rules, temp dirs, etc.) should be
|
||||
contained in this file. Replacing with another DRC/LVS tool involves
|
||||
rewriting this code to work properly. Porting to a new technology in
|
||||
Assura means pointing the code to the proper DRC and LVS rule files.
|
||||
|
||||
LVS Notes:
|
||||
|
||||
For some processes the FET models are sub-circuits. Meaning, the
|
||||
first letter of their SPICE instantiation begins with 'X' not 'M'.
|
||||
The former confuses Assura, however, so to get these sub-circuit models
|
||||
to LVS properly, an empty sub-circuit must be inserted into the
|
||||
LVS SPICE netlist. The sub-circuits are pointed to using the
|
||||
drc["lvs_subcircuits"] variable, and additional options must be
|
||||
inserted in the runset.
|
||||
"""
|
||||
|
||||
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
import debug
|
||||
import globals
|
||||
|
||||
|
||||
def run_drc(name, gds_name):
|
||||
"""Run DRC check on a given top-level name which is
|
||||
implemented in gds_name."""
|
||||
OPTS = globals.get_opts()
|
||||
|
||||
from tech import drc
|
||||
|
||||
drc_rules = drc["drc_rules"]
|
||||
drc_runset = OPTS.openram_temp + name + ".rsf"
|
||||
drc_log_file = "%s%s.log" % (OPTS.openram_temp, name)
|
||||
|
||||
# write the runset file
|
||||
# the runset file contains all the options to run Assura
|
||||
# different processes may require different options
|
||||
f = open(drc_runset, "w")
|
||||
f.write("avParameters(\n")
|
||||
f.write(" ?flagDotShapes t\n")
|
||||
f.write(" ?flagMalformed t\n")
|
||||
f.write(" ?flagPathNonManhattanSeg all\n")
|
||||
f.write(" ?flagPathShortSegments endOnlySmart\n")
|
||||
f.write(" ?maintain45 nil\n")
|
||||
f.write(" ?combineNearCollinearEdges nil\n")
|
||||
f.write(")\n")
|
||||
f.write("\n")
|
||||
f.write("avParameters(\n")
|
||||
f.write(" ?inputLayout ( \"gds2\" \"%s\" )\n" % (gds_name))
|
||||
f.write(" ?cellName \"%s\"\n" % (name))
|
||||
f.write(" ?workingDirectory \"%s\"\n" % (OPTS.openram_temp))
|
||||
f.write(" ?rulesFile \"%s\"\n" % (drc_rules))
|
||||
f.write(" ?set ( \"GridCheck\" )\n")
|
||||
f.write(" ?avrpt t\n")
|
||||
f.write(")\n")
|
||||
f.close()
|
||||
|
||||
# run drc
|
||||
cwd = os.getcwd()
|
||||
os.chdir(OPTS.openram_temp)
|
||||
cmd = "assura {0} 2> {1} 1> {2}".format(drc_runset, drc_log_file, drc_log_file)
|
||||
debug.info(1, cmd)
|
||||
os.system(cmd)
|
||||
os.chdir(cwd)
|
||||
|
||||
# count and report errors
|
||||
errors = 0
|
||||
try:
|
||||
f = open(OPTS.openram_temp+name+".err", "r")
|
||||
except:
|
||||
debug.error("Unable to retrieve DRC results file.",1)
|
||||
results = f.readlines()
|
||||
f.close()
|
||||
for line in results:
|
||||
if re.match("Rule No.", line):
|
||||
if re.search("# INFO:", line) == None:
|
||||
errors = errors + 1
|
||||
debug.info(1, line)
|
||||
|
||||
if errors > 0:
|
||||
debug.error("Errors: %d" % (errors))
|
||||
|
||||
return errors
|
||||
|
||||
|
||||
def run_lvs(name, gds_name, sp_name):
|
||||
"""Run LVS check on a given top-level name which is
|
||||
implemented in gds_name and sp_name. """
|
||||
OPTS = globals.get_opts()
|
||||
|
||||
from tech import drc
|
||||
|
||||
lvs_rules = drc["lvs_rules"]
|
||||
lvs_runset = OPTS.openram_temp + name + ".rsf"
|
||||
lvs_compare = drc["lvs_compare"]
|
||||
lvs_bindings = drc["lvs_bindings"]
|
||||
lvs_log_file = "{0}{1}.log".format(OPTS.openram_temp, name)
|
||||
# Needed when FET models are sub-circuits
|
||||
if drc.has_key("lvs_subcircuits"):
|
||||
lvs_sub_file = drc["lvs_subcircuits"]
|
||||
else:
|
||||
lvs_sub_file = ""
|
||||
|
||||
# write the runset file
|
||||
# the runset file contains all the options to run Assura
|
||||
# different processes may require different options
|
||||
f = open(lvs_runset, "w")
|
||||
f.write("avParameters(\n")
|
||||
f.write(" ?inputLayout ( \"gds2\" \"{}\" )\n".format(gds_name))
|
||||
f.write(" ?cellName \"{}\"\n".format(name))
|
||||
f.write(" ?workingDirectory \"{}\"\n".format(OPTS.openram_temp))
|
||||
f.write(" ?rulesFile \"{}\"\n".format(lvs_rules))
|
||||
f.write(" ?autoGrid nil\n")
|
||||
f.write(" ?avrpt t\n")
|
||||
# The below options vary greatly between processes and cell-types
|
||||
f.write(" ?set (\"NO_SUBC_IN_GRLOGIC\")\n")
|
||||
f.write(")\n")
|
||||
f.write("\n")
|
||||
c = open(lvs_compare, "r")
|
||||
lines = c.read()
|
||||
c.close
|
||||
f.write(lines)
|
||||
f.write("\n")
|
||||
f.write("avCompareRules(\n")
|
||||
f.write(" schematic(\n")
|
||||
# Needed when FET models are sub-circuits
|
||||
if os.path.isfile(lvs_sub_file):
|
||||
f.write(" genericDevice(emptySubckt)\n")
|
||||
f.write(" netlist( spice \"{}\" )\n".format(lvs_sub_file))
|
||||
f.write(" netlist( spice \"{}\" )\n".format(sp_name))
|
||||
f.write(" )\n")
|
||||
f.write(" layout(\n")
|
||||
# Separate gnd shapes are sometimes not connected by metal, so this connects by name
|
||||
# The use of this option is not recommended for final DRC
|
||||
f.write(" joinNets( root \"gnd\" \"gnd*\" ) \n")
|
||||
f.write(" )\n")
|
||||
f.write(" bindingFile( \"{}\" )\n".format(lvs_bindings))
|
||||
f.write(")\n")
|
||||
f.write("\n")
|
||||
f.write("avLVS()\n")
|
||||
f.close()
|
||||
|
||||
# run lvs
|
||||
cwd = os.getcwd()
|
||||
os.chdir(OPTS.openram_temp)
|
||||
cmd = "assura {0} 2> {1} 1> {2}".format(lvs_runset, lvs_log_file, lvs_log_file)
|
||||
debug.info(1, cmd)
|
||||
os.system(cmd)
|
||||
os.chdir(cwd)
|
||||
|
||||
errors = 0
|
||||
try:
|
||||
f = open(OPTS.openram_temp+name+".csm", "r")
|
||||
except:
|
||||
debug.error("Unable to retrieve LVS results file.",1)
|
||||
results = f.readlines()
|
||||
f.close()
|
||||
for line in results:
|
||||
if re.search("errors", line):
|
||||
errors = errors + 1
|
||||
debug.info(1, line)
|
||||
elif re.search("Schematic and Layout", line):
|
||||
debug.info(1, line)
|
||||
|
||||
return errors
|
||||
@@ -0,0 +1,344 @@
|
||||
"""
|
||||
This is a DRC/LVS interface for calibre. It implements completely
|
||||
independently two functions: run_drc and run_lvs, that perform these
|
||||
functions in batch mode and will return true/false if the result
|
||||
passes. All of the setup (the rules, temp dirs, etc.) should be
|
||||
contained in this file. Replacing with another DRC/LVS tool involves
|
||||
rewriting this code to work properly. Porting to a new technology in
|
||||
Calibre means pointing the code to the proper DRC and LVS rule files.
|
||||
|
||||
A calibre DRC runset file contains, at the minimum, the following information:
|
||||
|
||||
*drcRulesFile: /mada/software/techfiles/FreePDK45/ncsu_basekit/techfile/calibre/calibreDRC.rul
|
||||
*drcRunDir: .
|
||||
*drcLayoutPaths: ./cell_6t.gds
|
||||
*drcLayoutPrimary: cell_6t
|
||||
*drcLayoutSystem: GDSII
|
||||
*drcResultsformat: ASCII
|
||||
*drcResultsFile: cell_6t.drc.results
|
||||
*drcSummaryFile: cell_6t.drc.summary
|
||||
*cmnFDILayerMapFile: ./layer.map
|
||||
*cmnFDIUseLayerMap: 1
|
||||
|
||||
This can be executed in "batch" mode with the following command:
|
||||
|
||||
calibre -gui -drc example_drc_runset -batch
|
||||
|
||||
To open the results, you can do this:
|
||||
|
||||
calibredrv cell_6t.gds
|
||||
Select Verification->Start RVE.
|
||||
Select the cell_6t.drc.results file.
|
||||
Click on the errors and they will highlight in the design layout viewer.
|
||||
|
||||
For LVS:
|
||||
|
||||
*lvsRulesFile: /mada/software/techfiles/FreePDK45/ncsu_basekit/techfile/calibre/calibreLVS.rul
|
||||
*lvsRunDir: .
|
||||
*lvsLayoutPaths: ./cell_6t.gds
|
||||
*lvsLayoutPrimary: cell_6t
|
||||
*lvsSourcePath: ./cell_6t.sp
|
||||
*lvsSourcePrimary: cell_6t
|
||||
*lvsSourceSystem: SPICE
|
||||
*lvsSpiceFile: extracted.sp
|
||||
*lvsPowerNames: vdd
|
||||
*lvsGroundNames: vss
|
||||
*lvsIgnorePorts: 1
|
||||
*lvsERCDatabase: cell_6t.erc.results
|
||||
*lvsERCSummaryFile: cell_6t.erc.summary
|
||||
*lvsReportFile: cell_6t.lvs.report
|
||||
*lvsMaskDBFile: cell_6t.maskdb
|
||||
*cmnFDILayerMapFile: ./layer.map
|
||||
*cmnFDIUseLayerMap: 1
|
||||
|
||||
To run and see results:
|
||||
|
||||
calibre -gui -lvs example_lvs_runset -batch
|
||||
more cell_6t.lvs.report
|
||||
"""
|
||||
|
||||
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
import debug
|
||||
import globals
|
||||
import subprocess
|
||||
|
||||
|
||||
def run_drc(name, gds_name):
|
||||
"""Run DRC check on a given top-level name which is
|
||||
implemented in gds_name."""
|
||||
OPTS = globals.get_opts()
|
||||
|
||||
# the runset file contains all the options to run calibre
|
||||
from tech import drc
|
||||
drc_rules = drc["drc_rules"]
|
||||
|
||||
drc_runset = {
|
||||
'drcRulesFile': drc_rules,
|
||||
'drcRunDir': OPTS.openram_temp,
|
||||
'drcLayoutPaths': gds_name,
|
||||
'drcLayoutPrimary': name,
|
||||
'drcLayoutSystem': 'GDSII',
|
||||
'drcResultsformat': 'ASCII',
|
||||
'drcResultsFile': OPTS.openram_temp + name + ".drc.results",
|
||||
'drcSummaryFile': OPTS.openram_temp + name + ".drc.summary",
|
||||
'cmnFDILayerMapFile': drc["layer_map"],
|
||||
'cmnFDIUseLayerMap': 1
|
||||
}
|
||||
|
||||
# write the runset file
|
||||
f = open(OPTS.openram_temp + "drc_runset", "w")
|
||||
for k in sorted(drc_runset.iterkeys()):
|
||||
f.write("*%s: %s\n" % (k, drc_runset[k]))
|
||||
f.close()
|
||||
|
||||
# run drc
|
||||
cwd = os.getcwd()
|
||||
os.chdir(OPTS.openram_temp)
|
||||
errfile = "{0}{1}.drc.err".format(OPTS.openram_temp, name)
|
||||
outfile = "{0}{1}.drc.out".format(OPTS.openram_temp, name)
|
||||
|
||||
cmd = "calibre -gui -drc {0}drc_runset -batch 2> {1} 1> {2}".format(OPTS.openram_temp,
|
||||
errfile,
|
||||
outfile)
|
||||
debug.info(1, cmd)
|
||||
os.system(cmd)
|
||||
os.chdir(cwd)
|
||||
|
||||
# check the result for these lines in the summary:
|
||||
# TOTAL Original Layer Geometries: 106 (157)
|
||||
# TOTAL DRC RuleChecks Executed: 156
|
||||
# TOTAL DRC Results Generated: 0 (0)
|
||||
try:
|
||||
f = open(drc_runset['drcSummaryFile'], "r")
|
||||
except:
|
||||
debug.error("Unable to retrieve DRC results file. Is calibre set up?",1)
|
||||
results = f.readlines()
|
||||
f.close()
|
||||
# those lines should be the last 3
|
||||
results = results[-3:]
|
||||
geometries = int(re.split("\W+", results[0])[5])
|
||||
rulechecks = int(re.split("\W+", results[1])[4])
|
||||
errors = int(re.split("\W+", results[2])[5])
|
||||
|
||||
# always display this summary
|
||||
if errors > 0:
|
||||
debug.error("%-25s\tGeometries: %d\tChecks: %d\tErrors: %d" %
|
||||
(name, geometries, rulechecks, errors))
|
||||
else:
|
||||
debug.info(1, "%-25s\tGeometries: %d\tChecks: %d\tErrors: %d" %
|
||||
(name, geometries, rulechecks, errors))
|
||||
|
||||
return errors
|
||||
|
||||
|
||||
def run_lvs(name, gds_name, sp_name):
|
||||
"""Run LVS check on a given top-level name which is
|
||||
implemented in gds_name and sp_name. """
|
||||
OPTS = globals.get_opts()
|
||||
from tech import drc
|
||||
lvs_rules = drc["lvs_rules"]
|
||||
lvs_runset = {
|
||||
'lvsRulesFile': lvs_rules,
|
||||
'lvsRunDir': OPTS.openram_temp,
|
||||
'lvsLayoutPaths': gds_name,
|
||||
'lvsLayoutPrimary': name,
|
||||
'lvsSourcePath': sp_name,
|
||||
'lvsSourcePrimary': name,
|
||||
'lvsSourceSystem': 'SPICE',
|
||||
'lvsSpiceFile': OPTS.openram_temp + "extracted.sp",
|
||||
'lvsPowerNames': 'vdd',
|
||||
'lvsGroundNames': 'gnd',
|
||||
'lvsIncludeSVRFCmds': 1,
|
||||
'lvsSVRFCmds': '{VIRTUAL CONNECT NAME VDD? GND? ?}',
|
||||
'lvsIgnorePorts': 1,
|
||||
'lvsERCDatabase': OPTS.openram_temp + name + ".erc.results",
|
||||
'lvsERCSummaryFile': OPTS.openram_temp + name + ".erc.summary",
|
||||
'lvsReportFile': OPTS.openram_temp + name + ".lvs.report",
|
||||
'lvsMaskDBFile': OPTS.openram_temp + name + ".maskdb",
|
||||
'cmnFDILayerMapFile': drc["layer_map"],
|
||||
'cmnFDIUseLayerMap': 1,
|
||||
'cmnVConnectNames': 'vdd, gnd',
|
||||
#'cmnVConnectNamesState' : 'ALL', #connects all nets with the same name
|
||||
}
|
||||
|
||||
# write the runset file
|
||||
f = open(OPTS.openram_temp + "lvs_runset", "w")
|
||||
for k in sorted(lvs_runset.iterkeys()):
|
||||
f.write("*%s: %s\n" % (k, lvs_runset[k]))
|
||||
f.close()
|
||||
|
||||
# run LVS
|
||||
cwd = os.getcwd()
|
||||
os.chdir(OPTS.openram_temp)
|
||||
errfile = "{0}{1}.lvs.err".format(OPTS.openram_temp, name)
|
||||
outfile = "{0}{1}.lvs.out".format(OPTS.openram_temp, name)
|
||||
|
||||
cmd = "calibre -gui -lvs {0}lvs_runset -batch 2> {1} 1> {2}".format(OPTS.openram_temp,
|
||||
errfile,
|
||||
outfile)
|
||||
debug.info(1, cmd)
|
||||
os.system(cmd)
|
||||
os.chdir(cwd)
|
||||
|
||||
# check the result for these lines in the summary:
|
||||
f = open(lvs_runset['lvsReportFile'], "r")
|
||||
results = f.readlines()
|
||||
f.close()
|
||||
|
||||
# NOT COMPARED
|
||||
# CORRECT
|
||||
# INCORRECT
|
||||
test = re.compile("# CORRECT #")
|
||||
correct = filter(test.search, results)
|
||||
test = re.compile("NOT COMPARED")
|
||||
notcompared = filter(test.search, results)
|
||||
test = re.compile("# INCORRECT #")
|
||||
incorrect = filter(test.search, results)
|
||||
|
||||
# Errors begin with "Error:"
|
||||
test = re.compile("\s+Error:")
|
||||
errors = filter(test.search, results)
|
||||
for e in errors:
|
||||
debug.error(e.strip("\n"))
|
||||
|
||||
summary_errors = len(notcompared) + len(incorrect) + len(errors)
|
||||
|
||||
# also check the extraction summary file
|
||||
f = open(lvs_runset['lvsReportFile'] + ".ext", "r")
|
||||
results = f.readlines()
|
||||
f.close()
|
||||
|
||||
test = re.compile("ERROR:")
|
||||
exterrors = filter(test.search, results)
|
||||
for e in exterrors:
|
||||
debug.error(e.strip("\n"))
|
||||
|
||||
test = re.compile("WARNING:")
|
||||
extwarnings = filter(test.search, results)
|
||||
for e in extwarnings:
|
||||
debug.warning(e.strip("\n"))
|
||||
|
||||
# MRG - 9/26/17 - Change this to exclude warnings because of
|
||||
# multiple labels on different pins in column mux.
|
||||
ext_errors = len(exterrors)
|
||||
ext_warnings = len(extwarnings)
|
||||
|
||||
# also check the output file
|
||||
f = open(outfile, "r")
|
||||
results = f.readlines()
|
||||
f.close()
|
||||
|
||||
# Errors begin with "ERROR:"
|
||||
test = re.compile("ERROR:")
|
||||
stdouterrors = filter(test.search, results)
|
||||
for e in stdouterrors:
|
||||
debug.error(e.strip("\n"))
|
||||
|
||||
out_errors = len(stdouterrors)
|
||||
|
||||
total_errors = summary_errors + out_errors + ext_errors
|
||||
return total_errors
|
||||
|
||||
|
||||
def run_pex(name, gds_name, sp_name, output=None):
|
||||
"""Run pex on a given top-level name which is
|
||||
implemented in gds_name and sp_name. """
|
||||
OPTS = globals.get_opts()
|
||||
from tech import drc
|
||||
if output == None:
|
||||
output = name + ".pex.netlist"
|
||||
|
||||
# check if lvs report has been done
|
||||
# if not run drc and lvs
|
||||
if not os.path.isfile(name + ".lvs.report"):
|
||||
run_drc(name, gds_name)
|
||||
run_lvs(name, gds_name, sp_name)
|
||||
|
||||
pex_rules = drc["xrc_rules"]
|
||||
pex_runset = {
|
||||
'pexRulesFile': pex_rules,
|
||||
'pexRunDir': OPTS.openram_temp,
|
||||
'pexLayoutPaths': gds_name,
|
||||
'pexLayoutPrimary': name,
|
||||
#'pexSourcePath' : OPTS.openram_temp+"extracted.sp",
|
||||
'pexSourcePath': sp_name,
|
||||
'pexSourcePrimary': name,
|
||||
'pexReportFile': name + ".lvs.report",
|
||||
'pexPexNetlistFile': output,
|
||||
'pexPexReportFile': name + ".pex.report",
|
||||
'pexMaskDBFile': name + ".maskdb",
|
||||
'cmnFDIDEFLayoutPath': name + ".def",
|
||||
}
|
||||
|
||||
# write the runset file
|
||||
f = open(OPTS.openram_temp + "pex_runset", "w")
|
||||
for k in sorted(pex_runset.iterkeys()):
|
||||
f.write("*{0}: {1}\n".format(k, pex_runset[k]))
|
||||
f.close()
|
||||
|
||||
# run pex
|
||||
cwd = os.getcwd()
|
||||
os.chdir(OPTS.openram_temp)
|
||||
errfile = "{0}{1}.pex.err".format(OPTS.openram_temp, name)
|
||||
outfile = "{0}{1}.pex.out".format(OPTS.openram_temp, name)
|
||||
|
||||
cmd = "calibre -gui -pex {0}pex_runset -batch 2> {1} 1> {2}".format(OPTS.openram_temp,
|
||||
errfile,
|
||||
outfile)
|
||||
debug.info(2, cmd)
|
||||
os.system(cmd)
|
||||
os.chdir(cwd)
|
||||
|
||||
# also check the output file
|
||||
f = open(outfile, "r")
|
||||
results = f.readlines()
|
||||
f.close()
|
||||
|
||||
# Errors begin with "ERROR:"
|
||||
test = re.compile("ERROR:")
|
||||
stdouterrors = filter(test.search, results)
|
||||
for e in stdouterrors:
|
||||
debug.error(e.strip("\n"))
|
||||
|
||||
out_errors = len(stdouterrors)
|
||||
|
||||
assert(os.path.isfile(output))
|
||||
correct_port(name, output, sp_name)
|
||||
|
||||
return out_errors
|
||||
|
||||
|
||||
def correct_port(name, output_file_name, ref_file_name):
|
||||
pex_file = open(output_file_name, "r")
|
||||
contents = pex_file.read()
|
||||
# locate the start of circuit definition line
|
||||
match = re.search(".subckt " + str(name) + ".*", contents)
|
||||
match_index_start = match.start()
|
||||
pex_file.seek(match_index_start)
|
||||
rest_text = pex_file.read()
|
||||
# locate the end of circuit definition line
|
||||
match = re.search("\* \n", rest_text)
|
||||
match_index_end = match.start()
|
||||
# store the unchanged part of pex file in memory
|
||||
pex_file.seek(0)
|
||||
part1 = pex_file.read(match_index_start)
|
||||
pex_file.seek(match_index_start + match_index_end)
|
||||
part2 = pex_file.read()
|
||||
pex_file.close()
|
||||
|
||||
# obatin the correct definition line from the original spice file
|
||||
sp_file = open(ref_file_name, "r")
|
||||
contents = sp_file.read()
|
||||
circuit_title = re.search(".SUBCKT " + str(name) + ".*\n", contents)
|
||||
circuit_title = circuit_title.group()
|
||||
sp_file.close()
|
||||
|
||||
# write the new pex file with info in the memory
|
||||
output_file = open(output_file_name, "w")
|
||||
output_file.write(part1)
|
||||
output_file.write(circuit_title)
|
||||
output_file.write(part2)
|
||||
output_file.close()
|
||||
@@ -0,0 +1,320 @@
|
||||
"""
|
||||
This is a DRC/LVS/PEX interface file for magic + netgen.
|
||||
|
||||
This assumes you have the SCMOS magic rules installed. Get these from:
|
||||
ftp://ftp.mosis.edu/pub/sondeen/magic/new/beta/current.tar.gz
|
||||
and install them in:
|
||||
cd /opt/local/lib/magic/sys
|
||||
tar zxvf current.tar.gz
|
||||
ln -s 2001a current
|
||||
|
||||
1. magic can perform drc with the following:
|
||||
#!/bin/sh
|
||||
magic -dnull -noconsole << EOF
|
||||
tech load SCN3ME_SUBM.30
|
||||
gds rescale false
|
||||
gds polygon subcell true
|
||||
gds warning default
|
||||
gds read $1
|
||||
drc count
|
||||
drc why
|
||||
quit -noprompt
|
||||
EOF
|
||||
|
||||
2. magic can perform extraction with the following:
|
||||
#!/bin/sh
|
||||
rm -f $1.ext
|
||||
rm -f $1.spice
|
||||
magic -dnull -noconsole << EOF
|
||||
tech load SCN3ME_SUBM.30
|
||||
gds rescale false
|
||||
gds polygon subcell true
|
||||
gds warning default
|
||||
gds read $1
|
||||
extract
|
||||
ext2spice scale off
|
||||
ext2spice
|
||||
quit -noprompt
|
||||
EOF
|
||||
|
||||
3. netgen can perform LVS with:
|
||||
#!/bin/sh
|
||||
netgen -noconsole <<EOF
|
||||
readnet $1.spice
|
||||
readnet $1.sp
|
||||
ignore class c
|
||||
permute transistors
|
||||
compare hierarchical $1.spice {$1.sp $1}
|
||||
permute
|
||||
run converge
|
||||
EOF
|
||||
|
||||
"""
|
||||
|
||||
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
import debug
|
||||
import globals
|
||||
import subprocess
|
||||
|
||||
|
||||
def run_drc(name, gds_name):
|
||||
"""Run DRC check on a given top-level name which is
|
||||
implemented in gds_name."""
|
||||
|
||||
debug.warning("DRC using magic not implemented.")
|
||||
return 0
|
||||
OPTS = globals.get_opts()
|
||||
|
||||
# the runset file contains all the options to run drc
|
||||
from tech import drc
|
||||
drc_rules = drc["drc_rules"]
|
||||
|
||||
drc_runset = {
|
||||
'drcRulesFile': drc_rules,
|
||||
'drcRunDir': OPTS.openram_temp,
|
||||
'drcLayoutPaths': gds_name,
|
||||
'drcLayoutPrimary': name,
|
||||
'drcLayoutSystem': 'GDSII',
|
||||
'drcResultsformat': 'ASCII',
|
||||
'drcResultsFile': OPTS.openram_temp + name + ".drc.results",
|
||||
'drcSummaryFile': OPTS.openram_temp + name + ".drc.summary",
|
||||
'cmnFDILayerMapFile': drc["layer_map"],
|
||||
'cmnFDIUseLayerMap': 1
|
||||
}
|
||||
|
||||
# write the runset file
|
||||
f = open(OPTS.openram_temp + "drc_runset", "w")
|
||||
for k in sorted(drc_runset.iterkeys()):
|
||||
f.write("*%s: %s\n" % (k, drc_runset[k]))
|
||||
f.close()
|
||||
|
||||
# run drc
|
||||
cwd = os.getcwd()
|
||||
os.chdir(OPTS.openram_temp)
|
||||
errfile = "{0}{1}.drc.err".format(OPTS.openram_temp, name)
|
||||
outfile = "{0}{1}.drc.out".format(OPTS.openram_temp, name)
|
||||
|
||||
cmd = "{0} -gui -drc {1}drc_runset -batch 2> {2} 1> {3}".format(OPTS.drc_exe,
|
||||
OPTS.openram_temp,
|
||||
errfile,
|
||||
outfile)
|
||||
debug.info(1, cmd)
|
||||
os.system(cmd)
|
||||
os.chdir(cwd)
|
||||
|
||||
# check the result for these lines in the summary:
|
||||
# TOTAL Original Layer Geometries: 106 (157)
|
||||
# TOTAL DRC RuleChecks Executed: 156
|
||||
# TOTAL DRC Results Generated: 0 (0)
|
||||
try:
|
||||
f = open(drc_runset['drcSummaryFile'], "r")
|
||||
except:
|
||||
debug.error("Unable to retrieve DRC results file. Is magic set up?",1)
|
||||
results = f.readlines()
|
||||
f.close()
|
||||
# those lines should be the last 3
|
||||
results = results[-3:]
|
||||
geometries = int(re.split("\W+", results[0])[5])
|
||||
rulechecks = int(re.split("\W+", results[1])[4])
|
||||
errors = int(re.split("\W+", results[2])[5])
|
||||
|
||||
# always display this summary
|
||||
if errors > 0:
|
||||
debug.error("%-25s\tGeometries: %d\tChecks: %d\tErrors: %d" %
|
||||
(name, geometries, rulechecks, errors))
|
||||
else:
|
||||
debug.info(1, "%-25s\tGeometries: %d\tChecks: %d\tErrors: %d" %
|
||||
(name, geometries, rulechecks, errors))
|
||||
|
||||
return errors
|
||||
|
||||
|
||||
def run_lvs(name, gds_name, sp_name):
|
||||
"""Run LVS check on a given top-level name which is
|
||||
implemented in gds_name and sp_name. """
|
||||
|
||||
debug.warning("LVS using magic+netgen not implemented.")
|
||||
return 0
|
||||
|
||||
OPTS = globals.get_opts()
|
||||
from tech import drc
|
||||
lvs_rules = drc["lvs_rules"]
|
||||
lvs_runset = {
|
||||
'lvsRulesFile': lvs_rules,
|
||||
'lvsRunDir': OPTS.openram_temp,
|
||||
'lvsLayoutPaths': gds_name,
|
||||
'lvsLayoutPrimary': name,
|
||||
'lvsSourcePath': sp_name,
|
||||
'lvsSourcePrimary': name,
|
||||
'lvsSourceSystem': 'SPICE',
|
||||
'lvsSpiceFile': OPTS.openram_temp + "extracted.sp",
|
||||
'lvsPowerNames': 'vdd',
|
||||
'lvsGroundNames': 'gnd',
|
||||
'lvsIncludeSVRFCmds': 1,
|
||||
'lvsSVRFCmds': '{VIRTUAL CONNECT NAME VDD? GND? ?}',
|
||||
'lvsIgnorePorts': 1,
|
||||
'lvsERCDatabase': OPTS.openram_temp + name + ".erc.results",
|
||||
'lvsERCSummaryFile': OPTS.openram_temp + name + ".erc.summary",
|
||||
'lvsReportFile': OPTS.openram_temp + name + ".lvs.report",
|
||||
'lvsMaskDBFile': OPTS.openram_temp + name + ".maskdb",
|
||||
'cmnFDILayerMapFile': drc["layer_map"],
|
||||
'cmnFDIUseLayerMap': 1,
|
||||
'cmnVConnectNames': 'vdd, gnd',
|
||||
#'cmnVConnectNamesState' : 'ALL', #connects all nets with the same name
|
||||
}
|
||||
|
||||
# write the runset file
|
||||
f = open(OPTS.openram_temp + "lvs_runset", "w")
|
||||
for k in sorted(lvs_runset.iterkeys()):
|
||||
f.write("*%s: %s\n" % (k, lvs_runset[k]))
|
||||
f.close()
|
||||
|
||||
# run LVS
|
||||
cwd = os.getcwd()
|
||||
os.chdir(OPTS.openram_temp)
|
||||
errfile = "{0}{1}.lvs.err".format(OPTS.openram_temp, name)
|
||||
outfile = "{0}{1}.lvs.out".format(OPTS.openram_temp, name)
|
||||
|
||||
cmd = "{0} -gui -lvs {1}lvs_runset -batch 2> {2} 1> {3}".format(OPTS.lvs_exe,
|
||||
OPTS.openram_temp,
|
||||
errfile,
|
||||
outfile)
|
||||
debug.info(1, cmd)
|
||||
os.system(cmd)
|
||||
os.chdir(cwd)
|
||||
|
||||
# check the result for these lines in the summary:
|
||||
f = open(lvs_runset['lvsReportFile'], "r")
|
||||
results = f.readlines()
|
||||
f.close()
|
||||
|
||||
# NOT COMPARED
|
||||
# CORRECT
|
||||
# INCORRECT
|
||||
test = re.compile("# CORRECT #")
|
||||
correct = filter(test.search, results)
|
||||
test = re.compile("NOT COMPARED")
|
||||
notcompared = filter(test.search, results)
|
||||
test = re.compile("# INCORRECT #")
|
||||
incorrect = filter(test.search, results)
|
||||
|
||||
# Errors begin with "Error:"
|
||||
test = re.compile("\s+Error:")
|
||||
errors = filter(test.search, results)
|
||||
for e in errors:
|
||||
debug.error(e.strip("\n"))
|
||||
|
||||
summary_errors = len(notcompared) + len(incorrect) + len(errors)
|
||||
|
||||
# also check the extraction summary file
|
||||
f = open(lvs_runset['lvsReportFile'] + ".ext", "r")
|
||||
results = f.readlines()
|
||||
f.close()
|
||||
|
||||
test = re.compile("ERROR:")
|
||||
exterrors = filter(test.search, results)
|
||||
for e in exterrors:
|
||||
debug.error(e.strip("\n"))
|
||||
|
||||
test = re.compile("WARNING:")
|
||||
extwarnings = filter(test.search, results)
|
||||
for e in extwarnings:
|
||||
debug.warning(e.strip("\n"))
|
||||
|
||||
# MRG - 9/26/17 - Change this to exclude warnings because of
|
||||
# multiple labels on different pins in column mux.
|
||||
ext_errors = len(exterrors)
|
||||
ext_warnings = len(extwarnings)
|
||||
|
||||
# also check the output file
|
||||
f = open(outfile, "r")
|
||||
results = f.readlines()
|
||||
f.close()
|
||||
|
||||
# Errors begin with "ERROR:"
|
||||
test = re.compile("ERROR:")
|
||||
stdouterrors = filter(test.search, results)
|
||||
for e in stdouterrors:
|
||||
debug.error(e.strip("\n"))
|
||||
|
||||
out_errors = len(stdouterrors)
|
||||
|
||||
total_errors = summary_errors + out_errors + ext_errors
|
||||
return total_errors
|
||||
|
||||
|
||||
def run_pex(name, gds_name, sp_name, output=None):
|
||||
"""Run pex on a given top-level name which is
|
||||
implemented in gds_name and sp_name. """
|
||||
|
||||
debug.warning("PEX using magic not implemented.")
|
||||
return 0
|
||||
|
||||
OPTS = globals.get_opts()
|
||||
from tech import drc
|
||||
if output == None:
|
||||
output = name + ".pex.netlist"
|
||||
|
||||
# check if lvs report has been done
|
||||
# if not run drc and lvs
|
||||
if not os.path.isfile(name + ".lvs.report"):
|
||||
run_drc(name, gds_name)
|
||||
run_lvs(name, gds_name, sp_name)
|
||||
|
||||
pex_rules = drc["xrc_rules"]
|
||||
pex_runset = {
|
||||
'pexRulesFile': pex_rules,
|
||||
'pexRunDir': OPTS.openram_temp,
|
||||
'pexLayoutPaths': gds_name,
|
||||
'pexLayoutPrimary': name,
|
||||
#'pexSourcePath' : OPTS.openram_temp+"extracted.sp",
|
||||
'pexSourcePath': sp_name,
|
||||
'pexSourcePrimary': name,
|
||||
'pexReportFile': name + ".lvs.report",
|
||||
'pexPexNetlistFile': output,
|
||||
'pexPexReportFile': name + ".pex.report",
|
||||
'pexMaskDBFile': name + ".maskdb",
|
||||
'cmnFDIDEFLayoutPath': name + ".def",
|
||||
}
|
||||
|
||||
# write the runset file
|
||||
f = open(OPTS.openram_temp + "pex_runset", "w")
|
||||
for k in sorted(pex_runset.iterkeys()):
|
||||
f.write("*{0}: {1}\n".format(k, pex_runset[k]))
|
||||
f.close()
|
||||
|
||||
# run pex
|
||||
cwd = os.getcwd()
|
||||
os.chdir(OPTS.openram_temp)
|
||||
errfile = "{0}{1}.pex.err".format(OPTS.openram_temp, name)
|
||||
outfile = "{0}{1}.pex.out".format(OPTS.openram_temp, name)
|
||||
|
||||
cmd = "{0} -gui -pex {1}pex_runset -batch 2> {2} 1> {3}".format(OPTS.pex_exe,
|
||||
OPTS.openram_temp,
|
||||
errfile,
|
||||
outfile)
|
||||
debug.info(2, cmd)
|
||||
os.system(cmd)
|
||||
os.chdir(cwd)
|
||||
|
||||
# also check the output file
|
||||
f = open(outfile, "r")
|
||||
results = f.readlines()
|
||||
f.close()
|
||||
|
||||
# Errors begin with "ERROR:"
|
||||
test = re.compile("ERROR:")
|
||||
stdouterrors = filter(test.search, results)
|
||||
for e in stdouterrors:
|
||||
debug.error(e.strip("\n"))
|
||||
|
||||
out_errors = len(stdouterrors)
|
||||
|
||||
assert(os.path.isfile(output))
|
||||
#correct_port(name, output, sp_name)
|
||||
|
||||
return out_errors
|
||||
|
||||
Reference in New Issue
Block a user