Skip to content

Conversation

@braydenlouie
Copy link
Contributor

@braydenlouie braydenlouie commented Jan 22, 2026

PR migrates TCL scripts called in ram.tcl to cpp methods within ram.cpp

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>
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

Comment on lines +417 to +418
// need parameters for power and ground nets
auto power_net = dbNet::create(block_, "VDD");
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
// 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");

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ignore

Comment on lines 61 to 68
odb::dbDatabase* db,
Logger* logger,
pdn::PdnGen* pdngen,
ppl::IOPlacer* ioPlacer,
dpl::Opendp* opendp_,
grt::GlobalRouter* global_router_,
drt::TritonRoute* detailed_router_);
~RamGen() = default;
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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.

Copy link
Collaborator

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?

Copy link
Contributor

@github-actions github-actions bot left a 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_);
Copy link
Contributor

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
      ^

RamGen(sta::dbNetwork* network, odb::dbDatabase* db, utl::Logger* logger);
RamGen(sta::dbNetwork* network,
odb::dbDatabase* db,
Logger* logger,
Copy link
Contributor

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,
         ^

RamGen(sta::dbNetwork* network, odb::dbDatabase* db, utl::Logger* logger);
RamGen(sta::dbNetwork* network,
odb::dbDatabase* db,
Logger* logger,
Copy link
Contributor

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]

Suggested change
Logger* logger,
utl::Logger* logger,
Additional context

src/ram/include/ram/ram.h:26: 'utl::Logger' declared here

class Logger;
      ^

block_->addGlobalConnect(nullptr, ".*", power_pin, power_net, true);
block_->addGlobalConnect(nullptr, ".*", ground_pin, ground_net, true);

block_->globalConnect();
Copy link
Contributor

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);
      ^

@rovinski
Copy link
Collaborator

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>
Copy link
Contributor

@github-actions github-actions bot left a 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()));
Copy link
Contributor

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) {

@rovinski
Copy link
Collaborator

rovinski commented Jan 25, 2026

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.

@braydenlouie
Copy link
Contributor Author

@rovinski I'm working on getting the clang-format and clang-tidy fixed as of now. I've been running into build issues with boost::stacktrace_basic when I tried to pull the new globalConnect, that's why last two commits have just been merges. I'm in the process of rebuilding right now, but if I run into the same issue again, I'll comment again.

@maliberty
Copy link
Member

Note that we upgraded boost versions so you might need to re-run the dependency installer.

Signed-off-by: braydenl9988 <braydenl9988@gmail.com>
@github-actions
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Signed-off-by: braydenl9988 <braydenl9988@gmail.com>
@github-actions
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Copy link
Collaborator

@rovinski rovinski left a 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.

@rovinski rovinski requested a review from maliberty January 28, 2026 03:35
@braydenlouie braydenlouie marked this pull request as ready for review January 28, 2026 03:50
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.

3 participants