Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reintroduce mock_area feature #146

Merged
merged 5 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ BLOCK_FLOORPLAN = {
orfs_flow(
name = "tag_array_64x184",
args = SRAM_SYNTH_ARGUMENTS | SRAM_FLOOR_PLACE_ARGUMENTS | {
"CORE_UTILIZATION": "40",
"CORE_ASPECT_RATIO": "2",
"SKIP_REPORT_METRICS": "1",
"CORE_UTILIZATION": "40",
"CORE_ASPECT_RATIO": "2",
"SKIP_REPORT_METRICS": "1",
},
stage_sources = {
"synth": [":constraints-sram"],
Expand All @@ -77,13 +77,10 @@ orfs_flow(
visibility = [":__subpackages__"],
)

LB_STAGE_ARGS = {
"synth": SRAM_SYNTH_ARGUMENTS,
"floorplan": SRAM_FLOOR_PLACE_ARGUMENTS | {
"CORE_UTILIZATION": "40",
"CORE_ASPECT_RATIO": "2",
},
"place": SRAM_FLOOR_PLACE_ARGUMENTS | {"PLACE_DENSITY": "0.65"},
LB_ARGS = SRAM_SYNTH_ARGUMENTS | SRAM_FLOOR_PLACE_ARGUMENTS | {
"CORE_UTILIZATION": "40",
"CORE_ASPECT_RATIO": "2",
"PLACE_DENSITY": "0.65",
}

LB_STAGE_SOURCES = {
Expand All @@ -97,7 +94,8 @@ LB_VERILOG_FILES = ["test/rtl/lb_32x128.sv"]
orfs_flow(
name = "lb_32x128",
abstract_stage = "floorplan",
stage_args = LB_STAGE_ARGS,
mock_area = 1.0,
args = LB_ARGS,
stage_sources = LB_STAGE_SOURCES,
verilog_files = LB_VERILOG_FILES,
)
Expand All @@ -106,7 +104,7 @@ orfs_flow(
orfs_flow(
name = "lb_32x128",
abstract_stage = "place",
stage_args = LB_STAGE_ARGS,
args = LB_ARGS,
stage_sources = LB_STAGE_SOURCES,
variant = "test",
verilog_files = LB_VERILOG_FILES,
Expand Down
66 changes: 36 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,25 +88,22 @@ The macro from the example above spawns the following Bazel targets:

```
Dependency targets:
//:L1MetadataArray_canonicalize_deps
//:L1MetadataArray_cts_deps
//:L1MetadataArray_floorplan_deps
//:L1MetadataArray_generate_abstract_deps
//:L1MetadataArray_grt_deps
//:L1MetadataArray_place_deps
//:L1MetadataArray_route_deps
//:L1MetadataArray_synth_deps

Stage targets:
//:L1MetadataArray_canonicalize
//:L1MetadataArray_cts
//:L1MetadataArray_floorplan
//:L1MetadataArray_generate_abstract
//:L1MetadataArray_grt
//:L1MetadataArray_place
//:L1MetadataArray_route
//:L1MetadataArray_synth

Abstract targets:
//:L1MetadataArray_generate_abstract
```

The example comes from the [BUILD](./BUILD) file in this repository.
Expand All @@ -127,18 +124,15 @@ This definition creates similar Bazel targets with additional variant appended a

```
Dependency targets:
//:L1MetadataArray_test_canonicalize_deps
//:L1MetadataArray_test_cts_deps
//:L1MetadataArray_test_floorplan_deps
...
//:L1MetadataArray_test_generate_abstract_deps

Stage targets:
//:L1MetadataArray_test_canonicalize
//:L1MetadataArray_test_synth
//:L1MetadataArray_test_floorplan
...

Abstract targets:
//:L1MetadataArray_test_generate_abstract
```

Expand All @@ -153,7 +147,6 @@ These are the genrules spawned in this macro:

* ORFS stage-specific (named: `target_name + “_” + stage` or `target_name + “_” + variant + “_” + stage`)
* ORFS stage dependencies (named: `target_name + “_” + stage + “_deps”` or `target_name + “_” + variant + “_” + stage + “_deps”`)
* Abstract targets (named: `target_name + “_generate_abstract”` or `target_name + “_” + variant + “_generate_abstract”`)

### Bazel flow

Expand Down Expand Up @@ -204,17 +197,14 @@ bazel run <target>_<stage>_deps -- <absolute_path>
<absolute_path>/make do-<stage>
```

> **NOTE:** The synthesis (`canonicalize` and `synth`) stage requires the `do-yosys-canonicalize` and `do-yosys` steps to be completed beforehand.
> **NOTE:** The synthesis stage requires the `do-yosys-canonicalize`, `do-yosys-keep-hierarchy` and `do-yosys` steps to be completed beforehand.
> These steps are necessary to generate the required `.rtlil` file for the synthesis stage.
>
> ```bash
> source <orfs_path>/env.sh
>
> bazel run <target>_canonicalize_deps -- <absolute_path>
> <absolute_path>/make do-yosys-canonicalize
>
> bazel run <target>_synth_deps -- <absolute_path>
> <absolute_path>/make do-yosys do-synth
> <absolute_path>/make do-yosys-canonicalize do-yosys-keep-hierarchy do-yosys do-synth
> ```

### Stage targets
Expand All @@ -224,21 +214,19 @@ Each stage of the physical design flow is represented by a separate target and f
The stages are as follows:

* `synth` (synthesis)
* `canonicalize` - substage generating canonicalized input for the synthesis (it receives the same arguments and sources as `synth`)
* `floorplan`
* `place`
* `cts` (clock tree synthesis)
* `grt` (global route)
* `route`
* `final`
* `generate_abstract`

### generate abstract targets
### Generate abstract targets

Those targets are used to create mocked abstracts (`.lef` and `.lib` files) for macros.
The mock contains the description of macro which has its whole internal logic removed.
At the same time the mock has the same pinout as the original macro and similar size which makes it useful in early design stages.
Those targets are used to create abstracts (`.lef` and `.lib` files) for macros.

Mocked abstracts are generated at the `target + "generate_abstract"` stage, which follows one defined via `abstract_stage` attribute passed to the `orfs_flow()` macro:
Abstracts are generated at the `target + "generate_abstract"` stage, which follows one defined via `abstract_stage` attribute passed to the `orfs_flow()` macro:

<pre lang="starlark">
orfs_flow(
Expand Down Expand Up @@ -266,13 +254,37 @@ orfs_flow(

By default it's the latest ORFS-specific target (`final`).

> **NOTE:** Mocked abstracts can be generated starting from the `floorplan` stage, thus skipping the `canonicalize` and `synth` stage.
> **NOTE:** Abstracts can be generated starting from the `floorplan` stage, thus skipping the `synth` stage.

Mocked abstracts are intended to be used in builds of other parts of the design that use the given macro.
Abstracts are intended to be used in builds of other parts of the design that use the given macro.
They're useful for estimating sizes of macros with long build times and checking if they will fit in upper-level modules without running time consuming place and route flow.

> **NOTE:** Stages that follow the one passed to `abstract_stage` will not be created by the `orfs_flow()` macro.

### Mock area targets

Mock area targets are created on top of the stage targets and overrides `_generate_abstract` target to produced mocked abstracts.

The flow contains:
* `target_name_variant + “_synth_mock_area”` - synthesis which has its whole internal logic removed,
* `target_name_variant + “_mock_area”` - reads `DIE_AREA` and `CORE_AREA` from default floorplan results and scale them by value defined in `mock_area`,
* `target_name_variant + “_floorplan_mock_area”` - floorplan with overridden `DIE_AREA` and `CORE_AREA` values,
* `target_name_variant + “_generate_abstract”` - abstracts generated based on mocked synthesis and floorplan.

To create mock area targets, `mock_area` has to be added to `orfs_flow` definition:

```starlark
orfs_flow(
name = "lb_32x128",
stage_args = LB_STAGE_ARGS,
stage_sources = LB_STAGE_SOURCES,
verilog_files = LB_VERILOG_FILES,
mock_area = 0.5,
)
```

The mock has the same pinout as the original macro and similar size which makes it useful in early design stages.

### Constraints handling

Constraint files are passed down to `orfs_flow()` macro through [Stage targets](#stage-targets) arguments and sources:
Expand Down Expand Up @@ -406,17 +418,11 @@ Let's assume we want to perform a `floorplan` stage for the `L1MetadataArray` de
2. Build the stages prior to the `floorplan` stage:

```bash
# Initialize dependencies for the Synthesis stage for L1MetadataArray target
bazel run @bazel-orfs//:L1MetadataArray_canonicalize_deps -- `pwd`/build

# Build Synthesis stage for L1MetadataArray target using local ORFS
build/make do-yosys-canonicalize

# Initialize dependencies for the Synthesis stage for L1MetadataArray target
bazel run @bazel-orfs//:L1MetadataArray_synth_deps -- `pwd`/build

# Build Synthesis stage for L1MetadataArray target using local ORFS
build/make do-yosys do-synth
build/make do-yosys-canonicalize do-yosys-keep-hierarchy do-yosys do-synth

# Initialize dependencies for the Floorplan stage for L1MetadataArray target
bazel run @bazel-orfs//:L1MetadataArray_floorplan_deps -- `pwd`/build
Expand Down
3 changes: 3 additions & 0 deletions make.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ else
fi
export MAKE_PATH="$(command -v make)"
fi
if [[ -f "${EXTRA_ENVS}" ]]; then
source "${EXTRA_ENVS}"
fi
exec $MAKE_PATH --file "$FLOW_HOME/Makefile" "$@"
18 changes: 14 additions & 4 deletions mock_area.tcl
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
read_db $::env(RESULTS_DIR)/../base/2_floorplan.odb
proc tee {file content} {
puts $content
puts $file $content
}

set out_file [lindex [split $::env(OUTPUTS) ":"] 0]

read_db $::env(RESULTS_DIR)/2_floorplan.odb
set db [::ord::get_db]
set dbu_per_uu [expr double([[$db getTech] getDbUnitsPerMicron])]
set block [[$db getChip] getBlock]
set die_bbox [$block getDieArea]
set core_bbox [$block getCoreArea]
set scale [expr $::env(MOCK_AREA) / $dbu_per_uu]
#set scale [expr 0.5 / $dbu_per_uu]
puts "export DIE_AREA=\"0 0 [expr $scale*[$die_bbox xMax]] [expr $scale*[$die_bbox yMax]]\""
puts "export CORE_AREA=\"[expr $scale*[$core_bbox xMin]] [expr $scale*[$core_bbox yMin]] \

set file [open $out_file w]
tee $file "export DIE_AREA=\"0 0 [expr $scale*[$die_bbox xMax]] [expr $scale*[$die_bbox yMax]]\""
tee $file "export CORE_AREA=\"[expr $scale*[$core_bbox xMin]] [expr $scale*[$core_bbox yMin]] \
[expr $scale*([$die_bbox xMax] - ([$die_bbox xMax] - [$core_bbox xMax]))] \
[expr $scale*([$die_bbox yMax] - ([$die_bbox yMax] - [$core_bbox yMax]))]\""
tee $file "export CORE_UTILIZATION="
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The need for this line would have been caught by The-OpenROAD-Project/OpenROAD-flow-scripts#2344

close $file
Loading