Files
OpenSTA/include/sta/Bfs.hh
T
James Cherry 2c866d5f2d bfs update kahns prep
commit 4075953c9798444b9d5275f8fa0320f74b9bf1ef
Author: James Cherry <[email protected]>
Date:   Sat Jul 4 09:00:48 2026 -0700

    bfs resort hasNext

    Signed-off-by: James Cherry <[email protected]>

commit 4fb0dd19e479f507935129fe940bcd1cf93b29d0
Author: James Cherry <[email protected]>
Date:   Thu Jul 2 12:23:54 2026 -0700

    ApiChanges

    Signed-off-by: James Cherry <[email protected]>

commit 510afbc1403c9fd2b764b4f3a71dddabd696f052
Author: James Cherry <[email protected]>
Date:   Thu Jul 2 11:07:44 2026 -0700

    bfs enqueueFanin/out

    Signed-off-by: James Cherry <[email protected]>

commit 9a5aa570e910c289b276a519bdf532dfa2e28c5f
Author: James Cherry <[email protected]>
Date:   Thu Jul 2 10:41:27 2026 -0700

    Revert "bfs continueFrom/enqueueFanin/out"

    This reverts commit d18498c947a7df2b615fafda38fbdbe8033eca9d.

commit 02a253ab252f6637cfea29bdd788cb25da16813d
Author: James Cherry <[email protected]>
Date:   Thu Jul 2 08:21:49 2026 -0700

    Revert "Bfs rm search_pred"

    This reverts commit d858b3380b5e1d81ff6162b6378672a6099a246f.

commit 0adf03613d91c5774545d12cba1dc52052ca732a
Author: James Cherry <[email protected]>
Date:   Thu Jul 2 08:08:04 2026 -0700

    Genclks::ensureMaster

    Signed-off-by: James Cherry <[email protected]>

commit 089b373c548b77f9189a2617c3168867de620dfe
Author: James Cherry <[email protected]>
Date:   Wed Jul 1 17:50:43 2026 -0700

    Search::ensureDownstreamClkPins() use dfs

    Signed-off-by: James Cherry <[email protected]>

commit 000ca16adb9bdcb92266e5f242629bc3e8612658
Author: James Cherry <[email protected]>
Date:   Wed Jul 1 10:03:57 2026 -0700

    ApiChangeLog

    Signed-off-by: James Cherry <[email protected]>

commit d858b3380b5e1d81ff6162b6378672a6099a246f
Author: James Cherry <[email protected]>
Date:   Wed Jul 1 09:56:53 2026 -0700

    Bfs rm search_pred

    Signed-off-by: James Cherry <[email protected]>

commit d18498c947a7df2b615fafda38fbdbe8033eca9d
Author: James Cherry <[email protected]>
Date:   Wed Jul 1 08:07:15 2026 -0700

    bfs continueFrom/enqueueFanin/out

    Signed-off-by: James Cherry <[email protected]>

commit a8c55b12b3ad7a1041766775727ad758ae8c6d18
Author: James Cherry <[email protected]>
Date:   Tue Jun 30 10:07:46 2026 -0700

    bfs continue

    Signed-off-by: James Cherry <[email protected]>

commit 8530dcd86b7ee736f1858143c3b2cee57cdbc991
Author: James Cherry <[email protected]>
Date:   Tue Jun 30 07:15:28 2026 -0700

    Graph::visitFanin/out uninline edge iter

    Signed-off-by: James Cherry <[email protected]>

commit 1ba1f4576f4b72c64db742369a63dcf8726ba002
Author: James Cherry <[email protected]>
Date:   Mon Jun 29 21:09:17 2026 -0700

    BfsIterator rm Iterator<Vector> subclass

    Signed-off-by: James Cherry <[email protected]>

commit b3ddd2580298958ad6da8225ecac0d255315504c
Author: James Cherry <[email protected]>
Date:   Mon Jun 29 20:15:23 2026 -0700

    ClkNetwork::findClkPins use VertexQueue instead of bfs

    Signed-off-by: James Cherry <[email protected]>

commit 9e73154db48a7301be4039a25aec1fef589ef18a
Author: James Cherry <[email protected]>
Date:   Mon Jun 29 18:39:39 2026 -0700

    Search::ensureDownstreamClkPins use VertexQueue

    Signed-off-by: James Cherry <[email protected]>

commit 9cd1b160e126ccacc47375ef508fdbb580bfa162
Author: James Cherry <[email protected]>
Date:   Mon Jun 29 11:18:03 2026 -0700

    comment

    Signed-off-by: James Cherry <[email protected]>

commit 0baf3838e2b8faa5fea560b0c95431b277631fea
Author: James Cherry <[email protected]>
Date:   Mon Jun 29 10:57:39 2026 -0700

    findClkArrivals use invalid for clk fringe

    Signed-off-by: James Cherry <[email protected]>

commit e82ccd10a5e4bd69e41ce889685d7a130ae79ed6
Author: James Cherry <[email protected]>
Date:   Sun Jun 28 20:36:48 2026 -0700

    Search::findClkArrivals

    Signed-off-by: James Cherry <[email protected]>

commit cb66a72686c8728141c72ceb593b8a4b895ff696
Author: James Cherry <[email protected]>
Date:   Sun Jun 28 10:11:55 2026 -0700

    rm Search::postponeClkFanouts

    Signed-off-by: James Cherry <[email protected]>

Signed-off-by: James Cherry <[email protected]>
2026-07-04 09:04:31 -07:00

176 lines
5.5 KiB
C++

// OpenSTA, Static Timing Analyzer
// Copyright (c) 2026, Parallax Software, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//
// The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software.
//
// Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
//
// This notice may not be removed or altered from any source distribution.
#pragma once
#include <functional>
#include <mutex>
#include <vector>
#include "GraphClass.hh"
#include "Iterator.hh"
#include "StaState.hh"
#include "VertexVisitor.hh"
namespace sta {
class SearchPred;
class BfsFwdIterator;
class BfsBkwdIterator;
using VertexFn = std::function<void(Vertex*)>;
// LevelQueue is a vector of vertex vectors indexed by logic level.
using LevelQueue = std::vector<VertexSeq>;
// Abstract base class for forward and backward breadth first search iterators.
// Visit all of the vertices at a level before moving to the next.
// Use enqueue to seed the search.
// Use enqueueAdjacentVertices as a vertex is visited to queue the
// fanout vertices filtered by the search predicate.
//
// Vertices are marked as being in the queue by using a flag on
// the vertex indexed by bfs_index. A unique flag is only needed
// if the BFS in in use when other BFS's are simultaneously in use.
class BfsIterator : public StaState
{
public:
// Make sure that the BFS queue is deep enough for the max logic level.
void ensureSize();
// Reset to virgin state.
void clear();
// Apply fn to each vertex and clear.
void clear(const VertexFn &fn);
[[nodiscard]] bool empty() const;
// Enqueue a vertex to search from.
void enqueue(Vertex *vertex);
// Enqueue vertices adjacent to a vertex.
virtual void enqueueAdjacentVertices(Vertex *vertex) = 0;
virtual void enqueueAdjacentVertices(Vertex *vertex,
const Mode *mode) = 0;
[[nodiscard]] bool inQueue(Vertex *vertex);
void checkInQueue(Vertex *vertex);
// Notify iterator that vertex will be deleted.
void deleteVertexBefore(Vertex *vertex);
void remove(Vertex *vertex);
void reportEntries() const;
// Apply visitor to all vertices in the queue in level order.
// Returns the number of vertices that are visited.
virtual int visit(Level to_level,
VertexVisitor *visitor);
// Apply visitor to all vertices in the queue in level order,
// using threads to parallelize the visits. visitor must be thread safe.
// Returns the number of vertices that are visited.
int visitParallel(Level to_level,
VertexVisitor *visitor);
bool hasNext();
bool hasNext(Level to_level);
Vertex *next();
protected:
BfsIterator(BfsIndex bfs_index,
Level level_min,
Level level_max,
SearchPred *search_pred,
StaState *sta);
void init();
void deleteEntries(Level level);
virtual bool levelLess(Level level1,
Level level2) const = 0;
virtual bool levelLessOrEqual(Level level1,
Level level2) const = 0;
virtual void incrLevel(Level &level) const = 0;
void deleteEntries();
void checkLevel(Vertex *vertex,
Level level);
void findNext(Level to_level);
BfsIndex bfs_index_;
Level level_min_;
Level level_max_;
SearchPred *search_pred_;
LevelQueue queue_;
std::mutex queue_lock_;
// Min (max) level of queued vertices.
Level first_level_;
// Max (min) level of queued vertices.
Level last_level_;
friend class BfsFwdIterator;
friend class BfsBkwdIterator;
};
class BfsFwdIterator : public BfsIterator
{
public:
BfsFwdIterator(BfsIndex bfs_index,
SearchPred *search_pred,
StaState *sta);
~BfsFwdIterator() override;
void enqueueAdjacentVertices(Vertex *vertex) override;
void enqueueAdjacentVertices(Vertex *vertex,
const Mode *mode) override;
using BfsIterator::enqueueAdjacentVertices;
void enqueueFanout(Vertex *vertex);
void enqueueFanout(Vertex *vertex,
const Mode *mode);
protected:
bool levelLessOrEqual(Level level1,
Level level2) const override;
bool levelLess(Level level1,
Level level2) const override;
void incrLevel(Level &level) const override;
};
class BfsBkwdIterator : public BfsIterator
{
public:
BfsBkwdIterator(BfsIndex bfs_index,
SearchPred *search_pred,
StaState *sta);
~BfsBkwdIterator() override;
void enqueueAdjacentVertices(Vertex *vertex) override;
void enqueueAdjacentVertices(Vertex *vertex,
const Mode *mode) override;
using BfsIterator::enqueueAdjacentVertices;
void enqueueFanin(Vertex *vertex);
void enqueueFanin(Vertex *vertex,
const Mode *mode);
protected:
void enqueueFanin(Vertex *vertex,
SearchPred *search_pred);
bool levelLessOrEqual(Level level1,
Level level2) const override;
bool levelLess(Level level1,
Level level2) const override;
void incrLevel(Level &level) const override;
};
} // namespace sta