Repository: calyxir/calyx (language: rust)

Issue:
Resource estimate executive summary lacks BRAM numbers
_[Synthesis 101](https://github.com/cucapra/notes/blob/main/synthesis.md)_ is a short guide about generating syntheses from .futil files. In refreshing it, I noticed that the executive summary, generated using the command:
```
fud e --to resource-estimate <filename>.futil
```
makes no mention of BRAMs. If you generate the actual report using:
```
fud e --to synth-files -o report <filename>.futil
```
the report has, deep in its guts, the appropriate numbers. 

If you digest the `report` directory into an executive summary using:
```
fud e --from synth-files --to resource-estimate report
```
the executive summary again lacks the BRAM numbers.

So: it's all in there, and it's not a `fud` chaining issue. Some script is just failing to grab and display the BRAM numbers.


Discussion / hints:
cc @polybeandip in case you have anything to add!
Heh I have tried to give this issue an appropriate label, but nothing seems to fit. Sorry Rachit, I know those are important
Not much to add from me!

I guess in case anyone wants to tackle this issue, I think the function to be tweaked is `place_and_route_extract` in [`extract.py`](https://github.com/calyxir/calyx/blob/c497dd4a97eac53822ffd072f3162f08d15e7d4a/fud/fud/stages/vivado/extract.py#L55). Not fully sure though
Yup, you need to find the right table using the parser’s API and then extract the information!
Just to clarify, is this number from `report/out/FutilBuild.runs/impl_1/main_utilization_placed.rpt` what we want?
![bram](https://github.com/user-attachments/assets/cbd26149-044f-4fa5-8f2b-74e842063664)
Yup, looks like the right place to me. It is surprising and perhaps a little concerning that no BRAMs are used. Maybe the internal memories used in FIFOs are not getting mapped correctly?

OTOH, John Demme did mention that LUTRAMs often get used to map FIFOs...

Fix patch:
diff --git a/fud/fud/stages/vivado/extract.py b/fud/fud/stages/vivado/extract.py
index 964e95ee24..e393972e49 100644
--- a/fud/fud/stages/vivado/extract.py
+++ b/fud/fud/stages/vivado/extract.py
@@ -80,6 +80,7 @@ def place_and_route_extract(
         if util_file.exists():
             impl_parser = rpt.RPTParser(util_file)
             slice_logic = impl_parser.get_table(re.compile(r"1\. CLB Logic"), 2)
+            bram_table = impl_parser.get_table(re.compile(r"3\. BLOCKRAM"), 2)
             dsp_table = impl_parser.get_table(re.compile(r"4\. ARITHMETIC"), 2)
 
             clb_lut = to_int(find_row(slice_logic, "Site Type", "CLB LUTs")["Used"])
@@ -96,6 +97,9 @@ def place_and_route_extract(
                         find_row(slice_logic, "Site Type", "CLB LUTs")["Used"]
                     ),
                     "dsp": to_int(find_row(dsp_table, "Site Type", "DSPs")["Used"]),
+                    "brams": to_int(
+                        find_row(bram_table, "Site Type", "Block RAM Tile")["Used"]
+                    ),
                     "registers": rtl_component_extract(synth_file, "Registers"),
                     "muxes": rtl_component_extract(synth_file, "Muxes"),
                     "clb_registers": clb_reg,


Test patch: