diff --git a/flow/BUILD.bazel b/flow/BUILD.bazel index 3e42c9ba5c..823d19658e 100644 --- a/flow/BUILD.bazel +++ b/flow/BUILD.bazel @@ -1,5 +1,4 @@ load("@bazel-orfs//:openroad.bzl", "orfs_flow") -load("@rules_python//python:pip.bzl", "compile_pip_requirements") filegroup( name = "constraints-gcd", @@ -101,158 +100,8 @@ orfs_flow( ]), ) -filegroup( - name = "mock-array-constraints", - srcs = [ - "designs/asap7/mock-array/constraints.sdc", - ], - visibility = [":__subpackages__"], -) - -filegroup( - name = "mock-array-io", - srcs = [ - "designs/asap7/mock-array/io.tcl", - ], - data = [ - "designs/src/mock-array/util.tcl", - ], - visibility = [":__subpackages__"], -) - -MOCK_ARRAY_FLOORPLAN_PLACE = { - "PLACE_PINS_ARGS": "-annealing", - "IO_CONSTRAINTS": "$(location :mock-array-io)", - "PLACE_DENSITY": "0.30", - "DIE_AREA": "0 0 358.56 388.8", - "CORE_AREA": "2.16 2.16 356.40000000000003 386.64000000000004", - "MACRO_PLACE_HALO": "0 2.16", - "RTLMP_BOUNDARY_WT": "0", - "PDN_TCL": "$(PLATFORM_DIR)/openRoad/pdn/BLOCKS_grid_strategy.tcl", - "MACRO_HALO_X": "0.5", - "MACRO_HALO_Y": "0.5", - "MACRO_BLOCKAGE_HALO": "0", - "ADDITIONAL_FILES": "$(locations :mock-array-io)", -} - -orfs_flow( - name = "MockArray", - macros = ["Element_generate_abstract"], - stage_arguments = { - "synth": { - "SDC_FILE": "$(location :mock-array-constraints)", - }, - "floorplan": MOCK_ARRAY_FLOORPLAN_PLACE | { - }, - "place": MOCK_ARRAY_FLOORPLAN_PLACE | { - }, - "cts": { - "CTS_BUF_DISTANCE": "60", - }, - "route": { - # works with 28 or more iterations as of writing, so give it a few more. - "GLOBAL_ROUTE_ARGS": "-congestion_iterations 40 -verbose", - # If this design isn't quickly done in detailed routing, something is wrong. - # At time of adding this option, only 12 iterations were needed for 0 - # violations. - "DETAILED_ROUTE_ARGS": "-bottom_routing_layer M2 -top_routing_layer M7 -save_guide_updates -verbose 1 -droute_end_iter 15", - # since we are specifying DETAILED_ROUTE_ARGS, we need to communicate the - # same information to other stages in the flow. - "MIN_ROUTING_LAYER": "M2", - "MAX_ROUTING_LAYER": "M7", - }, - "final": { - "GDS_ALLOW_EMPTY": "Element", - "PWR_NETS_VOLTAGEsS": "", - "GND_NETS_VOLTAGES": "", - }, - }, - stage_sources = { - "synth": all_sources + [":mock-array-constraints"] + [":mock-array-io"], - "floorplan": all_sources + [":mock-array-io"], - "place": all_sources + [":mock-array-io"], - "cts": all_sources, - "final": all_sources, - }, - verilog_files = glob(include = ["designs/src/mock-array/*.v"]), -) - -filegroup( - name = "mock-array-element-io", - srcs = [ - "designs/asap7/mock-array/Element/io.tcl", - ], - data = [ - "designs/src/mock-array/util.tcl", - ], - visibility = [":__subpackages__"], -) - -MOCK_ARRAY_ELEMENT_FLOORPLAN_PLACE = { - "IO_CONSTRAINTS": "$(location :mock-array-element-io)", - "PLACE_PINS_ARGS": "-annealing", -} - -MOCK_ARRAY_ELEMENT_ALL = { - "MOCK_ARRAY_ROWS": "8", - "MOCK_ARRAY_COLS": "8", -} - -mock_array_all_sources = ["designs/src/mock-array/util.tcl"] - -orfs_flow( - name = "Element", - abstract_stage = "route", - arguments = { - "PLACE_DENSITY": "0.82", - }, - stage_arguments = { - "synth": MOCK_ARRAY_ELEMENT_ALL | { - "SDC_FILE": "$(location :mock-array-constraints)", - }, - "floorplan": MOCK_ARRAY_ELEMENT_ALL | MOCK_ARRAY_ELEMENT_FLOORPLAN_PLACE | { - "DIE_AREA": "0 0 43.2 43.2", - "CORE_AREA": "1.08 1.08 42.120000000000005 42.120000000000005", - "PDN_TCL": "$(PLATFORM_DIR)/openRoad/pdn/BLOCK_grid_strategy.tcl", - }, - "place": MOCK_ARRAY_ELEMENT_ALL | MOCK_ARRAY_ELEMENT_FLOORPLAN_PLACE | { - }, - "cts": MOCK_ARRAY_ELEMENT_ALL | { - }, - "route": MOCK_ARRAY_ELEMENT_ALL | { - # If this design isn't quickly done in detailed routing, something is wrong. - # At time of adding this option, only 3 iterations were needed for 0 - # violations. - "DETAILED_ROUTE_ARGS": "-bottom_routing_layer M2 -top_routing_layer M5 -save_guide_updates -verbose 1 -droute_end_iter 10", - # since we are specifying DETAILED_ROUTE_ARGS, we need to communicate the - # same information to other stages in the flow. - "MIN_ROUTING_LAYER": "M2", - "MAX_ROUTING_LAYER": "M5", - }, - "final": MOCK_ARRAY_ELEMENT_ALL | { - "PWR_NETS_VOLTAGES": "", - "GND_NETS_VOLTAGES": "", - }, - }, - stage_sources = { - "synth": mock_array_all_sources + [":mock-array-constraints"], - "floorplan": mock_array_all_sources + [":mock-array-element-io"], - "place": mock_array_all_sources + [":mock-array-element-io"], - "cts": mock_array_all_sources, - "route": mock_array_all_sources, - "final": mock_array_all_sources, - }, - verilog_files = glob(include = ["designs/src/mock-array/*.v"]), -) - filegroup( name = "ethmac_lvt_src", srcs = glob(include = ["designs/src/ethmac_lvt/*.v"]), visibility = [":__subpackages__"], ) - -compile_pip_requirements( - name = "requirements", - src = "util/requirements.in", - requirements_txt = "util/requirements_lock.txt", -) diff --git a/flow/designs/asap7/ethmac_lvt/BUILD.bazel b/flow/designs/asap7/ethmac_lvt/BUILD.bazel new file mode 100644 index 0000000000..a0abaeeaaf --- /dev/null +++ b/flow/designs/asap7/ethmac_lvt/BUILD.bazel @@ -0,0 +1,59 @@ +load("@bazel-orfs//:sweep.bzl", "orfs_sweep") +load("//util:plot_congestion.bzl", "plot_congestion") + +# Format densities, rounding to 2 decimal places. +SWEEPS = { + "PLACE_DENSITY": [str(0.60 + x * 0.01 + 0.005)[:4] for x in range(20)], + "CORE_UTILIZATION": [str(40 + x * 5) for x in range(4)], +} + +SWEEP = "PLACE_DENSITY" + +orfs_sweep( + name = "ethmac_lvt", + arguments = { + # Faster builds + "SKIP_INCREMENTAL_REPAIR": "1", + "GPL_TIMING_DRIVEN": "0", + # Various + "SDC_FILE": "$(location :constraint.sdc)", + "ABC_AREA": "1", + "CORE_UTILIZATION": "40", + "CORE_ASPECT_RATIO": "1", + "CORE_MARGIN": "2", + "PLACE_DENSITY": "0.60", + "ASAP7_USELVT": "1", + "RECOVER_POWER": "1", + "ADDITIONAL_LIBS": "$(LIB_DIR)/asap7sc7p5t_AO_RVT_FF_nldm_211120.lib.gz \ + $(LIB_DIR)/asap7sc7p5t_INVBUF_RVT_FF_nldm_220122.lib.gz \ + $(LIB_DIR)/asap7sc7p5t_OA_RVT_FF_nldm_211120.lib.gz \ + $(LIB_DIR)/asap7sc7p5t_SIMPLE_RVT_FF_nldm_211120.lib.gz \ + $(LIB_DIR)/asap7sc7p5t_SEQ_RVT_FF_nldm_220123.lib", + "ADDITIONAL_GDS": "$(PLATFORM_DIR)/gds/asap7sc7p5t_28_R_220121a.gds", + "ADDITIONAL_LEFS": "$(PLATFORM_DIR)/lef/asap7sc7p5t_28_R_1x_220121a.lef", + }, + other_variants = {"base": {}}, + sources = { + "SDC_FILE": [":constraint.sdc"], + }, + sweep = { + value: { + "arguments": { + SWEEP: value, + }, + "previous_stage": { + "floorplan": "ethmac_lvt_synth", + }, + } + for value in SWEEPS[SWEEP] + }, + top = "ethmac", + verilog_files = ["//:ethmac_lvt_src"], +) + +plot_congestion( + name = "plot", + srcs = [":ethmac_lvt_{value}_grt".format(value = value) for value in SWEEPS[SWEEP]], + argument = SWEEP, + values = SWEEPS[SWEEP], +) diff --git a/flow/designs/asap7/mock-array/BUILD.bazel b/flow/designs/asap7/mock-array/BUILD.bazel new file mode 100644 index 0000000000..0c14955475 --- /dev/null +++ b/flow/designs/asap7/mock-array/BUILD.bazel @@ -0,0 +1,122 @@ +load("@bazel-orfs//:openroad.bzl", "orfs_flow") +load("@bazel-orfs//:sweep.bzl", "orfs_sweep") +load("//util:plot_congestion.bzl", "plot_congestion") + +# Format densities, rounding to 2 decimal places. +SWEEPS = { + "PLACE_DENSITY": [str(0.82 + x * 0.01 + 0.005)[:4] for x in range(10)], +} + +SWEEP = "PLACE_DENSITY" + +filegroup( + name = "mock-array-constraints", + srcs = [ + "constraints.sdc", + ], + visibility = [":__subpackages__"], +) + +filegroup( + name = "mock-array-io", + srcs = [ + "io.tcl", + ], + data = [ + "//designs/src/mock-array:util.tcl", + ], + visibility = [":__subpackages__"], +) + +orfs_flow( + name = "MockArray", + arguments = { + "PLACE_PINS_ARGS": "-annealing", + "IO_CONSTRAINTS": "$(location :mock-array-io)", + "PLACE_DENSITY": "0.30", + "DIE_AREA": "0 0 358.56 388.8", + "CORE_AREA": "2.16 2.16 356.40000000000003 386.64000000000004", + "MACRO_PLACE_HALO": "0 2.16", + "RTLMP_BOUNDARY_WT": "0", + "PDN_TCL": "$(PLATFORM_DIR)/openRoad/pdn/BLOCKS_grid_strategy.tcl", + "MACRO_HALO_X": "0.5", + "MACRO_HALO_Y": "0.5", + "MACRO_BLOCKAGE_HALO": "0", + "SDC_FILE": "$(location :mock-array-constraints)", + "MAX_ROUTING_LAYER": "M9", + "GDS_ALLOW_EMPTY": "Element", + "PWR_NETS_VOLTAGEsS": "", + "GND_NETS_VOLTAGES": "", + }, + macros = ["Element_generate_abstract"], + stage_sources = { + "synth": [":mock-array-constraints"] + [":mock-array-io"], + "floorplan": [":mock-array-io"], + "place": [":mock-array-io"], + }, + verilog_files = ["//designs/src/mock-array:verilog"], +) + +filegroup( + name = "mock-array-element-io", + srcs = [ + "Element/io.tcl", + ], + data = [ + "//designs/src/mock-array:util.tcl", + ], + visibility = [":__subpackages__"], +) + +mock_array_all_sources = ["//designs/src/mock-array:util.tcl"] + +orfs_sweep( + name = "Element", + abstract_stage = "route", + arguments = { + "PLACE_DENSITY": "0.82", + "MOCK_ARRAY_ROWS": "8", + "MOCK_ARRAY_COLS": "8", + "DETAILED_ROUTE_END_ITERATION": "6", + "MIN_ROUTING_LAYER": "M2", + "MAX_ROUTING_LAYER": "M5", + "IO_PLACER_H": "M2 M4", + "IO_PLACER_V": "M3 M5", + "PLACE_PINS_ARGS": "-annealing", + "GND_NETS_VOLTAGES": "", + "PWR_NETS_VOLTAGES": "", + "SDC_FILE": "$(location :mock-array-constraints)", + "IO_CONSTRAINTS": "$(location :mock-array-element-io)", + "DIE_AREA": "0 0 43.2 43.2", + "CORE_AREA": "1.08 1.08 42.120000000000005 42.120000000000005", + "PDN_TCL": "$(PLATFORM_DIR)/openRoad/pdn/BLOCK_grid_strategy.tcl", + }, + other_variants = {"base": {}}, + stage_sources = { + "synth": mock_array_all_sources + [":mock-array-constraints"], + "floorplan": mock_array_all_sources + [":mock-array-element-io"], + "place": mock_array_all_sources + [":mock-array-element-io"], + "cts": mock_array_all_sources, + "route": mock_array_all_sources, + "final": mock_array_all_sources, + }, + sweep = { + value: { + "arguments": { + SWEEP: value, + }, + "previous_stage": { + "floorplan": "Element_synth", + }, + } + for value in SWEEPS[SWEEP] + }, + verilog_files = ["//designs/src/mock-array:verilog"], +) + +plot_congestion( + name = "plot", + srcs = [":Element_{value}_grt".format(value = value) for value in SWEEPS[SWEEP]], + argument = SWEEP, + values = SWEEPS[SWEEP], +) diff --git a/flow/designs/src/mock-array/BUILD.bazel b/flow/designs/src/mock-array/BUILD.bazel new file mode 100644 index 0000000000..fc10b865c2 --- /dev/null +++ b/flow/designs/src/mock-array/BUILD.bazel @@ -0,0 +1,7 @@ +exports_files(["util.tcl"] + glob(["*.v"])) + +filegroup( + name = "verilog", + srcs = glob(["*.v"]), + visibility = ["//visibility:public"], +) diff --git a/flow/util/BUILD.bazel b/flow/util/BUILD.bazel new file mode 100644 index 0000000000..b5b9d74a0c --- /dev/null +++ b/flow/util/BUILD.bazel @@ -0,0 +1,18 @@ +load("@orfs-pip//:requirements.bzl", "requirement") +load("@rules_python//python:pip.bzl", "compile_pip_requirements") + +exports_files(["open_plots.sh"]) + +py_binary( + name = "plot_congestion", + srcs = ["plot_congestion.py"], + main = "plot_congestion.py", + visibility = ["//visibility:public"], + deps = [requirement("matplotlib")], +) + +compile_pip_requirements( + name = "requirements", + src = "requirements.in", + requirements_txt = "requirements_lock.txt", +) diff --git a/flow/util/open_plots.sh b/flow/util/open_plots.sh new file mode 100755 index 0000000000..b7fe40d779 --- /dev/null +++ b/flow/util/open_plots.sh @@ -0,0 +1,2 @@ +#!/bin/bash +xdg-open $1 diff --git a/flow/util/plot_congestion.bzl b/flow/util/plot_congestion.bzl new file mode 100644 index 0000000000..0266febbc3 --- /dev/null +++ b/flow/util/plot_congestion.bzl @@ -0,0 +1,23 @@ +"""Plots congestion against some parameter such as PLACE_DENSITY""" + +def plot_congestion(name, srcs, argument, values): + native.filegroup( + name = "{name}_congestion".format(name = name), + srcs = srcs, + output_group = "congestion.rpt", + ) + + native.genrule( + name = "{}_pdf".format(name), + srcs = ["{name}_congestion".format(name = name)], + outs = ["{}.pdf".format(name)], + cmd = "$(execpath //util:plot_congestion) {argument} $@ $(locations :{name}_congestion) {values}".format(values = " ".join(values), argument = argument, name = name), + tools = ["//util:plot_congestion"], + ) + + native.sh_binary( + name = name, + srcs = ["//util:open_plots.sh"], + args = ["$(location :{}.pdf)".format(name)], + data = ["{}.pdf".format(name)], + ) diff --git a/flow/util/plot_congestion.py b/flow/util/plot_congestion.py new file mode 100644 index 0000000000..da6ce3056b --- /dev/null +++ b/flow/util/plot_congestion.py @@ -0,0 +1,31 @@ +import matplotlib.pyplot as plt +import numpy as np +import sys +import re +import os + + +sweep = sys.argv[1] +output = sys.argv[2] +remainder = sys.argv[3:] +files = remainder[: len(remainder) // 2] +values = remainder[len(remainder) // 2 :] + +# count lines in each file and divide by 3 and create a list of those +# numbers +congestion = [] +for file in files: + with open(file, "r") as f: + lines = f.readlines() + congestion.append(len(lines) // 4) + +# xy plot of density vs DRC errors +x = list(map(float, values)) +y = congestion +plt.plot(x, y, "o-") +plt.xlabel(sweep) +plt.ylabel("DRC Errors") +plt.title(sweep + " vs DRC Errors") +plt.grid() +plt.yscale("log") +plt.savefig(output)