diff --git a/include/verilated_imp.h b/include/verilated_imp.h index a844a613b..da8e50a10 100644 --- a/include/verilated_imp.h +++ b/include/verilated_imp.h @@ -409,7 +409,7 @@ public: // But only for verilated*.cpp static void fdDelete(IData fdi) VL_MT_SAFE { IData idx = VL_MASK_I(31) & fdi; VerilatedLockGuard lock(s_s.m_fdMutex); - if (VL_UNLIKELY(!(fdi & (1ULL<<31)) || idx >= s_s.m_fdps.size())) return; + if (VL_UNLIKELY(!(fdi & (VL_ULL(1) << 31)) || idx >= s_s.m_fdps.size())) return; if (VL_UNLIKELY(!s_s.m_fdps[idx])) return; // Already free s_s.m_fdps[idx] = NULL; s_s.m_fdFree.push_back(idx); @@ -417,7 +417,7 @@ public: // But only for verilated*.cpp static inline FILE* fdToFp(IData fdi) VL_MT_SAFE { IData idx = VL_MASK_I(31) & fdi; VerilatedLockGuard lock(s_s.m_fdMutex); // This might get slow, if it does we can cache it - if (VL_UNLIKELY(!(fdi & (1ULL<<31)) || idx >= s_s.m_fdps.size())) return NULL; + if (VL_UNLIKELY(!(fdi & (VL_ULL(1) << 31)) || idx >= s_s.m_fdps.size())) return NULL; return s_s.m_fdps[idx]; } }; diff --git a/include/verilated_vcd_c.cpp b/include/verilated_vcd_c.cpp index 8ae2256ff..ee245b665 100644 --- a/include/verilated_vcd_c.cpp +++ b/include/verilated_vcd_c.cpp @@ -708,9 +708,12 @@ void VerilatedVcd::flush_all() VL_MT_UNSAFE_ONE { //====================================================================== #ifdef VERILATED_VCD_TEST +#include + vluint32_t v1, v2, s1, s2[3]; vluint32_t tri96[3]; vluint32_t tri96__tri[3]; +vluint64_t quad96[2]; vluint8_t ch; vluint64_t timestamp = 1; double doub = 0; @@ -734,6 +737,8 @@ void vcdInit(VerilatedVcd* vcdp, void* userthis, vluint32_t code) { // Note need to add 6 for next code. vcdp->declDouble (0x1c, "doub",-1); // Note need to add 2 for next code. + vcdp->declArray(0x1e, "q2",-1, 95, 0); + // Note need to add 4 for next code. } void vcdFull(VerilatedVcd* vcdp, void* userthis, vluint32_t code) { @@ -746,6 +751,7 @@ void vcdFull(VerilatedVcd* vcdp, void* userthis, vluint32_t code) { vcdp->fullTriBus (0x12, tri96[0]&0x1f, tri96__tri[0]&0x1f, 5); vcdp->fullTriArray(0x16, tri96, tri96__tri, 96); vcdp->fullDouble(0x1c, doub); + vcdp->fullArray(0x1e, &quad96[0], 96); } void vcdChange(VerilatedVcd* vcdp, void* userthis, vluint32_t code) { @@ -758,15 +764,17 @@ void vcdChange(VerilatedVcd* vcdp, void* userthis, vluint32_t code) { vcdp->chgTriBus (0x12, tri96[0]&0x1f, tri96__tri[0]&0x1f, 5); vcdp->chgTriArray (0x16, tri96, tri96__tri, 96); vcdp->chgDouble (0x1c, doub); + vcdp->chgArray(0x1e, &quad96[0], 96); } main() { - cout<<"test: O_LARGEFILE="<(&m_sigs_oldvalp[code]))) = newval; *m_writep++='b'; for (int bit=bits-1; bit>=0; --bit) { - *m_writep++=((newval&(1ULL<=0; --bit) { - *m_writep++=((newval[(bit/32)]&(1L<<(bit&0x1f)))?'1':'0'); + *m_writep++ = 'b'; + for (int bit = bits - 1; bit >= 0; --bit) { + *m_writep++ = ((newval[(bit / 32)] & (1L << (bit & 0x1f))) ? '1' : '0'); } - *m_writep++=' '; printCode(code); *m_writep++='\n'; + *m_writep ++= ' '; printCode(code); *m_writep ++= '\n'; + bufferCheck(); + } + void fullArray(vluint32_t code, const vluint64_t* newval, int bits) { + for (int word = 0; word < (((bits - 1) / 64) + 1); ++word) { + m_sigs_oldvalp[code + word] = newval[word]; + } + *m_writep ++= 'b'; + for (int bit = bits - 1; bit >= 0; --bit) { + *m_writep++ = ((newval[(bit / 64)] & (VL_ULL(1) << (bit & 0x3f))) ? '1' : '0'); + } + *m_writep ++= ' '; printCode(code); *m_writep ++= '\n'; bufferCheck(); } void fullTriBit(vluint32_t code, const vluint32_t newval, const vluint32_t newtri) { @@ -272,8 +283,8 @@ public: (*(reinterpret_cast(&m_sigs_oldvalp[code+1]))) = newtri; *m_writep++='b'; for (int bit=bits-1; bit>=0; --bit) { - *m_writep++ = "01zz"[((newval >> bit)&1ULL) - | (((newtri >> bit)&1ULL)<<1ULL)]; + *m_writep++ = "01zz"[((newval >> bit) & VL_ULL(1)) + | (((newtri >> bit) & VL_ULL(1)) << VL_ULL(1))]; } *m_writep++=' '; printCode(code); *m_writep++='\n'; bufferCheck(); @@ -337,7 +348,7 @@ public: inline void chgQuad(vluint32_t code, const vluint64_t newval, int bits) { vluint64_t diff = (*(reinterpret_cast(&m_sigs_oldvalp[code]))) ^ newval; if (VL_UNLIKELY(diff)) { - if (VL_UNLIKELY(bits == 64 || (diff & ((1ULL << bits) - 1)))) { + if (VL_UNLIKELY(bits == 64 || (diff & ((VL_ULL(1) << bits) - 1)))) { fullQuad(code, newval, bits); } } @@ -350,6 +361,14 @@ public: } } } + inline void chgArray(vluint32_t code, const vluint64_t* newval, int bits) { + for (int word = 0; word < (((bits - 1) / 64) + 1); ++word) { + if (VL_UNLIKELY(m_sigs_oldvalp[code + word] ^ newval[word])) { + fullArray(code, newval, bits); + return; + } + } + } inline void chgTriBit(vluint32_t code, const vluint32_t newval, const vluint32_t newtri) { vluint32_t diff = ((m_sigs_oldvalp[code] ^ newval) @@ -377,7 +396,7 @@ public: vluint64_t diff = ( ((*(reinterpret_cast(&m_sigs_oldvalp[code]))) ^ newval) | ((*(reinterpret_cast(&m_sigs_oldvalp[code+1]))) ^ newtri)); if (VL_UNLIKELY(diff)) { - if (VL_UNLIKELY(bits == 64 || (diff & ((1ULL << bits) - 1)))) { + if (VL_UNLIKELY(bits == 64 || (diff & ((VL_ULL(1) << bits) - 1)))) { fullTriQuad(code, newval, newtri, bits); } }