Skip to content

Commit

Permalink
Added undo for net name swap
Browse files Browse the repository at this point in the history
Signed-off-by: andyfox-rushc <[email protected]>
  • Loading branch information
andyfox-rushc committed Dec 5, 2024
1 parent f08e23f commit 6bd3da4
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/odb/include/odb/db.h
Original file line number Diff line number Diff line change
Expand Up @@ -2116,7 +2116,7 @@ class dbNet : public dbObject

///
/// Swaps the current db net name with the source db net
void swapNetNames(dbNet* source);
void swapNetNames(dbNet* source, bool journal = true);

///
/// RC netowork disconnect
Expand Down
26 changes: 26 additions & 0 deletions src/odb/src/db/dbJournal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1754,6 +1754,32 @@ void dbJournal::undo_swapObject()
auto obj_type = popObjectType();

switch (obj_type) {
case dbNameObj: {
// name swapping undo
auto sub_obj_type = popObjectType();
switch (sub_obj_type) {
// net name swap
case dbNetObj: {
// assume source and destination
uint source_net_id;
uint dest_net_id;
_log.pop(source_net_id);
_log.pop(dest_net_id);
// note because we are undoing the source is the prior dest
//(we are move dest name back to source name).
dbNet* source_net = dbNet::getNet(_block, dest_net_id);
dbNet* dest_net = dbNet::getNet(_block, source_net_id);
// don't allow undo to be undone, turn off journaling doing swap
source_net->swapNetNames(dest_net, false);
}
default: {
_logger->critical(utl::ODB,
444,
"No undo_swapObject Name support for type {}",
dbObject::getTypeName(sub_obj_type));
}
}
}
case dbInstObj: {
uint inst_id;
_log.pop(inst_id);
Expand Down
16 changes: 15 additions & 1 deletion src/odb/src/db/dbNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ bool dbNet::rename(const char* name)
return true;
}

void dbNet::swapNetNames(dbNet* source)
void dbNet::swapNetNames(dbNet* source, bool ok_to_journal)
{
_dbNet* dest_net = (_dbNet*) this;
_dbNet* source_net = (_dbNet*) source;
Expand All @@ -736,6 +736,20 @@ void dbNet::swapNetNames(dbNet* source)
char* dest_name_ptr = dest_net->_name;
char* source_name_ptr = source_net->_name;

// allow undo..
if (block->_journal && ok_to_journal) {
block->_journal->beginAction(dbJournal::SWAP_OBJECT);
// a name
block->_journal->pushParam(dbNameObj);
// the type of name swap
block->_journal->pushParam(dbNetObj);
// stash the source and dest in that order,
// let undo reorder
block->_journal->pushParam(source_net->getId());
block->_journal->pushParam(dest_net->getId());
block->_journal->endAction();
}

block->_net_hash.remove(dest_net);
block->_net_hash.remove(source_net);

Expand Down

0 comments on commit 6bd3da4

Please sign in to comment.