From ce2b11ebd935b808737e2068519772363e305634 Mon Sep 17 00:00:00 2001 From: Mik Igor <136681630+htm23x@users.noreply.github.com> Date: Thu, 26 Oct 2023 23:53:03 +0200 Subject: [PATCH 1/6] Validate tech_name param in compiler/globals.py We need to pre-validate the tech_name param in the config file or python will comply with a non-very-descriptive message that can confuse the user about where's the problem. --- compiler/globals.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/compiler/globals.py b/compiler/globals.py index b0de2c06d..9d39b80f5 100644 --- a/compiler/globals.py +++ b/compiler/globals.py @@ -564,6 +564,12 @@ def import_tech(): sys.path.append(tech_path) debug.info(1, "Adding technology path: {}".format(tech_path)) + # Validate tech_name param + techname_lower = OPTS.tech_name.lower() + if (techname_lower is None) or (techname_lower!="sky130" and techname_lower!="scn3m_subm" and techname_lower!="scn4m_subm") : + debug.error("tech_name in config file should be sky130|scn3m_subm|scn4m_subm") + quit() + # Import the tech try: tech_mod = __import__(OPTS.tech_name) From 123e43e9422864b4ce6791e49d7fcd1cc9d70a27 Mon Sep 17 00:00:00 2001 From: Mik Igor <136681630+htm23x@users.noreply.github.com> Date: Fri, 27 Oct 2023 00:40:55 +0200 Subject: [PATCH 2/6] Add freepdk45 to tech_name validation in compiler/globals.py Forgot to add the freepdk45 tech_name in validation --- compiler/globals.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/globals.py b/compiler/globals.py index 9d39b80f5..04442601a 100644 --- a/compiler/globals.py +++ b/compiler/globals.py @@ -566,7 +566,7 @@ def import_tech(): # Validate tech_name param techname_lower = OPTS.tech_name.lower() - if (techname_lower is None) or (techname_lower!="sky130" and techname_lower!="scn3m_subm" and techname_lower!="scn4m_subm") : + if (techname_lower is None) or (techname_lower!="sky130" and techname_lower!="scn3m_subm" and techname_lower!="scn4m_subm" and techname_lower!="freepdk45") : debug.error("tech_name in config file should be sky130|scn3m_subm|scn4m_subm") quit() From 189824429cb5d58ac87762560450a90ce3a7e721 Mon Sep 17 00:00:00 2001 From: Mik Igor <136681630+htm23x@users.noreply.github.com> Date: Fri, 27 Oct 2023 00:45:32 +0200 Subject: [PATCH 3/6] Add freepdk45 to debug error in tech_name validation Ooops, I forgot to add the freepdk45 mention in the debug.log string --- compiler/globals.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/globals.py b/compiler/globals.py index 04442601a..0d7863e01 100644 --- a/compiler/globals.py +++ b/compiler/globals.py @@ -567,7 +567,7 @@ def import_tech(): # Validate tech_name param techname_lower = OPTS.tech_name.lower() if (techname_lower is None) or (techname_lower!="sky130" and techname_lower!="scn3m_subm" and techname_lower!="scn4m_subm" and techname_lower!="freepdk45") : - debug.error("tech_name in config file should be sky130|scn3m_subm|scn4m_subm") + debug.error("tech_name in config file should be sky130|scn3m_subm|scn4m_subm|freepdk45") quit() # Import the tech From 5811c5ce99ab20c1979f9e2065005f9ad6a47bad Mon Sep 17 00:00:00 2001 From: Mik Igor <136681630+htm23x@users.noreply.github.com> Date: Fri, 27 Oct 2023 00:49:31 +0200 Subject: [PATCH 4/6] FIX: scn3me_subm typo Fixed incorrect tech_name "scn3m_subm" (correct is "scn3me_subm", note the 3mE). --- compiler/globals.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/globals.py b/compiler/globals.py index 0d7863e01..f30245d82 100644 --- a/compiler/globals.py +++ b/compiler/globals.py @@ -566,8 +566,8 @@ def import_tech(): # Validate tech_name param techname_lower = OPTS.tech_name.lower() - if (techname_lower is None) or (techname_lower!="sky130" and techname_lower!="scn3m_subm" and techname_lower!="scn4m_subm" and techname_lower!="freepdk45") : - debug.error("tech_name in config file should be sky130|scn3m_subm|scn4m_subm|freepdk45") + if (techname_lower is None) or (techname_lower!="sky130" and techname_lower!="scn3me_subm" and techname_lower!="scn4m_subm" and techname_lower!="freepdk45") : + debug.error("tech_name in config file should be sky130|scn3me_subm|scn4m_subm|freepdk45") quit() # Import the tech From 173e47ae45bfe8462e66b721016cbcaedf9f36cf Mon Sep 17 00:00:00 2001 From: Mik Igor <136681630+htm23x@users.noreply.github.com> Date: Fri, 27 Oct 2023 01:29:27 +0200 Subject: [PATCH 5/6] Validate tech_name in config file iterating over technology dir We're now validating the tech_name param specified by the user in the config file listing all the subfolders present in the technology folder. If the technology specified is not present as folder, we will emit an error and quit. --- compiler/globals.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/compiler/globals.py b/compiler/globals.py index f30245d82..6c983ec38 100644 --- a/compiler/globals.py +++ b/compiler/globals.py @@ -558,16 +558,22 @@ def import_tech(): openram.OPENRAM_TECH = OPENRAM_TECH # Add all of the paths + tech_found = None for tech_path in OPENRAM_TECH.split(":"): debug.check(os.path.isdir(tech_path), "$OPENRAM_TECH does not exist: {}".format(tech_path)) sys.path.append(tech_path) debug.info(1, "Adding technology path: {}".format(tech_path)) - # Validate tech_name param - techname_lower = OPTS.tech_name.lower() - if (techname_lower is None) or (techname_lower!="sky130" and techname_lower!="scn3me_subm" and techname_lower!="scn4m_subm" and techname_lower!="freepdk45") : - debug.error("tech_name in config file should be sky130|scn3me_subm|scn4m_subm|freepdk45") + # List all tech dirs in that path and check if we can find the tech_name inside + for tech_dir in os.listdir(tech_path): + if tech_dir==OPTS.tech_name : + tech_found = tech_dir + break; + + # If the tech_name param specified by the user is not present in the technology folder, emit an error and quit + if (tech_found is None): + debug.error(f"You specified \'tech_name={OPTS.tech_name}\' in your config file, but that technology is not present in the technologies folder!") quit() # Import the tech From aa2cf888707b2a78168d9d5dc6a22d22fb1f8627 Mon Sep 17 00:00:00 2001 From: Mik Igor <136681630+htm23x@users.noreply.github.com> Date: Fri, 27 Oct 2023 01:35:04 +0200 Subject: [PATCH 6/6] Fix tabs/spaces in globals.py Some tabs/extra spaces were inserted accidentally by GitHub text editor in the tech_name param validation, so has to remove them. --- compiler/globals.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/globals.py b/compiler/globals.py index 6c983ec38..9a1189e02 100644 --- a/compiler/globals.py +++ b/compiler/globals.py @@ -571,7 +571,7 @@ def import_tech(): tech_found = tech_dir break; - # If the tech_name param specified by the user is not present in the technology folder, emit an error and quit + # If the tech_name param specified by the user is not present in the technology folder, emit an error and quit if (tech_found is None): debug.error(f"You specified \'tech_name={OPTS.tech_name}\' in your config file, but that technology is not present in the technologies folder!") quit()