Skip to content

Commit 178c0ff

Browse files
oharboeclaude
andcommitted
AUTO_MEMORIES_MACRO_PLACE: register files not listed are inlined
AUTO_MEMORIES_REGFILES built every register file as a macro: blackboxed in synthesis, placed by the macro placer and, in `mode netlist`, dissolved into its cells after macro placement. On a small design the macro's outline and channels cost more core than the array saves: riscv32i's register file as a macro does not fit riscv32i's own 62 % utilisation beside its four FakeRAMs (MPL-0003). AUTO_MEMORIES_MACRO_PLACE lists the register files to place as macros. Any other is inlined: gen_memories.py writes only its generated netlist (no abstract, model liberty or taps) and inline.txt, and synthesis reads the RTL module as a blackbox and the netlist in its place. Its cells are then placed, sized and buffered with the rest of the design. A name no spec builds stops the build. asap7/regfile lists its RegFile, which keeps the dissolve its tests exercise. asap7/riscv32i-regfile lists nothing, takes riscv32i's own utilisation, and its spec writes through a clock gate per word (`write_style clock_gate`, OpenROAD#11669): 955 ps at global route against the flip-flops' 954, on a core 12 % smaller. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent e8246d8 commit 178c0ff

10 files changed

Lines changed: 206 additions & 79 deletions

File tree

‎docs/user/AutoMemories.md‎

Lines changed: 57 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -149,18 +149,33 @@ cell flop DFFHQNx1_ASAP7_75t_R
149149
...
150150
```
151151

152-
`generate_regfile` checks the spec against the module's ports, then
153-
writes `<m>.v` (the cells), `<m>.lef` (an abstract, its pins where
154-
their connections land in the array) and `<m>.lib`/`<m>_pre_layout.lib`
155-
(a timing model) beside the FakeRAM views. The module joins
156-
`blackboxes.txt`, so synthesis and macro placement see a macro.
157-
158-
In `mode netlist` (the usual one) the macro dissolves into its cells at
159-
the end of macro placement (`regfile_dissolve.tcl`): the array's core
160-
lands FIRM where the macro was placed, flipped as the macro was, on the
161-
parent's rows; the address decode is left to global placement and the
162-
resizer, and dead logic is eliminated as at synthesis. From there on it
163-
is standard cells. `mode macro` keeps the macro to the end.
152+
`generate_regfile` checks the spec against the module's ports and
153+
writes `<m>.v`, the array as standard cells. What happens next depends
154+
on `AUTO_MEMORIES_MACRO_PLACE`, the register files to place as macros:
155+
156+
- **Not listed (the default): inlined.** Synthesis reads the module as a
157+
blackbox and `<m>.v` in its place; from there on its cells are placed,
158+
sized and buffered with the rest of the design. No macro, no abstract,
159+
no dissolve. The better shape for a small design, where a macro's
160+
outline and channels cost more core than the array saves.
161+
- **Listed: a macro.** `generate_regfile` also writes `<m>.lef` (an
162+
abstract, its pins where their connections land in the array) and
163+
`<m>.lib`/`<m>_pre_layout.lib` (a timing model) beside the FakeRAM
164+
views, and the module joins `blackboxes.txt`, so synthesis and macro
165+
placement see a macro. In `mode netlist` (the usual one) the macro
166+
dissolves into its cells at the end of macro placement
167+
(`regfile_dissolve.tcl`): the array's core lands FIRM where the macro
168+
was placed, flipped as the macro was, on the parent's rows; the
169+
address decode is left to global placement and the resizer, and dead
170+
logic is eliminated as at synthesis. `mode macro` keeps the macro to
171+
the end. A large design whose floorplan plans its register files lists
172+
them.
173+
174+
A word holds its value between writes either through a hold term in
175+
every bit's write mux (`write_style mux`, the default) or through one
176+
integrated clock gate per word, enabled by its write selects
177+
(`write_style clock_gate`, as OpenROAD's `generate_ram` writes): with
178+
one write port a flop's D is then the write data itself.
164179

165180
Listed register files appear in `memories.json` with kind `regfile`;
166181
the rest have kind `fakeram` or `flops`. `designs/asap7/regfile` is the
@@ -194,41 +209,40 @@ seam in their RTL first.
194209
`designs/asap7/regfile` is the smallest case, for turnaround rather
195210
than measurement.
196211

197-
### Status: a prototype, slower and bigger on riscv32i
212+
### Status: at parity on riscv32i, on a smaller core
198213

199214
`designs/asap7/riscv32i-regfile` is riscv32i with its register file
200-
generated; the study case for what the generator gets wrong, because it
201-
reaches global route in minutes. To global route, against
202-
`designs/asap7/riscv32i`:
215+
generated, inlined and written through a clock gate per word, at
216+
riscv32i's own utilisation. To global route, 950 ps clock, global-route
217+
parasitics, against `designs/asap7/riscv32i`:
203218

204219
| | flops | register file |
205220
|---|---|---|
206-
| minimum period (950 ps clock, global-route parasitics) | 954 ps | 998 ps |
207-
| place to global route, stage time | 211 s | 536 s |
208-
| core area | 4 012 um2 (62 %) | 7 573 um2 (45 %) |
209-
| standard-cell area, without taps | 1 284 um2 | 1 413 um2 |
210-
| failing endpoints after global route | 79 | 992 |
211-
212-
Synthesis takes a second either way: a 32 x 32 file is too small for
213-
its synthesis time to show, which is where the larger files of a large
214-
core are expected to gain.
215-
216-
Why it is slower: every failing endpoint is a flop of the array, all
217-
within 50 ps, and the worst path runs from the instruction through the
218-
array's read path -- the address decode as three serial AND2 stages,
219-
the word select, five levels of OR2 -- into the ALU and back to the
220-
array's write mux: 232 ps from `instr` to read data. The flops
221-
version's same loop closes. `repair_timing` then spends its time at CTS
222-
and global route on 992 endpoints it cannot fix.
223-
224-
Why it is bigger: standard-cell area is within a tenth of the flops',
225-
and the array's cells fill 58 % of its box. The core is bigger because
226-
`riscv32i-regfile/config.mk` sets 45 % utilisation: at riscv32i's 62 %
227-
no macro placement fits the array beside the four FakeRAMs.
228-
229-
The rest is the generator's to fix: decode as a tree sized for its
230-
fanout, a read tree of AO22 and NAND/NOR rather than AND2 and OR2,
231-
cells the resizer may swap in place.
221+
| minimum period | 954 ps | 955 ps |
222+
| core area | 4 012 um2 | 3 544 um2 |
223+
| standard-cell area, without taps | 1 284 um2 | 973 um2 |
224+
| clock-tree buffers and inverters | 122 | 179 |
225+
| clock gates | 0 | 31 |
226+
| hold, worst slack | +36 ps | +86 ps |
227+
228+
Both are limited by the same single-cycle path: the instruction into
229+
the register file's read, the ALU, the data memory and back into the
230+
register file's write. The register file's share of it, decode and read
231+
tree, is about 260 ps in either.
232+
233+
What did not pay, measured on the same design:
234+
235+
- the register file as a macro dissolved after macro placement: it does
236+
not fit riscv32i's 62 % beside the four FakeRAMs, and at 55 % it is
237+
959 ps on a 4 644 um2 core;
238+
- a hold mux per bit instead of the clock gate: 994 ps inlined, every
239+
array endpoint carrying the mux;
240+
- predecoded read selects: 960 ps;
241+
- a tree of 2:1 muxes steered by the address bits instead of a decoded
242+
one-hot read: 959 ps, the address bits' fanout (about 1 000 inputs a
243+
port) needs as many buffer levels as the decode it replaces;
244+
- four-input gates in the read tree, stronger cells: 950 to 954 ps,
245+
within what any change to the placement moves.
232246

233247
## Platform support
234248

@@ -291,4 +305,5 @@ bazel-orfs implements this.
291305

292306
- [AUTO_MEMORIES](FlowVariables.md#AUTO_MEMORIES)
293307
- [ADDITIONAL_MEMORIES](FlowVariables.md#ADDITIONAL_MEMORIES)
308+
- [AUTO_MEMORIES_MACRO_PLACE](FlowVariables.md#AUTO_MEMORIES_MACRO_PLACE)
294309
- [AUTO_MEMORIES_REGFILES](FlowVariables.md#AUTO_MEMORIES_REGFILES)

‎docs/user/FlowVariables.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ configuration file.
100100
| <a name="ADDITIONAL_LEFS"></a>ADDITIONAL_LEFS| Hardened macro LEF view files listed here. The LEF information of the macros is immutable and used throughout all stages. Stored in the .odb file.| |
101101
| <a name="ADDITIONAL_LIBS"></a>ADDITIONAL_LIBS| Hardened macro library files listed here. The library information is immutable and used throughout all stages. Not stored in the .odb file.| |
102102
| <a name="ADDITIONAL_MEMORIES"></a>ADDITIONAL_MEMORIES| Experimental. Space-separated list of user-supplied `.memories` files (the memories.json JSON schema) merged onto the set AUTO_MEMORIES detects — to force-convert a memory the idiomatic gate rejects, or to describe one the scanner cannot find. See docs/user/AutoMemories.md.| |
103-
| <a name="AUTO_MEMORIES_REGFILES"></a>AUTO_MEMORIES_REGFILES| Experimental. Space-separated list of register-file spec files, one per RTL module to build as a register file of placed standard cells rather than synthesise to flops. Each spec names its module, words, bits, read and write ports by the RTL's own port names, and the cells; OpenROAD's generate_regfile checks the spec against the module's ports and writes `<module>.lef`, `<module>.lib` and `<module>_pre_layout.lib` under `$(RESULTS_DIR)/memories/`, and the module is blackboxed like an AUTO_MEMORIES macro and placed as one. A spec in `mode netlist` then dissolves into its cells after macro placement: its core FIRM where the macro was placed, in the macro's orientation, its address decode left to placement. Every register file appears in memories.json with kind `regfile`. Requires AUTO_MEMORIES=1.| |
103+
| <a name="AUTO_MEMORIES_MACRO_PLACE"></a>AUTO_MEMORIES_MACRO_PLACE| Experimental. Space-separated list of module names of AUTO_MEMORIES_REGFILES register files to place as macros, blackboxed in synthesis and placed by the macro placer (and, in `mode netlist`, dissolved after macro placement). A register file not listed is inlined: its generated netlist of standard cells replaces the module's body in synthesis, and its cells are placed, sized and buffered with the rest of the design -- the better shape for a small design, where a macro's outline and channels cost more core than the array saves. A name no spec builds stops the build. Requires AUTO_MEMORIES=1.| |
104+
| <a name="AUTO_MEMORIES_REGFILES"></a>AUTO_MEMORIES_REGFILES| Experimental. Space-separated list of register-file spec files, one per RTL module to build as a register file of placed standard cells rather than synthesise to flops. Each spec names its module, words, bits, read and write ports by the RTL's own port names, and the cells; OpenROAD's generate_regfile checks the spec against the module's ports and writes `<module>.lef`, `<module>.lib` and `<module>_pre_layout.lib` under `$(RESULTS_DIR)/memories/`. A module named in AUTO_MEMORIES_MACRO_PLACE is blackboxed like an AUTO_MEMORIES macro and placed as one; any other is inlined as its generated netlist. A placed spec in `mode netlist` then dissolves into its cells after macro placement: its core FIRM where the macro was placed, in the macro's orientation, its address decode left to placement. Every register file appears in memories.json with kind `regfile`. Requires AUTO_MEMORIES=1.| |
104105
| <a name="ADDITIONAL_SITES"></a>ADDITIONAL_SITES| Passed as -additional_sites to initialize_floorplan.| |
105106
| <a name="ASAP7_USE_VT"></a>ASAP7_USE_VT| A space separated list of VT options to use with the ASAP7 standard cell library: RVT, LVT, SLVT.| RVT|
106107
| <a name="AUTO_MEMORIES"></a>AUTO_MEMORIES| Experimental. When set to 1, memories that yosys infers in the RTL (`$mem_v2` cells, module boundary only) are detected pre-synthesis, inventoried in `$(RESULTS_DIR)/memories.json`, and — when idiomatic as an SRAM macro — given generated .lib/.lef views under `$(RESULTS_DIR)/memories/`. Synthesis blackboxes those modules and all later stages read the generated views, so an existing design gets macro-based results without a memory compiler. Supported for the asap7 platform only. See docs/user/AutoMemories.md.| 0|
@@ -342,6 +343,7 @@ configuration file.
342343
- [ABC_LOAD_IN_FF](#ABC_LOAD_IN_FF)
343344
- [ADDER_MAP_FILE](#ADDER_MAP_FILE)
344345
- [ADDITIONAL_MEMORIES](#ADDITIONAL_MEMORIES)
346+
- [AUTO_MEMORIES_MACRO_PLACE](#AUTO_MEMORIES_MACRO_PLACE)
345347
- [AUTO_MEMORIES_REGFILES](#AUTO_MEMORIES_REGFILES)
346348
- [CACHED_REPORTS](#CACHED_REPORTS)
347349
- [CLKGATE_MAP_FILE](#CLKGATE_MAP_FILE)

‎flow/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ do-auto-memories: $(RESULTS_DIR)/memories_inferred.json
280280
$(foreach file,$(VERILOG_FILES),--verilog $(file)) \
281281
$(foreach file,$(ADDITIONAL_MEMORIES),--memories $(file)) \
282282
$(foreach file,$(AUTO_MEMORIES_REGFILES),--regfile-spec $(file)) \
283+
$(foreach m,$(AUTO_MEMORIES_MACRO_PLACE),--macro-place $(m)) \
283284
$(if $(AUTO_MEMORIES_REGFILES),--openroad $(OPENROAD_EXE)) \
284285
$(foreach file,$(TECH_LEF) $(SC_LEF),--lef $(file))
285286

‎flow/designs/asap7/regfile/config.mk‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ export SDC_FILE = $(DESIGN_HOME)/$(PLATFORM)/$(DESIGN_NICKNAME)/constraint.
99

1010
export AUTO_MEMORIES = 1
1111
export AUTO_MEMORIES_REGFILES = $(DESIGN_HOME)/$(PLATFORM)/$(DESIGN_NICKNAME)/RegFile.regfile
12+
# Placed as a macro and dissolved after macro placement, the path this
13+
# design exists to exercise; unlisted, it would be inlined.
14+
export AUTO_MEMORIES_MACRO_PLACE = RegFile
1215

1316
# The file's macro is 28.5 x 10 um; a core sized by utilization alone
1417
# would be square and narrower than the macro and its halo.
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
# riscv32i with its register file built by AUTO_MEMORIES_REGFILES rather
2-
# than synthesised to flip-flops: the same RTL and constraints. The study
3-
# case for why a generated register file is slower and bigger than the
4-
# flops it replaces -- minutes to global route, simple to build, and both
5-
# are true of it today. docs/user/AutoMemories.md has the numbers.
2+
# than synthesised to flip-flops: the same RTL, constraints and
3+
# utilisation. Not in AUTO_MEMORIES_MACRO_PLACE, so the generated netlist
4+
# is inlined in synthesis. Minutes to global route, the case to measure
5+
# the generator on; docs/user/AutoMemories.md has the numbers.
66
export DESIGN_NICKNAME = riscv32i-regfile
77

88
include designs/asap7/riscv32i/config.mk
99

10-
export CORE_UTILIZATION = 45
11-
1210
export AUTO_MEMORIES = 1
1311
export AUTO_MEMORIES_REGFILES = $(DESIGN_HOME)/$(PLATFORM)/$(DESIGN_NICKNAME)/regfile.regfile
Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# riscv32i's `regfile` (src/riscv32i/regfile.v) as a register file of
2-
# placed standard cells: 32 x 32, two combinational reads, one write,
3-
# x0 reads 0 and drops its writes.
2+
# standard cells, inlined in synthesis: 32 x 32, two combinational reads,
3+
# one write through a clock gate per word, x0 reads 0 and drops its
4+
# writes.
45
module regfile
5-
mode netlist
66
words 32
77
bits 32
88
clock clk
@@ -12,16 +12,8 @@ write wa3 wd3 we3
1212
zero_word 0
1313
write_style clock_gate
1414
cell icg ICGx1_ASAP7_75t_R
15-
# Flat, 58 x 19 um: it stacks under the four FakeRAMs at riscv32i's own
16-
# 62 %, where two folds (32 x 36 um) fit beside them at no utilisation
17-
# above 35 %. The clock tree's free sites are sized for a 32-word file.
18-
bit_folds 1
19-
service_sites 16
20-
tap_columns 16
2115
cell flop DFFHQNx1_ASAP7_75t_R
2216
cell and2 AND2x2_ASAP7_75t_R
2317
cell or2 OR2x2_ASAP7_75t_R
2418
cell ao22 AO22x2_ASAP7_75t_R
2519
cell inv INVx1_ASAP7_75t_R
26-
cell tap TAPCELL_ASAP7_75t_R
27-
pin_layer M4

0 commit comments

Comments
 (0)