Skip to content

Commit bef9c86

Browse files
committed
place_and_route: Added rules and providers to handle SDC files
Signed-off-by: Jan Bylicki <[email protected]>
1 parent 005be53 commit bef9c86

File tree

4 files changed

+45
-4
lines changed

4 files changed

+45
-4
lines changed

place_and_route/open_road.bzl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"""File encapsulating the open road command"""
1616

1717
load("//pdk:open_road_configuration.bzl", "get_open_road_configuration")
18-
load("//synthesis:defs.bzl", "SynthesisInfo")
18+
load("//synthesis:defs.bzl", "SynthesisInfo", "SdcInfo")
1919

2020
OpenRoadInfo = provider(
2121
"Provider to support running openroad outside of bazel",
@@ -100,7 +100,9 @@ def clock_commands(ctx):
100100
Returns:
101101
Struct with params inputs and commands. Both return values are lists.
102102
"""
103-
sdc = ctx.file.sdc
103+
sdc = None
104+
if SdcInfo in ctx.attr.sdc:
105+
sdc = ctx.attr.sdc[SdcInfo].sdc.files.to_list()[0]
104106

105107
if sdc:
106108
return struct(inputs = [sdc], commands = ["read_sdc {}".format(sdc.path)])

synthesis/build_defs.bzl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,3 +443,32 @@ Example:
443443
attrs = benchmark_synth_attrs,
444444
executable = True,
445445
)
446+
447+
SdcInfo = provider(
448+
doc = "sdc",
449+
fields = {
450+
"sdc": "Path to the SDC file",
451+
}
452+
)
453+
454+
def _sdc_library_impl(ctx):
455+
return [
456+
DefaultInfo(
457+
files = depset(transitive=[t.files for t in ctx.attr.srcs])
458+
),
459+
SdcInfo (
460+
sdc = ctx.attr.srcs[0]
461+
)
462+
]
463+
464+
sdc_library = rule(
465+
doc = "Define an SDC library.",
466+
implementation = _sdc_library_impl,
467+
attrs = {
468+
"srcs": attr.label_list(
469+
doc = "SDC sources.",
470+
allow_files = [".sdc"],
471+
),
472+
},
473+
)
474+

synthesis/defs.bzl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ load(
88
_benchmark_synth = "benchmark_synth",
99
_synthesis_binary = "synthesis_binary",
1010
_synthesize_rtl = "synthesize_rtl",
11+
_sdc_library = "sdc_library",
12+
_SdcInfo = "SdcInfo"
1113
)
1214

1315
benchmark_synth = _benchmark_synth
@@ -16,3 +18,6 @@ synthesis_binary = _synthesis_binary
1618
SynthesisInfo = _SynthesisInfo
1719
synthesize_rtl = _synthesize_rtl
1820
UhdmInfo = _UhdmInfo
21+
SdcInfo = _SdcInfo
22+
sdc_library = _sdc_library
23+

tests/BUILD

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ load("//flows:basic_asic.bzl", "basic_asic_flow")
1919
load("//gds_write:build_defs.bzl", "gds_write")
2020
load("//place_and_route:build_defs.bzl", "place_and_route")
2121
load("//static_timing:build_defs.bzl", "run_opensta")
22-
load("//synthesis:defs.bzl", "synthesize_rtl")
22+
load("//synthesis:defs.bzl", "synthesize_rtl", "sdc_library")
2323
load("//verilog:defs.bzl", "verilog_library")
2424

2525
package(
@@ -78,14 +78,19 @@ place_and_route(
7878
synthesized_rtl = ":verilog_adder-synth",
7979
)
8080

81+
sdc_library(
82+
name="constraint",
83+
srcs=["constraint.sdc"]
84+
)
85+
8186
place_and_route(
8287
name = "verilog_counter-place_and_route",
8388
clock_period = "10",
8489
core_padding_microns = 20,
8590
die_height_microns = 200,
8691
die_width_microns = 200,
8792
placement_density = "0.7",
88-
sdc = "constraint.sdc",
93+
sdc = ":constraint",
8994
synthesized_rtl = ":verilog_counter-synth",
9095
)
9196

0 commit comments

Comments
 (0)