Skip to content

Commit

Permalink
python based regression flow
Browse files Browse the repository at this point in the history
  • Loading branch information
saicharan0112 committed Apr 8, 2023
1 parent e143884 commit 211677b
Show file tree
Hide file tree
Showing 23 changed files with 948 additions and 10 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/ldo_regression.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: ldo

on:
# push:
# branches:
# - main
# pull_request:
workflow_dispatch:


jobs:
generate:
runs-on: self-hosted
steps:

- name: Clone this repo
uses: actions/checkout@v2

- name: Clone OpenFASOC repo
run: |
mkdir $GITHUB_WORKSPACE/openfasoc && cd $GITHUB_WORKSPACE/openfasoc
git clone https://github.com/idea-fasoc/OpenFASOC && cd OpenFASOC
- name: Run the generator and build gds, verilog, reports and spice decks
run: |
cd $GITHUB_WORKSPACE/regression && python3 run_regression.py ldo generate
simulate:
runs-on: self-hosted
steps:

- name: Clone this repo
uses: actions/checkout@v2


- name: Run simulations by sweeping input parameters defined inside the config file under configuration directory
run: |
cd $GITHUB_WORKSPACE/regression
docker run --rm -v $HOME:$HOME -e USER=$USER -w $PWD openfasoc_ci_image:latest bash -c "pip install pyyaml && python3 run_regression.py ldo simulate"
process:
runs-on: self-hosted
steps:

- name: Clone this repo
uses: actions/checkout@v2


- name: Process the results using the simulation log files and extract results
run: |
cd $GITHUB_WORKSPACE/regression && python3 run_regression.py ldo process
52 changes: 52 additions & 0 deletions .github/workflows/tempsense_regression.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: tempsense

on:
# push:
# branches:
# - main
# pull_request:
workflow_dispatch:


jobs:
generate:
runs-on: self-hosted
steps:

- name: Clone this repo
uses: actions/checkout@v2

- name: Clone OpenFASOC repo
run: |
mkdir $GITHUB_WORKSPACE/openfasoc && cd $GITHUB_WORKSPACE/openfasoc
git clone https://github.com/idea-fasoc/OpenFASOC && cd OpenFASOC
- name: Run the generator and build gds, verilog, reports and spice decks
run: |
cd $GITHUB_WORKSPACE/regression && python3 run_regression.py tempsense generate
simulate:
runs-on: self-hosted
steps:

- name: Clone this repo
uses: actions/checkout@v2


- name: Run simulations by sweeping input parameters defined inside the config file under configuration directory
run: |
cd $GITHUB_WORKSPACE/regression
docker run --rm -v $HOME:$HOME -e USER=$USER -w $PWD openfasoc_ci_image:latest bash -c "pip install pyyaml && python3 run_regression.py tempsense simulate"
process:
runs-on: self-hosted
steps:

- name: Clone this repo
uses: actions/checkout@v2


- name: Process the results using the simulation log files and extract results
run: |
cd $GITHUB_WORKSPACE/regression && python3 run_regression.py tempsense process
Empty file modified docker_image/Dockerfile
100755 → 100644
Empty file.
Empty file modified docker_image/get_versions.sh
100755 → 100644
Empty file.
Empty file modified docker_image/xyce_install.sh
100755 → 100644
Empty file.
16 changes: 16 additions & 0 deletions inputs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# generator_name
ldo-gen:

# technology
- sky130hvl

# inputs:
# - header: start, stop, step
# - inverter: start, stop, step

# inputs:
# - VoltsOut: start, stop, step
# - AmpsMax: start, stop, step
- inputs:
- VoltsOut: 1.8, 3.3, 0.5
- AmpsMax: 0.5, 25, 0.5
3 changes: 3 additions & 0 deletions regression/configs/config_ldo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
designName: ldoInst
vin: [1.8, 1.9, 0.1]
imax: [1, 1.5, 0.5]
3 changes: 3 additions & 0 deletions regression/configs/config_tempsense.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
designName: tempSenseInst_error
ninv: [2, 10, 2]
nhead: [5, 9, 1]
6 changes: 6 additions & 0 deletions regression/generators_checks/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# https://stackoverflow.com/a/1057534

from os.path import dirname, basename, isfile, join
import glob
modules = glob.glob(join(dirname(__file__), "*.py"))
__all__ = [ basename(f)[:-3] for f in modules if isfile(f) and not f.endswith('__init__.py')]
164 changes: 164 additions & 0 deletions regression/generators_checks/run_checks_ldo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
# idea is to use this file to run checks for the particular generator. Basically it should include prePEX simulations, postPEX simulations,
# DRC/LVS checks.

# each check will be a python module. Before the check, another module should be present to run the generator. The concept behind having these
# modules is to import them into the main run_regression script. There is also another config file which has the input parameters range. It can also contain additional info but for now nothing other than the range is read.

import os, sys, fileinput, datetime, math
import subprocess as sp


class regression_ldo():

'''
Regression class will have the following methods -
1. run_generator() -> to run the generator with the given arguments (not the input range directly) and generate all files
2. checkDRC() -> to check and display the count of DRC errors - extracted from the report generated in the end
3. checkLVS() -> to check and display the LVS errors if any - extracted from the report generated in the end
4. copyData() -> to copy data from the generated location to the temporary result location.
5. runSimulations() -> to run the simulations and generate logfiles
6. processSims() -> to process the simulations log data and generate final data
'''

def __init__(self) -> None:
self.image = "openfasoc_ci_image:latest"
self.home_dir = "/home/"+os.getenv("USER")+"/OpenFASOC/"
self.results_work_dir = self.home_dir+"openfasoc/generators/ldo-gen/work"
self.runner_results_dir = "/home/"+os.getenv("USER")+"/runner_results"


def run_generator(self, imax, vin):
'''
Run the generator using subprocess for the given configuration vins and imaxs.
Returns the path where the work folder is present along with simulations/run folder which contains the spice netlists
'''

cmd = "pip3 install -r requirements.txt && cd openfasoc/generators/ldo-gen/ && make clean && make sky130hvl_ldo_full VoltsOut={0} AmpsMax={1}e-03 | tee -a {0}_vin_{1}mA_imax.log".format(vin, imax)

os.chdir(self.home_dir)

status = os.system("docker run --rm -v {0}:{0} -w {0} {1} bash -c '{2}'".format(os.getcwd(),self.image, cmd))

return status


def checkDRC(self):
'''
Reads 6_final_drc.rpt inside work directory of the generator and returns 1, if errors are found. Else 0.
'''
drc_rpt = self.results_work_dir+"/6_final_drc.rpt"
with open(drc_rpt) as report:
drc_errors = len(report.readlines()) - 3

if drc_errors:
return 1
else:
return 0


def checkLVS(self):
'''
Read 6_final_lvs.rpt inside work directory of the generator and grep for the word 'Failed'. If found, return 1. Else return 0.
'''
lvs_rpt = self.results_work_dir+"/6_final_lvs.rpt"
with open(lvs_rpt) as report:

if "failed" in report.read():
return 1
else:
return 0


def copyData(self, imax, vin):
'''
Copy work directory and simulation/run directory to temporary run location where simulations and processing of data are done.
'''
os.system("mkdir -p "+self.runner_results_dir+"/ldo/{0}_vin_{1}mA_imax".format(vin, imax))
os.system("cp -rf "+ self.results_work_dir + "/../simulations/run/* "+ self.runner_results_dir+"/ldo/{0}_vin_{1}mA_imax".format(vin, imax))
os.system("cp -rf "+ self.results_work_dir + " " + self.runner_results_dir+"/ldo/{0}_vin_{1}mA_imax".format(vin, imax))
os.system("mv "+self.results_work_dir+"/../{0}_vin_{1}mA_imax.log ".format(vin, imax) + self.runner_results_dir+"/ldo/{0}_vin_{1}mA_imax".format(vin, imax))
os.system("sudo rm -rf "+self.results_work_dir + "/../simulations/run")


def runSimulations(self, vin, imax):
'''
Run through all above copied directories, go into each prePEX folder and replace tempInstance_error.spice netlist path.
Then run simulations using subprocess python library. Returns the list of subprocess which
we loop through and run wait command.
ref: https://github.com/idea-fasoc/OpenFASOC-sims/blob/main/utils/run_sim.py
'''


# get the list of all folders inside /home/runner_results/

designName = "ldo"
freqs_list = [0.1,1.0,10.0]
caps_list = [1,5]
processes=[]

rootDir = self.runner_results_dir+"/ldo/{0}_vin_{1}mA_imax".format(vin, imax)
i = rootDir

if os.path.isdir(i):

config=i.split("/")[-1].split("_")
vin=config[0]
imax=config[2]

# "['ngspice -b -o ldo_0.1MHz_1p_out.txt -i ldo_tran_1.0mA_0.1MHz_1p.sp', 'ngspice -b -o ldo_0.1MHz_5p_out.txt -i ldo_tran_1.0mA_0.1MHz_5p.sp', 'ngspice -b -o ldo_1.0MHz_1p_out.txt -i ldo_tran_1.0mA_1.0MHz_1p.sp', 'ngspice -b -o ldo_1.0MHz_5p_out.txt -i ldo_tran_1.0mA_1.0MHz_5p.sp', 'ngspice -b -o ldo_10.0MHz_1p_out.txt -i ldo_tran_1.0mA_10.0MHz_1p.sp', 'ngspice -b -o ldo_10.0MHz_5p_out.txt -i ldo_tran_1.0mA_10.0MHz_5p.sp', 'ngspice -b -o pwrout.txt -i pwrarr.sp', 'ngspice -b -o ldo_load_change.txt -i ldo_load_change.sp']"


# look for directory name starting with PEX and prePEX and build path to ammend to the filename.
for j in ["prePEX"]:
path = i+"/{0}_PT_cells_13".format(j)
runDir = path

for freq in freqs_list:
for cap in caps_list:

p = sp.Popen(
[
"ngspice",
"-b",
"-o",
"{0}/{1}_{2}MHz_{3}p_out.txt".format(path, designName, freq, cap),
"-i",
"{0}/{1}_tran_{2}_{3}MHz_{4}p.sp".format(path, designName, imax, freq, cap),
],
cwd=runDir,
)
processes.append(p)

# last two testbenches
p = sp.Popen(
[
"ngspice",
"-b",
"-o",
"pwrout.txt",
"-i",
"pwrarr.sp",
]
)
processes.append(p)

p = sp.Popen(
[
"ngspice",
"-b",
"-o",
"ldo_load_change.txt",
"-i",
"ldo_load_change.sp",
]
)
processes.append(p)

return processes


def processSims(self, vin, imax):

pass

Loading

0 comments on commit 211677b

Please sign in to comment.