-
Notifications
You must be signed in to change notification settings - Fork 893
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
Represent string constants as strings #4516
Conversation
60fa41a
to
04d9ec6
Compare
On the sky130hd/jpeg design from OpenROAD-flow-scripts, dumping the netlist just after the
|
I have tried the following patch to hashlib on top of the PR, and updated the table:
|
Switching from |
@povik the prime list change adds runtime improvements up to 3% on top of this with a 0.5% regression in one case |
3214b7b
to
caf5086
Compare
9a0edd4
to
c34691b
Compare
c34691b
to
f1951b9
Compare
dad4b1b
to
d4a6563
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comparison and indexing isn't consistent across backings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good apart from the extra cxxrtl change and the extra assert
767da07
to
005a6fe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't looked at the new unit testing but the Const change itself looks fine with the points from the last review resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
0049444
to
76dfda7
Compare
just some fixes from the functional merges |
I validated the memory savings to be 0-30%. ORFS peak:
In the flow I dumped out the RTLIL before synthesis and outside of ORFS loaded the RTLIL and ran just the basic
As for runtime, there was negligible improvement (0-1%) |
67a97f5
to
2dd0ae3
Compare
2dd0ae3
to
bc5d9d1
Compare
This PR introduced a lot of warnings along the lines of |
True. I brought up size types on a dev jf and we decided to stick with int for Yosys data structures so I guess I'll make |
Currently, a
RTLIL::Const
representing a string will usestd::vector<RTLIL::State>
, encoding the string into a vector of individual bits. This increases the memory consumption of string attributes, such assrc
andhdlname
, by a factor of 8.As of this PR, the structure now holds data represented with
ana union. Thestd::variant<bitvectype, std::string>
namedbacking
bits
vector is no longer accessible and insteadstd::vector<RTLIL::State>& bits()
has to be used. When a Const is constructed from a string, it is represented with the string alternative. When itsbits()
method is used, the string is encoded into the bit vector alternative as prior to this PR, seeConst::bitvectorize()
. This is similar to howRTLIL::SigSpec
"unpacks" into bits.In the initial implementation, when
bits()
were being accessed, I asserted that the Const isn't represented with a string. This found some places in Yosys that access string attributes bit-by-bit. As a result, this PR comes with bonus content:kernel/cellaigs.cc
frontends/ast/ast.cc
Const::pretty_fmt
is_param
that doesn't try return bitsIt's possible to split these now necessary changes out to a separate PR, but it will be heavy on git conflicts. Please advise.
This PR does not affect constant
SigChunk
s which also have anstd::vector<RTLIL::State>
each.std::get
fromassert_get_bits
etc)add some way of debugging how much unpacking we're doingrequires unrelated changes in followup PRPlease comment what memory usage changes you see with this PR. I've observed memory savings of 0-20% depending on the design with negligible runtime improvements. The open source Verilog frontend often dominates memory usage, so flows that use Verific may more readily show these improvements.