Skip to content

Commit d592917

Browse files
oharboeclaude
andcommitted
makeIssue: EXCLUDE_PLATFORM drops the platform variables by name
makeIssue.sh left the platform's files out of an EXCLUDE_PLATFORM archive by the variable that names them. makeIssue.py left out the files whose resolved path is under PLATFORM_DIR instead, so a PDK installed elsewhere was archived: LIB_FILES naming a .lib.gz, CDL_FILE and RCX_RULES outside PLATFORM_DIR, and a file in PLATFORM_DIR that is a link to somewhere else, all of which makeIssue.sh left out. variables.yaml now marks the variables that name the platform's files with `platform: true`, makeIssue.sh's platform list without the unread PDN_CFG and without ADDITIONAL_LEFS, which names the design's macros. EXCLUDE_PLATFORM leaves those variables out by name, and still leaves out a file under PLATFORM_DIR whichever variable names it, as the path is written or through a symlink. The tests name platform files outside PLATFORM_DIR and a link in each direction, in the file list and in the finished archive; they failed before this change. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent e5c8a59 commit d592917

3 files changed

Lines changed: 117 additions & 10 deletions

File tree

‎flow/scripts/variables.yaml‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,12 @@ TECH_LEF:
135135
A technology LEF file of the PDK that includes all relevant information
136136
regarding metal layers, vias, and spacing requirements.
137137
type: file
138+
platform: true
138139
SC_LEF:
139140
description: |
140141
Path to technology standard cell LEF file.
141142
type: file
143+
platform: true
142144
GDS_FILES:
143145
description: |
144146
Path to platform GDS files.
@@ -148,6 +150,7 @@ LIB_FILES:
148150
input and output characteristics, timing and power definitions for each
149151
cell.
150152
type: file
153+
platform: true
151154
LIB_MODEL:
152155
description: >
153156
Selects between NLDM and CCS timing models for the ASAP7 platform.
@@ -455,18 +458,21 @@ LATCH_MAP_FILE:
455458
stages:
456459
- synth
457460
type: file
461+
platform: true
458462
CLKGATE_MAP_FILE:
459463
description: |
460464
Optional mapping file supplied to Yosys to map clock gating cells
461465
stages:
462466
- synth
463467
type: file
468+
platform: true
464469
ADDER_MAP_FILE:
465470
description: |
466471
Optional mapping file supplied to Yosys to map adders
467472
stages:
468473
- synth
469474
type: file
475+
platform: true
470476
INFER_CLKGATES:
471477
description: >
472478
Enables Yosys clock gate inference. By default, it uses the Liberty cell
@@ -642,6 +648,7 @@ TAPCELL_TCL:
642648
stages:
643649
- floorplan
644650
type: file
651+
platform: true
645652
MACRO_PLACEMENT_TCL:
646653
description: |
647654
Specifies the path of a TCL file on how to place macros manually.
@@ -663,6 +670,7 @@ PDN_TCL:
663670
stages:
664671
- floorplan
665672
type: file
673+
platform: true
666674
GLOBAL_CONNECT_TCL:
667675
description: >
668676
File path to the add_global_connection rules that connect the supply pins
@@ -674,12 +682,14 @@ GLOBAL_CONNECT_TCL:
674682
stages:
675683
- floorplan
676684
type: file
685+
platform: true
677686
MAKE_TRACKS:
678687
description: |
679688
Tcl file that defines add routing tracks to a floorplan.
680689
stages:
681690
- floorplan
682691
type: file
692+
platform: true
683693
IO_CONSTRAINTS:
684694
description: |
685695
File path to the IO constraints .tcl file. Also used for manual placement.
@@ -1082,10 +1092,12 @@ RCX_RULES:
10821092
description: |
10831093
RC Extraction rules file path.
10841094
type: file
1095+
platform: true
10851096
FILL_CONFIG:
10861097
description: |
10871098
JSON rule file for metal fill during chip finishing.
10881099
type: file
1100+
platform: true
10891101
KLAYOUT_TECH_FILE:
10901102
description: |
10911103
A mapping from LEF/DEF to GDS using the KLayout tool.
@@ -1139,6 +1151,7 @@ ADDITIONAL_FILES:
11391151
description: |
11401152
Additional files to be added to `make issue` archive.
11411153
type: file
1154+
platform: true
11421155
ADDITIONAL_LEFS:
11431156
description: >
11441157
Hardened macro LEF view files listed here. The LEF information of the
@@ -1346,6 +1359,7 @@ POST_CTS_TCL:
13461359
stages:
13471360
- cts
13481361
type: file
1362+
platform: true
13491363
POST_DENSITY_FILL_TCL:
13501364
description: |
13511365
Specifies a Tcl script with commands to run after density fill.
@@ -1362,6 +1376,7 @@ POST_DETAIL_ROUTE_TCL:
13621376
stages:
13631377
- route
13641378
type: file
1379+
platform: true
13651380
POST_FILLCELL_TCL:
13661381
description: |
13671382
Specifies a Tcl script with commands to run after fillcell insertion.
@@ -1378,6 +1393,7 @@ POST_FLOORPLAN_TCL:
13781393
stages:
13791394
- floorplan
13801395
type: file
1396+
platform: true
13811397
POST_GLOBAL_PLACE_SKIP_IO_TCL:
13821398
description: |
13831399
Specifies a Tcl script with commands to run after global placement (skip IO).
@@ -1409,6 +1425,7 @@ POST_PDN_TCL:
14091425
stages:
14101426
- floorplan
14111427
type: file
1428+
platform: true
14121429
POST_RESIZE_TCL:
14131430
description: |
14141431
Specifies a Tcl script with commands to run after resize.
@@ -1503,6 +1520,7 @@ FASTROUTE_TCL:
15031520
description: |
15041521
Specifies a Tcl script with commands to run before FastRoute.
15051522
type: file
1523+
platform: true
15061524
USE_FILL:
15071525
description: >
15081526
Whether to perform metal density filling.
@@ -1521,6 +1539,7 @@ PRE_GLOBAL_ROUTE_TCL:
15211539
stages:
15221540
- grt
15231541
type: file
1542+
platform: true
15241543
GLOBAL_ROUTE_ARGS:
15251544
description: >
15261545
Replaces default arguments for global route. The -congestion_iterations
@@ -1873,6 +1892,7 @@ CDL_FILE:
18731892
stages:
18741893
- final
18751894
type: file
1895+
platform: true
18761896
OPT_POST_GRT_WNS:
18771897
default: 1
18781898
description: >

‎flow/test/test_make_issue.py‎

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,70 @@ def test_exclude_platform_leaves_out_the_platform_files(self):
321321
self.assertIn(sdc, files)
322322
self.assertFalse([f for f in files if f.startswith(self.stub.platform_dir)])
323323

324+
def outside_platform(self):
325+
"""The platform's files where a PDK installed outside PLATFORM_DIR
326+
has them, and a link to one of them inside it."""
327+
pdk = os.path.join(self.stub.tmp, "pdk")
328+
files = {
329+
name: os.path.join(pdk, name)
330+
for name in ["cells.lib.gz", "cells.cdl", "rcx.rules", "pdk.sdc"]
331+
}
332+
for path in files.values():
333+
self.stub.write(path, "\n")
334+
link = os.path.join(self.stub.platform_dir, "link.sdc")
335+
os.symlink(files["pdk.sdc"], link)
336+
return files, link
337+
338+
def test_exclude_platform_leaves_out_the_platform_variables(self):
339+
"""By name: a PDK may be installed outside PLATFORM_DIR, where
340+
only the variable says a file is the platform's."""
341+
outside, _ = self.outside_platform()
342+
files = self.files(
343+
EXCLUDE_PLATFORM="1",
344+
LIB_FILES=outside["cells.lib.gz"],
345+
CDL_FILE=outside["cells.cdl"],
346+
RCX_RULES=outside["rcx.rules"],
347+
)
348+
for path in outside.values():
349+
self.assertNotIn(path, files)
350+
351+
def test_exclude_platform_leaves_out_a_link_in_the_platform(self):
352+
"""A file in PLATFORM_DIR that is a link to somewhere else is
353+
the platform's, as much as a link from elsewhere into it."""
354+
outside, link = self.outside_platform()
355+
into = os.path.join(self.stub.design_dir, "into.sdc")
356+
self.stub.write(os.path.join(self.stub.platform_dir, "platform.sdc"), "\n")
357+
os.symlink(os.path.join(self.stub.platform_dir, "platform.sdc"), into)
358+
for sdc in [link, into]:
359+
self.assertEqual(
360+
[f for f in self.files(EXCLUDE_PLATFORM="1", SDC_FILE=sdc) if f == sdc],
361+
[],
362+
)
363+
364+
def test_the_platform_variables_are_file_variables(self):
365+
platform = makeIssue.platform_file_variables()
366+
self.assertIn("LIB_FILES", platform)
367+
self.assertNotIn("SDC_FILE", platform)
368+
self.assertLessEqual(set(platform), set(makeIssue.file_variables()))
369+
370+
def test_exclude_platform_end_to_end(self):
371+
outside, link = self.outside_platform()
372+
sdc = os.path.join(self.stub.design_dir, "constraint.sdc")
373+
self.stub.write(sdc, "\n")
374+
archive = self.stub.make_issue(
375+
".",
376+
EXCLUDE_PLATFORM="1",
377+
LIB_FILES=outside["cells.lib.gz"],
378+
CDL_FILE=outside["cells.cdl"],
379+
RCX_RULES=outside["rcx.rules"],
380+
IO_CONSTRAINTS=link,
381+
SDC_FILE=sdc,
382+
)
383+
names = [os.path.basename(m) for m in self.stub.members(archive)]
384+
for name in list(outside) + ["link.sdc"]:
385+
self.assertNotIn(name, names)
386+
self.assertIn("constraint.sdc", names)
387+
324388
def test_archived_end_to_end(self):
325389
lib = os.path.join(self.stub.platform_dir, "dff.lib")
326390
cells = os.path.join(self.stub.platform_dir, "cells.lib")

‎flow/util/makeIssue.py‎

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,33 +57,56 @@ def platform_globs(platform_dir):
5757
return globs
5858

5959

60+
def flow_variables():
61+
with open(VARIABLES_YAML) as f:
62+
return yaml.safe_load(f)
63+
64+
6065
def file_variables():
6166
"""The flow variables that name files: `type: file` in
6267
variables.yaml."""
63-
with open(VARIABLES_YAML) as f:
64-
variables = yaml.safe_load(f)
6568
return sorted(
66-
name for name, variable in variables.items() if variable.get("type") == "file"
69+
name
70+
for name, variable in flow_variables().items()
71+
if variable.get("type") == "file"
72+
)
73+
74+
75+
def platform_file_variables():
76+
"""The file variables that name the platform's files, wherever the
77+
platform keeps them: `platform: true` in variables.yaml."""
78+
return sorted(
79+
name
80+
for name, variable in flow_variables().items()
81+
if variable.get("type") == "file" and variable.get("platform")
6782
)
6883

6984

7085
def in_platform(path, platform_dir):
71-
"""Whether the file lies under the platform directory."""
72-
platform = os.path.realpath(platform_dir)
73-
return os.path.realpath(path).startswith(platform + os.sep)
86+
"""Whether the file lies under the platform directory, as it is
87+
named or through a symlink."""
88+
return any(
89+
resolve(path).startswith(resolve(platform_dir) + os.sep)
90+
for resolve in [os.path.abspath, os.path.realpath]
91+
)
7492

7593

7694
def issue_files(env, vars_basename, run_me_script):
7795
"""The files the flow variables name, the platform's scripts and the
7896
issue's own vars and run-me files, sorted and without duplicates.
79-
EXCLUDE_PLATFORM leaves out the files under the platform directory,
80-
whichever variable names them."""
81-
files = expand(" ".join(env[name] for name in file_variables() if name in env))
97+
EXCLUDE_PLATFORM leaves out the files the platform's variables name
98+
and the files under the platform directory, whichever variable names
99+
them."""
100+
names = file_variables()
82101
words = []
83102
if "EXCLUDE_PLATFORM" in env:
84-
files = [f for f in files if not in_platform(f, env["PLATFORM_DIR"])]
103+
platform = platform_file_variables()
104+
names = [name for name in names if name not in platform]
85105
else:
86106
words += platform_globs(env["PLATFORM_DIR"])
107+
files = expand(" ".join(env[name] for name in names if name in env))
108+
if "EXCLUDE_PLATFORM" in env:
109+
files = [f for f in files if not in_platform(f, env["PLATFORM_DIR"])]
87110
words += [
88111
f"{env['UTILS_DIR']}/def2stream.py",
89112
run_me_script,

0 commit comments

Comments
 (0)