Skip to content

mem_dump: add summary of inferred memory usage - #3855

Merged
maliberty merged 1 commit into
The-OpenROAD-Project:masterfrom
NishDs-06:mem-dump-summary
Feb 2, 2026
Merged

maliberty merged 1 commit into
The-OpenROAD-Project:masterfrom
NishDs-06:mem-dump-summary

Conversation

@NishDs-06

Copy link
Copy Markdown
Contributor

This PR improves the usability of mem_dump.py by adding a small summary section
after the inferred memory table.

The summary highlights:

  • total number of inferred memories
  • largest single inferred memory instance
  • total inferred memory bits across all instances
  • status relative to SYNTH_MEMORY_MAX_BITS (when provided)

This makes it easier for users to understand why synthesis may be slow or fail
early due to large inferred memories, and complements the existing fail-fast
and memory mocking mechanisms discussed in #3645.

Signed-off-by: Nishanth <ndszz306@gmail.com>

@oharboe oharboe left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Probably better that @povik comments on this. I just hacked together something that read in the .json file and that has done the job for a year or two...

These days, I think the best way to do this is to query the AST in Yosys directly?

That's what @povik did when updating synth.tcl to handle mocking of large memories which ties into the motivation for this report/error: avoid synthesis getting stuck silently forever on unintentional massive flip flop memories.

if { $::env(SYNTH_MOCK_LARGE_MEMORIES) } {
memory_collect
set select [tee -q -s result.string select -list t:\$mem_v2]
set report_file [open $::env(REPORTS_DIR)/synth_mocked_memories.txt "w"]
foreach path [split [string trim $select] "\n"] {
set index [string first "/" $path]
set module [string range $path 0 [expr { $index - 1 }]]
set instance [string range $path [expr { $index + 1 }] end]
set width [rtlil::get_param -uint $module $instance WIDTH]
set size [rtlil::get_param -uint $module $instance SIZE]
set nbits [expr $width * $size]
puts "Memory $path has dimensions $size x $width = $nbits"
if { $nbits > $::env(SYNTH_MEMORY_MAX_BITS) } {
rtlil::set_param -uint $module $instance SIZE 1
puts "Shrunk memory $path from $size rows to 1"
puts -nonewline $report_file "$module:\n width: $width\n size: $size\n"
if { $::env(SYNTH_KEEP_MOCKED_MEMORIES) } {
select -module $module
setattr -mod -set keep_hierarchy 1
select -clear
}
}
}
close $report_file
}

@maliberty

Copy link
Copy Markdown
Member

I think suggesting a different approach entirely is beyond the scope of this PR

@maliberty
maliberty merged commit 419cd9b into The-OpenROAD-Project:master Feb 2, 2026
5 checks passed
@oharboe

oharboe commented Feb 2, 2026

Copy link
Copy Markdown
Collaborator

Thanks! I tried to clean up this code, but failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants