Skip to content
Open
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
2 changes: 2 additions & 0 deletions passes/techmap/dfflibmap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,8 @@ struct DfflibmapPass : public Pass {
for (auto it : cell_mappings)
dfflegalize_cmd += stringf(" -cell %s 01", it.first);
dfflegalize_cmd += " t:$_DFF* t:$_SDFF*";
for (auto module : design->selected_modules())
dfflegalize_cmd += " " + module -> name.str();
Comment on lines +697 to +698
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This ain't it. Not only does this expand partially selected modules into fully selected modules, but it is still selecting all t:$_DFF* t:$_SDFF*, making this actively worse and causing failures if the design contains any other types of flop (raising an error in dfflegalize).

My current thought is running through all the currently selected cells, pushing them to a new selection if they are the right type, and then using Pass::call_on_selection() with the new selection. Or doing % t:$_DFF* t:$_SDFF* %u %i might work, but that's starting to get messy in terms of readability.

if (info_mode) {
log("dfflegalize command line: %s\n", dfflegalize_cmd);
} else {
Expand Down
11 changes: 11 additions & 0 deletions tests/techmap/dfflibmap.ys
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,14 @@ select -assert-count 1 t:dffe
# but we have to invert it because the CLEAR pin is active low.
# ff2.CLEAR = !R
select -assert-count 1 c:ff2 %x:+[CLEAR] %ci t:$_NOT_ %i

# Test that dfflibmap respects selection and doesn't run dfflegalize on unselected modules
design -load orig
copy top top_unmapped
dfflibmap -liberty dfflibmap.lib top
# top should be mapped
select -module top -assert-count 1 t:dffn
# top_unmapped should have no mapped cells
select -module top_unmapped -assert-none t:dffn
select -module top_unmapped -assert-none t:dffe
select -module top_unmapped -assert-none t:dffsr
Comment on lines +108 to +110
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Test dfflegalize isn't running, not dfflibmap.

Suggested change
select -module top_unmapped -assert-none t:dffn
select -module top_unmapped -assert-none t:dffe
select -module top_unmapped -assert-none t:dffsr
select -module top_unmapped -assert-count 1 t:$_DFFE_PP_
select -module top_unmapped -assert-none t:$_DFF_N_