Skip to content

Commit e15a33e

Browse files
committed
makefile: make memory report review tweaks
Signed-off-by: Øyvind Harboe <[email protected]>
1 parent 0816ffc commit e15a33e

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

flow/scripts/mem_dump.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import sys
44

55

6-
def find_top_module(data):
6+
def find_top_modules(data):
77
# There can be some cruft in the modules list so that
88
# we have multiple top level candidates.
99
top_module = []
@@ -23,6 +23,16 @@ def find_top_module(data):
2323
def find_cells_by_type_in_module(
2424
module_name, data, target_type, current_path, matching_cells
2525
):
26+
"""
27+
Searches through hierarchy starting at module_name to find all instances of
28+
the given module/type in the hierarchy.
29+
30+
Returns list of cell paths, which are constructed as:
31+
32+
<top_module_name>.(<child_inst_name>.<child_module_name>+).<memory_inst_name>
33+
34+
where the child_inst_name/child_module_name pairs are repeated for each level of the hierarchy.
35+
"""
2636
for cell_name, cell in data["modules"][module_name]["cells"].items():
2737
cell_path = (
2838
f"{current_path}.{module_name}.{cell_name}"
@@ -42,10 +52,10 @@ def find_cells_by_type_in_module(
4252
return matching_cells
4353

4454

45-
def find_cells_by_type(data, module_name, current_path=""):
55+
def find_cells_by_type(top_modules, data, module_name, current_path=""):
4656
# first find top module, the module without any submodules
4757
names = []
48-
for top_module in find_top_module(data):
58+
for top_module in top_modules:
4959
names.extend(
5060
find_cells_by_type_in_module(
5161
top_module, data, module_name, current_path, []
@@ -55,6 +65,7 @@ def find_cells_by_type(data, module_name, current_path=""):
5565

5666

5767
def format_ram_table_from_json(data, max_bits=None):
68+
top_modules = find_top_modules(data)
5869
formatting = "{:>5} | {:>5} | {:>6} | {:<20} | {:<80}\n"
5970
table = formatting.format("Rows", "Width", "Bits", "Module", "Instances")
6071
table += "-" * len(table) + "\n"
@@ -70,7 +81,7 @@ def format_ram_table_from_json(data, max_bits=None):
7081
parameters = cell["parameters"]
7182
size = int(parameters["SIZE"], 2)
7283
width = int(parameters["WIDTH"], 2)
73-
instances = find_cells_by_type(data, module_name)
84+
instances = find_cells_by_type(top_modules, data, module_name)
7485
bits = size * width * len(instances)
7586
entries.append((size, width, bits, module_name, ", ".join(instances)))
7687
if max_bits is not None and bits > max_bits:

0 commit comments

Comments
 (0)