Skip to content

Commit e4b5044

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 e4b5044

File tree

5 files changed

+46
-10
lines changed

5 files changed

+46
-10
lines changed

pdk/open_road_configuration.bzl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ open_road_pdk_configuration = rule(
117117
mandatory = True,
118118
doc = "This value can be an empty list if all cells should be used in P&R",
119119
),
120-
"endcap_cell": attr.string(
121-
),
120+
"endcap_cell": attr.string(),
122121
"fill_cells": attr.string_list(
123122
mandatory = True,
124123
),
@@ -160,10 +159,8 @@ open_road_pdk_configuration = rule(
160159
"rc_script_configuration": attr.label(
161160
allow_single_file = True,
162161
),
163-
"tap_cell": attr.string(
164-
),
165-
"tapcell_distance": attr.int(
166-
),
162+
"tap_cell": attr.string(),
163+
"tapcell_distance": attr.int(),
167164
"tapcell_tcl": attr.label(
168165
allow_single_file = True,
169166
doc = "TCL file that sets tapcell options. This overrides other tapcell attributes in this rule.",

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", "SdcInfo", "SynthesisInfo")
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: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,3 +443,31 @@ 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+
)

synthesis/defs.bzl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
load(
44
":build_defs.bzl",
55
_ExternalSynthesisInfo = "ExternalSynthesisInfo",
6+
_SdcInfo = "SdcInfo",
67
_SynthesisInfo = "SynthesisInfo",
78
_UhdmInfo = "UhdmInfo",
89
_benchmark_synth = "benchmark_synth",
10+
_sdc_library = "sdc_library",
911
_synthesis_binary = "synthesis_binary",
1012
_synthesize_rtl = "synthesize_rtl",
1113
)
@@ -16,3 +18,5 @@ synthesis_binary = _synthesis_binary
1618
SynthesisInfo = _SynthesisInfo
1719
synthesize_rtl = _synthesize_rtl
1820
UhdmInfo = _UhdmInfo
21+
SdcInfo = _SdcInfo
22+
sdc_library = _sdc_library

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", "sdc_library", "synthesize_rtl")
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)