Skip to content

rename: add -move-to-cell option in -wire mode #5100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jix
Copy link
Member

@jix jix commented May 7, 2025

What are the reasons/motivation for this change?

For some use cases it is desirable to transfer names from wires to their driving cells.

Explain how this is achieved.

This adds a -move-to-cell option to rename -wire which doesn't add a suffix to the cell name but instead adds a suffix to the wire name, if necessary to avoid conflicts.

It also makes rename -wire use the correct HDL indices for wires with non-zero-indexing, whether using -move-to-cell or not.

If applicable, please suggest to reviewers how they can test the change.

By replacing rename -wire with rename -wire -move-to-cell in an existing flow.

@jix jix requested a review from widlarizer May 7, 2025 11:46
@jix
Copy link
Member Author

jix commented May 7, 2025

@tspyrou @precisionmoon: This implements the renaming we were discussing. To make it easy to test this change in isolation, I rebased this PR branch on top of the Yosys commit that the ORFS master is currently using. Note that this adds a new rename variant, so testing it does require also changing rename -wire to rename -wire -move-to-cell in ORFS's synth.tcl.

@widlarizer
Copy link
Collaborator

This is a pattern that I created with rename -hide that prevents the new mode from doing its job as it checks whatever is the directly driven wire without traversing the tree of aliases or querying a sigmap that would have a public name promoted. The purpose for this pass is to be able to refer cells post-synthesis, so I think we can assume such a shape won't happen, but I'm not 100% sure

image

name += std::to_string(chunk.offset) + "]";
int lhs = chunk.wire->to_hdl_index(chunk.offset + chunk.width - 1);
int rhs = chunk.wire->to_hdl_index(chunk.offset);
if (chunk.wire->upto)
Copy link
Collaborator

Choose a reason for hiding this comment

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

On some level, I would expect printing to respect the uptoness of the original hdl objects, so I don't think we should be undoing it here with the swap

In case it's useful / becomes part of a test, here's the input for trying out this code path

read_verilog <<EOF
module top(input [0:7] a, input [0:7] b, output [0:4] o1, output [4:0] o2);
    wire [0:7] int1 = a + b;
    wire [0:7] int2 = a + b;
    assign o1[0:3] = int1[0:3];
    assign o2[3:0] = int2[4:7];
endmodule
EOF

proc -noopt
rename -hide w:int*
opt
rename -wire -move-to-cell

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.

2 participants