2021-05-21 13:34:27 +00:00
|
|
|
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
|
|
|
//*************************************************************************
|
|
|
|
// DESCRIPTION: Verilator: Hash calculation
|
|
|
|
//
|
|
|
|
// Code available from: https://verilator.org
|
|
|
|
//
|
|
|
|
//*************************************************************************
|
|
|
|
//
|
2022-01-01 13:26:40 +00:00
|
|
|
// Copyright 2003-2022 by Wilson Snyder. This program is free software; you
|
2021-05-21 13:34:27 +00:00
|
|
|
// can redistribute it and/or modify it under the terms of either the GNU
|
|
|
|
// Lesser General Public License Version 3 or the Perl Artistic License
|
|
|
|
// Version 2.0.
|
|
|
|
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
|
|
|
//
|
|
|
|
//*************************************************************************
|
|
|
|
|
|
|
|
#include "V3Hash.h"
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
#include <iomanip>
|
2021-06-21 14:32:58 +00:00
|
|
|
#include <iostream>
|
2021-08-11 15:22:52 +00:00
|
|
|
#include <sstream>
|
2021-05-21 13:34:27 +00:00
|
|
|
|
|
|
|
V3Hash::V3Hash(const std::string& val)
|
|
|
|
: m_value{static_cast<uint32_t>(std::hash<std::string>{}(val))} {}
|
|
|
|
|
|
|
|
std::ostream& operator<<(std::ostream& os, const V3Hash& rhs) {
|
2021-08-11 15:22:52 +00:00
|
|
|
return os << 'h' << std::hex << std::setw(8) << std::setfill('0') << rhs.value();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string V3Hash::toString() const {
|
|
|
|
std::ostringstream os;
|
|
|
|
os << *this;
|
|
|
|
return os.str();
|
2021-05-21 13:34:27 +00:00
|
|
|
}
|