diff --git a/src/V3Error.h b/src/V3Error.h index 79088bee1..72790376f 100644 --- a/src/V3Error.h +++ b/src/V3Error.h @@ -24,6 +24,9 @@ #include "config_build.h" #include "verilatedos.h" +// Limited V3 headers here - this is a base class for Vlc etc +#include "V3String.h" + #include #include #include @@ -345,25 +348,4 @@ inline void v3errorEndFatal(std::ostringstream& sstr) { //---------------------------------------------------------------------- -template std::string cvtToStr(const T& t) { - std::ostringstream os; os< std::string cvtToHex(const T* tp) { - std::ostringstream os; os<(tp); return os.str(); -} - -inline uint32_t cvtToHash(const void* vp) { - // We can shove a 64 bit pointer into a 32 bit bucket - // On 32-bit systems, lower is always 0, but who cares? - union { const void* up; struct {uint32_t upper; uint32_t lower;} l;} u; - u.l.upper = 0; u.l.lower = 0; u.up = vp; - return u.l.upper^u.l.lower; -} - -inline string ucfirst(const string& text) { - string out = text; - out[0] = toupper(out[0]); - return out; -} - #endif // Guard diff --git a/src/V3Os.cpp b/src/V3Os.cpp index 97350aad4..2d892153a 100644 --- a/src/V3Os.cpp +++ b/src/V3Os.cpp @@ -21,6 +21,7 @@ #include "config_build.h" #include "verilatedos.h" +// Limited V3 headers here - this is a base class for Vlc etc #include "V3Global.h" #include "V3String.h" #include "V3Os.h" diff --git a/src/V3Os.h b/src/V3Os.h index fbe5df9d2..753a21b40 100644 --- a/src/V3Os.h +++ b/src/V3Os.h @@ -24,6 +24,7 @@ #include "config_build.h" #include "verilatedos.h" +// Limited V3 headers here - this is a base class for Vlc etc #include "V3Error.h" //============================================================================ diff --git a/src/V3String.cpp b/src/V3String.cpp index 93afb60f7..bd0761b80 100644 --- a/src/V3String.cpp +++ b/src/V3String.cpp @@ -21,7 +21,7 @@ #include "config_build.h" #include "verilatedos.h" -#include "V3Global.h" +// Limited V3 headers here - this is a base class for Vlc etc #include "V3String.h" #include "V3Error.h" diff --git a/src/V3String.h b/src/V3String.h index b192b10cb..573d93855 100644 --- a/src/V3String.h +++ b/src/V3String.h @@ -24,7 +24,35 @@ #include "config_build.h" #include "verilatedos.h" +// No V3 headers here - this is a base class for Vlc etc + #include +#include +#include + +//###################################################################### +// Global string-related functions + +template std::string cvtToStr(const T& t) { + std::ostringstream os; os< std::string cvtToHex(const T* tp) { + std::ostringstream os; os<(tp); return os.str(); +} + +inline uint32_t cvtToHash(const void* vp) { + // We can shove a 64 bit pointer into a 32 bit bucket + // On 32-bit systems, lower is always 0, but who cares? + union { const void* up; struct {uint32_t upper; uint32_t lower;} l;} u; + u.l.upper = 0; u.l.lower = 0; u.up = vp; + return u.l.upper^u.l.lower; +} + +inline string ucfirst(const string& text) { + string out = text; + out[0] = toupper(out[0]); + return out; +} //###################################################################### // VString - String manipulation