forked from github/verilator
Remove VL_ULL as ULL now in MSVC & C++11
This commit is contained in:
parent
3f66f846cd
commit
5089ac6119
@ -337,7 +337,7 @@ IData VL_RAND_RESET_I(int obits) VL_MT_SAFE {
|
||||
}
|
||||
QData VL_RAND_RESET_Q(int obits) VL_MT_SAFE {
|
||||
if (Verilated::randReset() == 0) return 0;
|
||||
QData data = VL_ULL(~0);
|
||||
QData data = ~0ULL;
|
||||
if (Verilated::randReset() != 1) { // if 2, randomize
|
||||
data = VL_RANDOM_Q(obits);
|
||||
}
|
||||
@ -394,7 +394,7 @@ WDataOutP _vl_moddiv_w(int lbits, WDataOutP owp, WDataInP lwp, WDataInP rwp,
|
||||
if (vw == 1) { // Single divisor word breaks rest of algorithm
|
||||
vluint64_t k = 0;
|
||||
for (int j = uw - 1; j >= 0; --j) {
|
||||
vluint64_t unw64 = ((k << VL_ULL(32)) + static_cast<vluint64_t>(lwp[j]));
|
||||
vluint64_t unw64 = ((k << 32ULL) + static_cast<vluint64_t>(lwp[j]));
|
||||
owp[j] = unw64 / static_cast<vluint64_t>(rwp[0]);
|
||||
k = unw64 - static_cast<vluint64_t>(owp[j]) * static_cast<vluint64_t>(rwp[0]);
|
||||
}
|
||||
@ -436,26 +436,25 @@ WDataOutP _vl_moddiv_w(int lbits, WDataOutP owp, WDataInP lwp, WDataInP rwp,
|
||||
// Main loop
|
||||
for (int j = uw - vw; j >= 0; --j) {
|
||||
// Estimate
|
||||
vluint64_t unw64 = (static_cast<vluint64_t>(un[j + vw]) << VL_ULL(32)
|
||||
vluint64_t unw64 = (static_cast<vluint64_t>(un[j + vw]) << 32ULL
|
||||
| static_cast<vluint64_t>(un[j + vw - 1]));
|
||||
vluint64_t qhat = unw64 / static_cast<vluint64_t>(vn[vw - 1]);
|
||||
vluint64_t rhat = unw64 - qhat * static_cast<vluint64_t>(vn[vw - 1]);
|
||||
|
||||
again:
|
||||
if (qhat >= VL_ULL(0x100000000)
|
||||
|| ((qhat * vn[vw - 2]) > ((rhat << VL_ULL(32)) + un[j + vw - 2]))) {
|
||||
if (qhat >= 0x100000000ULL || ((qhat * vn[vw - 2]) > ((rhat << 32ULL) + un[j + vw - 2]))) {
|
||||
qhat = qhat - 1;
|
||||
rhat = rhat + vn[vw - 1];
|
||||
if (rhat < VL_ULL(0x100000000)) goto again;
|
||||
if (rhat < 0x100000000ULL) goto again;
|
||||
}
|
||||
|
||||
vlsint64_t t = 0; // Must be signed
|
||||
vluint64_t k = 0;
|
||||
for (int i = 0; i < vw; ++i) {
|
||||
vluint64_t p = qhat * vn[i]; // Multiply by estimate
|
||||
t = un[i + j] - k - (p & VL_ULL(0xFFFFFFFF)); // Subtract
|
||||
t = un[i + j] - k - (p & 0xFFFFFFFFULL); // Subtract
|
||||
un[i + j] = t;
|
||||
k = (p >> VL_ULL(32)) - (t >> VL_ULL(32));
|
||||
k = (p >> 32ULL) - (t >> 32ULL);
|
||||
}
|
||||
t = un[j + vw] - k;
|
||||
un[j + vw] = t;
|
||||
@ -468,7 +467,7 @@ WDataOutP _vl_moddiv_w(int lbits, WDataOutP owp, WDataInP lwp, WDataInP rwp,
|
||||
for (int i = 0; i < vw; ++i) {
|
||||
t = static_cast<vluint64_t>(un[i + j]) + static_cast<vluint64_t>(vn[i]) + k;
|
||||
un[i + j] = t;
|
||||
k = t >> VL_ULL(32);
|
||||
k = t >> 32ULL;
|
||||
}
|
||||
un[j + vw] = un[j + vw] + k;
|
||||
}
|
||||
@ -519,7 +518,7 @@ QData VL_POW_QQW(int, int, int rbits, QData lhs, WDataInP rwp) VL_MT_SAFE {
|
||||
// Skip check for rhs == 0, as short-circuit doesn't save time
|
||||
if (VL_UNLIKELY(lhs == 0)) return 0;
|
||||
QData power = lhs;
|
||||
QData out = VL_ULL(1);
|
||||
QData out = 1ULL;
|
||||
for (int bit = 0; bit < rbits; ++bit) {
|
||||
if (bit > 0) power = power * power;
|
||||
if (VL_BITISSET_W(rwp, bit)) out *= power;
|
||||
@ -1050,7 +1049,7 @@ IData _vl_vsscanf(FILE* fp, // If a fscanf
|
||||
// Note LSBs are preserved if there's an overflow
|
||||
const int obits = inIgnore ? 0 : va_arg(ap, int);
|
||||
WData qowp[VL_WQ_WORDS_E];
|
||||
VL_SET_WQ(qowp, VL_ULL(0));
|
||||
VL_SET_WQ(qowp, 0ULL);
|
||||
WDataOutP owp = qowp;
|
||||
if (obits > VL_QUADSIZE) owp = va_arg(ap, WDataOutP);
|
||||
for (int i = 0; i < VL_WORDS_I(obits); ++i) owp[i] = 0;
|
||||
@ -1815,7 +1814,7 @@ bool VlReadMem::get(QData& addrr, std::string& valuer) {
|
||||
lastc = c;
|
||||
}
|
||||
|
||||
if (VL_UNLIKELY(m_end != ~VL_ULL(0) && m_addr <= m_end)) {
|
||||
if (VL_UNLIKELY(m_end != ~0ULL && m_addr <= m_end)) {
|
||||
VL_FATAL_MT(m_filename.c_str(), m_linenum, "",
|
||||
"$readmem file ended before specified final address (IEEE 2017 21.4)");
|
||||
}
|
||||
@ -1823,7 +1822,7 @@ bool VlReadMem::get(QData& addrr, std::string& valuer) {
|
||||
return false; // EOF
|
||||
}
|
||||
void VlReadMem::setData(void* valuep, const std::string& rhs) {
|
||||
QData shift = m_hex ? VL_ULL(4) : VL_ULL(1);
|
||||
QData shift = m_hex ? 4ULL : 1ULL;
|
||||
bool innum = false;
|
||||
// Shift value in
|
||||
for (std::string::const_iterator it = rhs.begin(); it != rhs.end(); ++it) {
|
||||
|
@ -707,7 +707,7 @@ extern const char* vl_mc_scan_plusargs(const char* prefixp); // PLIish
|
||||
|
||||
/// Return true if data[bit] set; not 0/1 return, but 0/non-zero return.
|
||||
#define VL_BITISSET_I(data, bit) ((data) & (VL_UL(1) << VL_BITBIT_I(bit)))
|
||||
#define VL_BITISSET_Q(data, bit) ((data) & (VL_ULL(1) << VL_BITBIT_Q(bit)))
|
||||
#define VL_BITISSET_Q(data, bit) ((data) & (1ULL << VL_BITBIT_Q(bit)))
|
||||
#define VL_BITISSET_E(data, bit) ((data) & (VL_EUL(1) << VL_BITBIT_E(bit)))
|
||||
#define VL_BITISSET_W(data, bit) ((data)[VL_BITWORD_E(bit)] & (VL_EUL(1) << VL_BITBIT_E(bit)))
|
||||
#define VL_BITISSETLIMIT_W(data, width, bit) (((bit) < (width)) && VL_BITISSET_W(data, bit))
|
||||
@ -730,7 +730,7 @@ extern const char* vl_mc_scan_plusargs(const char* prefixp); // PLIish
|
||||
#define VL_SET_QW(lwp) \
|
||||
((static_cast<QData>((lwp)[0])) \
|
||||
| (static_cast<QData>((lwp)[1]) << (static_cast<QData>(VL_EDATASIZE))))
|
||||
#define _VL_SET_QII(ld, rd) ((static_cast<QData>(ld) << VL_ULL(32)) | static_cast<QData>(rd))
|
||||
#define _VL_SET_QII(ld, rd) ((static_cast<QData>(ld) << 32ULL) | static_cast<QData>(rd))
|
||||
|
||||
/// Return FILE* from IData
|
||||
extern FILE* VL_CVT_I_FP(IData lhs) VL_MT_SAFE;
|
||||
@ -776,7 +776,7 @@ static inline IData VL_RTOI_I_D(double lhs) VL_PURE {
|
||||
// Sign extend such that if MSB set, we get ffff_ffff, else 0s
|
||||
// (Requires clean input)
|
||||
#define VL_SIGN_I(nbits, lhs) ((lhs) >> VL_BITBIT_I((nbits)-VL_UL(1)))
|
||||
#define VL_SIGN_Q(nbits, lhs) ((lhs) >> VL_BITBIT_Q((nbits)-VL_ULL(1)))
|
||||
#define VL_SIGN_Q(nbits, lhs) ((lhs) >> VL_BITBIT_Q((nbits)-1ULL))
|
||||
#define VL_SIGN_E(nbits, lhs) ((lhs) >> VL_BITBIT_E((nbits)-VL_EUL(1)))
|
||||
#define VL_SIGN_W(nbits, rwp) \
|
||||
((rwp)[VL_BITWORD_E((nbits)-VL_EUL(1))] >> VL_BITBIT_E((nbits)-VL_EUL(1)))
|
||||
@ -788,7 +788,7 @@ static inline IData VL_EXTENDSIGN_I(int lbits, IData lhs) VL_PURE {
|
||||
return (-((lhs) & (VL_UL(1) << (lbits - 1))));
|
||||
}
|
||||
static inline QData VL_EXTENDSIGN_Q(int lbits, QData lhs) VL_PURE {
|
||||
return (-((lhs) & (VL_ULL(1) << (lbits - 1))));
|
||||
return (-((lhs) & (1ULL << (lbits - 1))));
|
||||
}
|
||||
|
||||
// Debugging prints
|
||||
@ -926,8 +926,7 @@ static inline void VL_ASSIGNBIT_II(int, int bit, IData& lhsr, IData rhs) VL_PURE
|
||||
lhsr = ((lhsr & ~(VL_UL(1) << VL_BITBIT_I(bit))) | (rhs << VL_BITBIT_I(bit)));
|
||||
}
|
||||
static inline void VL_ASSIGNBIT_QI(int, int bit, QData& lhsr, QData rhs) VL_PURE {
|
||||
lhsr = ((lhsr & ~(VL_ULL(1) << VL_BITBIT_Q(bit)))
|
||||
| (static_cast<QData>(rhs) << VL_BITBIT_Q(bit)));
|
||||
lhsr = ((lhsr & ~(1ULL << VL_BITBIT_Q(bit))) | (static_cast<QData>(rhs) << VL_BITBIT_Q(bit)));
|
||||
}
|
||||
static inline void VL_ASSIGNBIT_WI(int, int bit, WDataOutP owp, IData rhs) VL_MT_SAFE {
|
||||
EData orig = owp[VL_BITWORD_E(bit)];
|
||||
@ -945,7 +944,7 @@ static inline void VL_ASSIGNBIT_IO(int, int bit, IData& lhsr, IData) VL_PURE {
|
||||
lhsr = (lhsr | (VL_UL(1) << VL_BITBIT_I(bit)));
|
||||
}
|
||||
static inline void VL_ASSIGNBIT_QO(int, int bit, QData& lhsr, IData) VL_PURE {
|
||||
lhsr = (lhsr | (VL_ULL(1) << VL_BITBIT_Q(bit)));
|
||||
lhsr = (lhsr | (1ULL << VL_BITBIT_Q(bit)));
|
||||
}
|
||||
static inline void VL_ASSIGNBIT_WO(int, int bit, WDataOutP owp, IData) VL_MT_SAFE {
|
||||
EData orig = owp[VL_BITWORD_E(bit)];
|
||||
@ -1287,7 +1286,7 @@ static inline IData VL_CLOG2_Q(QData lhs) VL_PURE {
|
||||
if (VL_UNLIKELY(!lhs)) return 0;
|
||||
lhs--;
|
||||
int shifts = 0;
|
||||
for (; lhs != 0; ++shifts) lhs = lhs >> VL_ULL(1);
|
||||
for (; lhs != 0; ++shifts) lhs = lhs >> 1ULL;
|
||||
return shifts;
|
||||
}
|
||||
static inline IData VL_CLOG2_W(int words, WDataInP lwp) VL_MT_SAFE {
|
||||
@ -1485,8 +1484,8 @@ static inline WDataOutP VL_ADD_W(int words, WDataOutP owp, WDataInP lwp, WDataIn
|
||||
QData carry = 0;
|
||||
for (int i = 0; i < words; ++i) {
|
||||
carry = carry + static_cast<QData>(lwp[i]) + static_cast<QData>(rwp[i]);
|
||||
owp[i] = (carry & VL_ULL(0xffffffff));
|
||||
carry = (carry >> VL_ULL(32)) & VL_ULL(0xffffffff);
|
||||
owp[i] = (carry & 0xffffffffULL);
|
||||
carry = (carry >> 32ULL) & 0xffffffffULL;
|
||||
}
|
||||
// Last output word is dirty
|
||||
return owp;
|
||||
@ -1498,8 +1497,8 @@ static inline WDataOutP VL_SUB_W(int words, WDataOutP owp, WDataInP lwp, WDataIn
|
||||
carry = (carry + static_cast<QData>(lwp[i])
|
||||
+ static_cast<QData>(static_cast<IData>(~rwp[i])));
|
||||
if (i == 0) ++carry; // Negation of rwp
|
||||
owp[i] = (carry & VL_ULL(0xffffffff));
|
||||
carry = (carry >> VL_ULL(32)) & VL_ULL(0xffffffff);
|
||||
owp[i] = (carry & 0xffffffffULL);
|
||||
carry = (carry >> 32ULL) & 0xffffffffULL;
|
||||
}
|
||||
// Last output word is dirty
|
||||
return owp;
|
||||
@ -1512,8 +1511,8 @@ static inline WDataOutP VL_MUL_W(int words, WDataOutP owp, WDataInP lwp, WDataIn
|
||||
QData mul = static_cast<QData>(lwp[lword]) * static_cast<QData>(rwp[rword]);
|
||||
for (int qword = lword + rword; qword < words; ++qword) {
|
||||
mul += static_cast<QData>(owp[qword]);
|
||||
owp[qword] = (mul & VL_ULL(0xffffffff));
|
||||
mul = (mul >> VL_ULL(32)) & VL_ULL(0xffffffff);
|
||||
owp[qword] = (mul & 0xffffffffULL);
|
||||
mul = (mul >> 32ULL) & 0xffffffffULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1561,8 +1560,8 @@ static inline WDataOutP VL_MULS_WWW(int, int lbits, int, WDataOutP owp, WDataInP
|
||||
for (int i = 0; i < words; ++i) {
|
||||
carry = carry + static_cast<QData>(static_cast<IData>(~owp[i]));
|
||||
if (i == 0) ++carry; // Negation of temp2
|
||||
owp[i] = (carry & VL_ULL(0xffffffff));
|
||||
carry = (carry >> VL_ULL(32)) & VL_ULL(0xffffffff);
|
||||
owp[i] = (carry & 0xffffffffULL);
|
||||
carry = (carry >> 32ULL) & 0xffffffffULL;
|
||||
}
|
||||
// Not needed: owp[words-1] |= 1<<VL_BITBIT_E(lbits-1); // Set sign bit
|
||||
}
|
||||
@ -1653,7 +1652,7 @@ static inline IData VL_POW_III(int, int, int rbits, IData lhs, IData rhs) VL_PUR
|
||||
IData out = 1;
|
||||
for (int i = 0; i < rbits; ++i) {
|
||||
if (i > 0) power = power * power;
|
||||
if (rhs & (VL_ULL(1) << i)) out *= power;
|
||||
if (rhs & (1ULL << i)) out *= power;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@ -1661,10 +1660,10 @@ static inline QData VL_POW_QQQ(int, int, int rbits, QData lhs, QData rhs) VL_PUR
|
||||
if (VL_UNLIKELY(rhs == 0)) return 1;
|
||||
if (VL_UNLIKELY(lhs == 0)) return 0;
|
||||
QData power = lhs;
|
||||
QData out = VL_ULL(1);
|
||||
QData out = 1ULL;
|
||||
for (int i = 0; i < rbits; ++i) {
|
||||
if (i > 0) power = power * power;
|
||||
if (rhs & (VL_ULL(1) << i)) out *= power;
|
||||
if (rhs & (1ULL << i)) out *= power;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@ -1922,24 +1921,24 @@ static inline QData VL_STREAML_FAST_QQI(int, int lbits, int, QData ld, IData rd_
|
||||
vluint32_t lbitsFloor = lbits & ~VL_MASK_I(rd_log2);
|
||||
vluint32_t lbitsRem = lbits - lbitsFloor;
|
||||
QData msbMask = VL_MASK_Q(lbitsRem) << lbitsFloor;
|
||||
ret = (ret & ~msbMask) | ((ret & msbMask) << ((VL_ULL(1) << rd_log2) - lbitsRem));
|
||||
ret = (ret & ~msbMask) | ((ret & msbMask) << ((1ULL << rd_log2) - lbitsRem));
|
||||
}
|
||||
switch (rd_log2) {
|
||||
case 0:
|
||||
ret = (((ret >> 1) & VL_ULL(0x5555555555555555))
|
||||
| ((ret & VL_ULL(0x5555555555555555)) << 1)); // FALLTHRU
|
||||
ret = (((ret >> 1) & 0x5555555555555555ULL)
|
||||
| ((ret & 0x5555555555555555ULL) << 1)); // FALLTHRU
|
||||
case 1:
|
||||
ret = (((ret >> 2) & VL_ULL(0x3333333333333333))
|
||||
| ((ret & VL_ULL(0x3333333333333333)) << 2)); // FALLTHRU
|
||||
ret = (((ret >> 2) & 0x3333333333333333ULL)
|
||||
| ((ret & 0x3333333333333333ULL) << 2)); // FALLTHRU
|
||||
case 2:
|
||||
ret = (((ret >> 4) & VL_ULL(0x0f0f0f0f0f0f0f0f))
|
||||
| ((ret & VL_ULL(0x0f0f0f0f0f0f0f0f)) << 4)); // FALLTHRU
|
||||
ret = (((ret >> 4) & 0x0f0f0f0f0f0f0f0fULL)
|
||||
| ((ret & 0x0f0f0f0f0f0f0f0fULL) << 4)); // FALLTHRU
|
||||
case 3:
|
||||
ret = (((ret >> 8) & VL_ULL(0x00ff00ff00ff00ff))
|
||||
| ((ret & VL_ULL(0x00ff00ff00ff00ff)) << 8)); // FALLTHRU
|
||||
ret = (((ret >> 8) & 0x00ff00ff00ff00ffULL)
|
||||
| ((ret & 0x00ff00ff00ff00ffULL) << 8)); // FALLTHRU
|
||||
case 4:
|
||||
ret = (((ret >> 16) & VL_ULL(0x0000ffff0000ffff))
|
||||
| ((ret & VL_ULL(0x0000ffff0000ffff)) << 16)); // FALLTHRU
|
||||
ret = (((ret >> 16) & 0x0000ffff0000ffffULL)
|
||||
| ((ret & 0x0000ffff0000ffffULL) << 16)); // FALLTHRU
|
||||
case 5: ret = ((ret >> 32) | (ret << 32));
|
||||
}
|
||||
return ret >> (VL_QUADSIZE - lbits);
|
||||
@ -2390,8 +2389,8 @@ static inline QData VL_RTOIROUND_Q_D(int, double lhs) VL_PURE {
|
||||
lhs = VL_ROUND(lhs);
|
||||
if (lhs == 0.0) return 0;
|
||||
QData q = VL_CVT_Q_D(lhs);
|
||||
int lsb = static_cast<int>((q >> VL_ULL(52)) & VL_MASK_Q(11)) - 1023 - 52;
|
||||
vluint64_t mantissa = (q & VL_MASK_Q(52)) | (VL_ULL(1) << 52);
|
||||
int lsb = static_cast<int>((q >> 52ULL) & VL_MASK_Q(11)) - 1023 - 52;
|
||||
vluint64_t mantissa = (q & VL_MASK_Q(52)) | (1ULL << 52);
|
||||
vluint64_t out = 0;
|
||||
if (lsb < 0) {
|
||||
out = mantissa >> -lsb;
|
||||
@ -2411,8 +2410,8 @@ static inline WDataOutP VL_RTOIROUND_W_D(int obits, WDataOutP owp, double lhs) V
|
||||
VL_ZERO_W(obits, owp);
|
||||
if (lhs == 0.0) return owp;
|
||||
QData q = VL_CVT_Q_D(lhs);
|
||||
int lsb = static_cast<int>((q >> VL_ULL(52)) & VL_MASK_Q(11)) - 1023 - 52;
|
||||
vluint64_t mantissa = (q & VL_MASK_Q(52)) | (VL_ULL(1) << 52);
|
||||
int lsb = static_cast<int>((q >> 52ULL) & VL_MASK_Q(11)) - 1023 - 52;
|
||||
vluint64_t mantissa = (q & VL_MASK_Q(52)) | (1ULL << 52);
|
||||
if (lsb < 0) {
|
||||
VL_SET_WQ(owp, mantissa >> -lsb);
|
||||
} else if (lsb < obits) {
|
||||
|
@ -416,7 +416,7 @@ static svBit _vl_svGetBitArrElem(const svOpenArrayHandle s, int nargs, int indx1
|
||||
case VLVT_UINT16: return (*(reinterpret_cast<SData*>(datap)) >> lsb) & 1;
|
||||
case VLVT_UINT32: return (*(reinterpret_cast<IData*>(datap)) >> lsb) & 1;
|
||||
case VLVT_UINT64:
|
||||
return (*(reinterpret_cast<QData*>(datap)) >> static_cast<QData>(lsb)) & VL_ULL(1);
|
||||
return (*(reinterpret_cast<QData*>(datap)) >> static_cast<QData>(lsb)) & 1ULL;
|
||||
case VLVT_WDATA: {
|
||||
WDataOutP wdatap = (reinterpret_cast<WDataOutP>(datap));
|
||||
return VL_BITRSHIFT_W(wdatap, lsb) & 1;
|
||||
|
@ -225,8 +225,7 @@ public:
|
||||
return end();
|
||||
}
|
||||
const_iterator end() const {
|
||||
return iterator(VL_ULL(0xFFFFFFFFFFFFFFFF), const_cast<Bucket&>(m_emptyBucket).begin(),
|
||||
this);
|
||||
return iterator(0xFFFFFFFFFFFFFFFFULL, const_cast<Bucket&>(m_emptyBucket).begin(), this);
|
||||
}
|
||||
|
||||
bool empty() const { return m_numElements == 0; }
|
||||
@ -249,8 +248,7 @@ public:
|
||||
// function further. This permits the use of very fast client
|
||||
// hash funcs (like just returning the int or pointer value as
|
||||
// is!) and tolerates crappy client hash functions pretty well.
|
||||
size_t mult
|
||||
= hashVal * ((sizeof(size_t) == 8) ? VL_ULL(11400714819323198485) : 2654435769lu);
|
||||
size_t mult = hashVal * ((sizeof(size_t) == 8) ? 11400714819323198485ULL : 2654435769lu);
|
||||
size_t result = (mult >> (((sizeof(size_t) == 8) ? 64 : 32) - log2Buckets));
|
||||
return result;
|
||||
}
|
||||
@ -339,7 +337,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
size_t numBuckets() const { return (VL_ULL(1) << m_log2Buckets); }
|
||||
size_t numBuckets() const { return (1ULL << m_log2Buckets); }
|
||||
|
||||
Bucket* getBucket(size_t idx) {
|
||||
initBuckets();
|
||||
@ -372,7 +370,7 @@ private:
|
||||
new_log2Buckets = m_log2Buckets - 2;
|
||||
}
|
||||
|
||||
size_t new_num_buckets = VL_ULL(1) << new_log2Buckets;
|
||||
size_t new_num_buckets = 1ULL << new_log2Buckets;
|
||||
Bucket* new_bucketsp = new Bucket[new_num_buckets];
|
||||
|
||||
for (size_t i = 0; i < numBuckets(); i++) {
|
||||
|
@ -732,7 +732,7 @@ void VerilatedVcd::fullQuad(vluint32_t code, const vluint64_t newval, int bits)
|
||||
(*(reinterpret_cast<vluint64_t*>(oldp(code)))) = newval;
|
||||
*m_writep++ = 'b';
|
||||
for (int bit = bits - 1; bit >= 0; --bit) {
|
||||
*m_writep++ = ((newval & (VL_ULL(1) << bit)) ? '1' : '0');
|
||||
*m_writep++ = ((newval & (1ULL << bit)) ? '1' : '0');
|
||||
}
|
||||
*m_writep++ = ' ';
|
||||
m_writep = writeCode(m_writep, code);
|
||||
@ -754,7 +754,7 @@ void VerilatedVcd::fullArray(vluint32_t code, const vluint64_t* newval, int bits
|
||||
for (int word = 0; word < (((bits - 1) / 64) + 1); ++word) { oldp(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++ = ((newval[(bit / 64)] & (1ULL << (bit & 0x3f))) ? '1' : '0');
|
||||
}
|
||||
*m_writep++ = ' ';
|
||||
m_writep = writeCode(m_writep, code);
|
||||
@ -788,8 +788,7 @@ void VerilatedVcd::fullTriQuad(vluint32_t code, const vluint64_t newval, const v
|
||||
(*(reinterpret_cast<vluint64_t*>(oldp(code + 1)))) = newtri;
|
||||
*m_writep++ = 'b';
|
||||
for (int bit = bits - 1; bit >= 0; --bit) {
|
||||
*m_writep++
|
||||
= "01zz"[((newval >> bit) & VL_ULL(1)) | (((newtri >> bit) & VL_ULL(1)) << VL_ULL(1))];
|
||||
*m_writep++ = "01zz"[((newval >> bit) & 1ULL) | (((newtri >> bit) & 1ULL) << 1ULL)];
|
||||
}
|
||||
*m_writep++ = ' ';
|
||||
m_writep = writeCode(m_writep, code);
|
||||
@ -935,8 +934,8 @@ void vcdTestMain(const char* filenamep) {
|
||||
quad96[1] = 0; quad96[0] = ~0;
|
||||
doub = -1.66e13;
|
||||
flo = 0.123f;
|
||||
tquad = VL_ULL(0x00ff00ff00ff00ff);
|
||||
tquad__tri = VL_ULL(0x0000fffff0000ffff);
|
||||
tquad = 0x00ff00ff00ff00ffULL;
|
||||
tquad__tri = 0x0000fffff0000ffffULL;
|
||||
vcdp->dump(++timestamp);
|
||||
ch = 2;
|
||||
tri96[2] = ~4; tri96[1] = ~2; tri96[0] = ~1;
|
||||
@ -944,8 +943,8 @@ void vcdTestMain(const char* filenamep) {
|
||||
vcdp->dump(++timestamp);
|
||||
vcdp->dump(++timestamp);
|
||||
# ifdef VERILATED_VCD_TEST_64BIT
|
||||
vluint64_t bytesPerDump = VL_ULL(15);
|
||||
for (vluint64_t i = 0; i < ((VL_ULL(1) << 32) / bytesPerDump); i++) {
|
||||
vluint64_t bytesPerDump = 15ULL;
|
||||
for (vluint64_t i = 0; i < ((1ULL << 32) / bytesPerDump); i++) {
|
||||
v1 = i;
|
||||
vcdp->dump(++timestamp);
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ public:
|
||||
inline void chgQuad(vluint32_t code, const vluint64_t newval, int bits) {
|
||||
vluint64_t diff = (*(reinterpret_cast<vluint64_t*>(oldp(code)))) ^ newval;
|
||||
if (VL_UNLIKELY(diff)) {
|
||||
if (VL_UNLIKELY(bits == 64 || (diff & ((VL_ULL(1) << bits) - 1)))) {
|
||||
if (VL_UNLIKELY(bits == 64 || (diff & ((1ULL << bits) - 1)))) {
|
||||
fullQuad(code, newval, bits);
|
||||
}
|
||||
}
|
||||
@ -292,7 +292,7 @@ public:
|
||||
vluint64_t diff = (((*(reinterpret_cast<vluint64_t*>(oldp(code)))) ^ newval)
|
||||
| ((*(reinterpret_cast<vluint64_t*>(oldp(code + 1)))) ^ newtri));
|
||||
if (VL_UNLIKELY(diff)) {
|
||||
if (VL_UNLIKELY(bits == 64 || (diff & ((VL_ULL(1) << bits) - 1)))) {
|
||||
if (VL_UNLIKELY(bits == 64 || (diff & ((1ULL << bits) - 1)))) {
|
||||
fullTriQuad(code, newval, newtri, bits);
|
||||
}
|
||||
}
|
||||
|
@ -450,7 +450,7 @@ public:
|
||||
static QData cbNextDeadline() {
|
||||
VpioTimedCbs::const_iterator it = s_s.m_timedCbs.begin();
|
||||
if (VL_LIKELY(it != s_s.m_timedCbs.end())) return it->first;
|
||||
return ~VL_ULL(0); // maxquad
|
||||
return ~0ULL; // maxquad
|
||||
}
|
||||
static bool callCbs(vluint32_t reason) VL_MT_UNSAFE_ONE {
|
||||
VpioCbList& cbObjList = s_s.m_cbObjLists[reason];
|
||||
@ -1361,7 +1361,7 @@ void vpi_get_value(vpiHandle object, p_vpi_value value_p) {
|
||||
}
|
||||
case VLVT_UINT64: {
|
||||
QData data = *(reinterpret_cast<QData*>(vop->varDatap()));
|
||||
out[1].aval = static_cast<IData>(data >> VL_ULL(32));
|
||||
out[1].aval = static_cast<IData>(data >> 32ULL);
|
||||
out[1].bval = 0;
|
||||
out[0].aval = static_cast<IData>(data);
|
||||
out[0].bval = 0;
|
||||
|
@ -144,14 +144,7 @@
|
||||
#define VL_MT_UNSAFE_ONE ///< Comment tag that function is not threadsafe when VL_THREADED,
|
||||
///< protected to make sure single-caller
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define VL_ULL(c) (c##ULL) ///< Add appropriate suffix to 64-bit constant
|
||||
// Was "(c##ui64)". C++11 has standardized on ULL, and MSVC now supports this.
|
||||
// We propose to no longer require using this macro no sooner than June 2020.
|
||||
// File an issue ASAP if this breaks anything.
|
||||
#else
|
||||
# define VL_ULL(c) (c##ULL) ///< Add appropriate suffix to 64-bit constant
|
||||
#endif
|
||||
#define VL_ULL(c) (c##ULL) ///< Add appropriate suffix to 64-bit constant (deprecated)
|
||||
|
||||
// This is not necessarily the same as #UL, depending on what the IData typedef is.
|
||||
#define VL_UL(c) (static_cast<IData>(c##UL)) ///< Add appropriate suffix to 32-bit constant
|
||||
@ -401,7 +394,7 @@ typedef unsigned long long vluint64_t; ///< 64-bit unsigned type
|
||||
#define VL_MASK_I(nbits) (((nbits) & VL_SIZEBITS_I) ? ((1U << ((nbits) & VL_SIZEBITS_I)) - 1) : ~0)
|
||||
/// Mask for quads with 1's where relevant bits are (0=all bits)
|
||||
#define VL_MASK_Q(nbits) \
|
||||
(((nbits) & VL_SIZEBITS_Q) ? ((VL_ULL(1) << ((nbits) & VL_SIZEBITS_Q)) - VL_ULL(1)) : VL_ULL(~0))
|
||||
(((nbits) & VL_SIZEBITS_Q) ? ((1ULL << ((nbits) & VL_SIZEBITS_Q)) - 1ULL) : ~0ULL)
|
||||
/// Mask for EData with 1's where relevant bits are (0=all bits)
|
||||
#define VL_MASK_E(nbits) VL_MASK_I(nbits)
|
||||
#define VL_EUL(n) VL_UL(n) ///< Make constant number EData sized
|
||||
|
@ -7253,12 +7253,11 @@ class AstPreAdd : public AstNodeTriop {
|
||||
// Children: thsp: tree with AstVarRef LValue that is stored after operation
|
||||
public:
|
||||
AstPreAdd(FileLine* fl, AstNode* lhsp, AstNode* rhsp, AstNode* thsp)
|
||||
: ASTGEN_SUPER(fl, lhsp, rhsp, thsp) {
|
||||
}
|
||||
: ASTGEN_SUPER(fl, lhsp, rhsp, thsp) {}
|
||||
ASTNODE_NODE_FUNCS(PreAdd)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs,
|
||||
const V3Number& ths) {
|
||||
V3ERROR_NA; // Need to modify lhs
|
||||
V3ERROR_NA; // Need to modify lhs
|
||||
}
|
||||
virtual string emitVerilog() { return "%k(++%r)"; }
|
||||
virtual string emitC() { V3ERROR_NA_RETURN(""); }
|
||||
@ -7279,12 +7278,11 @@ class AstPreSub : public AstNodeTriop {
|
||||
// Children: thsp: tree with AstVarRef LValue that is stored after operation
|
||||
public:
|
||||
AstPreSub(FileLine* fl, AstNode* lhsp, AstNode* rhsp, AstNode* thsp)
|
||||
: ASTGEN_SUPER(fl, lhsp, rhsp, thsp) {
|
||||
}
|
||||
: ASTGEN_SUPER(fl, lhsp, rhsp, thsp) {}
|
||||
ASTNODE_NODE_FUNCS(PreSub)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs,
|
||||
const V3Number& ths) {
|
||||
V3ERROR_NA; // Need to modify lhs
|
||||
V3ERROR_NA; // Need to modify lhs
|
||||
}
|
||||
virtual string emitVerilog() { return "%k(--%r)"; }
|
||||
virtual string emitC() { V3ERROR_NA_RETURN(""); }
|
||||
@ -7305,12 +7303,11 @@ class AstPostAdd : public AstNodeTriop {
|
||||
// Children: thsp: tree with AstVarRef LValue that is stored after operation
|
||||
public:
|
||||
AstPostAdd(FileLine* fl, AstNode* lhsp, AstNode* rhsp, AstNode* thsp)
|
||||
: ASTGEN_SUPER(fl, lhsp, rhsp, thsp) {
|
||||
}
|
||||
: ASTGEN_SUPER(fl, lhsp, rhsp, thsp) {}
|
||||
ASTNODE_NODE_FUNCS(PostAdd)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs,
|
||||
const V3Number& ths) {
|
||||
V3ERROR_NA; // Need to modify lhs
|
||||
V3ERROR_NA; // Need to modify lhs
|
||||
}
|
||||
virtual string emitVerilog() { return "%k(%r++)"; }
|
||||
virtual string emitC() { V3ERROR_NA_RETURN(""); }
|
||||
@ -7331,12 +7328,11 @@ class AstPostSub : public AstNodeTriop {
|
||||
// Children: thsp: tree with AstVarRef LValue that is stored after operation
|
||||
public:
|
||||
AstPostSub(FileLine* fl, AstNode* lhsp, AstNode* rhsp, AstNode* thsp)
|
||||
: ASTGEN_SUPER(fl, lhsp, rhsp, thsp) {
|
||||
}
|
||||
: ASTGEN_SUPER(fl, lhsp, rhsp, thsp) {}
|
||||
ASTNODE_NODE_FUNCS(PostSub)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs,
|
||||
const V3Number& ths) {
|
||||
V3ERROR_NA; // Need to modify lhs
|
||||
V3ERROR_NA; // Need to modify lhs
|
||||
}
|
||||
virtual string emitVerilog() { return "%k(%r--)"; }
|
||||
virtual string emitC() { V3ERROR_NA_RETURN(""); }
|
||||
|
@ -585,7 +585,7 @@ public:
|
||||
if (nodep->msbp()) {
|
||||
iterateAndNextNull(nodep->msbp());
|
||||
} else {
|
||||
puts("~VL_ULL(0)");
|
||||
puts("~0ULL");
|
||||
}
|
||||
puts(");\n");
|
||||
}
|
||||
@ -1137,9 +1137,9 @@ public:
|
||||
} else if (nodep->isQuad()) {
|
||||
vluint64_t num = nodep->toUQuad();
|
||||
if (num < 10) {
|
||||
ofp()->printf("VL_ULL(%" VL_PRI64 "u)", num);
|
||||
ofp()->printf("%" VL_PRI64 "uULL", num);
|
||||
} else {
|
||||
ofp()->printf("VL_ULL(0x%" VL_PRI64 "x)", num);
|
||||
ofp()->printf("0x%" VL_PRI64 "xULL", num);
|
||||
}
|
||||
} else {
|
||||
uint32_t num = nodep->toUInt();
|
||||
@ -2440,7 +2440,7 @@ void EmitCImp::emitSavableImp(AstNodeModule* modp) {
|
||||
hash.insert(varp->dtypep()->width());
|
||||
}
|
||||
}
|
||||
ofp()->printf("vluint64_t __Vcheckval = VL_ULL(0x%" VL_PRI64 "x);\n",
|
||||
ofp()->printf("vluint64_t __Vcheckval = 0x%" VL_PRI64 "xULL;\n",
|
||||
static_cast<vluint64_t>(hash.digestUInt64()));
|
||||
if (de) {
|
||||
puts("os.readAssert(__Vcheckval);\n");
|
||||
|
@ -364,7 +364,7 @@ void V3Number::setNames(AstNode* nodep) {
|
||||
int V3Number::log2b(uint32_t num) {
|
||||
// See also opCLog2
|
||||
for (int bit = 31; bit > 0; bit--) {
|
||||
if (num & (VL_ULL(1) << bit)) return bit;
|
||||
if (num & (1ULL << bit)) return bit;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -378,8 +378,8 @@ V3Number& V3Number::setZero() {
|
||||
}
|
||||
V3Number& V3Number::setQuad(vluint64_t value) {
|
||||
for (int i = 0; i < words(); i++) m_value[i] = m_valueX[i] = 0;
|
||||
m_value[0] = value & VL_ULL(0xffffffff);
|
||||
m_value[1] = (value >> VL_ULL(32)) & VL_ULL(0xffffffff);
|
||||
m_value[0] = value & 0xffffffffULL;
|
||||
m_value[1] = (value >> 32ULL) & 0xffffffffULL;
|
||||
opCleanThis();
|
||||
return *this;
|
||||
}
|
||||
@ -851,14 +851,14 @@ vluint64_t V3Number::toUQuad() const {
|
||||
}
|
||||
}
|
||||
if (width() <= 32) return (static_cast<vluint64_t>(toUInt()));
|
||||
return ((static_cast<vluint64_t>(m_value[1]) << VL_ULL(32))
|
||||
return ((static_cast<vluint64_t>(m_value[1]) << 32ULL)
|
||||
| (static_cast<vluint64_t>(m_value[0])));
|
||||
}
|
||||
|
||||
vlsint64_t V3Number::toSQuad() const {
|
||||
if (isDouble()) return static_cast<vlsint64_t>(toDouble());
|
||||
vluint64_t v = toUQuad();
|
||||
vluint64_t signExtend = (-(v & (VL_ULL(1) << (width() - 1))));
|
||||
vluint64_t signExtend = (-(v & (1ULL << (width() - 1))));
|
||||
vluint64_t extended = v | signExtend;
|
||||
return static_cast<vlsint64_t>(extended);
|
||||
}
|
||||
@ -1837,8 +1837,8 @@ V3Number& V3Number::opMul(const V3Number& lhs, const V3Number& rhs) {
|
||||
* static_cast<vluint64_t>(rhs.m_value[rword]);
|
||||
for (int qword = lword + rword; qword < this->words(); qword++) {
|
||||
mul += static_cast<vluint64_t>(m_value[qword]);
|
||||
m_value[qword] = (mul & VL_ULL(0xffffffff));
|
||||
mul = (mul >> VL_ULL(32)) & VL_ULL(0xffffffff);
|
||||
m_value[qword] = (mul & 0xffffffffULL);
|
||||
mul = (mul >> 32ULL) & 0xffffffffULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1953,7 +1953,7 @@ V3Number& V3Number::opModDivGuts(const V3Number& lhs, const V3Number& rhs, bool
|
||||
if (vw == 1) { // Single divisor word breaks rest of algorithm
|
||||
vluint64_t k = 0;
|
||||
for (int j = uw - 1; j >= 0; j--) {
|
||||
vluint64_t unw64 = ((k << VL_ULL(32)) + static_cast<vluint64_t>(lhs.m_value[j]));
|
||||
vluint64_t unw64 = ((k << 32ULL) + static_cast<vluint64_t>(lhs.m_value[j]));
|
||||
m_value[j] = unw64 / static_cast<vluint64_t>(rhs.m_value[0]);
|
||||
k = unw64
|
||||
- (static_cast<vluint64_t>(m_value[j]) * static_cast<vluint64_t>(rhs.m_value[0]));
|
||||
@ -2003,26 +2003,25 @@ V3Number& V3Number::opModDivGuts(const V3Number& lhs, const V3Number& rhs, bool
|
||||
// Main loop
|
||||
for (int j = uw - vw; j >= 0; j--) {
|
||||
// Estimate
|
||||
vluint64_t unw64 = (static_cast<vluint64_t>(un[j + vw]) << VL_ULL(32)
|
||||
vluint64_t unw64 = (static_cast<vluint64_t>(un[j + vw]) << 32ULL
|
||||
| static_cast<vluint64_t>(un[j + vw - 1]));
|
||||
vluint64_t qhat = unw64 / static_cast<vluint64_t>(vn[vw - 1]);
|
||||
vluint64_t rhat = unw64 - qhat * static_cast<vluint64_t>(vn[vw - 1]);
|
||||
|
||||
again:
|
||||
if (qhat >= VL_ULL(0x100000000)
|
||||
|| ((qhat * vn[vw - 2]) > ((rhat << VL_ULL(32)) + un[j + vw - 2]))) {
|
||||
if (qhat >= 0x100000000ULL || ((qhat * vn[vw - 2]) > ((rhat << 32ULL) + un[j + vw - 2]))) {
|
||||
qhat = qhat - 1;
|
||||
rhat = rhat + vn[vw - 1];
|
||||
if (rhat < VL_ULL(0x100000000)) goto again;
|
||||
if (rhat < 0x100000000ULL) goto again;
|
||||
}
|
||||
|
||||
vlsint64_t t = 0; // Must be signed
|
||||
vluint64_t k = 0;
|
||||
for (int i = 0; i < vw; i++) {
|
||||
vluint64_t p = qhat * vn[i]; // Multiply by estimate
|
||||
t = un[i + j] - k - (p & VL_ULL(0xFFFFFFFF)); // Subtract
|
||||
t = un[i + j] - k - (p & 0xFFFFFFFFULL); // Subtract
|
||||
un[i + j] = t;
|
||||
k = (p >> VL_ULL(32)) - (t >> VL_ULL(32));
|
||||
k = (p >> 32ULL) - (t >> 32ULL);
|
||||
}
|
||||
t = un[j + vw] - k;
|
||||
un[j + vw] = t;
|
||||
@ -2035,7 +2034,7 @@ V3Number& V3Number::opModDivGuts(const V3Number& lhs, const V3Number& rhs, bool
|
||||
for (int i = 0; i < vw; i++) {
|
||||
t = static_cast<vluint64_t>(un[i + j]) + static_cast<vluint64_t>(vn[i]) + k;
|
||||
un[i + j] = t;
|
||||
k = t >> VL_ULL(32);
|
||||
k = t >> 32ULL;
|
||||
}
|
||||
un[j + vw] = un[j + vw] + k;
|
||||
}
|
||||
@ -2287,14 +2286,14 @@ V3Number& V3Number::opRToIRoundS(const V3Number& lhs) {
|
||||
u.d = v;
|
||||
if (u.d == 0.0) {}
|
||||
|
||||
int exp = static_cast<int>((u.q >> VL_ULL(52)) & VL_MASK_Q(11)) - 1023;
|
||||
int exp = static_cast<int>((u.q >> 52ULL) & VL_MASK_Q(11)) - 1023;
|
||||
int lsb = exp - 52;
|
||||
vluint64_t mantissa = (u.q & VL_MASK_Q(52)) | (VL_ULL(1) << 52);
|
||||
vluint64_t mantissa = (u.q & VL_MASK_Q(52)) | (1ULL << 52);
|
||||
if (v != 0) {
|
||||
// IEEE format: [63]=sign [62:52]=exp+1023 [51:0]=mantissa
|
||||
// This does not need to support subnormals as they are sub-integral
|
||||
for (int bit = 0; bit <= 52; ++bit) {
|
||||
if (mantissa & (VL_ULL(1) << bit)) {
|
||||
if (mantissa & (1ULL << bit)) {
|
||||
int outbit = bit + lsb;
|
||||
if (outbit >= 0) setBit(outbit, 1);
|
||||
}
|
||||
|
@ -330,7 +330,7 @@ private:
|
||||
}
|
||||
void go() {
|
||||
// Generate a pseudo-random graph
|
||||
vluint64_t rngState[2] = {VL_ULL(0x12345678), VL_ULL(0x9abcdef0)};
|
||||
vluint64_t rngState[2] = {0x12345678ULL, 0x9abcdef0ULL};
|
||||
// Create 50 vertices
|
||||
for (unsigned i = 0; i < 50; ++i) m_vx[i] = new V3GraphVertex(&m_graph);
|
||||
// Create 250 edges at random. Edges must go from
|
||||
|
@ -2206,7 +2206,7 @@ private:
|
||||
}
|
||||
}
|
||||
int selwidth = V3Number::log2b(msbdim) + 1; // Width to address a bit
|
||||
AstVar* varp = enumVarp(adtypep, attrType, (VL_ULL(1) << selwidth) - 1);
|
||||
AstVar* varp = enumVarp(adtypep, attrType, (1ULL << selwidth) - 1);
|
||||
AstVarRef* varrefp = new AstVarRef(nodep->fileline(), varp, false);
|
||||
varrefp->packagep(v3Global.rootp()->dollarUnitPkgAddp());
|
||||
AstNode* newp = new AstArraySel(
|
||||
|
@ -87,14 +87,14 @@ module tpub (
|
||||
$c("publicNoArgs();");
|
||||
$c("publicSetBool(true);");
|
||||
$c("publicSetLong(0x11bca);");
|
||||
$c("publicSetQuad(VL_ULL(0x66655554444));");
|
||||
$c("publicSetQuad(0x66655554444ULL);");
|
||||
$c("publicSetFlop(0x321);");
|
||||
//Unsupported: $c("WData w[3] = {0x12, 0x5678_9123, 0x1245_2352}; publicSetWide(w);");
|
||||
end
|
||||
if (cyc==12) begin
|
||||
$c("got_bool = publicGetSetBool(true);");
|
||||
$c("got_long = publicGetSetLong(0x11bca);");
|
||||
$c("got_quad = publicGetSetQuad(VL_ULL(0xaaaabbbbcccc));");
|
||||
$c("got_quad = publicGetSetQuad(0xaaaabbbbccccULL);");
|
||||
end
|
||||
if (cyc==13) begin
|
||||
$c("{ bool gb; publicGetBool(gb); got_bool=gb; }");
|
||||
|
@ -32,11 +32,11 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
topp->a0 = 0;
|
||||
topp->eval();
|
||||
check(topp->y, VL_ULL(0x0));
|
||||
check(topp->y, 0x0ULL);
|
||||
|
||||
topp->a0 = 15;
|
||||
topp->eval();
|
||||
check(topp->y, VL_ULL(0x3c00000000));
|
||||
check(topp->y, 0x3c00000000ULL);
|
||||
|
||||
topp->final();
|
||||
if (!fail) {
|
||||
|
Loading…
Reference in New Issue
Block a user