File tree Expand file tree Collapse file tree 2 files changed +62
-0
lines changed
Expand file tree Collapse file tree 2 files changed +62
-0
lines changed Original file line number Diff line number Diff line change @@ -786,6 +786,20 @@ class dbBlock : public dbObject
786786 // /
787787 dbModInst* findModInst (const char * path);
788788
789+ // /
790+ // / Find a specific moditerm in this block. path is
791+ // / master_module_name/modinst_name/term_name Returns nullptr if the object
792+ // / was not found.
793+ // /
794+ dbModITerm* findModITerm (const char * hierarchical_name);
795+
796+ // /
797+ // / Find a specific modbterm in this block. path is
798+ // / master_module_name/modinst_name/term_name Returns nullptr if the object
799+ // / was not found.
800+ // /
801+ dbModBTerm* findModBTerm (const char * hierarchical_name);
802+
789803 // /
790804 // / Find a specific PowerDomain in this block.
791805 // / Returns nullptr if the object was not found.
Original file line number Diff line number Diff line change @@ -3885,4 +3885,52 @@ const char* dbBlock::getBaseName(const char* full_name) const
38853885 return full_name;
38863886}
38873887
3888+ dbModITerm* dbBlock::findModITerm (const char * hierarchical_name)
3889+ {
3890+ if (hierarchical_name == nullptr ) {
3891+ return nullptr ;
3892+ }
3893+
3894+ const char * last_delim = strrchr (hierarchical_name, getHierarchyDelimiter ());
3895+ if (last_delim == nullptr ) {
3896+ return nullptr ;
3897+ }
3898+
3899+ std::string inst_path (hierarchical_name, last_delim - hierarchical_name);
3900+ const char * term_name = last_delim + 1 ;
3901+
3902+ dbModInst* inst = findModInst (inst_path.c_str ());
3903+ if (inst) {
3904+ return inst->findModITerm (term_name);
3905+ }
3906+ return nullptr ;
3907+ }
3908+
3909+ dbModBTerm* dbBlock::findModBTerm (const char * hierarchical_name)
3910+ {
3911+ if (hierarchical_name == nullptr ) {
3912+ return nullptr ;
3913+ }
3914+
3915+ const char * last_delim = strrchr (hierarchical_name, getHierarchyDelimiter ());
3916+ if (last_delim == nullptr ) {
3917+ // Top level port
3918+ if (dbModule* top_module = getTopModule ()) {
3919+ return top_module->findModBTerm (hierarchical_name);
3920+ }
3921+ return nullptr ;
3922+ }
3923+
3924+ std::string inst_path (hierarchical_name, last_delim - hierarchical_name);
3925+ const char * term_name = last_delim + 1 ;
3926+
3927+ dbModInst* inst = findModInst (inst_path.c_str ());
3928+ if (inst) {
3929+ if (dbModule* master = inst->getMaster ()) {
3930+ return master->findModBTerm (term_name);
3931+ }
3932+ }
3933+ return nullptr ;
3934+ }
3935+
38883936} // namespace odb
You can’t perform that action at this time.
0 commit comments