mirror of
https://github.com/TinyTapeout/tt-support-tools.git
synced 2026-11-03 04:36:09 +01:00
feat: copy_macros and copy_final_results commands
This commit is contained in:
+54
@@ -2,6 +2,17 @@ import logging
|
||||
import os
|
||||
import yaml
|
||||
import json
|
||||
import glob
|
||||
import shutil
|
||||
|
||||
def copy_print(src: str, dest: str):
|
||||
logging.info(f" -> {dest}")
|
||||
shutil.copy2(src, dest)
|
||||
|
||||
|
||||
def copy_print_glob(pattern: str, dest_dir: str):
|
||||
for file in glob.glob(pattern):
|
||||
copy_print(file, os.path.join(dest_dir, os.path.basename(file)))
|
||||
|
||||
class CaravelConfig():
|
||||
|
||||
@@ -58,3 +69,46 @@ class CaravelConfig():
|
||||
def list(self):
|
||||
for project in self.projects:
|
||||
logging.info(project)
|
||||
|
||||
|
||||
def find_last_run(self, macro: str):
|
||||
runs = f"tt-multiplexer/ol2/{macro}/runs/"
|
||||
runlist = sorted(
|
||||
[r for r in os.listdir(runs) if r.startswith("RUN_") and os.path.isdir(os.path.join(runs, r))]
|
||||
)
|
||||
if len(runlist) == 0:
|
||||
print(f"Error: no runs found for {macro}")
|
||||
exit(1)
|
||||
|
||||
return os.path.join(runs, runlist[-1])
|
||||
|
||||
|
||||
def copy_macros(self):
|
||||
logging.info('copying macros to tt_top:')
|
||||
copy_print_glob("projects/*/*.gds", "tt-multiplexer/ol2/tt_top/gds")
|
||||
copy_print_glob("projects/*/*.lef", "tt-multiplexer/ol2/tt_top/lef")
|
||||
copy_print_glob("projects/*/*.v", "tt-multiplexer/ol2/tt_top/verilog")
|
||||
macros = ["tt_ctrl", "tt_mux"]
|
||||
for macro in macros:
|
||||
lastrun = self.find_last_run(macro)
|
||||
copy_print(f"{lastrun}/final/gds/{macro}.magic.gds", f"tt-multiplexer/ol2/tt_top/gds/{macro}.gds")
|
||||
copy_print(f"{lastrun}/final/lef/{macro}.lef", f"tt-multiplexer/ol2/tt_top/lef/{macro}.lef")
|
||||
|
||||
|
||||
def copy_final_results(self):
|
||||
macros = ["tt_ctrl", "tt_mux", "tt_top"]
|
||||
|
||||
logging.info('copying final results:')
|
||||
for macro in macros:
|
||||
lastrun = self.find_last_run(macro)
|
||||
macro_name = macro if macro != "tt_top" else "user_project_wrapper"
|
||||
logging.info(f"** {macro_name} **")
|
||||
logging.info(f" FROM {lastrun}")
|
||||
copy_print(f"{lastrun}/final/gds/{macro_name}.magic.gds", f"gds/{macro_name}.gds")
|
||||
copy_print(f"{lastrun}/final/lef/{macro_name}.lef", f"lef/{macro_name}.lef")
|
||||
copy_print(f"{lastrun}/final/pnl/{macro_name}.pnl.v", f"verilog/gl/{macro_name}.v")
|
||||
copy_print(f"{lastrun}/final/nl/{macro_name}.nl.v", f"verilog/gl/{macro_name}.nl.v")
|
||||
shutil.copytree(
|
||||
f"{lastrun}/final/spef", f"spef/", copy_function=copy_print, dirs_exist_ok=True
|
||||
)
|
||||
copy_print(f"{lastrun}/final/spef/nom_/{macro_name}.nom.spef", f"spef/{macro_name}.spef")
|
||||
|
||||
@@ -162,6 +162,8 @@ if __name__ == '__main__':
|
||||
parser.add_argument('--list', help="list projects", action='store_const', const=True)
|
||||
parser.add_argument('--single', help="do action on single project", type=int, default=-1)
|
||||
parser.add_argument('--update-caravel', help='configure caravel for build', action='store_const', const=True)
|
||||
parser.add_argument('--copy-macros', help='copy macros for building the tt_top project', action='store_const', const=True)
|
||||
parser.add_argument('--copy-final-results', help='copy final project files to gds/lef directories', action='store_const', const=True)
|
||||
parser.add_argument('--harden', help="harden project", action="store_const", const=True)
|
||||
parser.add_argument('--test', help='use test projects', action='store_const', const=True)
|
||||
parser.add_argument('--sta-projects', help='use sta projects', action='store_const', const=True)
|
||||
@@ -216,6 +218,12 @@ if __name__ == '__main__':
|
||||
if not args.test:
|
||||
docs.build_index()
|
||||
|
||||
if args.copy_macros:
|
||||
caravel.copy_macros()
|
||||
|
||||
if args.copy_final_results:
|
||||
caravel.copy_final_results()
|
||||
|
||||
if args.update_image:
|
||||
docs.update_image()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user