2012-04-13 01:08:20 +00:00
|
|
|
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
2006-08-26 11:35:28 +00:00
|
|
|
//*************************************************************************
|
|
|
|
// DESCRIPTION: Verilator: Graph algorithm base class
|
|
|
|
//
|
2019-11-08 03:33:59 +00:00
|
|
|
// Code available from: https://verilator.org
|
2006-08-26 11:35:28 +00:00
|
|
|
//
|
|
|
|
//*************************************************************************
|
|
|
|
//
|
2020-03-21 15:24:24 +00:00
|
|
|
// Copyright 2003-2020 by Wilson Snyder. This program is free software; you
|
|
|
|
// can redistribute it and/or modify it under the terms of either the GNU
|
2009-05-04 21:07:57 +00:00
|
|
|
// Lesser General Public License Version 3 or the Perl Artistic License
|
|
|
|
// Version 2.0.
|
2020-03-21 15:24:24 +00:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
2006-08-26 11:35:28 +00:00
|
|
|
//
|
|
|
|
//*************************************************************************
|
2019-10-05 00:17:11 +00:00
|
|
|
|
2006-08-26 11:35:28 +00:00
|
|
|
#ifndef _V3GRAPHALG_H_
|
|
|
|
#define _V3GRAPHALG_H_ 1
|
2018-10-14 17:43:24 +00:00
|
|
|
|
2006-12-18 19:20:45 +00:00
|
|
|
#include "config_build.h"
|
|
|
|
#include "verilatedos.h"
|
2006-08-26 11:35:28 +00:00
|
|
|
|
|
|
|
#include "V3Global.h"
|
|
|
|
#include "V3Graph.h"
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
// Algorithms - common class
|
|
|
|
// For internal use, most graph algorithms use this as a base class
|
|
|
|
|
2018-07-10 01:32:10 +00:00
|
|
|
template <class T_Graph = V3Graph> // Or sometimes const V3Graph
|
2006-08-26 11:35:28 +00:00
|
|
|
class GraphAlg {
|
|
|
|
protected:
|
2018-07-10 01:32:10 +00:00
|
|
|
T_Graph* m_graphp; // Graph we're operating upon
|
2018-07-09 23:15:46 +00:00
|
|
|
V3EdgeFuncP m_edgeFuncp; // Function that says we follow this edge
|
|
|
|
// CONSTRUCTORS
|
2018-07-10 01:32:10 +00:00
|
|
|
GraphAlg(T_Graph* graphp, V3EdgeFuncP edgeFuncp)
|
2020-03-16 03:20:33 +00:00
|
|
|
: m_graphp(graphp)
|
|
|
|
, m_edgeFuncp(edgeFuncp) {}
|
2018-07-09 23:15:46 +00:00
|
|
|
~GraphAlg() {}
|
|
|
|
// METHODS
|
2006-08-26 11:35:28 +00:00
|
|
|
inline bool followEdge(V3GraphEdge* edgep) {
|
2018-07-09 23:15:46 +00:00
|
|
|
return (edgep->weight() && (m_edgeFuncp)(edgep));
|
2006-08-26 11:35:28 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
2019-05-19 20:13:13 +00:00
|
|
|
#endif // Guard
|