Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces bit-line segmentation to the RAM generator, allowing for automatic or manual configuration of rows per segment via the new -segmentation and -rows_per_segment options. It also implements per-slice buffering for word-select address bits to reduce loading, and adds an extra check to ensure latches are positive-triggered. The review feedback highlights a potential null pointer dereference in the cell upsizing helper that should trigger a loud error, and suggests distributing segment-select AND gates across different slices to prevent physical placement congestion.
| auto upsized = [&](dbMaster* base, int factor) -> dbMaster* { | ||
| const std::string name = base->getName(); | ||
| size_t pos = name.size(); | ||
| while (pos > 0 && std::isdigit(static_cast<unsigned char>(name[pos - 1]))) { | ||
| --pos; | ||
| } | ||
| if (pos == name.size() || pos == 0) { |
There was a problem hiding this comment.
If base is nullptr (for example, if and2_cell_ or tristate_cell_ is not found in the library), calling base->getName() will dereference a null pointer and cause a crash. To adhere to the repository's style guide, we should not use a silent guard but instead trigger a loud, early failure using logger_->error.
auto upsized = [&](dbMaster* base, int factor) -> dbMaster* {
if (!base) {
logger_->error(RAM, 114, "Required cell is missing for upsizing.");
}
const std::string name = base->getName();
size_t pos = name.size();
while (pos > 0 && std::isdigit(static_cast<unsigned char>(name[pos - 1]))) {
--pos;
}
if (pos == name.size() || pos == 0) {References
- Never suggest a guard that hides an impossible state: a null check, an empty, zero or negative check, or a missing-key check that returns a default, skips, clamps, continues or logs a warning and carries on. A null dereference that is reachable is reported with its triggering input; the fix is logger_->error(...) or an assert, never a silent default. (link)
| continue; | ||
| } | ||
| dbNet* out = makeNet(sp, fmt::format("sel_and{}", j)); | ||
| makeInst(ctl[0][0].get(), |
There was a problem hiding this comment.
To avoid physical placement congestion and potential overlaps in the select column of slice 0, consider distributing the segment-select AND gates across the select columns of the different slices instead of placing all of them in ctl[0][0]. Since slices_per_word is at least 1, you can use ctl[j % slices_per_word][0].get() to distribute them.
| makeInst(ctl[0][0].get(), | |
| makeInst(ctl[j % slices_per_word][0].get(), |
|
Ideally with an optimizer this option will not be exposed to the user and instead automatically selected. Also, please remember what I said about splitting separate concerns into separate PRs. The smaller a PR is, the easier it is to review. |
Signed-off-by: Thinh Nguyen <nguyenthinh19011@gmail.com>
a5a89af to
c2957e8
Compare
Summary
Adds bit-line segmentation to the RAM generator, and adds two options to control it. Also fixes a heavily loaded address net in mux 2 RAMs, and fix bug in the automatic latch cell choice for latch-based RAMs.
Currently in a column every stored bit drives one shared bit line, so the line is loaded by every row and gets slow as the RAM gets taller. Segmentation splits each column into groups of rows (segments). Each bit drives only the short line of its own segment and one extra buffer per segment switched by a segment select drives the shared line. Each line then has far fewer loads with one extra row of buffers per segment so the area grows very little with alot of delay decrease.
Segmentation is on automatically for RAMs with 32 or more rows, column mux 1 or 2, and one read/write port, without banking. This includes latch-based RAMs. The segment length is chosen automatically from the row count (about the square root of it, rounded to a power of two).
But this can be manually override using the flags:
-segmentation: turn segmentation off or on.-rows_per_segment N: set the number of rows per segment (turns segmentation on unless-segmentation 0is given).Mux 2 fix: In mux 2 RAMs, the word-select address signal drove every column group directly (about 580 loads on a 128×64 RAM). It is now buffered once per column group (about 72 loads).
Latch fix: With
-use_latch 1and no-storage_cell, the generator can pick negative latches instead of positive. Changes are made so that only positive latches are selectedType of Change
Impact
-segmentationvalue other than 0 or 1 is an error (RAM 111).README.md.Verification
./etc/Build.sh).Related Issues
This PR contaisn the OpenSTA integration code in #10784 which should be merged before this one
@rovinski