Skip to content

Commit

Permalink
Merge branch 'idea-fasoc:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
chetanyagoyal authored Nov 15, 2023
2 parents 4959c07 + fe7683e commit 6c4812e
Show file tree
Hide file tree
Showing 18 changed files with 241 additions and 65 deletions.
103 changes: 91 additions & 12 deletions .github/scripts/parse_rpt.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,112 @@
"""
This script performs checks on generated files and reports for different generators based on workflow parameters.
The `_generator_is` variable is a dictionary with keys and values indicating information about the workflow being run.
Values for each key are determined by how this script is called by the .yml files in .github/workflows.
The `cryo_library` variable is used to determine which library (sky130hd_cryo, sky130hs_cryo, sky130hvl_cryo) the workflow is targeting.
1. DRC and LVS Filename Declaration:
This section declares possible DRC and LVS filenames for different generators.
The first condition checks for sky130hd_temp and sky130hvl_ldo, while the elif condition checks for various cryo libraries.
2. DRC Check:
- Checks if the content in the generated DRC report file matches the template DRC report file stored in .github/scripts/expected_drc_reports/.
- If the number of lines in the DRC report files for temp-sense-gen and cryo-gen is greater than 3, it indicates non-zero errors in the make process.
3. LVS Check:
- Checks if the LVS report generated by the cryo-gen make has the word 'failed' in the last line, raising an error if found.
- Conducts a search for the word 'failed' in the LVS reports for ldo-gen and temp-sense-gen, raising a ValueError if found.
4. Result File Check:
- Calls the check_gen_files() function from generators/common/check_gen_files.py.
- Checks if various files (.v, .sdc, .cdl, .sp, .spice, etc.) have been generated for the required generators.
- Takes input parameters: the test.json filename, the dictionary of possible generators, and the cryo_library.
"""

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 or sys.argv[1] == "sky130hvl_ldo":
cryo_library = ""
_generator_is = {
'sky130hvl_ldo': 0,
'sky130hd_temp': 0,
'sky130XX_cryo': 0
}

if len(sys.argv) == 1:
_generator_is['sky130hd_temp'] = 1
elif len(sys.argv) > 1:
if sys.argv[1] == 'sky130hvl_ldo':
_generator_is['sky130hvl_ldo'] = 1
else:
_generator_is['sky130XX_cryo'] = 1

if _generator_is['sky130XX_cryo']:
# check which cryo-gen library's workflow is being run
dir_path = r'flow/reports'
lib = os.listdir(dir_path)
cryo_library = str(lib[0])

## DRC and LVS Filename Declaration
if _generator_is['sky130hd_temp'] or _generator_is['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"
elif len(sys.argv) > 1 and sys.argv[1] == cryo_library:
drc_filename = "flow/reports/" + sys.argv[1] + "/cryo/6_final_drc.rpt"
lvs_filename = "flow/reports/" + sys.argv[1] + "/cryo/6_final_lvs.rpt"


if len(sys.argv) > 1 and sys.argv[1] == "sky130hvl_ldo":
with open(drc_filename, 'r') as f1, open("../../../.github/scripts/expected_drc_reports/expected_ldo_drc.rpt", 'r') as f2:
## DRC check
if _generator_is['sky130hvl_ldo']:
expected_ldo_rpt_filename = "../../../.github/scripts/expected_drc_reports/expected_ldo_drc.rpt"
with open(drc_filename) as f1, open(expected_ldo_rpt_filename) as f2:
content1 = f1.readlines()
content2 = f2.readlines()
if content1 == content1:
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!")


with open(lvs_filename) as f:
f1 = f.read()

if "failed" in f1:
## LVS Check
if len(sys.argv) > 1 and sys.argv[1] == cryo_library:
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!")

## Result File Check
if _generator_is['sky130hvl_ldo']:
json_filename = "spec.json"
else:
json_filename = "test.json"

if check_gen_files(json_filename, _generator_is, cryo_library):
print("Flow check is clean!")
else:
print("Flow check failed!")
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ For more info on getting-started, please refer to ["Getting Started" section ](h

Below are the tool requirements along with their currently support versions that are updated regularly upon testing againsts the generators.

1. `Magic <https://github.com/RTimothyEdwards/magic>`_ (version:8.3.446)
1. `Magic <https://github.com/RTimothyEdwards/magic>`_ (version:8.3.447)

2. `Netgen <https://github.com/RTimothyEdwards/netgen>`_ (version:1.5.262)

Expand All @@ -60,7 +60,7 @@ Below are the tool requirements along with their currently support versions that

5. `OpenROAD <https://github.com/The-OpenROAD-Project/OpenROAD>`_ (version:2.0_10905)

6. `Open_pdks <https://github.com/RTimothyEdwards/open_pdks>`_ (version:1.0.286)
6. `Open_pdks <https://github.com/RTimothyEdwards/open_pdks>`_ (version:1.0.457)

- open_pdks is required to run drc/lvs check and the simulations
- After open_pdks is installed, please update the **open_pdks** key in `common/platform_config.json` with the installed path, down to the sky130A folder
Expand Down
4 changes: 2 additions & 2 deletions conda_versions.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
magic==8.3.445_3_g7db77d4
magic==8.3.446_1_g1108046
netgen==1.5.262_0_gc1ed4ce
open_pdks.sky130a==1.0.286_0_g52af776
open_pdks.sky130a==1.0.457_0_g32e8f23
openroad==2.0_10905_ge89829335
yosys==0.35_8_g5691cd095
5 changes: 4 additions & 1 deletion docker/conda/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ RUN conda install python=3.10 \
magic \
netgen \
openroad \
ngspice \
-c litex-hub \
-c conda-forge \
-c anaconda \
Expand All @@ -29,3 +28,7 @@ RUN dpkg -i klayout_0.28.12-1_amd64.deb
RUN strip --remove-section=.note.ABI-tag /usr/lib/x86_64-linux-gnu/libQt5Core.so.5

COPY ./scripts /scripts

RUN git clone http://git.code.sf.net/p/ngspice/ngspice && \
cd ngspice && \
./compile_linux.sh
6 changes: 6 additions & 0 deletions docker/conda/packages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@ libz-dev
build-essential
time
git
bison
flex
libx11-dev
libx11-6
libxaw7-dev
libreadline6-dev
1 change: 1 addition & 0 deletions openfasoc/generators/PMU-gen/tools/parse_rpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@
raise ValueError("LVS failed!")
else:
print("LVS is clean!")
print("Generator check is clean!")
5 changes: 4 additions & 1 deletion openfasoc/generators/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
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(parameters: json_filename, is_tempsense)`: Used to check if the various files that should be generated by the flow are present in their required directories.
- `common.check_gen_extensions`
1. Stores the extensions of the files generated by the flow.
See individual function documentation for more information on a particular function.
"""
64 changes: 64 additions & 0 deletions openfasoc/generators/common/check_gen_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
"""
This script is used to check for the presence of the required non-report files that each generator creates. It gets
the module_name (str) from the .json file present in the generator top-level folder.
Args:
json_filename (str): String containing the name of the .json filename for each generator
_generator_is (dict): Dictionary containing key-value pairs that signify which generator's flow results are being checked
cryo_library (str): String containing which cryo-gen library (sky130hs, sky130hd, sky130hvl) is being checked for
Uses:
work_dir (str): String containing the directory in which to check files
data (str): String containing data from the .json file
module_name (str): String containing the name of module that the check is being done for (eg. tempsenseInst_error)
extension_file_path (str): Contains the extensions of the files which each generator produces for the flows
Returns:
1: if all checks are successful
Raises:
ValueError: If any of the various checks go wrong (.csv file checks for temp-sense, flow generated files for all generators)
"""

import json
import os

def check_gen_files(json_filename, _generator_is, cryo_library) -> int:
with open(json_filename) as file:
data = json.load(file)

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

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

if _generator_is['sky130XX_cryo']:
work_dir = "./work/" + cryo_library + "/"
else:
work_dir = "./work/"

if (os.path.exists(work_dir) == 0):
raise ValueError("work directory does not exist!")
else:
filename = work_dir + module_name
extension_file_path = "./tools/check_gen_extensions"

if os.path.exists(extension_file_path):
with open(extension_file_path) as f:

for extension in f:
file = "".join([filename, extension.strip()])
if (os.path.exists(file) == 0):
raise ValueError(file + " does not exist!")
else:
print("checking flow results with possibly stale list of extensions...")
extensions = [".sdc", ".gds", ".def", ".spice", ".v", "_pex.spice"]
for extension in extensions:
file = "".join([filename, extension])

if (os.path.exists(file) == 0):
raise ValueError(file + " does not exist!")
# print("Found necessary work result files!")
if _generator_is['sky130hd_temp']:
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
8 changes: 8 additions & 0 deletions openfasoc/generators/cryo-gen/tools/check_gen_extensions
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.gds
.spice
.v
.cdl
_sim.spice
_pex.spice
.sdc
.def
26 changes: 23 additions & 3 deletions openfasoc/generators/cryo-gen/tools/parse_rpt.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
import re
import subprocess
import sys
import sys, os

drc_filename = "flow/reports/sky130hd/cyro/6_final_drc.rpt"
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..'))
from common.check_gen_files import check_gen_files

_generator_is = {
'sky130hvl_ldo': 0,
'sky130hd_temp': 0,
'sky130XX_cryo': 1
}

dir_path = r'flow/reports'
lib = os.listdir(dir_path)
cryo_library = str(lib[0])

drc_filename = "flow/reports/" + cryo_library + "/cryo/6_final_drc.rpt"
num_lines = sum(1 for line in open(drc_filename))

if num_lines > 3:
raise ValueError("DRC failed!")
else:
print("DRC is clean!")

lvs_filename = "flow/reports/sky130hd/cyro/6_final_lvs.rpt"
lvs_filename = "flow/reports/" + cryo_library + "/cryo/6_final_lvs.rpt"
lvs_line = subprocess.check_output(["tail", "-1", lvs_filename]).decode(
sys.stdout.encoding
)
Expand All @@ -22,3 +35,10 @@
raise ValueError("LVS failed!")
else:
print("LVS is clean!")

json_filename = "test.json"

if check_gen_files(json_filename, _generator_is, cryo_library):
print("Flow check is clean!")
else:
print("Flow check failed!")
1 change: 1 addition & 0 deletions openfasoc/generators/dcdc-gen/tools/parse_rpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@
raise ValueError("LVS failed!")
else:
print("LVS is clean!")
print("Generator check is clean!")
6 changes: 6 additions & 0 deletions openfasoc/generators/ldo-gen/tools/check_gen_extensions
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.gds
.spice
.v
_pex.spice
.sdc
.def
14 changes: 1 addition & 13 deletions openfasoc/generators/scpa-gen/tools/parse_rpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,4 @@
else:
print("DRC is clean!")


# LVS Bypassed

# lvs_filename = "flow/reports/sky130hd/tempsense/6_final_lvs.rpt"
# 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!")
print("Generator check is clean!")
2 changes: 0 additions & 2 deletions openfasoc/generators/temp-sense-gen/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ sky130hd_temp_verilog:
sky130hd_temp:
@python3 tools/temp-sense-gen.py --specfile test.json --outputDir ./work $(inv) $(ninv) $(head) $(nhead) --prepex $(sim_pex) --platform sky130hd --mode macro
@python3 tools/parse_rpt.py
@tools/verify_op.sh
@@echo "=================================================================================="
@@echo "Thank you for using OpenFASOC"
@@echo "For more info, please read the latest documentation on openfasoc.readthedocs.io"
Expand All @@ -58,7 +57,6 @@ sky130hd_temp_full:
# add --pex to also run pex simulations
@python3 tools/temp-sense-gen.py --specfile test.json --outputDir ./work --platform sky130hd --mode full --prepex $(sim_pex) $(inv) $(ninv) $(head) $(nhead)
@python3 tools/parse_rpt.py
@tools/verify_op.sh
@@echo "=================================================================================="
@@echo "Thank you for using OpenFASOC"
@@echo "For more info, please read the latest documentation on openfasoc.readthedocs.io"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.gds
.spice
.v
_pex.spice
.sdc
.def
Loading

0 comments on commit 6c4812e

Please sign in to comment.