palaniappan-r's picture
Add markdown sources
d59bb1b verified

Where can I find the block findInst implementation?

Tool: OpenDB

Subcategory: Implementation details

Conversation

oharboe

Silly question: where do I find the source code for findInst?

I seem unable to find it in the OpenROAD source code.

    set inst [$block findInst [format "ces_%d_%d" $row $col]]

https://github.com/The-OpenROAD-Project/OpenROAD-flow-scripts/blob/f90d853b3705338fa2d142acd20ac57626c71f12/flow/designs/asap7/mock-array/macro-placement.tcl#L10

QuantamHD

Header: https://github.com/The-OpenROAD-Project/OpenROAD/blob/master/src/odb/include/odb/db.h#L992 Impl: https://github.com/The-OpenROAD-Project/OpenROAD/blob/master/src/odb/src/db/dbBlock.cpp#L1790 Hidden Impl: https://github.com/The-OpenROAD-Project/OpenROAD/blob/master/src/odb/src/db/dbBlock.h#L173

oharboe

So findInst doesn't throw an exception if the element doesn't exist, like https://cplusplus.com/reference/map/map/at/ does.

This leads to a lot of repetition and context unique error messages and in tcl very poor error messages like:

Error: macro-placement.tcl, 27 invalid command name "NULL"

std::map has explicit accessors that either creates an element if it doesn't exist(returns empty by default) and another that throws an exception if it doesn't exist.

The equivalent here would be that findInst() threw an exception with an error message and the name, and that another hasInst() that doesn't and allows the user to handle it. try/catch is not approperiate because both findInst() that throws exception and hasInst() that checks for presence would both be part of normal exception.

maliberty

The odb code is old and was written without the use of exceptions. I would be fine to change that but it will require testing the full app to see if problems arise and resolving them. There are a number of similar APIs that return nullptr on failure.

oharboe

I see. I was just curious and surprised: there are LOT of methods in that .h file that are exposed in .tcl.

Not all of them are obviously compatible with a .tcl calling convention or even intended for .tcl?