Skip to content

Commit

Permalink
Adds ASAP7 support to bazel rules hdl.
Browse files Browse the repository at this point in the history
This commit adds the required PDK files, and some utilities to make
things work better with the system we have setup.
  • Loading branch information
QuantamHD committed Jan 31, 2022
1 parent 5c0ef20 commit f7dbd5e
Show file tree
Hide file tree
Showing 20 changed files with 817 additions and 1 deletion.
1 change: 1 addition & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#HDL
2 changes: 2 additions & 0 deletions dependency_support/dependency_support.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ load("@rules_hdl//dependency_support/org_sourceware_bzip2:org_sourceware_bzip2.b
load("@rules_hdl//dependency_support/org_sourceware_libffi:org_sourceware_libffi.bzl", "org_sourceware_libffi")
load("@rules_hdl//dependency_support/org_swig:org_swig.bzl", "org_swig")
load("@rules_hdl//dependency_support/org_theopenroadproject:org_theopenroadproject.bzl", "org_theopenroadproject")
load("@rules_hdl//dependency_support/org_theopenroadproject_asap7:org_theopenroadproject_asap7.bzl", "org_theopenroadproject_asap7")
load("@rules_hdl//dependency_support/org_tuxfamily_eigen:org_tuxfamily_eigen.bzl", "org_tuxfamily_eigen")
load("@rules_hdl//dependency_support/pybind11:pybind11.bzl", "pybind11")
load("@rules_hdl//dependency_support/tk_tcl:tk_tcl.bzl", "tk_tcl")
Expand Down Expand Up @@ -94,6 +95,7 @@ def dependency_support():
org_sourceware_libffi()
org_swig()
org_theopenroadproject()
org_theopenroadproject_asap7()
org_tuxfamily_eigen()
pybind11()
tk_tcl()
15 changes: 15 additions & 0 deletions dependency_support/org_theopenroadproject_asap7/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2022 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.

exports_files(["tracks.tcl", "rc_script.tcl", "pdn_config.pdn"])
80 changes: 80 additions & 0 deletions dependency_support/org_theopenroadproject_asap7/asap7.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
"""ASAP7 PDK rules."""

load("@rules_hdl//pdk:build_defs.bzl", "CornerInfo", "StandardCellInfo")
load("@rules_hdl//pdk:open_road_configuration.bzl", "OpenRoadPdkInfo")

def _asap7_cell_library_impl(ctx):
liberty_files = [file for file in ctx.files.srcs if file.extension == "gz"]
liberty_files = [file for file in liberty_files if "_{}_".format(ctx.attr.default_corner_delay_model) in file.basename]
liberty_files = [file for file in liberty_files if "SRAM" not in file.basename]
liberty_files = [file for file in liberty_files if ctx.attr.cell_type in file.basename]

uncompressed_files = []
for file in liberty_files:
uncompressed_file = ctx.actions.declare_file(file.basename[:-len(".gz")])
ctx.actions.run_shell(
outputs = [
uncompressed_file,
],
inputs = [
file,
],
command = "gunzip --to-stdout {compressed_file} > {uncompressed_file}".format(
compressed_file = file.path,
uncompressed_file = uncompressed_file.path,
),
)

uncompressed_files.append(uncompressed_file)

default_corner_libraries = [file for file in uncompressed_files if "_{}_".format(ctx.attr.default_corner_swing) in file.basename]

default_output_liberty = ctx.actions.declare_file("{}_{}.lib".format(ctx.attr.name, ctx.attr.default_corner_swing))

args = ctx.actions.args()
for file in default_corner_libraries:
args.add("--liberty_files", file)
args.add("--output", default_output_liberty)

ctx.actions.run(
outputs = [default_output_liberty],
inputs = default_corner_libraries,
arguments = [args],
executable = ctx.executable._combine_liberty,
)

open_road_configuration = None
if ctx.attr.openroad_configuration:
open_road_configuration = ctx.attr.openroad_configuration[OpenRoadPdkInfo]

return [
DefaultInfo(files = depset([default_output_liberty] + default_corner_libraries)),
StandardCellInfo(
corners = [],
cell_lef_definitions = [ctx.file.cell_lef],
tech_lef = ctx.file.tech_lef,
default_corner = CornerInfo(
liberty = default_output_liberty,
),
open_road_configuration = open_road_configuration,
),
]

asap7_cell_library = rule(
implementation = _asap7_cell_library_impl,
attrs = {
"srcs": attr.label_list(allow_files = True),
"tech_lef": attr.label(allow_single_file = True, mandatory = True, doc = "The tech lef file for these standard cells"),
"default_corner_swing": attr.string(mandatory = True, values = ["SS", "FF", "TT"]),
"default_corner_delay_model": attr.string(mandatory = True, values = ["ccs", "ccsn", "ccsa"]),
"cell_type": attr.string(mandatory = True, values = ["RVT", "LVT", "SLVT"]),
#TODO(b/212480812): Support multiple VTs in a single design.
"openroad_configuration": attr.label(providers = [OpenRoadPdkInfo]),
"cell_lef": attr.label(allow_single_file = True, mandatory = True, doc = "The lef file for the standard cells"),
"_combine_liberty": attr.label(
default = Label("@rules_hdl//pdk/liberty:combine_liberty"),
executable = True,
cfg = "exec",
),
},
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Copyright 2022 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.

"""Arizona State University 7nm PDK"""

load("@rules_hdl//pdk:open_road_configuration.bzl", "open_road_pdk_configuration")
load("@rules_hdl//dependency_support/org_theopenroadproject_asap7:asap7.bzl", "asap7_cell_library")

asap7_cell_library(
name = "asap7_rvt_1x",
srcs = glob(["asap7sc7p5t_27/LIB/CCS/*.lib.gz"]),
cell_lef = "asap7sc7p5t_27/LEF/scaled/asap7sc7p5t_27_R_4x_201211.lef",
cell_type = "RVT",
default_corner_delay_model = "ccs",
default_corner_swing = "SS",
openroad_configuration = ":open_road_asap7_1x",
tech_lef = "asap7sc7p5t_27/techlef_misc/asap7_tech_4x_201209.lef",
visibility = [
"//visibility:public",
]
)

open_road_pdk_configuration(
name = "open_road_asap7_1x",
cell_site = "asap7sc7p5t",
cts_buffer_cell = "BUFx4_ASAP7_75t_R",
do_not_use_cell_list = [
"*x1_ASAP7*",
"*x1p*_ASAP7*",
"*xp*_ASAP7*",
"SDF*",
"ICG*",
"DFFH*",
],
endcap_cell = "TAPCELL_ASAP7_75t_R",
fill_cells = [
"FILLERxp5_ASAP7_75t_R",
],
global_placement_cell_pad = 2,
global_routing_clock_layers = "M2-M7",
global_routing_layer_adjustments = {
"M2": "0.5",
"M3": "0.5",
"M4": "0.5",
"M5": "0.5",
"M6": "0.5",
"M7": "0.5",
},
global_routing_signal_layers = "M2-M7",
pdn_config = "@rules_hdl//dependency_support/org_theopenroadproject_asap7:pdn_config.pdn",
pin_horizontal_metal_layer = "M4",
pin_vertical_metal_layer = "M5",
rc_script_configuration = "@rules_hdl//dependency_support/org_theopenroadproject_asap7:rc_script.tcl",
tap_cell = "TAPCELL_ASAP7_75t_R",
tapcell_distance = 25 * 4, # We are using the by 4 variants of these cells.
tie_high_port = "TIEHIx1_ASAP7_75t_R/H",
tie_low_port = "TIELOx1_ASAP7_75t_R/L",
tie_separation = 0,
tracks_file = "@rules_hdl//dependency_support/org_theopenroadproject_asap7:tracks.tcl",
wire_rc_clock_metal_layer = "M5",
wire_rc_signal_metal_layer = "M2",
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2022 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.

"""Registers Bazel workspaces for the Boost C++ libraries."""

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")

def org_theopenroadproject_asap7():
maybe(
http_archive,
name = "org_theopenroadproject_asap7",
urls = [
"https://github.com/The-OpenROAD-Project/asap7/archive/157c92cfd2567a98c5f794fb10c2dd0713516374.tar.gz",
],
strip_prefix = "asap7-157c92cfd2567a98c5f794fb10c2dd0713516374",
sha256 = "bfa76681ee0f1b109cb73415728cf3d7508ce0be88ac491962e8a0016033a683",
build_file = Label("@rules_hdl//dependency_support/org_theopenroadproject_asap7:bundled.BUILD.bazel"),
)
32 changes: 32 additions & 0 deletions dependency_support/org_theopenroadproject_asap7/pdn_config.pdn
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Floorplan information - core boundary coordinates, std. cell row height,

set ::halo 2

# POWER or GROUND #Std. cell rails starting with power or ground rails at the bottom of the core area
set ::rails_start_with "POWER" ;

# POWER or GROUND #Upper metal stripes starting with power or ground rails at the left/bottom of the core area
set ::stripes_start_with "POWER" ;

# Power nets
set ::power_nets "VDD"
set ::ground_nets "VSS"

pdngen::specify_grid stdcell {
name top

rails {
M1 {width 0.072 offset 0}
M2 {width 0.072 offset 0}
}

straps {
M5 {width 0.216 pitch 47.52 spacing 0.288 offset 1.188}
M6 {width 0.544 pitch 48 spacing 0.384 offset 2.556}
}

connect {
{M5 M2}
}

}
35 changes: 35 additions & 0 deletions dependency_support/org_theopenroadproject_asap7/rc_script.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2022 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.

set_layer_rc -layer M1 -capacitance 6.33956E-02 -resistance 1.3889e-01
set_layer_rc -layer M2 -capacitance 8.02750E-02 -resistance 2.4222e-02
set_layer_rc -layer M3 -capacitance 1.23273E-01 -resistance 2.4222e-02
set_layer_rc -layer M4 -capacitance 1.29902E-01 -resistance 1.6778e-02
set_layer_rc -layer M5 -capacitance 1.19552E-01 -resistance 1.4677e-02
set_layer_rc -layer M6 -capacitance 1.23114E-01 -resistance 1.0371e-02
set_layer_rc -layer M7 -capacitance 1.05408E-01 -resistance 9.6720e-03
set_layer_rc -layer M8 -capacitance 1.1822e-01 -resistance 7.4310e-03
set_layer_rc -layer M9 -capacitance 1.3497e-01 -resistance 6.8740e-03

set_layer_rc -via V1 -resistance 1.00E-02
set_layer_rc -via V2 -resistance 1.00E-02
set_layer_rc -via V3 -resistance 1.00E-02
set_layer_rc -via V4 -resistance 1.00E-02
set_layer_rc -via V5 -resistance 1.00E-02
set_layer_rc -via V6 -resistance 1.00E-02
set_layer_rc -via V7 -resistance 1.00E-02
set_layer_rc -via V8 -resistance 1.00E-02
set_layer_rc -via V9 -resistance 1.00E-02

set_wire_rc -layer M3
33 changes: 33 additions & 0 deletions dependency_support/org_theopenroadproject_asap7/tracks.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2022 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.set multiplier 4

make_tracks Pad -x_offset [expr 0.116 * $multiplier] -x_pitch [expr 0.08 * $multiplier] -y_offset [expr 0.116 * $multiplier] -y_pitch [expr 0.08 * $multiplier]
make_tracks M9 -x_offset [expr 0.116 * $multiplier] -x_pitch [expr 0.08 * $multiplier] -y_offset [expr 0.116 * $multiplier] -y_pitch [expr 0.08 * $multiplier]
make_tracks M8 -x_offset [expr 0.116 * $multiplier] -x_pitch [expr 0.08 * $multiplier] -y_offset [expr 0.116 * $multiplier] -y_pitch [expr 0.08 * $multiplier]
make_tracks M7 -x_offset [expr 0.016 * $multiplier] -x_pitch [expr 0.064 * $multiplier] -y_offset [expr 0.016 * $multiplier] -y_pitch [expr 0.064 * $multiplier]
make_tracks M6 -x_offset [expr 0.012 * $multiplier] -x_pitch [expr 0.048 * $multiplier] -y_offset [expr 0.016 * $multiplier] -y_pitch [expr 0.064 * $multiplier]
make_tracks M5 -x_offset [expr 0.012 * $multiplier] -x_pitch [expr 0.048 * $multiplier] -y_offset [expr 0.012 * $multiplier] -y_pitch [expr 0.048 * $multiplier]
make_tracks M4 -x_offset [expr 0.009 * $multiplier] -x_pitch [expr 0.036 * $multiplier] -y_offset [expr 0.012 * $multiplier] -y_pitch [expr 0.048 * $multiplier]
make_tracks M3 -x_offset [expr 0.009 * $multiplier] -x_pitch [expr 0.036 * $multiplier] -y_offset [expr 0.009 * $multiplier] -y_pitch [expr 0.036 * $multiplier]

# Creating multiple sub tracks for metal M2 for off grid routing purposes.
make_tracks M2 -x_offset [expr 0.009 * $multiplier] -x_pitch [expr 0.036 * $multiplier] -y_offset [expr (0.045 - 0.000) * $multiplier] -y_pitch [expr 0.270 * $multiplier]
make_tracks M2 -x_offset [expr 0.009 * $multiplier] -x_pitch [expr 0.036 * $multiplier] -y_offset [expr (0.081 - 0.000) * $multiplier] -y_pitch [expr 0.270 * $multiplier]
make_tracks M2 -x_offset [expr 0.009 * $multiplier] -x_pitch [expr 0.036 * $multiplier] -y_offset [expr (0.117 - 0.000) * $multiplier] -y_pitch [expr 0.270 * $multiplier]
make_tracks M2 -x_offset [expr 0.009 * $multiplier] -x_pitch [expr 0.036 * $multiplier] -y_offset [expr (0.153 - 0.000) * $multiplier] -y_pitch [expr 0.270 * $multiplier]
make_tracks M2 -x_offset [expr 0.009 * $multiplier] -x_pitch [expr 0.036 * $multiplier] -y_offset [expr (0.189 - 0.000) * $multiplier] -y_pitch [expr 0.270 * $multiplier]
make_tracks M2 -x_offset [expr 0.009 * $multiplier] -x_pitch [expr 0.036 * $multiplier] -y_offset [expr (0.225 - 0.000) * $multiplier] -y_pitch [expr 0.270 * $multiplier]
make_tracks M2 -x_offset [expr 0.009 * $multiplier] -x_pitch [expr 0.036 * $multiplier] -y_offset [expr (0.270 - 0.000) * $multiplier] -y_pitch [expr 0.270 * $multiplier]

make_tracks M1 -x_offset [expr 0.009 * $multiplier] -x_pitch [expr 0.036 * $multiplier] -y_offset [expr 0.009 * $multiplier] -y_pitch [expr 0.036 * $multiplier]
1 change: 1 addition & 0 deletions dependency_support/pip_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dataclasses-json==0.5.2
jwt==1.1.0
requests==2.25.1
absl-py==1.0.0
13 changes: 13 additions & 0 deletions pdk/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2022 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.
Loading

0 comments on commit f7dbd5e

Please sign in to comment.