Skip to content

Commit

Permalink
More adder options.
Browse files Browse the repository at this point in the history
  • Loading branch information
mithro committed Jan 3, 2024
1 parent f23ec4f commit cffb66a
Show file tree
Hide file tree
Showing 22 changed files with 732 additions and 152 deletions.
33 changes: 14 additions & 19 deletions dependency_support/com_google_skywater_pdk/cells_info.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
load("@rules_hdl//dependency_support/com_google_skywater_pdk:cell_libraries.bzl", "CELL_LIBRARIES")
load("@rules_hdl//pdk:build_defs.bzl", "StandardCellOptionsInfo", "check_for_each_cells_args", "temp_normalize", "voltage_normalize")

_SKY130_CORNER_BITS = [cname.split("_") for libname in CELL_LIBRARIES for cname in CELL_LIBRARIES[libname]["corners"]]

SKY130_OPTIONS = StandardCellOptionsInfo(
libraries = [
"sc_hd",
Expand All @@ -28,21 +30,9 @@ SKY130_OPTIONS = StandardCellOptionsInfo(
#"sc_hvl",
],
vts = [],
corners = list(sorted({
cname.split("_")[0]: None
for libname in CELL_LIBRARIES
for cname in CELL_LIBRARIES[libname]["corners"]
}.keys())),
volts = list(sorted({
voltage_normalize(cname.split("_")[2]): None
for libname in CELL_LIBRARIES
for cname in CELL_LIBRARIES[libname]["corners"]
}.keys())),
temps = list(sorted({
temp_normalize(cname.split("_")[1]): None
for libname in CELL_LIBRARIES
for cname in CELL_LIBRARIES[libname]["corners"]
}.keys())),
corners = [b[0] for b in _SKY130_CORNER_BITS],
volts = [b[2] for b in _SKY130_CORNER_BITS],
temps = [b[1] for b in _SKY130_CORNER_BITS],
)

def sky130_cell_normalize(libname, corner_def):
Expand Down Expand Up @@ -78,7 +68,7 @@ def sky130_cell_normalize(libname, corner_def):
t = temp,
)

def for_each_sky130_cells(libname, include_vts = None, include_corners = None, include_volts = None, include_temps = None):
def for_each_sky130_cells(libname, include_vts = None, include_corners = None, include_volts = None, include_temps = None, include_adders = None):
"""Generate a list of each standard cell library name.
Args:
Expand All @@ -87,6 +77,7 @@ def for_each_sky130_cells(libname, include_vts = None, include_corners = None, i
include_corners: 'all' or list of corners ('ff', 'tt', 'ss') to include in the output.
include_volts: 'all' or list of voltages (in '0p55v' form) to include in the output.
include_temps: 'all' or list of temperatures (in 'm40c' or '125c' form) to include in the output.
include_adders: 'all' or list of adder styles to include in the output.
Returns:
A list of tuples containing a unique name for the cell library
Expand Down Expand Up @@ -120,6 +111,7 @@ def for_each_sky130_cells(libname, include_vts = None, include_corners = None, i
"include_corners": include_corners,
"include_volts": include_volts,
"include_temps": include_temps,
"include_adders": include_adders,
}
check_for_each_cells_args(kwargs, SKY130_OPTIONS)

Expand All @@ -143,8 +135,11 @@ def for_each_sky130_cells(libname, include_vts = None, include_corners = None, i
if temp not in kwargs["include_temps"]:
continue

cell_name = sky130_cell_normalize(libname, corner_def)
cell_target = "@com_google_skywater_pdk_sky130_fd_{l}//:{c}".format(l = libname, c = cell_name)
corners[cell_name] = cell_target
for add in kwargs["include_adders"]:
if add:
add = "-" + add
cell_name = sky130_cell_normalize(libname, corner_def) + add
cell_target = "@com_google_skywater_pdk_sky130_fd_{l}//:{c}".format(l = libname, c = cell_name)
corners[cell_name] = cell_target

return list(sorted(corners.items()))
107 changes: 61 additions & 46 deletions dependency_support/com_google_skywater_pdk/declare_cell_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ cell library workspace to set things up."""

load("@rules_hdl//dependency_support/com_google_skywater_pdk:build_defs.bzl", "skywater_cell_library", "skywater_corner")
load("@rules_hdl//dependency_support/com_google_skywater_pdk:cells_info.bzl", "sky130_cell_normalize")
load("//pdk:build_defs.bzl", "ADDER_TYPES")
load(":cell_libraries.bzl", "CELL_LIBRARIES")

def declare_cell_library(workspace_name, name):
Expand All @@ -32,6 +33,31 @@ def declare_cell_library(workspace_name, name):
visibility = ["//visibility:public"],
)
library = CELL_LIBRARIES[name]

common_args = dict(
srcs = native.glob(
include = [
"cells/**/*.lef",
"cells/**/*.gds",
],
# There are two types of lefs in the PDK. One for magic a layout
# tool that requires some different properties set in the LEF that
# are not always suitable for the downstream tools like OpenROAD
# and yosys. We're basically just choosing that we want the normal
# lefs instead of the magic ones.
#
# Currently this repo doesn't integrate magic into the flow. At
# some point it will, and we'll need to somehow have both lefs, or
# fix the lefs upstream. Just know that you may at some point in the
# future need to modify this.
exclude = [
"cells/**/*.magic.lef",
],
),
visibility = ["//visibility:public"],
tech_lef = "tech/{}.tlef".format(name) if library.get("library_type", None) != "ip_library" else None,
)

corners = library.get("corners", {})
all_corners = []
for corner in corners:
Expand Down Expand Up @@ -60,59 +86,48 @@ def declare_cell_library(workspace_name, name):
)

# Library with only just a single corner.
skywater_cell_library(
name = target_name,
srcs = native.glob(
include = [
"cells/**/*.lef",
"cells/**/*.gds",
],
# There are two types of lefs in the PDK. One for magic a layout
# tool that requires some different properties set in the LEF that
# are not always suitable for the downstream tools like OpenROAD
# and yosys. We're basically just choosing that we want the normal
# lefs instead of the magic ones.
#
# Currently this repo doesn't integrate magic into the flow. At
# some point it will, and we'll need to somehow have both lefs, or
# fix the lefs upstream. Just know that you may at some point in the
# future need to modify this.
exclude = [
"cells/**/*.magic.lef",
],
),
corner_args = dict(
process_corners = [":" + corner_name],
default_corner = corner,
**common_args
)
for add in ADDER_TYPES:
if add == "opt":
continue
skywater_cell_library(
name = target_name + "-" + add,
openroad_configuration = str(library.get("open_road_configuration", None)) + "-" + add,
**corner_args
)
native.alias(
name = target_name + "-opt",
actual = ":" + target_name + "-fa",
visibility = ["//visibility:public"],
openroad_configuration = library.get("open_road_configuration", None),
tech_lef = "tech/{}.tlef".format(name) if library.get("library_type", None) != "ip_library" else None,
)

# Multi-corner library
skywater_cell_library(
name = name,
srcs = native.glob(
include = [
"cells/**/*.lef",
"cells/**/*.gds",
],
# There are two types of lefs in the PDK. One for magic a layout
# tool that requires some different properties set in the LEF that
# are not always suitable for the downstream tools like OpenROAD
# and yosys. We're basically just choosing that we want the normal
# lefs instead of the magic ones.
#
# Currently this repo doesn't integrate magic into the flow. At
# some point it will, and we'll need to somehow have both lefs, or
# fix the lefs upstream. Just know that you may at some point in the
# future need to modify this.
exclude = [
"cells/**/*.magic.lef",
],
),
common_args = dict(
process_corners = [":{}".format(corner) for corner in all_corners],
default_corner = library.get("default_corner", ""),
**common_args
)
for add in ADDER_TYPES:
if add == "opt":
continue
skywater_cell_library(
name = name + "-" + add,
openroad_configuration = str(library.get("open_road_configuration", None)) + "-" + add,
**common_args
)

# Map the "optimal" configuration to the full adder.
native.alias(
name = name + "-opt",
actual = ":" + name + "-fa",
visibility = ["//visibility:public"],
)
native.alias(
name = name,
actual = ":" + name + "-fa",
visibility = ["//visibility:public"],
openroad_configuration = library.get("open_road_configuration", None),
tech_lef = "tech/{}.tlef".format(name) if library.get("library_type", None) != "ip_library" else None,
)
39 changes: 32 additions & 7 deletions dependency_support/com_google_skywater_pdk/sky130_fd_sc_hd/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("//pdk:open_road_configuration.bzl", "open_road_pdk_configuration")
load("//pdk:build_defs.bzl", "ADDER_MAPPINGS")
load("//pdk:open_road_configuration.bzl", "make_open_road_pdk_configuration")

package(
default_applicable_licenses = ["//:package_license"],
Expand All @@ -11,8 +12,7 @@ exports_files([
"sky130hd.lyt", # Imported from OpenROAD-flow-scripts on 24.07.2023 at 6ec980e1d49a1a8dcdd1e25ed81255b4bb8285c8 from: https://github.com/The-OpenROAD-Project/OpenROAD-flow-scripts/blob/6ec980e1d49a1a8dcdd1e25ed81255b4bb8285c8/flow/platforms/sky130hd/sky130hd.lyt
])

open_road_pdk_configuration(
name = "open_road_sky130_fd_sc_hd",
_open_road_pdk_configuration_common = dict(
cell_site = "unithd",
cts_buffer_cell = "sky130_fd_sc_hd__clkbuf_1",
density_fill_config = "fill.json",
Expand All @@ -34,7 +34,6 @@ open_road_pdk_configuration(
"met5": "0.5",
},
global_routing_signal_layers = "met1-met5",
ha_fa_mapping = "cell_adders.v",
klayout_tech_file = "sky130hd.lyt",
pdn_config = "pdn_config.pdn",
pin_horizontal_metal_layer = "met3",
Expand All @@ -45,9 +44,35 @@ open_road_pdk_configuration(
tie_low_port = "sky130_fd_sc_hd__conb_1/LO",
tie_separation = 5,
tracks_file = "tracks.tcl",
visibility = [
"//visibility:public",
],
visibility = ["//visibility:public"],
wire_rc_clock_metal_layer = "met5",
wire_rc_signal_metal_layer = "met2",
)

make_open_road_pdk_configuration(
name = "open_road_sky130_fd_sc_hd-nofa",
common = _open_road_pdk_configuration_common,
)

make_open_road_pdk_configuration(
name = "open_road_sky130_fd_sc_hd-fa",
common = _open_road_pdk_configuration_common,
ha_fa_mapping = "cell_adders.v",
)

# FIXME: Add in the adder mappers
[
alias(
name = "open_road_sky130_fd_sc_hd-" + add,
actual = ":open_road_sky130_fd_sc_hd-fa",
visibility = ["//visibility:public"],
)
for add in ADDER_MAPPINGS
]

# Map the "optimal" configuration to the full adder
alias(
name = "open_road_sky130_fd_sc_hd-opt",
actual = ":open_road_sky130_fd_sc_hd-fa",
visibility = ["//visibility:public"],
)
60 changes: 23 additions & 37 deletions dependency_support/org_theopenroadproject_asap7_pdk_r1p7/asap7.bzl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""ASAP7 PDK rules."""

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

def asap7_srams_files(name = None, rev = None, tracks = None, has_gds = True):
Expand Down Expand Up @@ -149,55 +149,41 @@ def asap7_cells_files(name = None, rev = None, tracks = None, vt = None, has_gds
)

# CCS delay model
asap7_cell_library(
name = "asap7-sc{tracks}_rev{rev}_{vt_long}-ccs_ss".format(**args),
asap7_cell_library_common = dict(
srcs = [
":asap7-cells-sc{tracks}_rev{rev}_{vt_long}-lib7z".format(**args),
#":asap7-srams-sc{tracks}_rev{rev}-lib7z".format(**args),
],
cell_lef = ":asap7-cells-sc{tracks}_rev{rev}_{vt_long}-lef".format(**args),
platform_gds = ":asap7-cells-sc{tracks}_rev{rev}_{vt_long}-gds".format(**args),
default_corner_delay_model = "ccs",
default_corner_swing = "SS",
openroad_configuration = ":open_road-asap7-sc{tracks}_rev{rev}_{vt_long}".format(**args),
tech_lef = ":asap7-misc-sc{tracks}_rev{rev}-lef".format(**args),
visibility = [
"//visibility:public",
],
)
asap7_cell_library(
name = "asap7-sc{tracks}_rev{rev}_{vt_long}-ccs_tt".format(**args),
srcs = [
":asap7-cells-sc{tracks}_rev{rev}_{vt_long}-lib7z".format(**args),
#":asap7-srams-sc{tracks}_rev{rev}-lib7z".format(**args),
],
cell_lef = ":asap7-cells-sc{tracks}_rev{rev}_{vt_long}-lef".format(**args),
platform_gds = ":asap7-cells-sc{tracks}_rev{rev}_{vt_long}-gds".format(**args),
default_corner_delay_model = "ccs",
default_corner_swing = "TT",
openroad_configuration = ":open_road-asap7-sc{tracks}_rev{rev}_{vt_long}".format(**args),
tech_lef = ":asap7-misc-sc{tracks}_rev{rev}-lef".format(**args),
visibility = [
"//visibility:public",
],
)
asap7_cell_library(
name = "asap7-sc{tracks}_rev{rev}_{vt_long}-ccs_ff".format(**args),
srcs = [
":asap7-cells-sc{tracks}_rev{rev}_{vt_long}-lib7z".format(**args),
#":asap7-srams-sc{tracks}_rev{rev}-lib7z".format(**args),
],
cell_lef = ":asap7-cells-sc{tracks}_rev{rev}_{vt_long}-lef".format(**args),
platform_gds = ":asap7-cells-sc{tracks}_rev{rev}_{vt_long}-gds".format(**args),
default_corner_delay_model = "ccs",
default_corner_swing = "FF",
openroad_configuration = ":open_road-asap7-sc{tracks}_rev{rev}_{vt_long}".format(**args),
tech_lef = ":asap7-misc-sc{tracks}_rev{rev}-lef".format(**args),
visibility = [
"//visibility:public",
],
)

for add in ADDER_TYPES:
args["add"] = add
asap7_cell_library(
name = "asap7-sc{tracks}_rev{rev}_{vt_long}-ccs_ss-{add}".format(**args),
default_corner_swing = "SS",
openroad_configuration = ":open_road-asap7-sc{tracks}_rev{rev}_{vt_long}-{add}".format(**args),
**asap7_cell_library_common
)
asap7_cell_library(
name = "asap7-sc{tracks}_rev{rev}_{vt_long}-ccs_tt-{add}".format(**args),
default_corner_swing = "TT",
openroad_configuration = ":open_road-asap7-sc{tracks}_rev{rev}_{vt_long}-{add}".format(**args),
**asap7_cell_library_common
)
asap7_cell_library(
name = "asap7-sc{tracks}_rev{rev}_{vt_long}-ccs_ff-{add}".format(**args),
default_corner_swing = "FF",
openroad_configuration = ":open_road-asap7-sc{tracks}_rev{rev}_{vt_long}-{add}".format(**args),
**asap7_cell_library_common
)

def _asap7_cell_library_impl(ctx):
liberty_files = [file for file in ctx.files.srcs if file.extension == "7z"]
liberty_files = [file for file in liberty_files if "_{}_".format(ctx.attr.default_corner_delay_model) in file.basename]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
the 7.5 track library using RVT transistors and slow corner.
"""
load("@rules_hdl//pdk:build_defs.bzl", "ADDER_TYPES")
load("@rules_hdl//pdk:open_road_configuration.bzl", "open_road_pdk_configuration")
load("@rules_hdl//dependency_support/org_theopenroadproject_asap7_pdk_r1p7:asap7.bzl", "asap7_cell_library")
load("@rules_hdl//dependency_support/org_theopenroadproject_asap7_pdk_r1p7:asap7.bzl", "asap7_cells_files")
Expand Down
Loading

0 comments on commit cffb66a

Please sign in to comment.