From b4617a371427a79ee13c98307138b735852dbb2a Mon Sep 17 00:00:00 2001 From: Tim Ansell Date: Mon, 18 Sep 2023 12:05:14 -0700 Subject: [PATCH] Export def during place and route. Signed-off-by: Tim Ansell --- place_and_route/build_defs.bzl | 8 +++- place_and_route/private/export_def.bzl | 58 ++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 place_and_route/private/export_def.bzl diff --git a/place_and_route/build_defs.bzl b/place_and_route/build_defs.bzl index 40bfd971..ca9a15c7 100644 --- a/place_and_route/build_defs.bzl +++ b/place_and_route/build_defs.bzl @@ -17,6 +17,7 @@ load("@rules_hdl//pdk:open_road_configuration.bzl", "assert_has_open_road_configuration") load("//place_and_route:private/clock_tree_synthesis.bzl", "clock_tree_synthesis") load("//place_and_route:private/detailed_routing.bzl", "detailed_routing") +load("//place_and_route:private/export_def.bzl", "export_def") load("//place_and_route:private/floorplan.bzl", "init_floor_plan") load("//place_and_route:private/global_placement.bzl", "global_placement") load("//place_and_route:private/global_routing.bzl", "global_routing") @@ -32,16 +33,21 @@ def _place_and_route_impl(ctx): output_files = [] open_road_provider = init_floor_plan(ctx) + open_road_provider, output_def = export_def(ctx, open_road_provider, "pre_pnr") + output_files.append(output_def) open_road_provider = place_pins(ctx, open_road_provider) open_road_provider = pdn_gen(ctx, open_road_provider) open_road_provider = global_placement(ctx, open_road_provider) + open_road_provider, output_def = export_def(ctx, open_road_provider, "global_placement") + output_files.append(output_def) open_road_provider = resize(ctx, open_road_provider) open_road_provider = clock_tree_synthesis(ctx, open_road_provider) open_road_provider = global_routing(ctx, open_road_provider) if not ctx.attr.skip_detailed_routing: open_road_provider = detailed_routing(ctx, open_road_provider) output_files.append(open_road_provider.routed_def) - + open_road_provider, output_def = export_def(ctx, open_road_provider, "post_pnr") + output_files.append(output_def) output_files.append(open_road_provider.output_db) output_files.extend(open_road_provider.logs.to_list()) diff --git a/place_and_route/private/export_def.bzl b/place_and_route/private/export_def.bzl new file mode 100644 index 00000000..eb5861ed --- /dev/null +++ b/place_and_route/private/export_def.bzl @@ -0,0 +1,58 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Export to def openROAD commands""" + +load("//place_and_route/open_road.bzl", "OpenRoadInfo", "merge_open_road_info", "openroad_command") + +def export_def(ctx, open_road_info, suffix): + """Export to def. + + Returns: + OpenRoadInfo: the openROAD info provider containing required input files and + and commands run. + Args: + ctx: Bazel rule ctx + open_road_info: OpenRoadInfo provider from a previous step. + suffix: Suffix to use for thr def file. + + """ + + inputs = [] + + outputs = [] + output_def = ctx.actions.declare_file("{}__{}.def".format(ctx.attr.name, suffix)) + outputs.append(output_def) + + open_road_commands = [] + write_def_command = "write_def {}".format(output_def.path) + open_road_commands.append(write_def_command) + + command_output = openroad_command( + ctx, + inputs = inputs, + outputs = outputs, + commands = open_road_commands, + input_db = open_road_info.output_db, + step_name = "export_def_" + suffix, + ) + + def_open_road_info = OpenRoadInfo( + commands = open_road_commands, + input_files = depset(inputs), + output_db = command_output.db, + logs = depset([command_output.log_file]), + ) + + return merge_open_road_info(open_road_info, def_open_road_info), output_def