-
Notifications
You must be signed in to change notification settings - Fork 773
ram: internal commands moved to cpp file #9312
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
base: master
Are you sure you want to change the base?
ram: internal commands moved to cpp file #9312
Conversation
Signed-off-by: braydenl9988 <braydenl9988@gmail.com>
Signed-off-by: braydenl9988 <braydenl9988@gmail.com>
Signed-off-by: braydenl9988 <braydenl9988@gmail.com>
Signed-off-by: braydenl9988 <braydenl9988@gmail.com>
Signed-off-by: braydenl9988 <braydenl9988@gmail.com>
Signed-off-by: braydenl9988 <braydenl9988@gmail.com>
Signed-off-by: braydenl9988 <braydenl9988@gmail.com>
Signed-off-by: braydenl9988 <braydenl9988@gmail.com>
Signed-off-by: braydenl9988 <braydenl9988@gmail.com>
Signed-off-by: braydenl9988 <braydenl9988@gmail.com>
Signed-off-by: Brayden Louie <braydenl9988@gmail.com>
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.
Code Review
The pull request successfully refactors the RAM generation flow by migrating power delivery network (PDN) generation, pin placement, filler placement, and routing logic from Tcl scripts to C++ methods within the ram::RamGen class. This improves modularity and provides more direct control over these operations. The RamGen constructor has been updated to incorporate necessary dependencies from other OpenROAD modules, and the Tcl interface now correctly invokes these new C++ functions. The review comments suggest improvements for robustness and maintainability, such as adding nullptr checks and refining constructor design. This is a positive step towards a more robust and maintainable codebase.
| // need parameters for power and ground nets | ||
| auto power_net = dbNet::create(block_, "VDD"); |
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.
The block_ member variable is accessed in ramPdngen, ramPinplacer, and ramRouting. This member is initialized within the generate method. While the generate_ram Tcl command ensures generate is called first, if these C++ methods are called directly via their Tcl/Python bindings without prior initialization of block_, it could lead to a nullptr dereference and a crash. Adding a check for block_ being nullptr at the beginning of these methods would make them more robust against out-of-order calls.
| // need parameters for power and ground nets | |
| auto power_net = dbNet::create(block_, "VDD"); | |
| if (!block_) { | |
| logger_->error(RAM, 1, "Block is not initialized. Call generate_ram_netlist first."); | |
| } | |
| auto power_net = dbNet::create(block_, "VDD"); | |
| auto ground_net = dbNet::create(block_, "VSS"); |
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.
Ignore
| odb::dbDatabase* db, | ||
| Logger* logger, | ||
| pdn::PdnGen* pdngen, | ||
| ppl::IOPlacer* ioPlacer, | ||
| dpl::Opendp* opendp_, | ||
| grt::GlobalRouter* global_router_, | ||
| drt::TritonRoute* detailed_router_); | ||
| ~RamGen() = default; |
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.
The RamGen constructor now accepts a large number of pointers as arguments. While these dependencies are necessary for the new functionality, a constructor with many parameters can sometimes reduce readability and make the class harder to instantiate or test. Consider if some of these related dependencies could be grouped into a single helper struct or if some could be retrieved on-demand from the OpenRoad singleton within the RamGen methods, rather than being stored as direct member pointers. This is a design consideration for improved maintainability.
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.
@maliberty what is the preference on this?
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.
clang-tidy made some suggestions
src/OpenRoad.cc
Outdated
| replace_ = new gpl::Replace(db_, sta_, resizer_, global_router_, logger_); | ||
| pdnsim_ = new psm::PDNSim(logger_, db_, sta_, estimate_parasitics_, opendp_); | ||
| pdngen_ = new pdn::PdnGen(db_, logger_); | ||
| ram_gen_ = new ram::RamGen(getDbNetwork(), db_, logger_, pdngen_, ioPlacer_, opendp_, global_router_, detailed_router_); |
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.
warning: no matching constructor for initialization of 'ram::RamGen' [clang-diagnostic-error]
ram_gen_ = new ram::RamGen(getDbNetwork(), db_, logger_, pdngen_, ioPlacer_, opendp_, global_router_, detailed_router_);
^Additional context
src/ram/include/ram/ram.h:56: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 8 were provided
class RamGen
^src/ram/include/ram/ram.h:56: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 8 were provided
class RamGen
^
src/ram/include/ram/ram.h
Outdated
| RamGen(sta::dbNetwork* network, odb::dbDatabase* db, utl::Logger* logger); | ||
| RamGen(sta::dbNetwork* network, | ||
| odb::dbDatabase* db, | ||
| Logger* logger, |
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.
warning: unknown type name 'Logger' [clang-diagnostic-error]
Logger* logger,
^
src/ram/include/ram/ram.h
Outdated
| RamGen(sta::dbNetwork* network, odb::dbDatabase* db, utl::Logger* logger); | ||
| RamGen(sta::dbNetwork* network, | ||
| odb::dbDatabase* db, | ||
| Logger* logger, |
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.
warning: unknown type name 'Logger'; did you mean 'utl::Logger'? [clang-diagnostic-error]
| Logger* logger, | |
| utl::Logger* logger, |
Additional context
src/ram/include/ram/ram.h:26: 'utl::Logger' declared here
class Logger;
^
src/ram/src/ram.cpp
Outdated
| block_->addGlobalConnect(nullptr, ".*", power_pin, power_net, true); | ||
| block_->addGlobalConnect(nullptr, ".*", ground_pin, ground_net, true); | ||
|
|
||
| block_->globalConnect(); |
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.
warning: no matching member function for call to 'globalConnect' [clang-diagnostic-error]
block_->globalConnect();
^Additional context
src/odb/include/odb/db.h:751: candidate function not viable: requires 2 arguments, but 0 were provided
int globalConnect(bool force, bool verbose);
^src/odb/include/odb/db.h:752: candidate function not viable: requires 3 arguments, but 0 were provided
int globalConnect(dbGlobalConnect* gc, bool force, bool verbose);
^|
Mostly looks good, please fix the build errors and clang-tidy then I can review. |
Signed-off-by: braydenl9988 <braydenl9988@gmail.com>
Signed-off-by: braydenl9988 <braydenl9988@gmail.com>
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.
clang-tidy made some suggestions
| { | ||
| vector<odb::dbMaster*> filler_masters; | ||
| for (const std::string& cell : filler_cells) { | ||
| filler_masters.push_back(db_->findMaster(cell.c_str())); |
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.
warning: 'push_back' is called inside a loop; consider pre-allocating the container capacity before the loop [performance-inefficient-vector-operation]
src/ram/src/ram.cpp:530:
- for (const std::string& cell : filler_cells) {
+ filler_masters.reserve(filler_cells.size());
+ for (const std::string& cell : filler_cells) {|
Looks like clang-format, clang-tidy, and the ram8x8 test are all failing. Please fix the first 2 and investigate the last one. There appears to be an unrelated bazel failure so you can ignore that. |
|
@rovinski I'm working on getting the clang-format and clang-tidy fixed as of now. I've been running into build issues with |
|
Note that we upgraded boost versions so you might need to re-run the dependency installer. |
Signed-off-by: braydenl9988 <braydenl9988@gmail.com>
|
clang-tidy review says "All clean, LGTM! 👍" |
Signed-off-by: braydenl9988 <braydenl9988@gmail.com>
|
clang-tidy review says "All clean, LGTM! 👍" |
rovinski
left a comment
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.
LGTM. Go ahead and mark as ready for review.
PR migrates TCL scripts called in
ram.tclto cpp methods withinram.cpp