diff --git a/Changes b/Changes index e85264813..54ff45b55 100644 --- a/Changes +++ b/Changes @@ -5,6 +5,8 @@ The contributors that suggested a given feature are shown in []. Thanks! * Verilator 4.035 devel +**** Support multi channel descriptor I/O (#2190) [Stephen Henry] + **** Support $countbits. (#2287) [Yossi Nivin] **** Support $isunbounded and parameter $. (#2104) diff --git a/include/verilated.cpp b/include/verilated.cpp index 58a2fdd55..62592476e 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -1222,15 +1222,11 @@ IData VL_FOPEN_MCD_N(const std::string& filename) VL_MT_SAFE { return VerilatedImp::fdNewMcd(filename.c_str()); } -void VL_FFLUSH_I(IData fdi) VL_MT_SAFE { - VerilatedImp::fdFlush(fdi); -} +void VL_FFLUSH_I(IData fdi) VL_MT_SAFE { VerilatedImp::fdFlush(fdi); } IData VL_FSEEK_I(IData fdi, IData offset, IData origin) VL_MT_SAFE { return VerilatedImp::fdSeek(fdi, offset, origin); } -IData VL_FTELL_I(IData fdi) VL_MT_SAFE { - return VerilatedImp::fdTell(fdi); -} +IData VL_FTELL_I(IData fdi) VL_MT_SAFE { return VerilatedImp::fdTell(fdi); } void VL_FCLOSE_I(IData fdi) VL_MT_SAFE { // While threadsafe, each thread can only access different file handles VerilatedImp::fdClose(fdi); diff --git a/include/verilated_imp.h b/include/verilated_imp.h index e31effa34..23214bddd 100644 --- a/include/verilated_imp.h +++ b/include/verilated_imp.h @@ -457,7 +457,7 @@ public: // But only for verilated*.cpp IData idx = s_s.m_fdFreeMct.back(); s_s.m_fdFreeMct.pop_back(); s_s.m_fdps[idx] = fopen(filenamep, "w"); - if(VL_UNLIKELY(!s_s.m_fdps[idx])) return 0; + if (VL_UNLIKELY(!s_s.m_fdps[idx])) return 0; return (1 << idx); } static IData fdNew(const char* filenamep, const char* modep) VL_MT_SAFE { @@ -489,14 +489,14 @@ public: // But only for verilated*.cpp FILE* fp; VerilatedLockGuard lock(s_s.m_fdMutex); const int n = fdToFp(fdi, &fp); - if(VL_UNLIKELY(!fp || (n != 1))) return 0; + if (VL_UNLIKELY(!fp || (n != 1))) return 0; return static_cast(fseek(fp, static_cast(offset), static_cast(origin))); } static IData fdTell(IData fdi) VL_MT_SAFE { FILE* fp; VerilatedLockGuard lock(s_s.m_fdMutex); const int n = fdToFp(fdi, &fp); - if(VL_UNLIKELY(!fp || (n != 1))) return 0; + if (VL_UNLIKELY(!fp || (n != 1))) return 0; return static_cast(ftell(fp)); } static void fdClose(IData fdi) VL_MT_SAFE { @@ -531,8 +531,7 @@ public: // But only for verilated*.cpp case 1: fp[out++] = stdout; break; case 2: fp[out++] = stderr; break; default: - if (VL_LIKELY(idx < s_s.m_fdps.size())) - fp[out++] = s_s.m_fdps[idx]; + if (VL_LIKELY(idx < s_s.m_fdps.size())) fp[out++] = s_s.m_fdps[idx]; break; } } else {