diff --git a/Changes b/Changes index b542131da..46e14d873 100644 --- a/Changes +++ b/Changes @@ -6,6 +6,7 @@ The contributors that suggested a given feature are shown in []. Thanks! *** Fix Mac OSX 10.13.6 / LLVM 9.1 compile issues, bug1348. [Kevin Kiningham] +*** Fix MinGW compile issues, msg2636. [HyungKi Jeong] * Verilator 4.002 2018-09-16 diff --git a/src/V3Os.cpp b/src/V3Os.cpp index fc515adbe..781bc6067 100644 --- a/src/V3Os.cpp +++ b/src/V3Os.cpp @@ -188,6 +188,19 @@ void V3Os::unlinkRegexp(const string& dir, const string& regexp) { } } +//###################################################################### +// METHODS (random) + +vluint64_t V3Os::rand64(vluint64_t* statep) { + // Xoroshiro128+ algorithm + vluint64_t result = statep[0] + statep[1]; + statep[1] ^= statep[0]; + statep[0] = (((statep[0] << 55) | (statep[0] >> 9)) + ^ statep[1] ^ (statep[1] << 14)); + statep[1] = (statep[1] << 36) | (statep[1] >> 28); + return result; +} + //###################################################################### // METHODS (performance) diff --git a/src/V3Os.h b/src/V3Os.h index 85adc15b4..742614407 100644 --- a/src/V3Os.h +++ b/src/V3Os.h @@ -49,6 +49,9 @@ public: static void createDir(const string& dirname); static void unlinkRegexp(const string& dir, const string& regexp); + // METHODS (random) + static vluint64_t rand64(vluint64_t* statep); + // METHODS (performance) static uint64_t timeUsecs(); ///< Return wall time since epoch in microseconds, or 0 if not implemented static uint64_t memUsageBytes(); ///< Return memory usage in bytes, or 0 if not implemented diff --git a/src/V3Partition.cpp b/src/V3Partition.cpp index 1e449f534..ad6a1a46e 100644 --- a/src/V3Partition.cpp +++ b/src/V3Partition.cpp @@ -347,7 +347,7 @@ private: } void go() { // Generate a pseudo-random graph - uint16_t rngState[3] = { 0xdead, 0xbeef, 0xf000 }; + vluint64_t rngState[2] = {VL_ULL(0x12345678), VL_ULL(0x9abcdef0)}; // Create 50 vertices for (unsigned i = 0; i < 50; ++i) { m_vx[i] = new V3GraphVertex(&m_graph); @@ -355,8 +355,8 @@ private: // Create 250 edges at random. Edges must go from // lower-to-higher index vertices, so we get a DAG. for (unsigned i = 0; i < 250; ++i) { - unsigned idx1 = nrand48(rngState) % 50; - unsigned idx2 = nrand48(rngState) % 50; + unsigned idx1 = V3Os::rand64(rngState) % 50; + unsigned idx2 = V3Os::rand64(rngState) % 50; if (idx1 > idx2) { new V3GraphEdge(&m_graph, m_vx[idx2], m_vx[idx1], 1); } else if (idx2 > idx1) {