From ee2ed63d35c8dee35221ea2a16bb8fbb85a68e12 Mon Sep 17 00:00:00 2001 From: Gabriel Gouvine Date: Thu, 22 Jun 2023 18:28:48 +0200 Subject: [PATCH] Automatic slice height adjustment for multi-row cells --- etesian/src/EtesianEngine.cpp | 37 +++++++++++++++-------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/etesian/src/EtesianEngine.cpp b/etesian/src/EtesianEngine.cpp index 66bafeb6..223c9e41 100644 --- a/etesian/src/EtesianEngine.cpp +++ b/etesian/src/EtesianEngine.cpp @@ -1051,34 +1051,29 @@ namespace Etesian { * Useful for Bookshelf benchmarks */ - bool isSliceHeightSet = false; + std::set heights; for ( Occurrence occurrence : getCell()->getTerminalNetlistInstanceOccurrences(getBlockInstance()) ) { Instance* instance = static_cast(occurrence.getEntity()); - Cell* masterCell = instance->getMasterCell(); - if ( (instance->getPlacementStatus() != Instance::PlacementStatus::PLACED) - and (instance->getPlacementStatus() != Instance::PlacementStatus::FIXED )) + if (instance->getPlacementStatus() != Instance::PlacementStatus::FIXED) { - DbU::Unit cellHeight = masterCell->getAbutmentBox().getHeight(); - bool sliceHeightChange = cellHeight != getSliceHeight(); - if (isSliceHeightSet) - { - if (sliceHeightChange) throw Error( "EtesianEngine::toColoquinte(): Cannot manage unplaced block, instance \"%s\" of \"%s\": slice height was set to %d but cell height is %d." - , getString(instance ->getName()).c_str() - , getString(masterCell->getName()).c_str() - , getSliceHeight() - , cellHeight - ); - } - else - { - if (sliceHeightChange) cerr << Warning("Adjusting slice height from %d to %d fit a placeable cell.", getSliceHeight(), cellHeight) << endl; - _sliceHeight = cellHeight; - } - isSliceHeightSet = true; + Cell* masterCell = instance->getMasterCell(); + heights.emplace(masterCell->getAbutmentBox().getHeight()); } } + if (heights.empty() || *heights.begin() <= 0) { + cerr << Warning("No appropriate slice height found") << endl; + return; + } + DbU::Unit newSliceHeight = *heights.begin(); + for (DbU::Unit h : heights) { + if (h % newSliceHeight != 0) { + cerr << Warning("Cannot set slice height to %d (does not divide cell height %d).", newSliceHeight, h) << endl; + return; + } + _sliceHeight = newSliceHeight; + } } void EtesianEngine::_coloquinteCallback(coloquinte::PlacementStep step) {