Add a less operator to BddPortVarMap (#258)

bdd_port_var_map_, of type BddPortVarMap, is iterated over in
Power::evalBddActivity.  Previously the map used pointer comparison so
the iteration order was non-deterministic.  The computed density was
therefore non-deterministic due to the non-associativity of
floating-point addition.

Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
This commit is contained in:
Matt Liberty 2025-07-13 17:59:51 +00:00 committed by GitHub
parent fa70c6cf2b
commit 06f94cafd8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 1 deletions

View File

@ -34,7 +34,7 @@ struct DdManager;
namespace sta {
typedef std::map<const LibertyPort*, DdNode*> BddPortVarMap;
typedef std::map<const LibertyPort*, DdNode*, LibertyPortLess> BddPortVarMap;
typedef std::map<unsigned, const LibertyPort*> BddVarIdxPortMap;
class Bdd : public StaState

View File

@ -145,6 +145,12 @@ enum class TableAxisVariable {
enum class PathType { clk, data, clk_and_data };
const int path_type_count = 2;
class LibertyPortLess
{
public:
bool operator()(const LibertyPort *port1, const LibertyPort *port2) const;
};
class LibertyPortNameLess
{
public:

View File

@ -2833,6 +2833,13 @@ sortByName(const LibertyPortSet *set)
return ports;
}
bool
LibertyPortLess::operator()(const LibertyPort *port1,
const LibertyPort *port2) const
{
return LibertyPort::less(port1, port2);
}
bool
LibertyPortNameLess::operator()(const LibertyPort *port1,
const LibertyPort *port2) const