Skip to content

Commit

Permalink
modularised code and fixed misc. erros in .github/scripts/parse_rpt.py
Browse files Browse the repository at this point in the history
  • Loading branch information
chetanyagoyal committed Nov 8, 2023
1 parent ed795dc commit 516ac53
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 67 deletions.
32 changes: 10 additions & 22 deletions .github/scripts/parse_rpt.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import sys
import json
import os
import re, subprocess
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from common.check_gen_files import check_gen_files

sys.stdout.flush()

Expand All @@ -14,6 +17,7 @@
drc_filename = "work/"+sys.argv[1]+"/6_final_drc.rpt"
lvs_filename = "work/"+sys.argv[1]+"/6_final_lvs.rpt"

# using full because sims disabled for LDO for now
if (len(sys.argv) > 1) and ((sys.argv[1] == "sky130hvl_ldo") or (sys.argv[1] == "sky130hvl_ldo_full")):
with open(drc_filename, 'r') as f1, open("../../../.github/scripts/expected_drc_reports/expected_ldo_drc.rpt", 'r') as f2:
content1 = f1.readlines()
Expand All @@ -27,6 +31,7 @@
else:
print("DRC is clean!")

# cryo LVS check
if (len(sys.argv) > 1) and (sys.argv[1] == "sky130hd_cryo"):
lvs_line = subprocess.check_output(["tail", "-1", lvs_filename]).decode(
sys.stdout.encoding
Expand All @@ -48,31 +53,14 @@
print("LVS is clean!")

if ((len(sys.argv) > 1) and ((sys.argv[1] == "sky130hvl_ldo") or (sys.argv[1] == "sky130hvl_ldo_full"))) or ((len(sys.argv) > 1) and (sys.argv[1] == "sky130hd_cryo")):
print("Generator check is clean!")
print("Flow check is clean!")
else:
json_filename = "test.json"

if os.path.exists(json_filename):
with open(json_filename) as file:
data = json.load(file)
print('Found .json config file...')

module_name = data.get("module_name", "default")

work_dir = "./work/"

if (os.path.exists(work_dir) == 0):
raise ValueError("work directory does not exist!")
if check_gen_files():
print("Flow check is clean!")
else:
filename = work_dir + module_name
for file in (filename + ".gds", filename + ".spice", filename + ".v", filename + ".def", filename + "_pex.spice", filename + ".sdc"):
if (os.path.exists(file) == 0):
raise ValueError(file + " does not exist!")
print("Found necessary work result files!")

for file in ("error_within_x.csv", "golden_error_opt.csv", "search_result.csv"):
if os.path.exists(file) == 0:
raise ValueError(file + " does not exist!")
print("Found generated .csv files!")
print("Generator check is clean!")
print("Flow check failed!")
else:
raise ValueError(".json config file not found!")
2 changes: 2 additions & 0 deletions openfasoc/generators/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
2. `COMMON_PLATFORMS_PREFIX_MAP` (dict): This is a dictionary of common platforms (currently sky130) and their cell naming prefixes.
- `common.simulation`
1. `run_simulations()`: Used to run SPICE testbenches with multiple parameters.
- `common.check_gen_files`
1. `check_gen_files()`: Used to check if the various files that should be generated by the flow are present in their required directories.
See individual function documentation for more information on a particular function.
"""
29 changes: 29 additions & 0 deletions openfasoc/generators/common/check_gen_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import json
import os

def check_gen_files():
with open('test.json', 'r') as file:
data = json.load(file)

# print('Found .json config file...')

module_name = data.get("module_name", "default")

work_dir = "./work/"

if (os.path.exists(work_dir) == 0):
raise ValueError("work directory does not exist!")
else:
filename = work_dir + module_name
for file in (filename + ".gds", filename + ".spice", filename + ".v", filename + ".def", filename + "_pex.spice", filename + ".sdc"):
if (os.path.exists(file) == 0):
raise ValueError(file + " does not exist!")

# print("Found necessary work result files!")

for file in ("error_within_x.csv", "golden_error_opt.csv", "search_result.csv"):
if os.path.exists(file) == 0:
raise ValueError(file + " does not exist!")

#print("Found generated .csv files!")
return 1
66 changes: 66 additions & 0 deletions openfasoc/generators/cryo-gen/parse_rpt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import sys
import json
import os
import re, subprocess
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from common.check_gen_files import check_gen_files

sys.stdout.flush()

if (len(sys.argv) > 1) and (sys.argv[1] == "sky130hd_cryo"):
drc_filename = "flow/reports/sky130hd/cryo/6_final_drc.rpt"
lvs_filename = "flow/reports/sky130hd/cyro/6_final_lvs.rpt"
elif (len(sys.argv) == 1) or (sys.argv[1] == "sky130hvl_ldo"):
drc_filename = "work/6_final_drc.rpt"
lvs_filename = "work/6_final_lvs.rpt"
else:
drc_filename = "work/"+sys.argv[1]+"/6_final_drc.rpt"
lvs_filename = "work/"+sys.argv[1]+"/6_final_lvs.rpt"

# using full because sims disabled for LDO for now
if (len(sys.argv) > 1) and ((sys.argv[1] == "sky130hvl_ldo") or (sys.argv[1] == "sky130hvl_ldo_full")):
with open(drc_filename, 'r') as f1, open("../../../.github/scripts/expected_drc_reports/expected_ldo_drc.rpt", 'r') as f2:
content1 = f1.readlines()
content2 = f2.readlines()
if content1 == content2:
print("DRC is clean!")
else:
raise ValueError("DRC failed!")
elif sum(1 for line in open(drc_filename)) > 3:
raise ValueError("DRC failed!")
else:
print("DRC is clean!")

# cryo LVS check
if (len(sys.argv) > 1) and (sys.argv[1] == "sky130hd_cryo"):
lvs_line = subprocess.check_output(["tail", "-1", lvs_filename]).decode(
sys.stdout.encoding
)
regex = r"failed"
match = re.search(regex, lvs_line)

if match != None:
raise ValueError("LVS failed!")
else:
print("LVS is clean!")
else:
with open(lvs_filename) as f:
f1 = f.read()

if "failed" in f1:
raise ValueError("LVS failed!")
else:
print("LVS is clean!")

if ((len(sys.argv) > 1) and ((sys.argv[1] == "sky130hvl_ldo") or (sys.argv[1] == "sky130hvl_ldo_full"))) or ((len(sys.argv) > 1) and (sys.argv[1] == "sky130hd_cryo")):
print("Flow check is clean!")
else:
json_filename = "test.json"

if os.path.exists(json_filename):
if check_gen_files():
print("Flow check is clean!")
else:
print("Flow check failed!")
else:
raise ValueError(".json config file not found!")
35 changes: 12 additions & 23 deletions openfasoc/generators/cryo-gen/tools/parse_rpt.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import re
import subprocess
import sys
import sys, os

sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..'))
from common.check_gen_files import check_gen_files

drc_filename = "flow/reports/sky130hd/cryo/6_final_drc.rpt"
num_lines = sum(1 for line in open(drc_filename))
Expand All @@ -23,26 +26,12 @@
else:
print("LVS is clean!")

# with open('test.json', 'r') as file:
# data = json.load(file)
# print('Found .json config file...')

# module_name = data.get("module_name", "default")

# work_dir = "./work/"
json_filename = "test.json"

# if (os.path.exists(work_dir) == 0):
# raise ValueError("work directory does not exist!")
# else:
# filename = work_dir + module_name
# for file in (filename + ".gds", filename + ".spice", filename + ".v", filename + ".def", filename + "_pex.spice", filename + ".sdc"):
# if (os.path.exists(file) == 0):
# raise ValueError(file + " does not exist!")
# print("Found necessary work result files!")

# for file in ("error_within_x.csv", "golden_error_opt.csv", "search_result.csv"):
# if os.path.exists(file) == 0:
# raise ValueError(file + " does not exist!")
# print("Found generated .csv files!")

print("Generator check is clean!")
if os.path.exists(json_filename):
if check_gen_files():
print("Flow check is clean!")
else:
print("Flow check failed!")
else:
raise ValueError(".json config file not found!")
33 changes: 11 additions & 22 deletions openfasoc/generators/temp-sense-gen/tools/parse_rpt.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import json
import os
import os, sys

sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..'))
from common.check_gen_files import check_gen_files

drc_filename = "flow/reports/sky130hd/tempsense/6_final_drc.rpt"
num_lines = sum(1 for line in open(drc_filename))
Expand All @@ -19,26 +21,13 @@
raise ValueError("LVS failed!")
else:
print("LVS is clean!")

with open('test.json', 'r') as file:
data = json.load(file)
print('Found .json config file...')

module_name = data.get("module_name", "default")

work_dir = "./work/"
json_filename = "test.json"

if (os.path.exists(work_dir) == 0):
raise ValueError("work directory does not exist!")
if os.path.exists(json_filename):
if check_gen_files():
print("Flow check is clean!")
else:
print("Flow check failed!")
else:
filename = work_dir + module_name
for file in (filename + ".gds", filename + ".spice", filename + ".v", filename + ".def", filename + "_pex.spice", filename + ".sdc"):
if (os.path.exists(file) == 0):
raise ValueError(file + " does not exist!")
print("Found necessary work result files!")

for file in ("error_within_x.csv", "golden_error_opt.csv", "search_result.csv"):
if os.path.exists(file) == 0:
raise ValueError(file + " does not exist!")
print("Found generated .csv files!")
print("Generator check is clean!")
raise ValueError(".json config file not found!")

0 comments on commit 516ac53

Please sign in to comment.