Skip to content
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

Add "buffered-normalized mode", add $buf cell type, and add "bufnorm" command #3967

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

clairexen
Copy link
Member

This PR adds "buffered-normalized mode" to RTLIL. In that mode there's a 1:1 relationship between cell ouput ports and wires, and each wire is annotated with a reference to the cell and cell port driving it.

Once in "buffered-normalized mode" calling design->bufNormalize() (or module->bufNormalize()) will ensure that the above condition is met, by adding additional intermediate wires and buffer cells as needed.

This PR also adds a $buf "coarse-grain" buffer cell type, similar in behavior to $pos, but techmap/simplemap/etc is not mapping this buffer type to an array of single-bit buffers. bufNormalize() is adding buffers of that new $buf type. Note that bufNormalize() is very efficient and only looks at the parts of the design that have been changed since the last time bufNormalize() has been run, i.e. it does not require a complete scan over the design.

This PR also adds the bufnorm command for getting the design into and out of "buffered-normalized mode", with more control over the exact type of network of buffers that is being created.

Signed-off-by: Claire Xenia Wolf <claire@clairexen.net>
Signed-off-by: Claire Xenia Wolf <claire@clairexen.net>
Signed-off-by: Claire Xenia Wolf <claire@clairexen.net>
Signed-off-by: Claire Xenia Wolf <claire@clairexen.net>
Signed-off-by: Claire Xenia Wolf <claire@clairexen.net>
Signed-off-by: Claire Xenia Wolf <claire@clairexen.net>
Signed-off-by: Claire Xenia Wolf <claire@clairexen.net>
@clairexen clairexen marked this pull request as draft September 29, 2023 14:10
{
for (auto &it : wire->attributes) {
f << stringf("%s" "attribute %s ", indent.c_str(), it.first.c_str());
dump_const(f, it.second);
f << stringf("\n");
}
if (flag_d && wire->driverCell) {
f << stringf("%s" "driver %s %s\n", indent.c_str(),
wire->driverCell->name.c_str(), wire->driverPort.c_str());
Copy link
Member

@povik povik Oct 9, 2023

Choose a reason for hiding this comment

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

Since it should be always possible to reconstruct this data, why not dump it as a comment in the RTLIL output? (Does RTLIL support comments?) And if we do dump it as a comment, maybe we could include it unconditionally and drop the argument to dump_wire.

Copy link
Member

Choose a reason for hiding this comment

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

...and drop the other new dump arguments and the option to the pass.

@povik
Copy link
Member

povik commented Oct 16, 2023

This PR also adds a $buf "coarse-grain" buffer cell type, similar in behavior to $pos, but techmap/simplemap/etc is not mapping this buffer type to an array of single-bit buffers.

FWIW that doesn't seem to be the behavior for $pos cells either

void simplemap_pos(RTLIL::Module *module, RTLIL::Cell *cell)
{
RTLIL::SigSpec sig_a = cell->getPort(ID::A);
RTLIL::SigSpec sig_y = cell->getPort(ID::Y);
sig_a.extend_u0(GetSize(sig_y), cell->parameters.at(ID::A_SIGNED).as_bool());
module->connect(RTLIL::SigSig(sig_y, sig_a));
}

@widlarizer
Copy link
Collaborator

widlarizer commented Jun 5, 2024

Since setPort may bufNormQueue.insert, a Cell* may survive in bufNormQueue beyond when the underlying cell is removed. Repro: rebase this branch onto main (855ac28), then read_rtlil bug.proc.il; bufnorm -update; opt; bufnorm -update segfaults on my linux machine, where bug.proc.il is

autoidx 16

module \bug

  wire width 32 $procmux$14_Y

  wire $procmux$15_CMP

  wire $auto$bugpoint.cc:258:simplify_something$1

  wire width 32 output 1 $auto$bugpoint.cc:258:simplify_something$3

  wire width 30 $auto$bugpoint.cc:258:simplify_something$4

  wire width 32 $auto$bugpoint.cc:258:simplify_something$5

  wire $delete_wire$6

  wire width 32 \pc$next

  cell $mux $procmux$14
    parameter \WIDTH 32
    connect \Y $procmux$14_Y
    connect \S $procmux$15_CMP
    connect \B 0
    connect \A 32'x
  end

  cell $dff $7
    parameter \WIDTH 32
    parameter \CLK_POLARITY 1
    connect \Q $auto$bugpoint.cc:258:simplify_something$3
    connect \D \pc$next
    connect \CLK $auto$bugpoint.cc:258:simplify_something$1
  end

  connect $procmux$15_CMP $delete_wire$6
  connect \pc$next $procmux$14_Y
end

@whitequark
Copy link
Member

oh hey, a new user of bugpoint :D

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.

None yet

4 participants