diff --git a/include/verilated.cpp b/include/verilated.cpp index 49955fb9d..2cb5cd9f6 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -607,7 +607,7 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA width = 0; } else if (!inPct) { // Normal text // Fast-forward to next escape and add to output - const char *ep = pos; + const char* ep = pos; while (ep[0] && ep[0]!='%') ep++; if (ep != pos) { output.append(pos, ep-pos); diff --git a/include/verilated.h b/include/verilated.h index d81f4a1da..6cce56a65 100644 --- a/include/verilated.h +++ b/include/verilated.h @@ -24,7 +24,6 @@ /// //************************************************************************* - #ifndef _VERILATED_H_ #define _VERILATED_H_ 1 ///< Header Guard @@ -353,7 +352,7 @@ class Verilated { // Slow path variables static VerilatedMutex m_mutex; ///< Mutex for s_s/s_ns members, when VL_THREADED - static VerilatedVoidCb s_flushCb; ///< Flush callback function + static VerilatedVoidCb s_flushCb; ///< Flush callback function static struct Serialized { // All these members serialized/deserialized // Fast path @@ -417,9 +416,9 @@ public: /// 1 = Set all bits to one /// 2 = Randomize all bits static void randReset(int val) VL_MT_SAFE; - static int randReset() VL_MT_SAFE { return s_s.s_randReset; } ///< Return randReset value + static int randReset() VL_MT_SAFE { return s_s.s_randReset; } ///< Return randReset value static void randSeed(int val) VL_MT_SAFE; - static int randSeed() VL_MT_SAFE { return s_s.s_randSeed; } ///< Return randSeed value + static int randSeed() VL_MT_SAFE { return s_s.s_randSeed; } ///< Return randSeed value /// Enable debug of internal verilated code static void debug(int level) VL_MT_SAFE; diff --git a/include/verilated_cov.h b/include/verilated_cov.h index bc14f5dd6..4e36ba25e 100644 --- a/include/verilated_cov.h +++ b/include/verilated_cov.h @@ -67,7 +67,7 @@ #define VL_COVER_INSERT(countp,args...) \ VL_IF_COVER(VerilatedCov::_inserti(countp); \ - VerilatedCov::_insertf(__FILE__,__LINE__); \ + VerilatedCov::_insertf(__FILE__, __LINE__); \ VerilatedCov::_insertp("hier", name(), args)) //============================================================================= diff --git a/include/verilated_dpi.cpp b/include/verilated_dpi.cpp index 469f87ffa..2f70e91ea 100644 --- a/include/verilated_dpi.cpp +++ b/include/verilated_dpi.cpp @@ -43,7 +43,8 @@ // Not supported yet #define _VL_SVDPI_UNIMP() \ - VL_FATAL_MT(__FILE__,__LINE__,"",(std::string("%%Error: Unsupported DPI function: ")+VL_FUNC).c_str()) + VL_FATAL_MT(__FILE__, __LINE__, "", \ + (std::string("%%Error: Unsupported DPI function: ")+VL_FUNC).c_str()) #define _VL_SVDPI_WARN(message...) \ VL_PRINTF_MT(message) diff --git a/include/verilated_dpi.h b/include/verilated_dpi.h index 75fb03f4a..66275f078 100644 --- a/include/verilated_dpi.h +++ b/include/verilated_dpi.h @@ -24,7 +24,6 @@ /// //************************************************************************* - #ifndef _VERILATED_DPI_H_ #define _VERILATED_DPI_H_ 1 ///< Header Guard diff --git a/include/verilated_fst_c.cpp b/include/verilated_fst_c.cpp index d7b1a8841..365a77b92 100644 --- a/include/verilated_fst_c.cpp +++ b/include/verilated_fst_c.cpp @@ -178,7 +178,7 @@ void VerilatedFst::addCallback( if (VL_UNLIKELY(isOpen())) { std::string msg = (std::string("Internal: ")+__FILE__+"::"+__FUNCTION__ +" called with already open file"); - VL_FATAL_MT(__FILE__,__LINE__,"",msg.c_str()); + VL_FATAL_MT(__FILE__, __LINE__, "", msg.c_str()); } VerilatedFstCallInfo* vci = new VerilatedFstCallInfo(initcb, fullcb, changecb, userthis, 1); m_callbacks.push_back(vci); diff --git a/include/verilated_fst_c.h b/include/verilated_fst_c.h index a7d4eb21b..a61a2c199 100644 --- a/include/verilated_fst_c.h +++ b/include/verilated_fst_c.h @@ -89,7 +89,7 @@ public: /// Change character that splits scopes. Note whitespace are ALWAYS escapes. void scopeEscape(char flag) { m_scopeEscape = flag; } /// Is this an escape? - bool isScopeEscape(char c) { return isspace(c) || c==m_scopeEscape; } + bool isScopeEscape(char c) { return isspace(c) || c == m_scopeEscape; } /// Inside dumping routines, called each cycle to make the dump void dump(vluint64_t timeui); /// Inside dumping routines, declare callbacks for tracings diff --git a/include/verilated_heavy.h b/include/verilated_heavy.h index 73d30f719..b071e5af4 100644 --- a/include/verilated_heavy.h +++ b/include/verilated_heavy.h @@ -25,7 +25,6 @@ /// //************************************************************************* - #ifndef _VERILATED_HEAVY_H_ #define _VERILATED_HEAVY_H_ 1 ///< Header Guard @@ -49,7 +48,7 @@ inline std::string VL_CVT_PACK_STR_NI(IData lhs) VL_PURE { return VL_CVT_PACK_STR_NW(1, lw); } inline std::string VL_CONCATN_NNN(const std::string& lhs, const std::string& rhs) VL_PURE { - return lhs+rhs; + return lhs + rhs; } inline std::string VL_REPLICATEN_NNQ(int,int,int, const std::string& lhs, IData rep) VL_PURE { std::string out; out.reserve(lhs.length() * rep); @@ -78,13 +77,13 @@ extern std::string VL_SFORMATF_NX(const char* formatp, ...) VL_MT_SAFE; extern IData VL_VALUEPLUSARGS_INW(int rbits, const std::string& ld, WDataOutP rwp) VL_MT_SAFE; inline IData VL_VALUEPLUSARGS_INI(int rbits, const std::string& ld, IData& rdr) VL_MT_SAFE { WData rwp[2]; // WData must always be at least 2 - IData got = VL_VALUEPLUSARGS_INW(rbits,ld,rwp); + IData got = VL_VALUEPLUSARGS_INW(rbits, ld, rwp); if (got) rdr = rwp[0]; return got; } inline IData VL_VALUEPLUSARGS_INQ(int rbits, const std::string& ld, QData& rdr) VL_MT_SAFE { WData rwp[2]; - IData got = VL_VALUEPLUSARGS_INW(rbits,ld,rwp); + IData got = VL_VALUEPLUSARGS_INW(rbits, ld, rwp); if (got) rdr = VL_SET_QW(rwp); return got; } diff --git a/include/verilated_imp.h b/include/verilated_imp.h index 0e8d4effd..a844a613b 100644 --- a/include/verilated_imp.h +++ b/include/verilated_imp.h @@ -20,7 +20,6 @@ /// //========================================================================= - #ifndef _VERILATED_IMP_H_ #define _VERILATED_IMP_H_ 1 ///< Header Guard @@ -62,7 +61,8 @@ private: public: // CONSTRUCTORS VerilatedMsg(const std::function& cb) - : m_mtaskId(Verilated::mtaskId()), m_cb(cb) {} + : m_mtaskId(Verilated::mtaskId()) + , m_cb(cb) {} ~VerilatedMsg() {} // METHODS vluint32_t mtaskId() const { return m_mtaskId; } @@ -73,7 +73,7 @@ public: /// Each thread has a queue it pushes to /// This assumes no thread starts pushing the next tick until the previous has drained. /// If more aggressiveness is needed, a double-buffered scheme might work well. -class VerilatedEvalMsgQueue { +class VerilatedEvalMsgQueue { typedef std::multiset VerilatedThreadQueue; std::atomic m_depth; ///< Current depth of queue (see comments below) @@ -82,10 +82,12 @@ class VerilatedEvalMsgQueue { VerilatedThreadQueue m_queue VL_GUARDED_BY(m_mutex); ///< Message queue public: // CONSTRUCTORS - VerilatedEvalMsgQueue() : m_depth(0) { + VerilatedEvalMsgQueue() + : m_depth(0) { assert(atomic_is_lock_free(&m_depth)); } - ~VerilatedEvalMsgQueue() { } + ~VerilatedEvalMsgQueue() {} + private: VL_UNCOPYABLE(VerilatedEvalMsgQueue); public: @@ -122,11 +124,11 @@ public: }; /// Each thread has a local queue to build up messages until the end of the eval() call -class VerilatedThreadMsgQueue { +class VerilatedThreadMsgQueue { std::queue m_queue; public: // CONSTRUCTORS - VerilatedThreadMsgQueue() { } + VerilatedThreadMsgQueue() {} ~VerilatedThreadMsgQueue() { // The only call of this with a non-empty queue is a fatal error. // So this does not flush the queue, as the destination queue is not known to this class. @@ -170,8 +172,8 @@ class VerilatedImp { // TYPES typedef std::vector ArgVec; - typedef std::map,void*> UserMap; - typedef std::map ExportNameMap; + typedef std::map, void*> UserMap; + typedef std::map ExportNameMap; // MEMBERS static VerilatedImp s_s; ///< Static Singleton; One and only static this @@ -204,7 +206,8 @@ class VerilatedImp { public: // But only for verilated*.cpp // CONSTRUCTORS VerilatedImp() - : m_argVecLoaded(false), m_exportNext(0) { + : m_argVecLoaded(false) + , m_exportNext(0) { m_fdps.resize(3); m_fdps[0] = stdin; m_fdps[1] = stdout; @@ -232,9 +235,9 @@ public: "%Error: Verilog called $test$plusargs or $value$plusargs without" " testbench C first calling Verilated::commandArgs(argc,argv)."); } - for (ArgVec::const_iterator it=s_s.m_argVec.begin(); it!=s_s.m_argVec.end(); ++it) { - if ((*it)[0]=='+') { - if (0==strncmp(prefixp, it->c_str()+1, len)) return *it; + for (ArgVec::const_iterator it = s_s.m_argVec.begin(); it != s_s.m_argVec.end(); ++it) { + if ((*it)[0] == '+') { + if (0 == strncmp(prefixp, it->c_str() + 1, len)) return *it; } } return ""; @@ -252,7 +255,7 @@ public: // per map overhead * N scopes would take much more space and cache thrashing. static inline void userInsert(const void* scopep, void* userKey, void* userData) VL_MT_SAFE { VerilatedLockGuard lock(s_s.m_userMapMutex); - UserMap::iterator it=s_s.m_userMap.find(std::make_pair(scopep, userKey)); + UserMap::iterator it = s_s.m_userMap.find(std::make_pair(scopep, userKey)); if (it != s_s.m_userMap.end()) it->second = userData; // When we support VL_THREADs, we need a lock around this insert, as it's runtime else s_s.m_userMap.insert(it, std::make_pair(std::make_pair(scopep, userKey), userData)); @@ -268,7 +271,7 @@ private: static void userEraseScope(const VerilatedScope* scopep) VL_MT_SAFE { // Slow ok - called once/scope on destruction, so we simply iterate. VerilatedLockGuard lock(s_s.m_userMapMutex); - for (UserMap::iterator it=s_s.m_userMap.begin(); it!=s_s.m_userMap.end(); ) { + for (UserMap::iterator it = s_s.m_userMap.begin(); it != s_s.m_userMap.end();) { if (it->first.first == scopep) { s_s.m_userMap.erase(it++); } else { @@ -291,7 +294,7 @@ public: // But only for verilated*.cpp static void scopeInsert(const VerilatedScope* scopep) VL_MT_SAFE { // Slow ok - called once/scope at construction VerilatedLockGuard lock(s_s.m_nameMutex); - VerilatedScopeNameMap::iterator it=s_s.m_nameMap.find(scopep->name()); + VerilatedScopeNameMap::iterator it = s_s.m_nameMap.find(scopep->name()); if (it == s_s.m_nameMap.end()) { s_s.m_nameMap.insert(it, std::make_pair(scopep->name(), scopep)); } @@ -307,14 +310,14 @@ public: // But only for verilated*.cpp // Slow ok - called once/scope at destruction VerilatedLockGuard lock(s_s.m_nameMutex); userEraseScope(scopep); - VerilatedScopeNameMap::iterator it=s_s.m_nameMap.find(scopep->name()); + VerilatedScopeNameMap::iterator it = s_s.m_nameMap.find(scopep->name()); if (it != s_s.m_nameMap.end()) s_s.m_nameMap.erase(it); } static void scopesDump() VL_MT_SAFE { VerilatedLockGuard lock(s_s.m_nameMutex); VL_PRINTF_MT(" scopesDump:\n"); - for (VerilatedScopeNameMap::const_iterator it=s_s.m_nameMap.begin(); - it!=s_s.m_nameMap.end(); ++it) { + for (VerilatedScopeNameMap::const_iterator it = s_s.m_nameMap.begin(); + it != s_s.m_nameMap.end(); ++it) { const VerilatedScope* scopep = it->second; scopep->scopeDump(); } @@ -349,7 +352,7 @@ public: // But only for verilated*.cpp static int exportInsert(const char* namep) VL_MT_SAFE { // Slow ok - called once/function at creation VerilatedLockGuard lock(s_s.m_exportMutex); - ExportNameMap::iterator it=s_s.m_exportMap.find(namep); + ExportNameMap::iterator it = s_s.m_exportMap.find(namep); if (it == s_s.m_exportMap.end()) { s_s.m_exportMap.insert(it, std::make_pair(namep, s_s.m_exportNext++)); return s_s.m_exportNext++; @@ -359,7 +362,7 @@ public: // But only for verilated*.cpp } static int exportFind(const char* namep) VL_MT_SAFE { VerilatedLockGuard lock(s_s.m_exportMutex); - ExportNameMap::const_iterator it=s_s.m_exportMap.find(namep); + ExportNameMap::const_iterator it = s_s.m_exportMap.find(namep); if (VL_LIKELY(it != s_s.m_exportMap.end())) return it->second; std::string msg = (std::string("%Error: Testbench C called ")+namep +" but no such DPI export function name exists in ANY model"); @@ -369,8 +372,8 @@ public: // But only for verilated*.cpp static const char* exportName(int funcnum) VL_MT_SAFE { // Slowpath; find name for given export; errors only so no map to reverse-map it VerilatedLockGuard lock(s_s.m_exportMutex); - for (ExportNameMap::const_iterator it=s_s.m_exportMap.begin(); - it!=s_s.m_exportMap.end(); ++it) { + for (ExportNameMap::const_iterator it = s_s.m_exportMap.begin(); + it != s_s.m_exportMap.end(); ++it) { if (it->second == funcnum) return it->first; } return "*UNKNOWN*"; diff --git a/include/verilated_save.h b/include/verilated_save.h index aadb9571e..fe1a2978c 100644 --- a/include/verilated_save.h +++ b/include/verilated_save.h @@ -51,7 +51,7 @@ protected: public: VerilatedSerialize() { m_isOpen = false; - m_bufp = new vluint8_t [bufferSize()]; + m_bufp = new vluint8_t[bufferSize()]; m_cp = m_bufp; } virtual ~VerilatedSerialize() { @@ -112,7 +112,7 @@ protected: public: VerilatedDeserialize() { m_isOpen = false; - m_bufp = new vluint8_t [bufferSize()]; + m_bufp = new vluint8_t[bufferSize()]; m_cp = m_bufp; m_endp = NULL; } @@ -158,11 +158,11 @@ private: class VerilatedSave : public VerilatedSerialize { private: - int m_fd; ///< File descriptor we're writing to + int m_fd; ///< File descriptor we're writing to public: // CONSTRUCTORS - VerilatedSave() { m_fd=-1; } + VerilatedSave() { m_fd = -1; } virtual ~VerilatedSave() { close(); } // METHODS void open(const char* filenamep) VL_MT_UNSAFE_ONE; ///< Open the file; call isOpen() to see if errors @@ -177,11 +177,11 @@ public: class VerilatedRestore : public VerilatedDeserialize { private: - int m_fd; ///< File descriptor we're writing to + int m_fd; ///< File descriptor we're writing to public: // CONSTRUCTORS - VerilatedRestore() { m_fd=-1; } + VerilatedRestore() { m_fd = -1; } virtual ~VerilatedRestore() { close(); } // METHODS diff --git a/include/verilated_sc.h b/include/verilated_sc.h index a20f21430..ef9324829 100644 --- a/include/verilated_sc.h +++ b/include/verilated_sc.h @@ -23,7 +23,6 @@ /// //************************************************************************* - #ifndef _VERILATED_SC_H_ #define _VERILATED_SC_H_ 1 ///< Header Guard diff --git a/include/verilated_sym_props.h b/include/verilated_sym_props.h index 5a0adeb92..c8c92a7ce 100644 --- a/include/verilated_sym_props.h +++ b/include/verilated_sym_props.h @@ -28,7 +28,6 @@ /// //************************************************************************* - #ifndef _VERILATED_SYM_PROPS_H_ #define _VERILATED_SYM_PROPS_H_ 1 ///< Header Guard @@ -128,7 +127,7 @@ public: public: ~VerilatedVarProps() {} // METHODS - bool magicOk() const { return m_magic==MAGIC; } + bool magicOk() const { return m_magic == MAGIC; } VerilatedVarType vltype() const { return m_vltype; } VerilatedVarFlags vldir() const { return static_cast(static_cast(m_vlflags) & VLVF_MASK_DIR); } @@ -177,13 +176,15 @@ public: class VerilatedDpiOpenVar { // MEMBERS const VerilatedVarProps* m_propsp; // Variable properties - void* m_datap; // Location of data (local to thread always, so safe) + void* m_datap; // Location of data (local to thread always, so safe) public: // CONSTRUCTORS VerilatedDpiOpenVar(const VerilatedVarProps* propsp, void* datap) - : m_propsp(propsp), m_datap(datap) {} + : m_propsp(propsp) + , m_datap(datap) {} VerilatedDpiOpenVar(const VerilatedVarProps* propsp, const void* datap) - : m_propsp(propsp), m_datap(const_cast(datap)) {} + : m_propsp(propsp) + , m_datap(const_cast(datap)) {} ~VerilatedDpiOpenVar() {} // METHODS void* datap() const { return m_datap; } @@ -211,7 +212,7 @@ public: class VerilatedVar : public VerilatedVarProps { // MEMBERS - void* m_datap; // Location of data + void* m_datap; // Location of data const char* m_namep; // Name - slowpath protected: friend class VerilatedScope; diff --git a/include/verilated_syms.h b/include/verilated_syms.h index 6db1b8be2..418a7bc6c 100644 --- a/include/verilated_syms.h +++ b/include/verilated_syms.h @@ -27,7 +27,6 @@ /// //************************************************************************* - #ifndef _VERILATED_SYMS_H_ #define _VERILATED_SYMS_H_ 1 ///< Header Guard @@ -43,7 +42,7 @@ /// Class to sort maps keyed by const char*'s struct VerilatedCStrCmp { - bool operator() (const char *a, const char *b) const { + bool operator() (const char* a, const char* b) const { return std::strcmp(a, b) < 0; } }; diff --git a/include/verilated_threads.h b/include/verilated_threads.h index f704e7b5a..bb7ef2650 100644 --- a/include/verilated_threads.h +++ b/include/verilated_threads.h @@ -146,9 +146,7 @@ public: m_startTime = time; m_cpu = getcpu(); } - void endRecord(vluint64_t time) { - m_endTime = time; - } + void endRecord(vluint64_t time) { m_endTime = time; } static int getcpu() { // Return current executing CPU #if defined(__linux) return sched_getcpu(); @@ -157,7 +155,7 @@ public: __cpuid_count(1, 0, info[0], info[1], info[2], info[3]); /* info[1] is EBX, bits 24-31 are APIC ID */ if ((info[3] & (1 << 9)) == 0) { - return -1; /* no APIC on chip */ + return -1; // no APIC on chip } else { return (unsigned)info[1] >> 24; } @@ -167,7 +165,6 @@ public: return 0; #endif } - }; class VlThreadPool; @@ -231,9 +228,7 @@ public: m_ready.erase(m_ready.begin()); m_ready_size.fetch_sub(1, std::memory_order_relaxed); } - inline void wakeUp() { - addTask(nullptr, false, nullptr); - } + inline void wakeUp() { addTask(nullptr, false, nullptr); } inline void addTask(VlExecFnp fnp, bool evenCycle, VlThrSymTab sym) { bool notify; { @@ -276,9 +271,7 @@ public: ~VlThreadPool(); // METHODS - inline int numThreads() const { - return m_workers.size(); - } + inline int numThreads() const { return m_workers.size(); } inline VlWorkerThread* workerp(int index) { assert(index >= 0); assert(index < m_workers.size()); diff --git a/include/verilated_unordered_set_map.h b/include/verilated_unordered_set_map.h index f9033fe97..d011ca647 100644 --- a/include/verilated_unordered_set_map.h +++ b/include/verilated_unordered_set_map.h @@ -19,7 +19,6 @@ // //************************************************************************* - //************************************************************************* // This file has clones of the std::unordered_set and std::unordered_map // hash table types. They are here so that Verilator can use hash tables @@ -114,7 +113,7 @@ class vl_unordered_set { public: // TYPES typedef std::list Bucket; - enum RehashType {GROW, SHRINK}; + enum RehashType { GROW, SHRINK }; template friend class vl_unordered_map; @@ -197,7 +196,7 @@ public: , m_log2Buckets(initLog2Buckets()) , m_bucketsp(NULL) , m_hash() - , m_equal() { } + , m_equal() {} vl_unordered_set(const vl_unordered_set& other) : m_numElements(other.m_numElements) @@ -317,7 +316,7 @@ public: return find_internal(key, bucketIdx); } - std::pair insert(const T_Key &val) { + std::pair insert(const T_Key& val) { size_t bucketIdx; iterator existIt = find_internal(val, bucketIdx); if (existIt != end()) { @@ -353,7 +352,7 @@ public: return next_it; } - size_t erase(const T_Key &key) { + size_t erase(const T_Key& key) { size_t bucketIdx; iterator it = find_internal(key, bucketIdx); if (it != end()) { @@ -373,7 +372,7 @@ public: void clear() { if (m_bucketsp) { - delete [] m_bucketsp; + delete[] m_bucketsp; m_bucketsp = NULL; } m_numElements = 0; @@ -417,7 +416,7 @@ private: size_t new_num_buckets = VL_ULL(1) << new_log2Buckets; Bucket* new_bucketsp = new Bucket[new_num_buckets]; - for (size_t i=0; i m_wrFlushp)) { - bufferFlush(); - } + if (VL_UNLIKELY(m_writep > m_wrFlushp)) { bufferFlush(); } } void closePrev(); void closeErr(); @@ -157,18 +155,18 @@ private: // CONSTRUCTORS VL_UNCOPYABLE(VerilatedVcd); public: - explicit VerilatedVcd(VerilatedVcdFile* filep=NULL); + explicit VerilatedVcd(VerilatedVcdFile* filep = NULL); ~VerilatedVcd(); // ACCESSORS /// Set size in megabytes after which new file should be created - void rolloverMB(vluint64_t rolloverMB) { m_rolloverMB=rolloverMB; } + void rolloverMB(vluint64_t rolloverMB) { m_rolloverMB = rolloverMB; } /// Is file open? bool isOpen() const { return m_isOpen; } /// Change character that splits scopes. Note whitespace are ALWAYS escapes. void scopeEscape(char flag) { m_scopeEscape = flag; } /// Is this an escape? - inline bool isScopeEscape(char c) { return isspace(c) || c==m_scopeEscape; } + inline bool isScopeEscape(char c) { return isspace(c) || c == m_scopeEscape; } // METHODS void open(const char* filename) VL_MT_UNSAFE_ONE; ///< Open the file; call isOpen() to see if errors @@ -331,7 +329,7 @@ public: inline void chgBus(vluint32_t code, const vluint32_t newval, int bits) { vluint32_t diff = m_sigs_oldvalp[code] ^ newval; if (VL_UNLIKELY(diff)) { - if (VL_UNLIKELY(bits==32 || (diff & ((1U<(&m_sigs_oldvalp[code]))) ^ newval; if (VL_UNLIKELY(diff)) { - if (VL_UNLIKELY(bits==64 || (diff & ((1ULL<(&m_sigs_oldvalp[code]))) ^ newval) | ((*(reinterpret_cast(&m_sigs_oldvalp[code+1]))) ^ newtri)); if (VL_UNLIKELY(diff)) { - if (VL_UNLIKELY(bits==64 || (diff & ((1ULL<=20171012) DECL_TRACE_METHOD_A( sc_event ) @@ -145,8 +145,8 @@ private: # define DECL_TRACE_METHOD_B(tp) \ virtual void trace(const tp& object, const sc_string& name, int width); - virtual void write_comment(const sc_string &); - virtual void trace(const unsigned int &, const sc_string &, const char **); + virtual void write_comment(const sc_string&); + virtual void trace(const unsigned int&, const sc_string&, const char**); virtual void delta_cycles(bool) {} virtual void space(int n) {} @@ -189,8 +189,8 @@ private: # define DECL_TRACE_METHOD_B(tp) \ virtual void trace(const tp& object, const sc_string& name, int width); - virtual void write_comment(const sc_string &); - virtual void trace(const unsigned int &, const sc_string &, const char **); + virtual void write_comment(const sc_string&); + virtual void trace(const unsigned int&, const sc_string&, const char**); DECL_TRACE_METHOD_A( bool ) DECL_TRACE_METHOD_B( unsigned char ) diff --git a/include/verilatedos.h b/include/verilatedos.h index 34c153c11..5be639aee 100644 --- a/include/verilatedos.h +++ b/include/verilatedos.h @@ -324,9 +324,9 @@ typedef unsigned long long vluint64_t; ///< 64-bit unsigned type #define VL_WORDSIZE_LOG2 5 ///< log2(VL_WORDSIZE) /// Bytes this number of bits needs (1 bit=1 byte) -#define VL_BYTES_I(nbits) (((nbits)+(VL_BYTESIZE-1))/VL_BYTESIZE) +#define VL_BYTES_I(nbits) (((nbits) + (VL_BYTESIZE - 1)) / VL_BYTESIZE) /// Words this number of bits needs (1 bit=1 word) -#define VL_WORDS_I(nbits) (((nbits)+(VL_WORDSIZE-1))/VL_WORDSIZE) +#define VL_WORDS_I(nbits) (((nbits) + (VL_WORDSIZE - 1)) / VL_WORDSIZE) //========================================================================= // Class definition helpers @@ -345,8 +345,8 @@ typedef unsigned long long vluint64_t; ///< 64-bit unsigned type //========================================================================= // Base macros -#define VL_SIZEBITS_I (VL_WORDSIZE-1) ///< Bit mask for bits in a word -#define VL_SIZEBITS_Q (VL_QUADSIZE-1) ///< Bit mask for bits in a quad +#define VL_SIZEBITS_I (VL_WORDSIZE - 1) ///< Bit mask for bits in a word +#define VL_SIZEBITS_Q (VL_QUADSIZE - 1) ///< Bit mask for bits in a quad /// Mask for words with 1's where relevant bits are (0=all bits) #define VL_MASK_I(nbits) (((nbits) & VL_SIZEBITS_I) \ diff --git a/src/V3Error.h b/src/V3Error.h index 55a7c4d52..0b865a290 100644 --- a/src/V3Error.h +++ b/src/V3Error.h @@ -307,8 +307,11 @@ inline void v3errorEndFatal(std::ostringstream& sstr) { ::v3errorEndFatal((V3Error::v3errorPrep(V3ErrorCode::EC_FATAL), \ (V3Error::v3errorStr()<=(level))) { cout<<"- "<=(level))) { cout<= (level))) { \ + cout << "- " << V3Error::lineStr(__FILE__, __LINE__) << stmsg; } } +#define UINFONL(level, stmsg) \ + { if (VL_UNCOVERABLE(debug() >= (level))) { cout << stmsg; } } #ifdef VL_DEBUG # define UDEBUGONLY(stmts) {stmts} diff --git a/src/V3File.cpp b/src/V3File.cpp index 0178f8077..cbf857e9b 100644 --- a/src/V3File.cpp +++ b/src/V3File.cpp @@ -638,7 +638,7 @@ bool V3OutFormatter::tokenEnd(const char* cp) { || tokenStart(cp, "endmodule")); } -int V3OutFormatter::endLevels(const char *strg) { +int V3OutFormatter::endLevels(const char* strg) { int levels = m_indentLevel; { const char* cp = strg; @@ -683,7 +683,7 @@ int V3OutFormatter::endLevels(const char *strg) { return levels; } -void V3OutFormatter::puts(const char *strg) { +void V3OutFormatter::puts(const char* strg) { if (m_prependIndent) { putsNoTracking(indentSpaces(endLevels(strg))); m_prependIndent = false; @@ -911,7 +911,7 @@ string V3OutFormatter::quoteNameControls(const string& namein, V3OutFormatter::L //---------------------------------------------------------------------- // Simple wrappers -void V3OutFormatter::printf(const char *fmt...) { +void V3OutFormatter::printf(const char* fmt...) { char sbuff[5000]; va_list ap; va_start(ap, fmt); diff --git a/src/V3FileLine.cpp b/src/V3FileLine.cpp index ced266c94..e00d051bb 100644 --- a/src/V3FileLine.cpp +++ b/src/V3FileLine.cpp @@ -175,7 +175,7 @@ void FileLine::lineDirective(const char* textp, int& enterExitRef) { while (*textp && (isspace(*textp) || *textp=='"')) textp++; // Grab linenumber - const char *ln = textp; + const char* ln = textp; while (*textp && !isspace(*textp)) textp++; if (isdigit(*ln)) { lineno(atoi(ln)); @@ -183,7 +183,7 @@ void FileLine::lineDirective(const char* textp, int& enterExitRef) { while (*textp && (isspace(*textp) || *textp=='"')) textp++; // Grab filename - const char *fn = textp; + const char* fn = textp; while (*textp && !(isspace(*textp) || *textp=='"')) textp++; if (textp != fn) { string strfn = fn; diff --git a/src/V3Options.cpp b/src/V3Options.cpp index a2670b876..e139a4bcb 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -683,7 +683,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char for (int i=0; i ColumnMap; // Map of {column} - typedef std::map LinenoMap; // Map of {lineno}{column} + typedef std::map ColumnMap; // Map of {column} + typedef std::map LinenoMap; // Map of {lineno}{column} private: // MEMBERS @@ -112,7 +112,8 @@ public: class VlcSources { public: // TYPES - typedef std::map NameMap; + typedef std::map NameMap; + private: // MEMBERS NameMap m_sources; //< List of all sources @@ -133,8 +134,7 @@ public: NameMap::iterator iter = m_sources.find(name); if (iter != m_sources.end()) { return iter->second; - } - else { + } else { iter = m_sources.insert(make_pair(name, VlcSource(name))).first; return iter->second; } diff --git a/src/VlcTest.h b/src/VlcTest.h index 6b81cb636..56c57a3bb 100644 --- a/src/VlcTest.h +++ b/src/VlcTest.h @@ -42,7 +42,7 @@ private: vluint64_t m_rank; //< Execution rank suggestion vluint64_t m_rankPoints; //< Ranked additional points vluint64_t m_user; //< User data for algorithms (not persisted in .dat file) - VlcBuckets m_buckets; //< Coverage data for each coverage point + VlcBuckets m_buckets; //< Coverage data for each coverage point public: // CONSTRUCTORS diff --git a/test_regress/t/TestSimulator.h b/test_regress/t/TestSimulator.h index 11ad3e474..0e933df92 100644 --- a/test_regress/t/TestSimulator.h +++ b/test_regress/t/TestSimulator.h @@ -70,7 +70,7 @@ public: } } // return absolute scope of obj - static const char* rooted(const char *obj) { + static const char* rooted(const char* obj) { static string buf; ostringstream os; os<clks = clk1<<1 | clk0; + topp->clks = clk1 << 1 | clk0; #ifndef T_CLK_2IN_VEC topp->c1 = clk1; topp->c0 = clk0; @@ -29,11 +27,11 @@ void clockit(int clk1, int clk0) { main_time++; } -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { topp = new VM_PREFIX; topp->check = 0; - clockit(0,0); - main_time+=10; + clockit(0, 0); + main_time += 10; Verilated::debug(0); @@ -50,5 +48,5 @@ int main(int argc, char *argv[]) { clockit(0, 0); } topp->check = 1; - clockit(0,0); + clockit(0, 0); } diff --git a/test_regress/t/t_clk_inp_init.cpp b/test_regress/t/t_clk_inp_init.cpp index 62160bf8c..9c267f64c 100644 --- a/test_regress/t/t_clk_inp_init.cpp +++ b/test_regress/t/t_clk_inp_init.cpp @@ -7,9 +7,7 @@ Vt_clk_inp_init* topp; vluint64_t main_time; -double sc_time_stamp() { - return main_time; -} +double sc_time_stamp() { return main_time; } void oneTest(int seed) { double sim_time = 1000; @@ -44,20 +42,20 @@ void oneTest(int seed) { } if (!Verilated::gotFinish()) { - vl_fatal(__FILE__,__LINE__,"main", "%Error: Timeout; never got a $finish"); + vl_fatal(__FILE__, __LINE__, "main", "%Error: Timeout; never got a $finish"); } topp->final(); - delete topp; topp=NULL; + delete topp; VL_DANGLING(topp); } -int main(int argc, char **argv, char **env) { +int main(int argc, char** argv, char** env) { Verilated::commandArgs(argc, argv); #if VL_DEBUG - //Verilated::debug(1); + // Verilated::debug(1); #endif - for (int seed=123; seed<133; ++seed) { + for (int seed = 123; seed < 133; ++seed) { oneTest(seed); } diff --git a/test_regress/t/t_dpi_accessors.cpp b/test_regress/t/t_dpi_accessors.cpp index f62d8f11e..8a201c40f 100644 --- a/test_regress/t/t_dpi_accessors.cpp +++ b/test_regress/t/t_dpi_accessors.cpp @@ -23,7 +23,6 @@ #include "Vt_dpi_accessors.h" #include "Vt_dpi_accessors__Dpi.h" - using std::cout; using std::dec; using std::endl; @@ -31,56 +30,40 @@ using std::hex; using std::setfill; using std::setw; - // Convenience function to check we didn't finish unexpectedly -static void checkFinish(const char *msg) { - if (Verilated::gotFinish ()) { +static void checkFinish(const char* msg) { + if (Verilated::gotFinish()) { vl_fatal(__FILE__, __LINE__, "dut", msg); exit(1); } } - // Convenience function to log the value of a register in hex. Only in verbose // mode. -static void logReg(int clk, - const char *desc, - int val, - const char *note) { +static void logReg(int clk, const char* desc, int val, const char* note) { #ifdef TEST_VERBOSE cout << "clk = " << clk << ", " << desc << " = " << val << note << endl; #endif } - // Convenience function to log the value of a register in hex. Only in verbose // mode. -static void logRegHex(int clk, - const char *desc, - int bitWidth, - int val, - const char *note) -{ +static void logRegHex(int clk, const char* desc, int bitWidth, int val, const char* note) { #ifdef TEST_VERBOSE cout << "clk = " << clk << ", " << desc << " = " << bitWidth << "\'h" << hex - << setw((bitWidth - 1) / 4 + 1) << setfill('0') << val - << setfill(' ') << setw(0) << dec << note << endl; + << setw((bitWidth - 1) / 4 + 1) << setfill('0') << val << setfill(' ') << setw(0) << dec + << note << endl; #endif - } - // Convenience function to check we got an expected result. Silent on success. -static void checkResult(bool p, const char *msg_fail) { - if (!p) { - vl_fatal(__FILE__, __LINE__, "dut", msg_fail); - } +static void checkResult(bool p, const char* msg_fail) { + if (!p) { vl_fatal(__FILE__, __LINE__, "dut", msg_fail); } } - // Main function instantiates the model and steps through the test. int main() { - Vt_dpi_accessors *dut = new Vt_dpi_accessors ("dut"); + Vt_dpi_accessors* dut = new Vt_dpi_accessors("dut"); svScope scope = svGetScopeFromName("dut.t"); if (!scope) vl_fatal(__FILE__, __LINE__, "dut", "No svGetScopeFromName result"); svSetScope(scope); @@ -94,32 +77,32 @@ int main() { cout << "==================" << endl; #endif - int a = (int) a_read(); - int b = (int) b_read(); - int mem32 = (int) mem32_read(); - int c = (int) c_read(); - int d = (int) d_read(); - int e = (int) e_read(); - int f = (int) f_read(); + int a = (int)a_read(); + int b = (int)b_read(); + int mem32 = (int)mem32_read(); + int c = (int)c_read(); + int d = (int)d_read(); + int e = (int)e_read(); + int f = (int)f_read(); #ifdef TEST_VERBOSE cout << "Read a = " << a << endl; - cout << "Read b = 8'h" << hex << setw(2) << setfill('0') << b - << setfill(' ') << setw(0) << dec << endl; - cout << "Read mem32 = 8'h" << hex << setw(2) << setfill('0') << mem32 - << setfill(' ') << setw(0) << dec << endl; + cout << "Read b = 8'h" << hex << setw(2) << setfill('0') << b << setfill(' ') << setw(0) + << dec << endl; + cout << "Read mem32 = 8'h" << hex << setw(2) << setfill('0') << mem32 << setfill(' ') + << setw(0) << dec << endl; cout << "Read c = " << c << endl; - cout << "Read d = 8'h" << hex << setw(2) << setfill('0') << d - << setfill(' ') << setw(0) << dec << endl; - cout << "Read e = 8'h" << hex << setw(2) << setfill('0') << e - << setfill(' ') << setw(0) << dec << endl; - cout << "Read f = 8'h" << hex << setw(2) << setfill('0') << f - << setfill(' ') << setw(0) << dec << endl; + cout << "Read d = 8'h" << hex << setw(2) << setfill('0') << d << setfill(' ') << setw(0) + << dec << endl; + cout << "Read e = 8'h" << hex << setw(2) << setfill('0') << e << setfill(' ') << setw(0) + << dec << endl; + cout << "Read f = 8'h" << hex << setw(2) << setfill('0') << f << setfill(' ') << setw(0) + << dec << endl; cout << endl; #endif - checkResult((0 == a) && (0x00 == b) && (0x20 == mem32) && (1 == c) - && (0xff == d) && (0x00 == e) && (0x00 == f), + checkResult((0 == a) && (0x00 == b) && (0x20 == mem32) && (1 == c) && (0xff == d) + && (0x00 == e) && (0x00 == f), "Bad initial DPI values."); // Initialize the clock @@ -131,13 +114,13 @@ int main() { cout << "===============================" << endl; #endif - for (int i = 0; !Verilated::gotFinish () && (i < 4); i++) { + for (int i = 0; !Verilated::gotFinish() && (i < 4); i++) { dut->clk = 1 - dut->clk; - a = (int) a_read(); + a = (int)a_read(); logReg(dut->clk, "read a", a, " (before clk)"); dut->eval(); - int a_after = (int) a_read(); + int a_after = (int)a_read(); logReg(dut->clk, "read a", a_after, " (after clk)"); #ifdef TEST_VERBOSE cout << endl; @@ -145,7 +128,7 @@ int main() { // On a posedge, a should toggle, on a negedge it should stay the // same. checkResult(((dut->clk == 1) && (a_after == (1 - a))) - || ((dut->clk == 0) && (a_after == a )), + || ((dut->clk == 0) && (a_after == a)), "Test of scalar register reading failed."); } @@ -157,18 +140,18 @@ int main() { cout << "===============================" << endl; #endif - for (int i = 0; !Verilated::gotFinish () && (i < 4); i++) { + for (int i = 0; !Verilated::gotFinish() && (i < 4); i++) { dut->clk = 1 - dut->clk; - b = (int) b_read(); + b = (int)b_read(); logRegHex(dut->clk, "read b", 8, b, " (before clk)"); dut->eval(); - int b_after = (int) b_read(); + int b_after = (int)b_read(); logRegHex(dut->clk, "read b", 8, b_after, " (after clk)"); // b should increment on a posedge and stay the same on a negedge. checkResult(((dut->clk == 1) && (b_after == (b + 1))) - || ((dut->clk == 0) && (b_after == b )), + || ((dut->clk == 0) && (b_after == b)), "Test of vector register reading failed."); } @@ -181,14 +164,14 @@ int main() { cout << "=============================" << endl; #endif - for (int i = 0; !Verilated::gotFinish () && (i < 4); i++) { + for (int i = 0; !Verilated::gotFinish() && (i < 4); i++) { dut->clk = 1 - dut->clk; - mem32 = (int) mem32_read(); + mem32 = (int)mem32_read(); logRegHex(dut->clk, "read mem32", 8, mem32, " (before clk)"); dut->eval(); - mem32 = (int) mem32_read(); + mem32 = (int)mem32_read(); logRegHex(dut->clk, "read mem32", 8, mem32, " (after clk)"); // In this case, the value never changes. But we should check it is @@ -205,17 +188,17 @@ int main() { cout << "===========================" << endl; #endif - for (int i = 0; !Verilated::gotFinish () && (i < 4); i++) { + for (int i = 0; !Verilated::gotFinish() && (i < 4); i++) { dut->clk = 1 - dut->clk; - a = (int) a_read(); - c = (int) c_read(); + a = (int)a_read(); + c = (int)c_read(); logReg(dut->clk, "read a", a, " (before clk)"); logReg(dut->clk, "read c", c, " (before clk)"); dut->eval(); - a = (int) a_read(); - c = (int) c_read(); + a = (int)a_read(); + c = (int)c_read(); logReg(dut->clk, "read a", a, " (after clk)"); logReg(dut->clk, "read c", c, " (after clk)"); // "c" is continuously assigned as the inverse of "a", but in @@ -234,17 +217,17 @@ int main() { cout << "===========================" << endl; #endif - for (int i = 0; !Verilated::gotFinish () && (i < 4); i++) { + for (int i = 0; !Verilated::gotFinish() && (i < 4); i++) { dut->clk = 1 - dut->clk; - b = (int) b_read(); - d = (int) d_read(); + b = (int)b_read(); + d = (int)d_read(); logRegHex(dut->clk, "read b", 8, b, " (before clk)"); logRegHex(dut->clk, "read d", 8, d, " (before clk)"); dut->eval(); - b = (int) b_read(); - d = (int) d_read(); + b = (int)b_read(); + d = (int)d_read(); logRegHex(dut->clk, "read b", 8, b, " (after clk)"); logRegHex(dut->clk, "read d", 8, d, " (after clk)"); @@ -264,9 +247,9 @@ int main() { cout << "===============================" << endl; #endif - for (int i = 0; !Verilated::gotFinish () && (i < 4); i++) { + for (int i = 0; !Verilated::gotFinish() && (i < 4); i++) { dut->clk = 1 - dut->clk; - a = 1 - (int) a_read(); + a = 1 - (int)a_read(); a_write(a); logReg(dut->clk, "write a", a, " (before clk)"); a = a_read(); @@ -274,14 +257,14 @@ int main() { dut->eval(); - int a_after = (int) a_read(); + int a_after = (int)a_read(); logReg(dut->clk, "read a", a_after, " (after clk)"); // On a posedge clock, the value of a that is written should toggle, // on a negedge, it should not. checkResult(((dut->clk == 1) && (a_after == (1 - a))) - || ((dut->clk == 0) && (a_after == a )), - "Test of scalar register writing failed."); + || ((dut->clk == 0) && (a_after == a)), + "Test of scalar register writing failed."); } checkFinish("t_dpi_accessors unexpected finish"); @@ -293,24 +276,24 @@ int main() { cout << "===============================" << endl; #endif - for (int i = 0; !Verilated::gotFinish () && (i < 4); i++) { + for (int i = 0; !Verilated::gotFinish() && (i < 4); i++) { dut->clk = 1 - dut->clk; - b = (int) b_read() - 1; - b_write((const svBitVecVal *) &b); + b = (int)b_read() - 1; + b_write((const svBitVecVal*)&b); logRegHex(dut->clk, "write b", 8, b, " (before clk)"); - b = (int) b_read(); + b = (int)b_read(); logRegHex(dut->clk, "read b", 8, b, " (before clk)"); dut->eval(); - int b_after = (int) b_read(); + int b_after = (int)b_read(); logRegHex(dut->clk, "read b", 8, b_after, " (after clk)"); // The value of "b" written should increment on a posedge and stay the // same on a negedge. checkResult(((dut->clk == 1) && (b_after == (b + 1))) - || ((dut->clk == 0) && (b_after == b )), - "Test of vector register writing failed."); + || ((dut->clk == 0) && (b_after == b)), + "Test of vector register writing failed."); } checkFinish("t_dpi_accessors unexpected finish"); @@ -322,25 +305,24 @@ int main() { cout << "=============================" << endl; #endif - for (int i = 0; !Verilated::gotFinish () && (i < 4); i++) { + for (int i = 0; !Verilated::gotFinish() && (i < 4); i++) { dut->clk = 1 - dut->clk; - mem32 = (int) mem32_read() - 1; - mem32_write((const svBitVecVal *) &mem32); + mem32 = (int)mem32_read() - 1; + mem32_write((const svBitVecVal*)&mem32); logRegHex(dut->clk, "write mem32", 8, mem32, " (before clk)"); - mem32 = (int) mem32_read(); + mem32 = (int)mem32_read(); logRegHex(dut->clk, "read mem32", 8, mem32, " (before clk)"); dut->eval(); - int mem32_after = (int) mem32_read(); + int mem32_after = (int)mem32_read(); logRegHex(dut->clk, "read mem32", 8, mem32_after, " (after clk)"); // In this case, the value we write never changes (this would only // happen if this part of the test coincided with the 32nd element // being overwritten, which it does not. Check that the value after // the clock is the same as before the clock. - checkResult(mem32_after == mem32, - "Test of array element writing failed."); + checkResult(mem32_after == mem32, "Test of array element writing failed."); } checkFinish("t_dpi_accessors unexpected finish"); @@ -352,23 +334,22 @@ int main() { cout << "=====================================" << endl; #endif - for (int i = 0; !Verilated::gotFinish () && (i < 4); i++) { + for (int i = 0; !Verilated::gotFinish() && (i < 4); i++) { dut->clk = 1 - dut->clk; - b = (int) b_read(); - int b_slice = (int) b_slice_read(); - logRegHex(dut->clk, "read b [7:0]", 8, b, " (before clk)"); + b = (int)b_read(); + int b_slice = (int)b_slice_read(); + logRegHex(dut->clk, "read b [7:0]", 8, b, " (before clk)"); logRegHex(dut->clk, "read b [3:0]", 4, b_slice, " (before clk)"); dut->eval(); - b = (int) b_read(); - b_slice = (int) b_slice_read(); - logRegHex(dut->clk, "read b [7:0]", 8, b, " (after clk)"); + b = (int)b_read(); + b_slice = (int)b_slice_read(); + logRegHex(dut->clk, "read b [7:0]", 8, b, " (after clk)"); logRegHex(dut->clk, "read b [3:0]", 4, b_slice, " (after clk)"); // The slice of "b" should always be the bottom 4 bits of "b" - checkResult(b_slice == (b & 0x0f), - "Test of vector register slice reading failed."); + checkResult(b_slice == (b & 0x0f), "Test of vector register slice reading failed."); } checkFinish("t_dpi_accessors unexpected finish"); @@ -380,21 +361,19 @@ int main() { cout << "===================================" << endl; #endif - for (int i = 0; !Verilated::gotFinish () && (i < 4); i++) { + for (int i = 0; !Verilated::gotFinish() && (i < 4); i++) { dut->clk = 1 - dut->clk; - mem32 = (int) mem32_read(); - int mem32_slice = (int) mem32_slice_read(); + mem32 = (int)mem32_read(); + int mem32_slice = (int)mem32_slice_read(); logRegHex(dut->clk, "read mem32 [7:0] ", 8, mem32, " (before clk)"); - logRegHex(dut->clk, "read mem32 [7:6,2:0]", 5, mem32_slice, - " (before clk)"); + logRegHex(dut->clk, "read mem32 [7:6,2:0]", 5, mem32_slice, " (before clk)"); dut->eval(); - mem32 = (int) mem32_read(); - mem32_slice = (int) mem32_slice_read(); - logRegHex(dut->clk, "read mem32 [7:0] ", 8, mem32," (after clk)"); - logRegHex(dut->clk, "read mem32 [7:6,2:0]", 5, mem32_slice, - " (after clk)"); + mem32 = (int)mem32_read(); + mem32_slice = (int)mem32_slice_read(); + logRegHex(dut->clk, "read mem32 [7:0] ", 8, mem32, " (after clk)"); + logRegHex(dut->clk, "read mem32 [7:6,2:0]", 5, mem32_slice, " (after clk)"); // The slice of "mem32" should always be the concatenation of the top // 2 and bottom 3 bits of "mem32" @@ -411,27 +390,26 @@ int main() { cout << "=================================" << endl; #endif - for (int i = 0; !Verilated::gotFinish () && (i < 4); i++) { + for (int i = 0; !Verilated::gotFinish() && (i < 4); i++) { dut->clk = 1 - dut->clk; - b = (int) b_read(); - d = (int) d_read(); - int d_slice = (int) d_slice_read(); - logRegHex(dut->clk, "read b [7:0]", 8, b, " (before clk)"); - logRegHex(dut->clk, "read d [7:0]", 8, d, " (before clk)"); + b = (int)b_read(); + d = (int)d_read(); + int d_slice = (int)d_slice_read(); + logRegHex(dut->clk, "read b [7:0]", 8, b, " (before clk)"); + logRegHex(dut->clk, "read d [7:0]", 8, d, " (before clk)"); logRegHex(dut->clk, "read d [6:1]", 6, d_slice, " (before clk)"); dut->eval(); - b = (int) b_read(); - d = (int) d_read(); - d_slice = (int) d_slice_read(); - logRegHex(dut->clk, "read b [7:0]", 8, b, " (after clk)"); - logRegHex(dut->clk, "read d [7:0]", 8, d, " (after clk)"); + b = (int)b_read(); + d = (int)d_read(); + d_slice = (int)d_slice_read(); + logRegHex(dut->clk, "read b [7:0]", 8, b, " (after clk)"); + logRegHex(dut->clk, "read d [7:0]", 8, d, " (after clk)"); logRegHex(dut->clk, "read d [6:1]", 6, d_slice, " (after clk)"); // The slice of "d" should always be the middle 6 bits of "d". - checkResult(d_slice == ((d & 0x7e) >> 1), - "Test of vector wire slice reading failed."); + checkResult(d_slice == ((d & 0x7e) >> 1), "Test of vector wire slice reading failed."); } checkFinish("t_dpi_accessors unexpected finish"); @@ -443,36 +421,33 @@ int main() { cout << "=====================================" << endl; #endif - for (int i = 0; !Verilated::gotFinish () && (i < 4); i++) { + for (int i = 0; !Verilated::gotFinish() && (i < 4); i++) { dut->clk = 1 - dut->clk; - b = (int) b_read(); - int b_slice = (int) b_slice_read(); - logRegHex(dut->clk, "read b [7:0]", 8, b, " (before write)"); + b = (int)b_read(); + int b_slice = (int)b_slice_read(); + logRegHex(dut->clk, "read b [7:0]", 8, b, " (before write)"); logRegHex(dut->clk, "read b [3:0]", 4, b_slice, " (before write)"); b_slice--; - b_slice_write((const svBitVecVal *) &b_slice); + b_slice_write((const svBitVecVal*)&b_slice); logRegHex(dut->clk, "write b [3:0]", 4, b_slice, " (before clk)"); - int b_after = (int) b_read(); - int b_slice_after = (int) b_slice_read(); - logRegHex(dut->clk, "read b [7:0]", 8, b_after, - " (before clk)"); - logRegHex(dut->clk, "read b [3:0]", 4, b_slice_after, - " (before clk)"); + int b_after = (int)b_read(); + int b_slice_after = (int)b_slice_read(); + logRegHex(dut->clk, "read b [7:0]", 8, b_after, " (before clk)"); + logRegHex(dut->clk, "read b [3:0]", 4, b_slice_after, " (before clk)"); // We must test that when we wrote the slice of "b", we only wrote the // correct bits. The slice of b is b[3:0] - int b_new = (b & 0xf0) | (b_slice &0x0f); - checkResult(b_after == b_new, - "Test of vector register slice writing failed."); + int b_new = (b & 0xf0) | (b_slice & 0x0f); + checkResult(b_after == b_new, "Test of vector register slice writing failed."); dut->eval(); - b = (int) b_read(); - b_slice = (int) b_slice_read(); - logRegHex(dut->clk, "read b [7:0]", 8, b, " (after clk)"); + b = (int)b_read(); + b_slice = (int)b_slice_read(); + logRegHex(dut->clk, "read b [7:0]", 8, b, " (after clk)"); logRegHex(dut->clk, "read b [3:0]", 4, b_slice, " (after clk)"); } @@ -485,43 +460,34 @@ int main() { cout << "===================================" << endl; #endif - for (int i = 0; !Verilated::gotFinish () && (i < 4); i++) { + for (int i = 0; !Verilated::gotFinish() && (i < 4); i++) { dut->clk = 1 - dut->clk; - mem32 = (int) mem32_read(); - int mem32_slice = (int) mem32_slice_read(); - logRegHex(dut->clk, "read mem32 [7:0] ", 8, mem32, - " (before write)"); - logRegHex(dut->clk, "read mem32 [7:6,2:0]", 5, mem32_slice, - " (before write)"); + mem32 = (int)mem32_read(); + int mem32_slice = (int)mem32_slice_read(); + logRegHex(dut->clk, "read mem32 [7:0] ", 8, mem32, " (before write)"); + logRegHex(dut->clk, "read mem32 [7:6,2:0]", 5, mem32_slice, " (before write)"); mem32_slice--; - mem32_slice_write((const svBitVecVal *) &mem32_slice); - logRegHex(dut->clk, "write mem32 [7:6,2:0]", 5, mem32_slice, - " (before clk)"); + mem32_slice_write((const svBitVecVal*)&mem32_slice); + logRegHex(dut->clk, "write mem32 [7:6,2:0]", 5, mem32_slice, " (before clk)"); - int mem32_after = (int) mem32_read(); - int mem32_slice_after = (int) mem32_slice_read(); - logRegHex(dut->clk, "read mem32 [7:0] ", 8, mem32_after, - " (before clk)"); - logRegHex(dut->clk, "read mem32 [7:6,2:0]", 5, mem32_slice_after, - " (before clk)"); + int mem32_after = (int)mem32_read(); + int mem32_slice_after = (int)mem32_slice_read(); + logRegHex(dut->clk, "read mem32 [7:0] ", 8, mem32_after, " (before clk)"); + logRegHex(dut->clk, "read mem32 [7:6,2:0]", 5, mem32_slice_after, " (before clk)"); // We must test that when we wrote the slice of "mem32", we only wrote // the correct bits. The slice of "mem32" is {mem32[7:6], mem32[2:0]}. - int mem32_new = (mem32 & 0x38) - | ((mem32_slice & 0x18) << 3) | - (mem32_slice & 0x7); - checkResult(mem32_after == mem32_new, - "Test of vector register slice writing failed."); + int mem32_new = (mem32 & 0x38) | ((mem32_slice & 0x18) << 3) | (mem32_slice & 0x7); + checkResult(mem32_after == mem32_new, "Test of vector register slice writing failed."); dut->eval(); - mem32 = (int) mem32_read(); - mem32_slice = (int) mem32_slice_read(); - logRegHex(dut->clk, "read mem32 [7:0] ", 8, mem32," (after clk)"); - logRegHex(dut->clk, "read mem32 [7:6,2:0]", 5, mem32_slice, - " (after clk)"); + mem32 = (int)mem32_read(); + mem32_slice = (int)mem32_slice_read(); + logRegHex(dut->clk, "read mem32 [7:0] ", 8, mem32, " (after clk)"); + logRegHex(dut->clk, "read mem32 [7:6,2:0]", 5, mem32_slice, " (after clk)"); // We have already tested that array element writing works, so we just // check that dhe slice of "mem32" after the clock is the @@ -539,68 +505,67 @@ int main() { cout << "================================" << endl; #endif - for (int i = 0; !Verilated::gotFinish () && (i < 4); i++) { + for (int i = 0; !Verilated::gotFinish() && (i < 4); i++) { dut->clk = 1 - dut->clk; - b = (int) b_read(); - mem32 = (int) mem32_read(); - e = (int) e_read(); - int l1 = (int) l1_read(); - logRegHex(dut->clk, "read b ", 8, b, " (before clk)"); - logRegHex(dut->clk, "read mem32", 8, mem32, " (before clk)"); - logRegHex(dut->clk, "read e ", 8, e, " (before clk)"); - logRegHex(dut->clk, "read l1 ", 15, l1, " (before clk)"); + b = (int)b_read(); + mem32 = (int)mem32_read(); + e = (int)e_read(); + int l1 = (int)l1_read(); + logRegHex(dut->clk, "read b ", 8, b, " (before clk)"); + logRegHex(dut->clk, "read mem32", 8, mem32, " (before clk)"); + logRegHex(dut->clk, "read e ", 8, e, " (before clk)"); + logRegHex(dut->clk, "read l1 ", 15, l1, " (before clk)"); dut->eval(); - b = (int) b_read(); - mem32 = (int) mem32_read(); - e = (int) e_read(); - l1 = (int) l1_read(); - logRegHex(dut->clk, "read b ", 8, b, " (after clk)"); - logRegHex(dut->clk, "read mem32", 8, mem32, " (after clk)"); - logRegHex(dut->clk, "read e ", 8, e, " (after clk)"); - logRegHex(dut->clk, "read l1 ", 15, l1, " (after clk)"); + b = (int)b_read(); + mem32 = (int)mem32_read(); + e = (int)e_read(); + l1 = (int)l1_read(); + logRegHex(dut->clk, "read b ", 8, b, " (after clk)"); + logRegHex(dut->clk, "read mem32", 8, mem32, " (after clk)"); + logRegHex(dut->clk, "read e ", 8, e, " (after clk)"); + logRegHex(dut->clk, "read l1 ", 15, l1, " (after clk)"); // We have already tested that reading of registers, memory elements // and wires works. So we just need to check that l1 reads back as the // correct combination of bits after the clock. It should be the 15 // bits: {b[3:0],mem[32][7:6],e[6:1],mem[32][2:0]}. - checkResult(l1 == ( (((b & 0x0f) >> 0) << 11) - | (((mem32 & 0xc0) >> 6) << 9) - | (((e & 0x7e) >> 1) << 3) - | (((mem32 & 0x07) >> 0) << 0)), + checkResult(l1 + == ((((b & 0x0f) >> 0) << 11) | (((mem32 & 0xc0) >> 6) << 9) + | (((e & 0x7e) >> 1) << 3) | (((mem32 & 0x07) >> 0) << 0)), "Test of complex register reading l1 failed."); } #ifdef TEST_VERBOSE - cout << endl; + cout << endl; #endif checkFinish("t_dpi_accessors unexpected finish"); - for (int i = 0; !Verilated::gotFinish () && (i < 4); i++) { + for (int i = 0; !Verilated::gotFinish() && (i < 4); i++) { dut->clk = 1 - dut->clk; e = 0x05 | (i << 4); f = 0xa0 | i; - e_write((const svBitVecVal *) &e); - f_write((const svBitVecVal *) &f); + e_write((const svBitVecVal*)&e); + f_write((const svBitVecVal*)&f); - e = (int) e_read(); - f = (int) f_read(); - int l2 = (int) l2_read(); - logRegHex(dut->clk, "read e ", 8, e, " (before clk)"); - logRegHex(dut->clk, "read f ", 8, f, " (before clk)"); + e = (int)e_read(); + f = (int)f_read(); + int l2 = (int)l2_read(); + logRegHex(dut->clk, "read e ", 8, e, " (before clk)"); + logRegHex(dut->clk, "read f ", 8, f, " (before clk)"); logRegHex(dut->clk, "read l2", 8, l2, " (before clk)"); dut->eval(); - e = (int) e_read(); - f = (int) f_read(); - l2 = (int) l2_read(); - logRegHex(dut->clk, "read e ", 8, e, " (before clk)"); - logRegHex(dut->clk, "read f ", 8, f, " (before clk)"); + e = (int)e_read(); + f = (int)f_read(); + l2 = (int)l2_read(); + logRegHex(dut->clk, "read e ", 8, e, " (before clk)"); + logRegHex(dut->clk, "read f ", 8, f, " (before clk)"); logRegHex(dut->clk, "read l2", 8, l2, " (before clk)"); // We have already tested that reading of registers, memory elements @@ -620,93 +585,91 @@ int main() { cout << "================================" << endl; #endif - for (int i = 0; !Verilated::gotFinish () && (i < 4); i++) { + for (int i = 0; !Verilated::gotFinish() && (i < 4); i++) { dut->clk = 1 - dut->clk; - b = (int) b_read(); - mem32 = (int) mem32_read(); - e = (int) e_read(); - logRegHex(dut->clk, "read b ", 8, b, " (before write)"); - logRegHex(dut->clk, "read mem32", 8, mem32, " (before write)"); - logRegHex(dut->clk, "read e ", 8, e, " (before write)"); + b = (int)b_read(); + mem32 = (int)mem32_read(); + e = (int)e_read(); + logRegHex(dut->clk, "read b ", 8, b, " (before write)"); + logRegHex(dut->clk, "read mem32", 8, mem32, " (before write)"); + logRegHex(dut->clk, "read e ", 8, e, " (before write)"); - int l1 = 0x5a5a; - l1_write((const svBitVecVal *) &l1); + int l1 = 0x5a5a; + l1_write((const svBitVecVal*)&l1); logRegHex(dut->clk, "write l1 ", 15, l1, " (before clk)"); - int b_after = (int) b_read(); - int mem32_after = (int) mem32_read(); - int e_after = (int) e_read(); - int l1_after = (int) l1_read(); - logRegHex(dut->clk, "read b ", 8, b_after, " (before clk)"); - logRegHex(dut->clk, "read mem32", 8, mem32_after, " (before clk)"); - logRegHex(dut->clk, "read e ", 8, e_after, " (before clk)"); - logRegHex(dut->clk, "read l1 ", 15, l1_after, " (before clk)"); + int b_after = (int)b_read(); + int mem32_after = (int)mem32_read(); + int e_after = (int)e_read(); + int l1_after = (int)l1_read(); + logRegHex(dut->clk, "read b ", 8, b_after, " (before clk)"); + logRegHex(dut->clk, "read mem32", 8, mem32_after, " (before clk)"); + logRegHex(dut->clk, "read e ", 8, e_after, " (before clk)"); + logRegHex(dut->clk, "read l1 ", 15, l1_after, " (before clk)"); // We need to check that when we write l1, the correct fields, and // only the correct fields are set in its component registers, wires // and memory elements. l1 is 15 bits: // {b[3:0],mem[32][7:6],e[6:1],mem[32][2:0]}. - int b_new = (b & 0xf0) | ((l1 & 0x7800) >> 11); - int mem32_new = (mem32 & 0x38) | ((l1 & 0x0600) >> 3) | (l1 & 0x0007); - int e_new = (e & 0x81) | ((l1 & 0x01f8) >> 2); - checkResult((b_new == b_after) - && (mem32_new == mem32_after) - && (e_new == e_after), + int b_new = (b & 0xf0) | ((l1 & 0x7800) >> 11); + int mem32_new = (mem32 & 0x38) | ((l1 & 0x0600) >> 3) | (l1 & 0x0007); + int e_new = (e & 0x81) | ((l1 & 0x01f8) >> 2); + checkResult((b_new == b_after) && (mem32_new == mem32_after) && (e_new == e_after), "Test of complex register writing l1 failed."); dut->eval(); - b = (int) b_read(); - mem32 = (int) mem32_read(); - d = (int) d_read(); - l1 = (int) l1_read(); - logRegHex(dut->clk, "read b ", 8, b, " (after clk)"); - logRegHex(dut->clk, "read mem32", 8, mem32, " (after clk)"); - logRegHex(dut->clk, "read d ", 8, d, " (after clk)"); - logRegHex(dut->clk, "read l1 ", 15, l1, " (after clk)"); + b = (int)b_read(); + mem32 = (int)mem32_read(); + d = (int)d_read(); + l1 = (int)l1_read(); + logRegHex(dut->clk, "read b ", 8, b, " (after clk)"); + logRegHex(dut->clk, "read mem32", 8, mem32, " (after clk)"); + logRegHex(dut->clk, "read d ", 8, d, " (after clk)"); + logRegHex(dut->clk, "read l1 ", 15, l1, " (after clk)"); } #ifdef TEST_VERBOSE - cout << endl; + cout << endl; #endif checkFinish("t_dpi_accessors unexpected finish"); - for (int i = 0; !Verilated::gotFinish () && (i < 4); i++) { + for (int i = 0; !Verilated::gotFinish() && (i < 4); i++) { dut->clk = 1 - dut->clk; - e = (int) e_read(); - f = (int) f_read(); - logRegHex(dut->clk, "read e ", 8, e, " (before write)"); - logRegHex(dut->clk, "read f ", 8, f, " (before write)"); + e = (int)e_read(); + f = (int)f_read(); + logRegHex(dut->clk, "read e ", 8, e, " (before write)"); + logRegHex(dut->clk, "read f ", 8, f, " (before write)"); - int l2 = 0xa5 + i; - l2_write((const svBitVecVal *) &l2); + int l2 = 0xa5 + i; + l2_write((const svBitVecVal*)&l2); logRegHex(dut->clk, "write l2", 8, l2, " (before clk)"); - int e_after = (int) e_read(); - int f_after = (int) f_read(); - int l2_after = (int) l2_read(); - logRegHex(dut->clk, "read e ", 8, e_after, " (before clk)"); - logRegHex(dut->clk, "read f ", 8, f_after, " (before clk)"); + int e_after = (int)e_read(); + int f_after = (int)f_read(); + int l2_after = (int)l2_read(); + logRegHex(dut->clk, "read e ", 8, e_after, " (before clk)"); + logRegHex(dut->clk, "read f ", 8, f_after, " (before clk)"); logRegHex(dut->clk, "read l2", 8, l2_after, " (before clk)"); // We need to check that when we write l2, the correct fields, and // only the correct fields are set in its component registers. l is 8 // bits: {e[5:2], f[5:2]} - int e_new = (e & 0xc3) | ((l2 & 0xf0) >> 2); - int f_new = (f & 0xc3) | ((l2 & 0x0f) << 2); + int e_new = (e & 0xc3) | ((l2 & 0xf0) >> 2); + int f_new = (f & 0xc3) | ((l2 & 0x0f) << 2); checkResult((e_new == e_after) && (f_new == f_after), "Test of complex register writing l2 failed."); dut->eval(); - e = (int) e_read(); - f = (int) f_read(); - l2 = (int) l2_read(); - logRegHex(dut->clk, "read e ", 8, e, " (before clk)"); - logRegHex(dut->clk, "read f ", 8, f, " (before clk)"); + e = (int)e_read(); + f = (int)f_read(); + l2 = (int)l2_read(); + logRegHex(dut->clk, "read e ", 8, e, " (before clk)"); + logRegHex(dut->clk, "read f ", 8, f, " (before clk)"); logRegHex(dut->clk, "read l2", 8, l2, " (before clk)"); } @@ -714,7 +677,7 @@ int main() { // Tidy up dut->final(); - cout << "*-* All Finished *-*" << endl;; + cout << "*-* All Finished *-*" << endl; } // Local Variables: diff --git a/test_regress/t/t_dpi_context_c.cpp b/test_regress/t/t_dpi_context_c.cpp index bedf3f85d..8d18468a7 100644 --- a/test_regress/t/t_dpi_context_c.cpp +++ b/test_regress/t/t_dpi_context_c.cpp @@ -57,9 +57,7 @@ int dpic_line() { #ifdef VERILATOR static int didDump = 0; - if (didDump++ == 0) { - Verilated::scopesDump(); - } + if (didDump++ == 0) { Verilated::scopesDump(); } #endif const char* scopenamep = svGetNameFromScope(scope); @@ -130,6 +128,7 @@ int dpic_restore() { unsigned dpic_getcontext() { svScope scope = svGetScope(); - printf("%%Info: svGetScope returned scope (%p) with name %s\n", scope, svGetNameFromScope(scope)); - return (unsigned) (uintptr_t) scope; + printf("%%Info: svGetScope returned scope (%p) with name %s\n", + scope, svGetNameFromScope(scope)); + return (unsigned)(uintptr_t)scope; } diff --git a/test_regress/t/t_dpi_export_c.cpp b/test_regress/t/t_dpi_export_c.cpp index df87236e4..46e78c3e2 100644 --- a/test_regress/t/t_dpi_export_c.cpp +++ b/test_regress/t/t_dpi_export_c.cpp @@ -73,7 +73,7 @@ extern "C" { #define CHECK_RESULT(type, got, exp) \ if ((got) != (exp)) { \ - printf("%%Error: %s:%d:", __FILE__,__LINE__); \ + printf("%%Error: %s:%d:", __FILE__, __LINE__); \ union { type a; long long l; } u; \ u.l = 0; u.a = got; if (u.a) {/*used*/} \ printf(" GOT = %" T_PRI64 "x", u.l); \ @@ -83,7 +83,7 @@ extern "C" { } #define CHECK_RESULT_NNULL(got) \ if (!(got)) { \ - printf("%%Error: %s:%d: GOT = %p EXP = !NULL\n", __FILE__,__LINE__, (got)); \ + printf("%%Error: %s:%d: GOT = %p EXP = !NULL\n", __FILE__, __LINE__, (got)); \ return __LINE__; \ } @@ -98,8 +98,8 @@ static int check_sub(const char* name, int i) { CHECK_RESULT(svScope, sout, prev); CHECK_RESULT(svScope, svGetScope(), scope); #ifndef T_DPI_EXPORT_NOOPT - int out = dpix_sub_inst(100*i); - CHECK_RESULT(int, out, 100*i + i); + int out = dpix_sub_inst(100 * i); + CHECK_RESULT(int, out, 100 * i + i); #endif return 0; // OK } @@ -118,14 +118,14 @@ int dpix_run_tests() { #endif #ifndef CADENCE // Unimplemented; how hard is it? - printf("svDpiVersion: %s\n",svDpiVersion()); + printf("svDpiVersion: %s\n", svDpiVersion()); CHECK_RESULT(bool, strcmp(svDpiVersion(), "1800-2005")==0 || strcmp(svDpiVersion(), "P1800-2005")==0 , 1); #endif - CHECK_RESULT(int, dpix_int123(), 0x123 ); + CHECK_RESULT(int, dpix_int123(), 0x123); #ifndef CADENCE // No export calls from an import int o; @@ -150,27 +150,27 @@ int dpix_run_tests() { CHECK_RESULT(void*, dpix_f_chandle((void*)(12345)), (void*)(12345)); { - svBitVecVal i_vec48[2] = {0xab782a12,0x8a413bd9}; - svBitVecVal o_vec48[2] = {0,0}; + svBitVecVal i_vec48[2] = {0xab782a12, 0x8a413bd9}; + svBitVecVal o_vec48[2] = {0, 0}; dpix_t_bit48(i_vec48, o_vec48); CHECK_RESULT(int, o_vec48[0], ~i_vec48[0]); #ifdef VCS // VCS has bug where doesn't clean input CHECK_RESULT(int, o_vec48[1], (~i_vec48[1])); #else - CHECK_RESULT(int, o_vec48[1], (~i_vec48[1])&0x0000ffffUL); + CHECK_RESULT(int, o_vec48[1], (~i_vec48[1]) & 0x0000ffffUL); #endif } { - svBitVecVal i_vec95[3] = {0x72912312,0xab782a12,0x8a413bd9}; - svBitVecVal o_vec95[3] = {0,0,0}; + svBitVecVal i_vec95[3] = {0x72912312, 0xab782a12, 0x8a413bd9}; + svBitVecVal o_vec95[3] = {0, 0, 0}; dpix_t_bit95(i_vec95, o_vec95); CHECK_RESULT(int, o_vec95[0], ~i_vec95[0]); CHECK_RESULT(int, o_vec95[1], ~i_vec95[1]); - CHECK_RESULT(int, o_vec95[2], (~i_vec95[2])&0x7fffffffUL); + CHECK_RESULT(int, o_vec95[2], (~i_vec95[2]) & 0x7fffffffUL); } { - svBitVecVal i_vec96[3] = {0xf2912312,0xab782a12,0x8a413bd9}; - svBitVecVal o_vec96[3] = {0,0,0}; + svBitVecVal i_vec96[3] = {0xf2912312, 0xab782a12, 0x8a413bd9}; + svBitVecVal o_vec96[3] = {0, 0, 0}; dpix_t_bit96(i_vec96, o_vec96); CHECK_RESULT(int, o_vec96[0], ~i_vec96[0]); CHECK_RESULT(int, o_vec96[1], ~i_vec96[1]); @@ -203,7 +203,7 @@ int dpix_run_tests() { dpix_t_reg95(i, o); CHECK_RESULT(int, o[0].aval, ~i[0].aval); CHECK_RESULT(int, o[1].aval, ~i[1].aval); - CHECK_RESULT(int, o[2].aval, (~i[2].aval)&0x7fffffffUL); + CHECK_RESULT(int, o[2].aval, (~i[2].aval) & 0x7fffffffUL); CHECK_RESULT(int, o[0].bval, 0); CHECK_RESULT(int, o[1].bval, 0); CHECK_RESULT(int, o[2].bval, 0); @@ -222,8 +222,8 @@ int dpix_run_tests() { } #endif - if (int bad=check_sub("top.t.a",1)) return bad; - if (int bad=check_sub("top.t.b",2)) return bad; + if (int bad = check_sub("top.t.a", 1)) return bad; + if (int bad = check_sub("top.t.b", 2)) return bad; return -1; // OK status } diff --git a/test_regress/t/t_dpi_imp_gen_c.cpp b/test_regress/t/t_dpi_imp_gen_c.cpp index 8ba2df5a3..366bb46c5 100644 --- a/test_regress/t/t_dpi_imp_gen_c.cpp +++ b/test_regress/t/t_dpi_imp_gen_c.cpp @@ -34,6 +34,6 @@ extern "C" { // Called from our Verilog code to run the tests void dpi_genvarTest() { - const char *scopeName = svGetNameFromScope(svGetScope()); + const char* scopeName = svGetNameFromScope(svGetScope()); printf("scope name : %s\n", scopeName); } diff --git a/test_regress/t/t_dpi_import_c.cpp b/test_regress/t/t_dpi_import_c.cpp index 9c34af74f..29d135772 100644 --- a/test_regress/t/t_dpi_import_c.cpp +++ b/test_regress/t/t_dpi_import_c.cpp @@ -29,7 +29,10 @@ # error "Unknown simulator for DPI test" #endif -typedef struct { int a; int b; } substruct_t; +typedef struct { + int a; + int b; +} substruct_t; #ifdef NEED_EXTERNS extern "C" { @@ -157,7 +160,7 @@ void dpii_v_struct(const svBitVecVal* i, svBitVecVal* o) { void dpii_v_substruct(const svBitVecVal* i, int* o) { // To be most like other tools, this should automagically take the substruct_t // as an argument, and not require this cast... - substruct_t* issp = (substruct_t*) i; + substruct_t* issp = (substruct_t*)i; o[0] = issp->b - issp->a; } void dpii_v_bit64(const svBitVecVal* i, svBitVecVal* o) { @@ -175,7 +178,7 @@ void dpii_v_bit96(const svBitVecVal* i, svBitVecVal* o) { o[2] = ~i[2]; } -int dpii_f_strlen(const char* i) { return strlen(i); } +int dpii_f_strlen(const char* i) { return strlen(i); } //====================================================================== @@ -184,18 +187,14 @@ void dpii_f_void() {} #ifdef VCS void dpii_t_void() {} void dpii_t_void_context() {} -void dpii_t_int(int i, int *o) { - *o = i; -} +void dpii_t_int(int i, int* o) { *o = i; } #else int dpii_t_void() { return svIsDisabledState(); } int dpii_t_void_context() { return svIsDisabledState(); } -int dpii_t_int(int i, int *o) { +int dpii_t_int(int i, int* o) { *o = i; return svIsDisabledState(); // Tasks generally need this } #endif -int dpii_fa_bit(int i) { - return ~i; -} +int dpii_fa_bit(int i) { return ~i; } diff --git a/test_regress/t/t_dpi_lib_c.cpp b/test_regress/t/t_dpi_lib_c.cpp index 4972d70f6..e1142a20b 100644 --- a/test_regress/t/t_dpi_lib_c.cpp +++ b/test_regress/t/t_dpi_lib_c.cpp @@ -46,16 +46,18 @@ int failure = 0; int dpii_failure() { return failure; } #define CHECK_RESULT_HEX(got, exp) \ - do { if ((got) != (exp)) { \ - std::cout<=1) { - int d=1; - if (c==0) { + if (u >= 1) { + int d = 1; + if (c == 0) { CHECK_RESULT_HEX(svLeft(i, d), -2); CHECK_RESULT_HEX(svRight(i, d), 2); CHECK_RESULT_HEX(svLow(i, d), -2); CHECK_RESULT_HEX(svHigh(i, d), 2); - //CHECK_RESULT_HEX(svIncrement(i, d), 0); + // CHECK_RESULT_HEX(svIncrement(i, d), 0); CHECK_RESULT_HEX(svSize(i, d), 5); - } else if (c==1) { + } else if (c == 1) { CHECK_RESULT_HEX(svLeft(i, d), 2); CHECK_RESULT_HEX(svRight(i, d), -2); CHECK_RESULT_HEX(svLow(i, d), -2); CHECK_RESULT_HEX(svHigh(i, d), 2); - //CHECK_RESULT_HEX(svIncrement(i, d), 0); + // CHECK_RESULT_HEX(svIncrement(i, d), 0); CHECK_RESULT_HEX(svSize(i, d), 5); } } - if (u>=2) { - int d=2; - if (c==0) { + if (u >= 2) { + int d = 2; + if (c == 0) { CHECK_RESULT_HEX(svLeft(i, d), -3); CHECK_RESULT_HEX(svRight(i, d), 3); CHECK_RESULT_HEX(svLow(i, d), -3); CHECK_RESULT_HEX(svHigh(i, d), 3); - //CHECK_RESULT_HEX(svIncrement(i, d), 0); + // CHECK_RESULT_HEX(svIncrement(i, d), 0); CHECK_RESULT_HEX(svSize(i, d), 7); - } else if (c==1) { + } else if (c == 1) { CHECK_RESULT_HEX(svLeft(i, d), 3); CHECK_RESULT_HEX(svRight(i, d), -3); CHECK_RESULT_HEX(svLow(i, d), -3); CHECK_RESULT_HEX(svHigh(i, d), 3); - //CHECK_RESULT_HEX(svIncrement(i, d), 0); + // CHECK_RESULT_HEX(svIncrement(i, d), 0); CHECK_RESULT_HEX(svSize(i, d), 7); } } - if (c==2 && p==1 && u==3) { - for (int a=svLow(i,1); a<=svHigh(i,1); ++a) { - for (int b=svLow(i,2); b<=svHigh(i,2); ++b) { - for (int c=svLow(i,3); c<=svHigh(i,3); ++c) { - //printf("Copy abc %d,%d,%d\n", a,b,c); + if (c == 2 && p == 1 && u == 3) { + for (int a = svLow(i, 1); a <= svHigh(i, 1); ++a) { + for (int b = svLow(i, 2); b <= svHigh(i, 2); ++b) { + for (int c = svLow(i, 3); c <= svHigh(i, 3); ++c) { + // printf("Copy abc %d,%d,%d\n", a,b,c); svLogicVecVal vec[3]; svGetLogicArrElemVecVal(vec, i, a, b, c); #ifdef NC - //printf(" %08lx_%08lx_%08lx\n", vec[2].a, vec[1].a, vec[0].a); + // printf(" %08lx_%08lx_%08lx\n", vec[2].a, vec[1].a, vec[0].a); vec[0].a = (~vec[0].a); vec[1].a = (~vec[1].a); vec[2].a = (~vec[2].a) & 0x7fffffff; - //vec[0].b = vec[0].b; - //vec[1].b = vec[1].b; - //vec[2].b = vec[2].b; + // vec[0].b = vec[0].b; + // vec[1].b = vec[1].b; + // vec[2].b = vec[2].b; #else vec[0].aval = (~vec[0].aval); vec[1].aval = (~vec[1].aval); vec[2].aval = (~vec[2].aval) & 0x7fffffff; - //vec[0].bval = vec[0].bval; - //vec[1].bval = vec[1].bval; - //vec[2].bval = vec[2].bval; + // vec[0].bval = vec[0].bval; + // vec[1].bval = vec[1].bval; + // vec[2].bval = vec[2].bval; #endif svPutLogicArrElemVecVal(o, vec, a, b, c); } @@ -195,39 +198,37 @@ void _dpii_all(int c, int p, int u, const svOpenArrayHandle i, const svOpenArray } void dpii_open_p0_u1(int c, int p, int u, const svOpenArrayHandle i, const svOpenArrayHandle o) { - _dpii_all(c,p,u,i,o); + _dpii_all(c, p, u, i, o); } void dpii_open_p1_u0(int c, int p, int u, const svOpenArrayHandle i, const svOpenArrayHandle o) { - _dpii_all(c,p,u,i,o); + _dpii_all(c, p, u, i, o); } void dpii_open_p1_u1(int c, int p, int u, const svOpenArrayHandle i, const svOpenArrayHandle o) { - _dpii_all(c,p,u,i,o); + _dpii_all(c, p, u, i, o); } void dpii_open_p1_u2(int c, int p, int u, const svOpenArrayHandle i, const svOpenArrayHandle o) { - _dpii_all(c,p,u,i,o); + _dpii_all(c, p, u, i, o); } void dpii_open_p1_u3(int c, int p, int u, const svOpenArrayHandle i, const svOpenArrayHandle o) { - _dpii_all(c,p,u,i,o); + _dpii_all(c, p, u, i, o); } void dpii_open_pw_u0(int c, int p, int u, const svOpenArrayHandle i, const svOpenArrayHandle o) { - _dpii_all(c,p,u,i,o); + _dpii_all(c, p, u, i, o); } void dpii_open_pw_u1(int c, int p, int u, const svOpenArrayHandle i, const svOpenArrayHandle o) { - _dpii_all(c,p,u,i,o); + _dpii_all(c, p, u, i, o); } void dpii_open_pw_u2(int c, int p, int u, const svOpenArrayHandle i, const svOpenArrayHandle o) { - _dpii_all(c,p,u,i,o); + _dpii_all(c, p, u, i, o); } void dpii_open_pw_u3(int c, int p, int u, const svOpenArrayHandle i, const svOpenArrayHandle o) { - _dpii_all(c,p,u,i,o); + _dpii_all(c, p, u, i, o); } -void dpii_open_bit(const svOpenArrayHandle i, const svOpenArrayHandle o) { } -void dpii_open_byte(const svOpenArrayHandle i, const svOpenArrayHandle o) { } -void dpii_open_int(const svOpenArrayHandle i, const svOpenArrayHandle o) { } -void dpii_open_integer(const svOpenArrayHandle i, const svOpenArrayHandle o) { } -void dpii_open_logic(const svOpenArrayHandle i, const svOpenArrayHandle o) { } +void dpii_open_bit(const svOpenArrayHandle i, const svOpenArrayHandle o) {} +void dpii_open_byte(const svOpenArrayHandle i, const svOpenArrayHandle o) {} +void dpii_open_int(const svOpenArrayHandle i, const svOpenArrayHandle o) {} +void dpii_open_integer(const svOpenArrayHandle i, const svOpenArrayHandle o) {} +void dpii_open_logic(const svOpenArrayHandle i, const svOpenArrayHandle o) {} -int dpii_failed() { - return failure; -} +int dpii_failed() { return failure; } diff --git a/test_regress/t/t_dpi_openfirst_c.cpp b/test_regress/t/t_dpi_openfirst_c.cpp index 4dea967e2..8de301afa 100644 --- a/test_regress/t/t_dpi_openfirst_c.cpp +++ b/test_regress/t/t_dpi_openfirst_c.cpp @@ -46,29 +46,31 @@ int failure = 0; int dpii_failure() { return failure; } #define CHECK_RESULT_HEX(got, exp) \ - do { if ((got) != (exp)) { \ - std::cout<= 0 && idx= 0 && idx < COUNTERS) ? global_count[idx] : -1; } unsigned char dpii_incx(int idx, unsigned char value) { - if (idx >= 0 && idx= 0 && idx < COUNTERS) global_count[idx]++; return value; } -unsigned char dpii_inc0(int idx) { return dpii_incx(idx,0); } -unsigned char dpii_inc1(int idx) { return dpii_incx(idx,1); } +unsigned char dpii_inc0(int idx) { return dpii_incx(idx, 0); } +unsigned char dpii_inc1(int idx) { return dpii_incx(idx, 1); } diff --git a/test_regress/t/t_dpi_sys_c.cpp b/test_regress/t/t_dpi_sys_c.cpp index 11a82f7c8..50dafff10 100644 --- a/test_regress/t/t_dpi_sys_c.cpp +++ b/test_regress/t/t_dpi_sys_c.cpp @@ -41,9 +41,5 @@ extern "C" { static int hidden = 0; -void dpii_sys_task(int i) { - hidden = i; -} -int dpii_sys_func(int i) { - return i + hidden; -} +void dpii_sys_task(int i) { hidden = i; } +int dpii_sys_func(int i) { return i + hidden; } diff --git a/test_regress/t/t_dpi_threads_c.cpp b/test_regress/t/t_dpi_threads_c.cpp index 814a8ce28..8ed0ac701 100644 --- a/test_regress/t/t_dpi_threads_c.cpp +++ b/test_regress/t/t_dpi_threads_c.cpp @@ -47,8 +47,9 @@ extern "C" { struct state { std::atomic task_is_running; std::atomic failure; - state() : task_is_running(false) - , failure(false) {} + state() + : task_is_running(false) + , failure(false) {} }; static state st; @@ -73,6 +74,4 @@ void dpii_sys_task() { atomic_exchange(&st.task_is_running, false); } -int dpii_failure() { - return st.failure; -} +int dpii_failure() { return st.failure; } diff --git a/test_regress/t/t_dpi_vams.cpp b/test_regress/t/t_dpi_vams.cpp index f56b64b73..5272d92e0 100644 --- a/test_regress/t/t_dpi_vams.cpp +++ b/test_regress/t/t_dpi_vams.cpp @@ -33,13 +33,11 @@ void dpii_call(double in, double* outp) { unsigned int main_time = 0; -double sc_time_stamp() { - return main_time; -} +double sc_time_stamp() { return main_time; } VM_PREFIX* topp = NULL; -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { topp = new VM_PREFIX; Verilated::debug(0); @@ -50,7 +48,7 @@ int main(int argc, char *argv[]) { VL_PRINTF("*-* All Finished *-*\n"); topp->final(); } else { - vl_fatal(__FILE__,__LINE__,"top", "Unexpected results\n"); + vl_fatal(__FILE__, __LINE__, "top", "Unexpected results\n"); } return 0; } diff --git a/test_regress/t/t_dpi_var.cpp b/test_regress/t/t_dpi_var.cpp index c7993be0e..36a545d49 100644 --- a/test_regress/t/t_dpi_var.cpp +++ b/test_regress/t/t_dpi_var.cpp @@ -23,7 +23,10 @@ struct MyMon { vluint32_t* sigsp[2]; - MyMon() { sigsp[0]=NULL; sigsp[1]=NULL; } + MyMon() { + sigsp[0] = NULL; + sigsp[1] = NULL; + } }; MyMon mons[2]; @@ -36,13 +39,13 @@ void mon_register_a(const char* namep, void* sigp, bool isOut) { } void mon_do(MyMon* monp) { - if (!monp->sigsp[0]) vl_fatal(__FILE__,__LINE__,"","never registered"); - if (!monp->sigsp[1]) vl_fatal(__FILE__,__LINE__,"","never registered"); - *monp->sigsp[1] = (*(monp->sigsp[0]))+1; + if (!monp->sigsp[0]) vl_fatal(__FILE__, __LINE__, "", "never registered"); + if (!monp->sigsp[1]) vl_fatal(__FILE__, __LINE__, "", "never registered"); + *monp->sigsp[1] = (*(monp->sigsp[0])) + 1; #ifdef TEST_VERBOSE - VL_PRINTF("- mon_do(%08x(&%p) -> %08x(&%p));\n", - *(monp->sigsp[0]), monp->sigsp[0], *(monp->sigsp[1]), monp->sigsp[1]); + VL_PRINTF("- mon_do(%08x(&%p) -> %08x(&%p));\n", *(monp->sigsp[0]), monp->sigsp[0], + *(monp->sigsp[1]), monp->sigsp[1]); #endif } @@ -51,7 +54,8 @@ void mon_class_name(const char* namep) { VL_PRINTF("- mon_class_name(\"%s\");\n", namep); #endif // Check the C's calling name of "" doesn't lead to extra dots in the name() - if (namep && namep[0]=='.') vl_fatal(__FILE__,__LINE__,"", (std::string("Unexp class name ")+namep).c_str()); + if (namep && namep[0] == '.') + vl_fatal(__FILE__, __LINE__, "", (std::string("Unexp class name ") + namep).c_str()); } extern "C" void mon_scope_name(const char* namep); @@ -60,8 +64,10 @@ void mon_scope_name(const char* namep) { #ifdef TEST_VERBOSE VL_PRINTF("- mon_scope_name('%s', \"%s\");\n", modp, namep); #endif - if (strcmp(namep,"t.sub")) vl_fatal(__FILE__,__LINE__,"", (std::string("Unexp scope name ")+namep).c_str()); - if (strcmp(modp,"t.sub")) vl_fatal(__FILE__,__LINE__,"", (std::string("Unexp dpiscope name ")+modp).c_str()); + if (strcmp(namep, "t.sub")) + vl_fatal(__FILE__, __LINE__, "", (std::string("Unexp scope name ") + namep).c_str()); + if (strcmp(modp, "t.sub")) + vl_fatal(__FILE__, __LINE__, "", (std::string("Unexp dpiscope name ") + modp).c_str()); } extern "C" void mon_register_b(const char* namep, int isOut); @@ -93,8 +99,7 @@ void mon_register_done() { // Print list of all signals - if we didn't register2 anything we'd pick them off here const VerilatedScope* scopep = Verilated::dpiScope(); if (VerilatedVarNameMap* varsp = scopep->varsp()) { - for (VerilatedVarNameMap::const_iterator it = varsp->begin(); - it != varsp->end(); ++it) { + for (VerilatedVarNameMap::const_iterator it = varsp->begin(); it != varsp->end(); ++it) { VL_PRINTF("- mon2: %s\n", it->first); } } @@ -111,10 +116,8 @@ void mon_eval() { unsigned int main_time = false; -double sc_time_stamp() { - return main_time; -} -int main(int argc, char **argv, char **env) { +double sc_time_stamp() { return main_time; } +int main(int argc, char** argv, char** env) { double sim_time = 1100; Verilated::commandArgs(argc, argv); Verilated::debug(0); @@ -135,13 +138,13 @@ int main(int argc, char **argv, char **env) { main_time += 1; topp->eval(); topp->clk = !topp->clk; - //mon_do(); + // mon_do(); } if (!Verilated::gotFinish()) { - vl_fatal(__FILE__,__LINE__,"main", "%Error: Timeout; never got a $finish"); + vl_fatal(__FILE__, __LINE__, "main", "%Error: Timeout; never got a $finish"); } topp->final(); - delete topp; topp=NULL; + delete topp; VL_DANGLING(topp); exit(0L); } diff --git a/test_regress/t/t_embed1_c.cpp b/test_regress/t/t_embed1_c.cpp index 2ba2aeaee..029d33323 100644 --- a/test_regress/t/t_embed1_c.cpp +++ b/test_regress/t/t_embed1_c.cpp @@ -34,7 +34,6 @@ #ifdef NEED_EXTERNS extern "C" { - extern void t_embed_child_initial(); extern void t_embed_child_final(); extern void t_embed_child_eval(); @@ -50,7 +49,7 @@ int T_Embed_Child_Unique = 0; // Address used for uniqueness Vt_embed1_child* __get_modelp() { svScope scope = svGetScope(); if (!scope) { - vl_fatal(__FILE__,__LINE__,__FILE__,"svGetScope failed"); + vl_fatal(__FILE__, __LINE__, __FILE__, "svGetScope failed"); return NULL; } @@ -58,29 +57,29 @@ Vt_embed1_child* __get_modelp() { if (!__modelp) { // Create the model const char* scopenamep = svGetNameFromScope(scope); - if (!scopenamep) vl_fatal(__FILE__,__LINE__,__FILE__,"svGetNameFromScope failed"); + if (!scopenamep) vl_fatal(__FILE__, __LINE__, __FILE__, "svGetNameFromScope failed"); __modelp = new Vt_embed1_child(scopenamep); if (svPutUserData(scope, &T_Embed_Child_Unique, __modelp)) { - vl_fatal(__FILE__,__LINE__,__FILE__,"svPutUserData failed"); + vl_fatal(__FILE__, __LINE__, __FILE__, "svPutUserData failed"); } } return (Vt_embed1_child*)(__modelp); } void t_embed_child_initial() { - VL_DEBUG_IF(VL_PRINTF(" t_embed1_child_initial\n"); ); + VL_DEBUG_IF(VL_PRINTF(" t_embed1_child_initial\n");); Vt_embed1_child* __modelp = __get_modelp(); __modelp->eval(); } void t_embed_child_final() { - VL_DEBUG_IF(VL_PRINTF(" t_embed1_child_final\n"); ); + VL_DEBUG_IF(VL_PRINTF(" t_embed1_child_final\n");); Vt_embed1_child* __modelp = __get_modelp(); __modelp->final(); } void t_embed_child_eval() { - VL_DEBUG_IF(VL_PRINTF(" t_embed1_child_eval\n"); ); + VL_DEBUG_IF(VL_PRINTF(" t_embed1_child_eval\n");); Vt_embed1_child* __modelp = __get_modelp(); __modelp->eval(); } @@ -94,7 +93,7 @@ void t_embed_child_io_eval(unsigned char clk, svBitVecVal* vec_out, svBitVecVal* wide_out, unsigned char* did_init_out) { - VL_DEBUG_IF(VL_PRINTF(" t_embed1_child_io_eval\n"); ); + VL_DEBUG_IF(VL_PRINTF(" t_embed1_child_io_eval\n");); Vt_embed1_child* __modelp = __get_modelp(); VL_DEBUG_IF(VL_PRINTF("[%0ld] in clk=%x b=%x V=%x R=%x\n", (long int) (VL_TIME_Q()), clk, bit_in, vec_in[0], diff --git a/test_regress/t/t_enum_public.cpp b/test_regress/t/t_enum_public.cpp index 84c996848..1a0f66f3e 100644 --- a/test_regress/t/t_enum_public.cpp +++ b/test_regress/t/t_enum_public.cpp @@ -11,8 +11,8 @@ #include "Vt_enum_public_p3.h" #include "Vt_enum_public_p62.h" -int main(int argc, char *argv[]) { - Vt_enum_public *topp = new Vt_enum_public; +int main(int argc, char* argv[]) { + Vt_enum_public* topp = new Vt_enum_public; Verilated::debug(0); diff --git a/test_regress/t/t_extend.v b/test_regress/t/t_extend.v index 31814f1df..e2a2ae788 100644 --- a/test_regress/t/t_extend.v +++ b/test_regress/t/t_extend.v @@ -56,7 +56,7 @@ module t (/*AUTOARG*/ #endif bool m_did_ctor; vluint32_t my_function() { - if (!m_did_ctor) vl_fatal(__FILE__,__LINE__,__FILE__,"`systemc_ctor didn't work"); + if (!m_did_ctor) vl_fatal(__FILE__, __LINE__, __FILE__, "`systemc_ctor didn't work"); return 1; } `systemc_imp_header diff --git a/test_regress/t/t_extend_class_c.h b/test_regress/t/t_extend_class_c.h index f98831edd..28f0db7d0 100644 --- a/test_regress/t/t_extend_class_c.h +++ b/test_regress/t/t_extend_class_c.h @@ -12,7 +12,5 @@ public: ~t_extend_class_c() {} // METHODS // This function will be called from a instance created in Verilog - inline vluint32_t my_math(vluint32_t in) { - return in+1; - } + inline vluint32_t my_math(vluint32_t in) { return in + 1; } }; diff --git a/test_regress/t/t_flag_fi.cpp b/test_regress/t/t_flag_fi.cpp index 4c971b386..f25e4b8d9 100644 --- a/test_regress/t/t_flag_fi.cpp +++ b/test_regress/t/t_flag_fi.cpp @@ -12,26 +12,20 @@ unsigned int main_time = 0; -double sc_time_stamp() { - return main_time; -} +double sc_time_stamp() { return main_time; } VM_PREFIX* topp = NULL; bool gotit = false; -void myfunction() { - gotit = true; -} +void myfunction() { gotit = true; } -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { topp = new VM_PREFIX; Verilated::debug(0); topp->eval(); - if (!gotit) { - vl_fatal(__FILE__, __LINE__, "dut", "Never got call to myfunction"); - } + if (!gotit) { vl_fatal(__FILE__, __LINE__, "dut", "Never got call to myfunction"); } topp->final(); diff --git a/test_regress/t/t_flag_ldflags_a.cpp b/test_regress/t/t_flag_ldflags_a.cpp index eb2d8eb14..bae28918f 100644 --- a/test_regress/t/t_flag_ldflags_a.cpp +++ b/test_regress/t/t_flag_ldflags_a.cpp @@ -14,5 +14,5 @@ //************************************************************************* extern "C" { - void dpii_a_library() {} +void dpii_a_library() {} }; diff --git a/test_regress/t/t_flag_ldflags_so.cpp b/test_regress/t/t_flag_ldflags_so.cpp index e861153b5..144ba7de2 100644 --- a/test_regress/t/t_flag_ldflags_so.cpp +++ b/test_regress/t/t_flag_ldflags_so.cpp @@ -14,5 +14,5 @@ //************************************************************************* extern "C" { - void dpii_so_library() {} +void dpii_so_library() {} }; diff --git a/test_regress/t/t_func_crc.v b/test_regress/t/t_func_crc.v index cd9f98c61..667b54a4f 100644 --- a/test_regress/t/t_func_crc.v +++ b/test_regress/t/t_func_crc.v @@ -52,7 +52,7 @@ module t (/*AUTOARG*/ reg [63:0] drev; begin drev = reverse(di); - crc = newcrc(drev, ci); + crc = newcrc(drev, ci); end endfunction diff --git a/test_regress/t/t_func_rand.cpp b/test_regress/t/t_func_rand.cpp index 86436e91b..bda91faba 100644 --- a/test_regress/t/t_func_rand.cpp +++ b/test_regress/t/t_func_rand.cpp @@ -8,8 +8,8 @@ #include #include "Vt_func_rand.h" -int main(int argc, char *argv[]) { - Vt_func_rand *topp = new Vt_func_rand; +int main(int argc, char* argv[]) { + Vt_func_rand* topp = new Vt_func_rand; Verilated::debug(0); @@ -21,7 +21,7 @@ int main(int argc, char *argv[]) { topp->eval(); } if (topp->Rand != 0xfeed0fad) { - vl_fatal(__FILE__,__LINE__,"top", "Unexpected value for Rand output\n"); + vl_fatal(__FILE__, __LINE__, "top", "Unexpected value for Rand output\n"); } printf("*-* All Finished *-*\n"); } diff --git a/test_regress/t/t_leak.cpp b/test_regress/t/t_leak.cpp index cc87736be..500a0a4cf 100644 --- a/test_regress/t/t_leak.cpp +++ b/test_regress/t/t_leak.cpp @@ -13,9 +13,7 @@ #include "Vt_leak.h" unsigned int main_time = false; -double sc_time_stamp() { - return main_time; -} +double sc_time_stamp() { return main_time; } long long get_memory_usage() { // Return memory usage. Return 0 if the system doesn't look quite right. @@ -29,8 +27,8 @@ long long get_memory_usage() { FILE* fp = fopen("/proc/self/stat", "r"); if (!fp) return 0; - int ps_ign; - vluint64_t ps_vsize, ps_rss; + int ps_ign; + vluint64_t ps_vsize, ps_rss; int items = fscanf(fp, ("%d (%*[^) ]) %*1s %d %*d %*d %*d %*d %u" " %u %u %u %u %d %d %d %d" " %*d %*d %*u %*u %d %" VL_PRI64 "u %" VL_PRI64 "u "), @@ -54,27 +52,27 @@ void make_and_destroy() { topp->eval(); topp->clk = true; while (!Verilated::gotFinish()) { - main_time+=5; - topp->clk=!topp->clk; + main_time += 5; + topp->clk = !topp->clk; topp->eval(); } - delete topp; topp=NULL; + delete topp; VL_DANGLING(topp); } -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { vluint64_t firstUsage = get_memory_usage(); // Warmup phase - for (int i=0; i<1000; i++) { + for (int i = 0; i < 1000; i++) { make_and_destroy(); } firstUsage = get_memory_usage(); printf("Memory size %" VL_PRI64 "d bytes\n", firstUsage); int loops = 100*1000; - for (int left=loops; left>0;) { - for (int j=0; j<1000; j++, left--) { + for (int left = loops; left > 0;) { + for (int j = 0; j < 1000; ++j, --left) { make_and_destroy(); } } @@ -82,7 +80,7 @@ int main(int argc, char *argv[]) { vluint64_t leaked = get_memory_usage() - firstUsage; if (leaked > 64*1024) { // Have to allow some slop for this code. printf("Leaked %" VL_PRI64 "d bytes, or ~ %" VL_PRI64 "d bytes/construt\n", leaked, leaked/loops); - vl_fatal(__FILE__,__LINE__,"top", "Leaked memory\n"); + vl_fatal(__FILE__, __LINE__, "top", "Leaked memory\n"); } printf("*-* All Finished *-*\n"); diff --git a/test_regress/t/t_math_imm2.cpp b/test_regress/t/t_math_imm2.cpp index 2a51f25f3..16cf354b2 100644 --- a/test_regress/t/t_math_imm2.cpp +++ b/test_regress/t/t_math_imm2.cpp @@ -10,26 +10,26 @@ QData MaskVal(int lbit, int hbit) { return val; } -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { Verilated::debug(0); - Vt_math_imm2 *sim = new Vt_math_imm2; - int lbit, hbit; + Vt_math_imm2* sim = new Vt_math_imm2; + int lbit, hbit; - int errs=0; + int errs = 0; for (lbit = 0; lbit < 32; lbit++) { for (hbit = lbit; hbit < 32; hbit++) { QData expected; - sim->LowMaskSel_Bot = lbit; - sim->LowMaskSel_Top = lbit; + sim->LowMaskSel_Bot = lbit; + sim->LowMaskSel_Top = lbit; sim->HighMaskSel_Bot = hbit; sim->HighMaskSel_Top = hbit; sim->eval(); - expected = (MaskVal(sim->LowMaskSel_Top, sim->HighMaskSel_Top) << 32ULL) - | MaskVal(sim->LowMaskSel_Bot, sim->HighMaskSel_Bot); + expected = ((MaskVal(sim->LowMaskSel_Top, sim->HighMaskSel_Top) << 32ULL) + | MaskVal(sim->LowMaskSel_Bot, sim->HighMaskSel_Bot)); if (sim->LogicImm != expected) { printf("%%Error: %d.%d,%d.%d -> %016" VL_PRI64 "x/%016" VL_PRI64 "x -> %016" VL_PRI64 "x (expected %016" VL_PRI64 "x)\n", diff --git a/test_regress/t/t_mem_multi_io2.cpp b/test_regress/t/t_mem_multi_io2.cpp index fbd2658a2..5ba03efce 100644 --- a/test_regress/t/t_mem_multi_io2.cpp +++ b/test_regress/t/t_mem_multi_io2.cpp @@ -8,9 +8,7 @@ VM_PREFIX* tb = NULL; bool pass = true; -double sc_time_stamp() { - return 0; -} +double sc_time_stamp() { return 0; } void check(const char* bus, int got, int exp) { if (got != exp) { @@ -29,19 +27,19 @@ int main() tb = new VM_PREFIX("tb"); #ifdef SYSTEMC_VERSION - sc_signal i3; - sc_signal o3; - sc_signal i34[4]; - sc_signal o34[4]; - sc_signal i345[4][5]; - sc_signal o345[4][5]; + sc_signal i3; + sc_signal o3; + sc_signal i34[4]; + sc_signal o34[4]; + sc_signal i345[4][5]; + sc_signal o345[4][5]; tb->i3(i3); tb->o3(o3); - for (int i=0; i<4; i++) { + for (int i = 0; i < 4; i++) { tb->i34[i](i34[i]); tb->o34[i](o34[i]); - for (int j=0; j<5; j++) { + for (int j = 0; j < 5; j++) { tb->i345[i][j](i345[i][j]); tb->o345[i][j](o345[i][j]); } @@ -60,31 +58,31 @@ int main() #endif ASSIGN(i3, 13); - for (int i=0; i<4; i++) { + for (int i = 0; i < 4; i++) { ASSIGN(i34[i], i); - for (int j=0; j<5; j++) { - ASSIGN(i345[i][j], i*8 + j); + for (int j = 0; j < 5; j++) { + ASSIGN(i345[i][j], i * 8 + j); } } #ifdef SYSTEMC_VERSION - sc_start(1,SC_NS); + sc_start(1, SC_NS); #else tb->eval(); #endif check("o3", READ(o3), 13); - for (int i=0; i<4; i++) { + for (int i = 0; i < 4; i++) { check("o34", READ(o34[i]), i); - for (int j=0; j<5; j++) { - check("o345", READ(o345[i][j]), i*8 + j); + for (int j = 0; j < 5; j++) { + check("o345", READ(o345[i][j]), i * 8 + j); } } if (pass) { VL_PRINTF("*-* All Finished *-*\n"); } else { - vl_fatal(__FILE__,__LINE__,"top", "Unexpected results from test\n"); + vl_fatal(__FILE__, __LINE__, "top", "Unexpected results from test\n"); } return 0; } diff --git a/test_regress/t/t_mem_multi_io3.cpp b/test_regress/t/t_mem_multi_io3.cpp index 0dd2de51d..30aa58aeb 100644 --- a/test_regress/t/t_mem_multi_io3.cpp +++ b/test_regress/t/t_mem_multi_io3.cpp @@ -8,9 +8,7 @@ VM_PREFIX* tb = NULL; bool pass = true; -double sc_time_stamp() { - return 0; -} +double sc_time_stamp() { return 0; } #ifdef SYSTEMC_VERSION int sc_main(int, char**) @@ -27,7 +25,7 @@ int main() if (pass) { VL_PRINTF("*-* All Finished *-*\n"); } else { - vl_fatal(__FILE__,__LINE__,"top", "Unexpected results from test\n"); + vl_fatal(__FILE__, __LINE__, "top", "Unexpected results from test\n"); } return 0; } diff --git a/test_regress/t/t_mem_slot.cpp b/test_regress/t/t_mem_slot.cpp index 4c6bded5f..0ea8f4d55 100644 --- a/test_regress/t/t_mem_slot.cpp +++ b/test_regress/t/t_mem_slot.cpp @@ -6,24 +6,24 @@ unsigned int Array[3]; -unsigned int StepSim(Vt_mem_slot *sim, unsigned int slot, unsigned int bit, unsigned int val, unsigned int rslot) { +unsigned int StepSim(Vt_mem_slot* sim, unsigned int slot, unsigned int bit, unsigned int val, + unsigned int rslot) { #ifdef TEST_VERBOSE printf("StepSim: slot=%u bit=%u val=%u rslot=%u\n", slot, bit, val, rslot); #endif - sim->SlotIdx = slot; - sim->BitToChange = bit; - sim->BitVal = val; + sim->SlotIdx = slot; + sim->BitToChange = bit; + sim->BitVal = val; sim->SlotToReturn = rslot; - sim->Clk = 0; + sim->Clk = 0; sim->eval(); - sim->Clk = 1; + sim->Clk = 1; sim->eval(); - if (sim->OutputVal != Array[rslot]) { printf("%%Error: got %x - expected %x\n", sim->OutputVal, Array[rslot]); exit(1); @@ -37,8 +37,8 @@ unsigned int StepSim(Vt_mem_slot *sim, unsigned int slot, unsigned int bit, unsi return sim->OutputVal; } -int main(int argc, char *argv[]) { - Vt_mem_slot *sim = new Vt_mem_slot; +int main(int argc, char* argv[]) { + Vt_mem_slot* sim = new Vt_mem_slot; int slot, bit, i; Verilated::debug(0); diff --git a/test_regress/t/t_multitop_sig.cpp b/test_regress/t/t_multitop_sig.cpp index 8f5ed43cf..d631a3738 100644 --- a/test_regress/t/t_multitop_sig.cpp +++ b/test_regress/t/t_multitop_sig.cpp @@ -9,18 +9,16 @@ #include #include "Vt_multitop_sig.h" - // Use cout to avoid issues with %d/%lx etc -#define CHECK_RESULT(got, exp) \ - if ((got) != (exp)) { \ - std::cout<i_clk_wr = !vcore->i_clk_wr; - if ( clk & 2 ) vcore->i_clk_rd = !vcore->i_clk_rd; +static void half_cycle(int clk) { + if (clk & 1) vcore->i_clk_wr = !vcore->i_clk_wr; + if (clk & 2) vcore->i_clk_rd = !vcore->i_clk_rd; vtime += 10 / 2; vcore->eval(); vcore->eval(); - vcd->dump( vtime ); + vcd->dump(vtime); } static void cycle() { #ifdef PHASE_90 - half_cycle( 1 ); - half_cycle( 2 ); - half_cycle( 1 ); - half_cycle( 2 ); + half_cycle(1); + half_cycle(2); + half_cycle(1); + half_cycle(2); #else - half_cycle( 3 ); - half_cycle( 3 ); + half_cycle(3); + half_cycle(3); #endif } int main() { - Verilated::traceEverOn( true ); + Verilated::traceEverOn(true); - vcore = new Vt_order_multidriven; - vcd = new VerilatedVcdC; + vcore = new Vt_order_multidriven; + vcd = new VerilatedVcdC; - vcore->trace( vcd, 99 ); - vcd->open(STRINGIFY(TEST_OBJ_DIR) "/simx.vcd" ); + vcore->trace(vcd, 99); + vcd->open(STRINGIFY(TEST_OBJ_DIR) "/simx.vcd"); - vcore->i_clk_wr = 0; - vcore->i_clk_rd = 0; + vcore->i_clk_wr = 0; + vcore->i_clk_rd = 0; - for ( int i = 0; i < 256; ++i ) - cycle( ); + for (int i = 0; i < 256; ++i) + cycle(); - vcd->close( ); + vcd->close(); printf("*-* All Finished *-*\n"); } diff --git a/test_regress/t/t_order_quad.cpp b/test_regress/t/t_order_quad.cpp index 52992e0d4..bfd0920e1 100644 --- a/test_regress/t/t_order_quad.cpp +++ b/test_regress/t/t_order_quad.cpp @@ -12,9 +12,7 @@ unsigned int main_time = 0; -double sc_time_stamp() { - return main_time; -} +double sc_time_stamp() { return main_time; } VM_PREFIX* topp = NULL; bool fail = false; @@ -26,7 +24,7 @@ void check(QData got, QData exp) { } } -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { topp = new VM_PREFIX; Verilated::debug(0); @@ -44,7 +42,7 @@ int main(int argc, char *argv[]) { VL_PRINTF("*-* All Finished *-*\n"); topp->final(); } else { - vl_fatal(__FILE__,__LINE__,"top", "Unexpected results\n"); + vl_fatal(__FILE__, __LINE__, "top", "Unexpected results\n"); } return 0; } diff --git a/test_regress/t/t_param_public.cpp b/test_regress/t/t_param_public.cpp index 21ef77f7f..fe4ec5788 100644 --- a/test_regress/t/t_param_public.cpp +++ b/test_regress/t/t_param_public.cpp @@ -10,8 +10,8 @@ #include "Vt_param_public_p.h" -int main(int argc, char *argv[]) { - Vt_param_public *topp = new Vt_param_public; +int main(int argc, char* argv[]) { + Vt_param_public* topp = new Vt_param_public; Verilated::debug(0); diff --git a/test_regress/t/t_scope_map.cpp b/test_regress/t/t_scope_map.cpp index 6047e3cb9..3e15a7a02 100644 --- a/test_regress/t/t_scope_map.cpp +++ b/test_regress/t/t_scope_map.cpp @@ -19,20 +19,18 @@ using namespace std; unsigned long long main_time = 0; -double sc_time_stamp() { - return (double)main_time; -} +double sc_time_stamp() { return (double)main_time; } const unsigned long long dt_2 = 3; -int main(int argc, char **argv, char **env) { - Vt_scope_map *top = new Vt_scope_map("top"); +int main(int argc, char** argv, char** env) { + Vt_scope_map* top = new Vt_scope_map("top"); Verilated::debug(0); Verilated::traceEverOn(true); VerilatedVcdC* tfp = new VerilatedVcdC; - top->trace(tfp,99); + top->trace(tfp, 99); tfp->open(STRINGIFY(TEST_OBJ_DIR) "/simx.vcd"); top->CLK = 0; @@ -41,21 +39,22 @@ int main(int argc, char **argv, char **env) { ++main_time; const VerilatedScopeNameMap* scopeMapp = Verilated::scopeNameMap(); - for (VerilatedScopeNameMap::const_iterator it = scopeMapp->begin(); - it != scopeMapp->end(); ++it) { + for (VerilatedScopeNameMap::const_iterator it = scopeMapp->begin(); it != scopeMapp->end(); + ++it) { #ifdef TEST_VERBOSE VL_PRINTF("---------------------------------------------\n"); VL_PRINTF("Scope = %s\n", it->first); it->second->scopeDump(); #endif - VerilatedVarNameMap * varNameMap = it->second->varsp(); + VerilatedVarNameMap* varNameMap = it->second->varsp(); if (varNameMap == NULL) { VL_PRINTF("%%Error: Bad varsp()\n"); return -1; } - for (VerilatedVarNameMap::iterator varIt = varNameMap->begin(); varIt != varNameMap->end(); ++varIt) { - VerilatedVar * var = &varIt->second; + for (VerilatedVarNameMap::iterator varIt = varNameMap->begin(); varIt != varNameMap->end(); + ++varIt) { + VerilatedVar* var = &varIt->second; int varLeft = var->packed().left(); int varRight = var->packed().right(); @@ -76,7 +75,7 @@ int main(int argc, char **argv, char **env) { int varBits = varLeft + 1; // First expect an incrementing byte pattern - vluint8_t * varData = reinterpret_cast(var->datap()); + vluint8_t* varData = reinterpret_cast(var->datap()); for (int i = 0; i < varBits / 8; i++) { #ifdef TEST_VERBOSE VL_PRINTF("%02x ", varData[i]); @@ -84,17 +83,19 @@ int main(int argc, char **argv, char **env) { vluint8_t expected = i % 0xff; if (varData[i] != expected) { - VL_PRINTF("%%Error: Data mismatch, got 0x%02x, expected 0x%02x\n", varData[i], expected); + VL_PRINTF("%%Error: Data mismatch, got 0x%02x, expected 0x%02x\n", varData[i], + expected); return -1; } } // Extra bits all set high initially if (varBits % 8 != 0) { - vluint8_t got = varData[ varBits / 8 ]; - vluint8_t expected = ~(0xff << ( varBits % 8 )); + vluint8_t got = varData[varBits / 8]; + vluint8_t expected = ~(0xff << (varBits % 8)); if (got != expected) { - VL_PRINTF("%%Error: Data mismatch, got 0x%02x, expected 0x%02x\n", got, expected); + VL_PRINTF("%%Error: Data mismatch, got 0x%02x, expected 0x%02x\n", got, + expected); return -1; } } @@ -104,7 +105,7 @@ int main(int argc, char **argv, char **env) { #endif // Clear out the data - memset(varData, 0, ( varBits + 7 ) / 8); + memset(varData, 0, (varBits + 7) / 8); } } @@ -119,33 +120,37 @@ int main(int argc, char **argv, char **env) { tfp->dump((unsigned int)(main_time)); ++main_time; - for (VerilatedScopeNameMap::const_iterator it = scopeMapp->begin(); it != scopeMapp->end(); ++it) { - VerilatedVarNameMap * varNameMap = it->second->varsp(); + for (VerilatedScopeNameMap::const_iterator it = scopeMapp->begin(); it != scopeMapp->end(); + ++it) { + VerilatedVarNameMap* varNameMap = it->second->varsp(); if (varNameMap == NULL) { VL_PRINTF("%%Error: Bad varsp()\n"); return -1; } - for (VerilatedVarNameMap::iterator varIt = varNameMap->begin(); varIt != varNameMap->end(); ++varIt) { - VerilatedVar * var = &varIt->second; + for (VerilatedVarNameMap::iterator varIt = varNameMap->begin(); varIt != varNameMap->end(); + ++varIt) { + VerilatedVar* var = &varIt->second; int varLeft = var->packed().left(); int varBits = varLeft + 1; - vluint8_t * varData = reinterpret_cast(var->datap()); + vluint8_t* varData = reinterpret_cast(var->datap()); // Check that all bits are high now for (int i = 0; i < varBits / 8; i++) { vluint8_t expected = 0xff; if (varData[i] != expected) { - VL_PRINTF("%%Error: Data mismatch (%s), got 0x%02x, expected 0x%02x\n", varIt->first, varData[i], expected); + VL_PRINTF("%%Error: Data mismatch (%s), got 0x%02x, expected 0x%02x\n", + varIt->first, varData[i], expected); return -1; } } if (varBits % 8 != 0) { - vluint8_t got = varData[ varBits / 8 ]; - vluint8_t expected = ~(0xff << ( varBits % 8 )); + vluint8_t got = varData[varBits / 8]; + vluint8_t expected = ~(0xff << (varBits % 8)); if (got != expected) { - VL_PRINTF("%%Error: Data mismatch (%s), got 0x%02x, expected 0x%02x\n", varIt->first, got, expected); + VL_PRINTF("%%Error: Data mismatch (%s), got 0x%02x, expected 0x%02x\n", + varIt->first, got, expected); return -1; } } diff --git a/test_regress/t/t_trace_cat.cpp b/test_regress/t/t_trace_cat.cpp index 21764902d..ab001d474 100644 --- a/test_regress/t/t_trace_cat.cpp +++ b/test_regress/t/t_trace_cat.cpp @@ -14,9 +14,7 @@ #define STRINGIFY2(x) #x unsigned long long main_time = 0; -double sc_time_stamp() { - return (double)main_time; -} +double sc_time_stamp() { return (double)main_time; } const char* trace_name() { static char name[1000]; @@ -24,14 +22,14 @@ const char* trace_name() { return name; } -int main(int argc, char **argv, char **env) { +int main(int argc, char** argv, char** env) { VM_PREFIX* top = new VM_PREFIX("top"); Verilated::debug(0); Verilated::traceEverOn(true); VerilatedVcdC* tfp = new VerilatedVcdC; - top->trace(tfp,99); + top->trace(tfp, 99); tfp->open(trace_name()); @@ -51,7 +49,7 @@ int main(int argc, char **argv, char **env) { tfp->close(); delete tfp; tfp = new VerilatedVcdC; - top->trace(tfp,99); + top->trace(tfp, 99); tfp->open(trace_name()); #else # error "Unknown test" diff --git a/test_regress/t/t_trace_public_func.cpp b/test_regress/t/t_trace_public_func.cpp index 86c02a6b6..21498ceec 100644 --- a/test_regress/t/t_trace_public_func.cpp +++ b/test_regress/t/t_trace_public_func.cpp @@ -16,24 +16,22 @@ #define STRINGIFY2(x) #x unsigned long long main_time = 0; -double sc_time_stamp() { - return (double)main_time; -} +double sc_time_stamp() { return (double)main_time; } const unsigned long long dt_2 = 3; -int main(int argc, char **argv, char **env) { - Vt_trace_public_func *top = new Vt_trace_public_func("top"); +int main(int argc, char** argv, char** env) { + Vt_trace_public_func* top = new Vt_trace_public_func("top"); Verilated::debug(0); Verilated::traceEverOn(true); VerilatedVcdC* tfp = new VerilatedVcdC; - top->trace(tfp,99); + top->trace(tfp, 99); tfp->open(STRINGIFY(TEST_OBJ_DIR) "/simx.vcd"); while (main_time <= 20) { - top->CLK = (main_time/dt_2)%2; + top->CLK = (main_time / dt_2) % 2; top->eval(); top->t->glbl->setGSR(main_time < 7); diff --git a/test_regress/t/t_trace_public_sig.cpp b/test_regress/t/t_trace_public_sig.cpp index 981f41e69..56b99eace 100644 --- a/test_regress/t/t_trace_public_sig.cpp +++ b/test_regress/t/t_trace_public_sig.cpp @@ -16,24 +16,22 @@ #define STRINGIFY2(x) #x unsigned long long main_time = 0; -double sc_time_stamp() { - return (double)main_time; -} +double sc_time_stamp() { return (double)main_time; } const unsigned long long dt_2 = 3; -int main(int argc, char **argv, char **env) { - Vt_trace_public_sig *top = new Vt_trace_public_sig("top"); +int main(int argc, char** argv, char** env) { + Vt_trace_public_sig* top = new Vt_trace_public_sig("top"); Verilated::debug(0); Verilated::traceEverOn(true); VerilatedVcdC* tfp = new VerilatedVcdC; - top->trace(tfp,99); + top->trace(tfp, 99); tfp->open(STRINGIFY(TEST_OBJ_DIR) "/simx.vcd"); while (main_time <= 20) { - top->CLK = (main_time/dt_2)%2; + top->CLK = (main_time / dt_2) % 2; top->eval(); top->t->glbl->GSR = (main_time < 7); diff --git a/test_regress/t/t_trace_timescale.cpp b/test_regress/t/t_trace_timescale.cpp index 7399de7b7..76ea0c5e1 100644 --- a/test_regress/t/t_trace_timescale.cpp +++ b/test_regress/t/t_trace_timescale.cpp @@ -14,11 +14,9 @@ #define STRINGIFY2(x) #x unsigned long long main_time = 0; -double sc_time_stamp() { - return ((double)main_time) / VL_TIME_MULTIPLIER; -} +double sc_time_stamp() { return ((double)main_time) / VL_TIME_MULTIPLIER; } -int main(int argc, char **argv, char **env) { +int main(int argc, char** argv, char** env) { VM_PREFIX* top = new VM_PREFIX("top"); Verilated::debug(0); @@ -28,19 +26,19 @@ int main(int argc, char **argv, char **env) { tfp->set_time_resolution("1ps"); tfp->set_time_unit("1ns"); - top->trace(tfp,99); + top->trace(tfp, 99); tfp->open(STRINGIFY(TEST_OBJ_DIR) "/simx.vcd"); top->clk = 0; - while (main_time < 190*VL_TIME_MULTIPLIER) { + while (main_time < 190 * VL_TIME_MULTIPLIER) { top->clk = !top->clk; top->eval(); tfp->dump((unsigned int)(main_time)); // Advance by 0.5 time units, to make sure our fractional // time is working correctly - main_time += VL_TIME_MULTIPLIER/2; + main_time += VL_TIME_MULTIPLIER / 2; } tfp->close(); top->final(); diff --git a/test_regress/t/t_tri_gate.cpp b/test_regress/t/t_tri_gate.cpp index 9b4dbc1a2..a0e57553e 100644 --- a/test_regress/t/t_tri_gate.cpp +++ b/test_regress/t/t_tri_gate.cpp @@ -7,9 +7,7 @@ VM_PREFIX* tb = NULL; -double sc_time_stamp() { - return 0; -} +double sc_time_stamp() { return 0; } bool check() { bool pass; @@ -20,7 +18,7 @@ bool check() { bool verbose = false; #endif - if(tb->W == c && tb->X == c && tb->Y == c && tb->Z == c) { + if (tb->W == c && tb->X == c && tb->Y == c && tb->Z == c) { pass = true; if (verbose) printf("- pass: "); } else { @@ -29,8 +27,8 @@ bool check() { printf("%%E-FAIL: "); } if (verbose) { - printf("SEL=%d A=%d got: W=%d X=%d Y=%d Z=%d exp: WXYZ=%d\n", - tb->SEL, tb->A, tb->W, tb->X, tb->Y, tb->Z, c); + printf("SEL=%d A=%d got: W=%d X=%d Y=%d Z=%d exp: WXYZ=%d\n", tb->SEL, tb->A, tb->W, + tb->X, tb->Y, tb->Z, c); } return pass; } @@ -42,20 +40,18 @@ int main() { tb = new VM_PREFIX("tb"); // loop through every possibility and check the result - for (tb->SEL=0; tb->SEL<2; tb->SEL++) { - for (tb->A=0; tb->A<4; tb->A++) { + for (tb->SEL = 0; tb->SEL < 2; tb->SEL++) { + for (tb->A = 0; tb->A < 4; tb->A++) { tb->eval(); - if(!check()) { - pass =false; - } + if (!check()) { pass = false; } } } - if(pass) { + if (pass) { VL_PRINTF("*-* All Finished *-*\n"); tb->final(); } else { - vl_fatal(__FILE__,__LINE__,"top", "Unexpected results from tristate test\n"); + vl_fatal(__FILE__, __LINE__, "top", "Unexpected results from tristate test\n"); } return 0; } diff --git a/test_regress/t/t_tri_inout.cpp b/test_regress/t/t_tri_inout.cpp index 9fc37dd2c..217ca8c35 100644 --- a/test_regress/t/t_tri_inout.cpp +++ b/test_regress/t/t_tri_inout.cpp @@ -5,11 +5,9 @@ #include "Vt_tri_inout.h" -Vt_tri_inout *tb = NULL; +Vt_tri_inout* tb = NULL; -double sc_time_stamp() { - return 0; -} +double sc_time_stamp() { return 0; } bool check() { bool pass; @@ -40,22 +38,20 @@ int main() { tb = new Vt_tri_inout("tb"); // loop through every possibility and check the result - for (tb->SEL=0; tb->SEL<2; tb->SEL++) { - for (tb->A=0; tb->A<2; tb->A++) { - for (tb->B=0; tb->B<2; tb->B++) { + for (tb->SEL = 0; tb->SEL < 2; tb->SEL++) { + for (tb->A = 0; tb->A < 2; tb->A++) { + for (tb->B = 0; tb->B < 2; tb->B++) { tb->eval(); - if (!check()) { - pass = false; - } + if (!check()) { pass = false; } } } } - if(pass) { + if (pass) { VL_PRINTF("*-* All Finished *-*\n"); tb->final(); } else { - vl_fatal(__FILE__,__LINE__,"top", "Unexpected results from inout test\n"); + vl_fatal(__FILE__, __LINE__, "top", "Unexpected results from inout test\n"); } return 0; } diff --git a/test_regress/t/t_tri_inz.cpp b/test_regress/t/t_tri_inz.cpp index c3ccca88f..127ddd8de 100644 --- a/test_regress/t/t_tri_inz.cpp +++ b/test_regress/t/t_tri_inz.cpp @@ -5,9 +5,7 @@ Vt_tri_inz* tb = NULL; bool pass = true; -double sc_time_stamp() { - return 0; -} +double sc_time_stamp() { return 0; } void checkone(const char* name, int got, int exp) { if (got != exp) { @@ -21,8 +19,8 @@ void check(int d, int en, int exp0, int exp1, int expx, int expz) { tb->d__en0 = en; tb->eval(); #ifdef TEST_VERBOSE - printf("Drive d=%d en=%d got0=%d/1=%d/x=%d/z=%d exp0=%d/1=%d/x=%d/z=%d\n", - d, en, tb->ext0, tb->ext1, tb->extx, tb->extz, exp0, exp1, expx, expz); + printf("Drive d=%d en=%d got0=%d/1=%d/x=%d/z=%d exp0=%d/1=%d/x=%d/z=%d\n", d, en, tb->ext0, + tb->ext1, tb->extx, tb->extz, exp0, exp1, expx, expz); #endif if (!expz) checkone("ext0", tb->ext0, exp0); if (!expz) checkone("ext1", tb->ext1, exp1); @@ -32,7 +30,7 @@ void check(int d, int en, int exp0, int exp1, int expx, int expz) { int main() { Verilated::debug(0); - tb = new Vt_tri_inz("tb"); + tb = new Vt_tri_inz("tb"); check(0, 1, 1,0,0,0); check(1, 1, 0,1,0,0); check(0, 0, 0,0,0,1); @@ -41,7 +39,7 @@ int main() { VL_PRINTF("*-* All Finished *-*\n"); tb->final(); } else { - vl_fatal(__FILE__,__LINE__,"top", "Unexpected results from t_tri_inz\n"); + vl_fatal(__FILE__, __LINE__, "top", "Unexpected results from t_tri_inz\n"); } return 0; } diff --git a/test_regress/t/t_tri_pullup.cpp b/test_regress/t/t_tri_pullup.cpp index 1842f9c72..e487ae342 100644 --- a/test_regress/t/t_tri_pullup.cpp +++ b/test_regress/t/t_tri_pullup.cpp @@ -5,11 +5,9 @@ #include "Vt_tri_pullup.h" -Vt_tri_pullup *tb = NULL; +Vt_tri_pullup* tb = NULL; -double sc_time_stamp() { - return 0; -} +double sc_time_stamp() { return 0; } bool check() { bool pass; @@ -30,7 +28,7 @@ bool check() { bool verbose = false; #endif - if (tb->Z == Z && tb->Y == Y && tb->X == X) { + if (tb->Z == Z && tb->Y == Y && tb->X == X) { if (verbose) printf("PASS: "); pass = true; } else { @@ -38,7 +36,9 @@ bool check() { verbose = true; pass = false; } - if (verbose) printf("OE=%d A=%d X=%d xexp=%d Y=%d yexp=%d Z=%d zexp=%d\n", tb->OE, tb->A, tb->X,X, tb->Y,Y, tb->Z,Z); + if (verbose) + printf("OE=%d A=%d X=%d xexp=%d Y=%d yexp=%d Z=%d zexp=%d\n", tb->OE, tb->A, tb->X, X, + tb->Y, Y, tb->Z, Z); return pass; } @@ -46,15 +46,13 @@ int main() { bool pass = true; Verilated::debug(0); - tb = new Vt_tri_pullup("tb"); + tb = new Vt_tri_pullup("tb"); // loop through every possibility and check the result - for (tb->OE=0; tb->OE<2; tb->OE++) { - for (tb->A=0; tb->A<2; tb->A++) { + for (tb->OE = 0; tb->OE < 2; tb->OE++) { + for (tb->A = 0; tb->A < 2; tb->A++) { tb->eval(); - if (!check()) { - pass = false; - } + if (!check()) { pass = false; } } } @@ -62,7 +60,7 @@ int main() { VL_PRINTF("*-* All Finished *-*\n"); tb->final(); } else { - vl_fatal(__FILE__,__LINE__,"top", "Unexpected results from pullup test\n"); + vl_fatal(__FILE__, __LINE__, "top", "Unexpected results from pullup test\n"); } return 0; } diff --git a/test_regress/t/t_tri_select.cpp b/test_regress/t/t_tri_select.cpp index c3c37744e..cf023bdee 100644 --- a/test_regress/t/t_tri_select.cpp +++ b/test_regress/t/t_tri_select.cpp @@ -2,11 +2,9 @@ #include "Vt_tri_select.h" -Vt_tri_select *tb = NULL; +Vt_tri_select* tb = NULL; -double sc_time_stamp() { - return 0; -} +double sc_time_stamp() { return 0; } bool check() { bool pass = true; @@ -16,15 +14,16 @@ bool check() { bool verbose = false; #endif - int Y = ((tb->OE1) & (!tb->OE2)) ? tb->A1 - : ((!tb->OE1) & (tb->OE2)) ? tb->A2 - : ((tb->OE1) & (tb->OE2)) ? (tb->A1 | tb->A2) - : 3; // pullup + int Y = ((tb->OE1) & (!tb->OE2)) + ? tb->A1 + : ((!tb->OE1) & (tb->OE2)) + ? tb->A2 + : ((tb->OE1) & (tb->OE2)) ? (tb->A1 | tb->A2) : 3; // pullup int W = (((tb->OE2) ? (tb->A2 & 0x1) : 0) << tb->A1) - | (((tb->OE1) ? (tb->A2 >> 1)&0x1 : 0) << tb->A2); + | (((tb->OE1) ? (tb->A2 >> 1) & 0x1 : 0) << tb->A2); - if(tb->Y1 == Y && tb->Y2 == Y && tb->Y3 == Y && tb->W == W) { + if (tb->Y1 == Y && tb->Y2 == Y && tb->Y3 == Y && tb->W == W) { pass = true; if (verbose) printf("- pass: "); } else { @@ -33,8 +32,10 @@ bool check() { printf("%%E-Fail: "); } - if (verbose) printf("Read: OE1=%d OE2=%d A1=0x%x A2=0x%x Y1=0x%x Y2=0x%x Y3=0x%x W=0x%x Expected: Y1=Y2=Y3=%d and W=0x%x\n", - tb->OE1, tb->OE2, tb->A1, tb->A2, tb->Y1, tb->Y2, tb->Y3, tb->W, Y,W); + if (verbose) + printf("Read: OE1=%d OE2=%d A1=0x%x A2=0x%x Y1=0x%x Y2=0x%x Y3=0x%x W=0x%x Expected: " + "Y1=Y2=Y3=%d and W=0x%x\n", + tb->OE1, tb->OE2, tb->A1, tb->A2, tb->Y1, tb->Y2, tb->Y3, tb->W, Y, W); return pass; } @@ -42,27 +43,25 @@ int main() { bool pass = true; Verilated::debug(0); - tb = new Vt_tri_select("tb"); + tb = new Vt_tri_select("tb"); // loop through every possibility and check the result - for (tb->OE1=0; tb->OE1<2; tb->OE1++) { - for (tb->OE2=0; tb->OE2<2; tb->OE2++) { - for (tb->A1=0; tb->A1<4; tb->A1++) { - for (tb->A2=0; tb->A2<4; tb->A2++) { + for (tb->OE1 = 0; tb->OE1 < 2; tb->OE1++) { + for (tb->OE2 = 0; tb->OE2 < 2; tb->OE2++) { + for (tb->A1 = 0; tb->A1 < 4; tb->A1++) { + for (tb->A2 = 0; tb->A2 < 4; tb->A2++) { tb->eval(); - if(!check()) { - pass = false; - } + if (!check()) { pass = false; } } } } } - if(pass) { + if (pass) { VL_PRINTF("*-* All Finished *-*\n"); tb->final(); } else { - vl_fatal(__FILE__,__LINE__,"top", "Unexpected results from t_tri_select\n"); + vl_fatal(__FILE__, __LINE__, "top", "Unexpected results from t_tri_select\n"); } return 0; } diff --git a/test_regress/t/t_var_overwidth_bad.cpp b/test_regress/t/t_var_overwidth_bad.cpp index ed95a41de..666a9baf0 100644 --- a/test_regress/t/t_var_overwidth_bad.cpp +++ b/test_regress/t/t_var_overwidth_bad.cpp @@ -20,11 +20,9 @@ double main_time; -double sc_time_stamp() { - return main_time; -} +double sc_time_stamp() { return main_time; } -int main(int argc, char **argv, char **env) { +int main(int argc, char** argv, char** env) { Verilated::debug(0); VM_PREFIX* topp = new VM_PREFIX(""); // Note null name - we're flattening it out @@ -39,6 +37,6 @@ int main(int argc, char **argv, char **env) { topp->eval(); topp->final(); - delete topp; topp=NULL; + delete topp; VL_DANGLING(topp); exit(0L); } diff --git a/test_regress/t/t_var_pinsizes.cpp b/test_regress/t/t_var_pinsizes.cpp index fba136f42..e6f88be13 100644 --- a/test_regress/t/t_var_pinsizes.cpp +++ b/test_regress/t/t_var_pinsizes.cpp @@ -4,21 +4,19 @@ VM_PREFIX* tb = NULL; -double sc_time_stamp() { - return 0; -} +double sc_time_stamp() { return 0; } int main() { Verilated::debug(0); - tb = new VM_PREFIX("tb"); + tb = new VM_PREFIX("tb"); VL_PRINTF("*-* All Finished *-*\n"); tb->final(); return 0; } -int sc_main(int argc, char *argv[]) { - tb = new VM_PREFIX("tb"); +int sc_main(int argc, char* argv[]) { + tb = new VM_PREFIX("tb"); VL_PRINTF("*-* All Finished *-*\n"); tb->final(); diff --git a/test_regress/t/t_vpi_get.cpp b/test_regress/t/t_vpi_get.cpp index e49a0f946..6f09bdd4b 100644 --- a/test_regress/t/t_vpi_get.cpp +++ b/test_regress/t/t_vpi_get.cpp @@ -42,7 +42,8 @@ using namespace std; // __FILE__ is too long #define FILENM "t_vpi_get.cpp" -#define TEST_MSG if (0) printf +#define TEST_MSG \ + if (0) printf unsigned int main_time = false; @@ -53,108 +54,102 @@ unsigned int main_time = false; #define CHECK_RESULT_VH(got, exp) \ if ((got) != (exp)) { \ - printf("%%Error: %s:%d: GOT = %p EXP = %p\n", \ - FILENM,__LINE__, (got), (exp)); \ + printf("%%Error: %s:%d: GOT = %p EXP = %p\n", FILENM, __LINE__, (got), (exp)); \ return __LINE__; \ } #define CHECK_RESULT_NZ(got) \ if (!(got)) { \ - printf("%%Error: %s:%d: GOT = NULL EXP = !NULL\n", FILENM,__LINE__); \ + printf("%%Error: %s:%d: GOT = NULL EXP = !NULL\n", FILENM, __LINE__); \ return __LINE__; \ } // Use cout to avoid issues with %d/%lx etc #define CHECK_RESULT(got, exp) \ - if ((got) != (exp)) { \ - cout<", (exp)?(exp):""); \ + if (strcmp((got), (exp))) { \ + printf("%%Error: %s:%d: GOT = '%s' EXP = '%s'\n", FILENM, __LINE__, \ + (got) ? (got) : "", (exp) ? (exp) : ""); \ return __LINE__; \ } -#define CHECK_RESULT_CSTR_STRIP(got, exp) \ - CHECK_RESULT_CSTR(got+strspn(got, " "), exp) +#define CHECK_RESULT_CSTR_STRIP(got, exp) CHECK_RESULT_CSTR(got + strspn(got, " "), exp) static int _mon_check_props(TestVpiHandle& handle, int size, int direction, int scalar, int type) { - s_vpi_value value = { - vpiIntVal, .value = {.integer = 0} - }; + s_vpi_value value = {vpiIntVal, .value = {.integer = 0}}; // check size of object int vpisize = vpi_get(vpiSize, handle); CHECK_RESULT(vpisize, size); // icarus verilog does not support vpiScalar, vpiVector or vpi*Range if (TestSimulator::has_get_scalar()) { - int vpiscalar = vpi_get(vpiScalar, handle); - CHECK_RESULT((bool)vpiscalar, (bool)scalar); - int vpivector = vpi_get(vpiVector, handle); - CHECK_RESULT((bool)vpivector, (bool)!scalar); + int vpiscalar = vpi_get(vpiScalar, handle); + CHECK_RESULT((bool)vpiscalar, (bool)scalar); + int vpivector = vpi_get(vpiVector, handle); + CHECK_RESULT((bool)vpivector, (bool)!scalar); } // Icarus only supports ranges on memories if (!scalar && !(TestSimulator::is_icarus() && type != vpiMemory)) { - TestVpiHandle left_h, right_h; + TestVpiHandle left_h, right_h; - // check coherency for vectors - // get left hand side of range - left_h = vpi_handle(vpiLeftRange, handle); - CHECK_RESULT_NZ(left_h); - vpi_get_value(left_h, &value); - int coherency = value.value.integer; - // get right hand side of range - right_h = vpi_handle(vpiRightRange, handle); - CHECK_RESULT_NZ(right_h); - vpi_get_value(right_h, &value); - TEST_MSG("%d:%d\n", coherency, value.value.integer); - coherency -= value.value.integer; - // calculate size & check - coherency = abs(coherency) + 1; - CHECK_RESULT(coherency, size); + // check coherency for vectors + // get left hand side of range + left_h = vpi_handle(vpiLeftRange, handle); + CHECK_RESULT_NZ(left_h); + vpi_get_value(left_h, &value); + int coherency = value.value.integer; + // get right hand side of range + right_h = vpi_handle(vpiRightRange, handle); + CHECK_RESULT_NZ(right_h); + vpi_get_value(right_h, &value); + TEST_MSG("%d:%d\n", coherency, value.value.integer); + coherency -= value.value.integer; + // calculate size & check + coherency = abs(coherency) + 1; + CHECK_RESULT(coherency, size); } // Only check direction on ports if (type == vpiPort) { - // check direction of object - int vpidir = vpi_get(vpiDirection, handle); - // Don't check port directions in verilator - // see #681 - if (!TestSimulator::is_verilator()) { - CHECK_RESULT(vpidir, direction); - } + // check direction of object + int vpidir = vpi_get(vpiDirection, handle); + // Don't check port directions in verilator + // see #681 + if (!TestSimulator::is_verilator()) { CHECK_RESULT(vpidir, direction); } } // check type of object int vpitype = vpi_get(vpiType, handle); if (!(TestSimulator::is_verilator() && type == vpiPort)) { - // Don't check for ports in verilator - // see #681 - CHECK_RESULT(vpitype, type); + // Don't check for ports in verilator + // see #681 + CHECK_RESULT(vpitype, type); } return 0; // Ok } struct params { - const char* signal; + const char* signal; struct { - unsigned int size; - unsigned int direction; - unsigned int scalar; - int type; + unsigned int size; + unsigned int direction; + unsigned int scalar; + int type; } attributes, children; }; @@ -165,35 +160,43 @@ int mon_check_props() { // the code that sets up the VerilatedAssertOneThread() check in // verilated_vpi.cc, it was causing the check to falsely fail // (due to m_threadid within the check not being initted yet.) - static struct params values[] = { - {"onebit", {1, vpiNoDirection, 1, vpiReg}, {0, 0, 0, 0}}, - {"twoone", {2, vpiNoDirection, 0, vpiReg}, {0, 0, 0, 0}}, - {"onetwo", {2, vpiNoDirection, 0, TestSimulator::is_verilator() ? vpiReg : vpiMemory}, {0, 0, 0, 0}}, - {"fourthreetwoone", {2, vpiNoDirection, 0, vpiMemory}, {2, vpiNoDirection, 0, vpiMemoryWord}}, - {"clk", {1, vpiInput, 1, vpiPort}, {0, 0, 0, 0}}, - {"testin", {16, vpiInput, 0, vpiPort}, {0, 0, 0, 0}}, - {"testout", {24, vpiOutput, 0, vpiPort}, {0, 0, 0, 0}}, - {"sub.subin", {1, vpiInput, 1, vpiPort}, {0, 0, 0, 0}}, - {"sub.subout", {1, vpiOutput, 1, vpiPort}, {0, 0, 0, 0}}, - {NULL, {0, 0, 0, 0}, {0, 0, 0, 0}} - }; + static struct params values[] + = {{"onebit", {1, vpiNoDirection, 1, vpiReg}, {0, 0, 0, 0}}, + {"twoone", {2, vpiNoDirection, 0, vpiReg}, {0, 0, 0, 0}}, + {"onetwo", + {2, vpiNoDirection, 0, TestSimulator::is_verilator() ? vpiReg : vpiMemory}, + {0, 0, 0, 0}}, + {"fourthreetwoone", + {2, vpiNoDirection, 0, vpiMemory}, + {2, vpiNoDirection, 0, vpiMemoryWord}}, + {"clk", {1, vpiInput, 1, vpiPort}, {0, 0, 0, 0}}, + {"testin", {16, vpiInput, 0, vpiPort}, {0, 0, 0, 0}}, + {"testout", {24, vpiOutput, 0, vpiPort}, {0, 0, 0, 0}}, + {"sub.subin", {1, vpiInput, 1, vpiPort}, {0, 0, 0, 0}}, + {"sub.subout", {1, vpiOutput, 1, vpiPort}, {0, 0, 0, 0}}, + {NULL, {0, 0, 0, 0}, {0, 0, 0, 0}}}; struct params* value = values; while (value->signal) { - TestVpiHandle h = VPI_HANDLE(value->signal); - CHECK_RESULT_NZ(h); - TEST_MSG("%s\n", value->signal); - if (int status = _mon_check_props(h, value->attributes.size, value->attributes.direction, value->attributes.scalar, value->attributes.type)) return status; - if (value->children.size) { - int size = 0; - TestVpiHandle iter_h = vpi_iterate(vpiMemoryWord, h); - while (TestVpiHandle word_h = vpi_scan(iter_h.nofree())) { - // check size and range - if (int status = _mon_check_props(word_h, value->children.size, value->children.direction, value->children.scalar, value->children.type)) return status; - size++; + TestVpiHandle h = VPI_HANDLE(value->signal); + CHECK_RESULT_NZ(h); + TEST_MSG("%s\n", value->signal); + if (int status = _mon_check_props(h, value->attributes.size, value->attributes.direction, + value->attributes.scalar, value->attributes.type)) + return status; + if (value->children.size) { + int size = 0; + TestVpiHandle iter_h = vpi_iterate(vpiMemoryWord, h); + while (TestVpiHandle word_h = vpi_scan(iter_h.nofree())) { + // check size and range + if (int status + = _mon_check_props(word_h, value->children.size, value->children.direction, + value->children.scalar, value->children.type)) + return status; + size++; + } + CHECK_RESULT(size, value->attributes.size); } - CHECK_RESULT(size, value->attributes.size); - } - value++; + value++; } return 0; } @@ -209,39 +212,34 @@ int mon_check() { #ifdef IS_VPI static int mon_check_vpi() { - vpiHandle href = vpi_handle(vpiSysTfCall, 0); - s_vpi_value vpi_value; + vpiHandle href = vpi_handle(vpiSysTfCall, 0); + s_vpi_value vpi_value; - vpi_value.format = vpiIntVal; - vpi_value.value.integer = mon_check(); - vpi_put_value(href, &vpi_value, NULL, vpiNoDelay); + vpi_value.format = vpiIntVal; + vpi_value.value.integer = mon_check(); + vpi_put_value(href, &vpi_value, NULL, vpiNoDelay); - return 0; + return 0; } -static s_vpi_systf_data vpi_systf_data[] = { - {vpiSysFunc, vpiIntFunc, (PLI_BYTE8*)"$mon_check", (PLI_INT32(*)(PLI_BYTE8*))mon_check_vpi, 0, 0, 0}, - 0 -}; +static s_vpi_systf_data vpi_systf_data[] = {{vpiSysFunc, vpiIntFunc, (PLI_BYTE8*)"$mon_check", + (PLI_INT32(*)(PLI_BYTE8*))mon_check_vpi, 0, 0, 0}, + 0}; // cver entry void vpi_compat_bootstrap(void) { - p_vpi_systf_data systf_data_p; - systf_data_p = &(vpi_systf_data[0]); - while (systf_data_p->type != 0) vpi_register_systf(systf_data_p++); + p_vpi_systf_data systf_data_p; + systf_data_p = &(vpi_systf_data[0]); + while (systf_data_p->type != 0) + vpi_register_systf(systf_data_p++); } // icarus entry -void (*vlog_startup_routines[])() = { - vpi_compat_bootstrap, - 0 -}; +void (*vlog_startup_routines[])() = {vpi_compat_bootstrap, 0}; #else -double sc_time_stamp() { - return main_time; -} -int main(int argc, char **argv, char **env) { +double sc_time_stamp() { return main_time; } +int main(int argc, char** argv, char** env) { double sim_time = 1100; Verilated::commandArgs(argc, argv); Verilated::debug(0); @@ -249,9 +247,9 @@ int main(int argc, char **argv, char **env) { Vt_vpi_get* topp = new Vt_vpi_get(""); // Note null name - we're flattening it out #ifdef VERILATOR -# ifdef TEST_VERBOSE +#ifdef TEST_VERBOSE Verilated::scopesDump(); -# endif +#endif #endif #if VM_TRACE @@ -271,13 +269,13 @@ int main(int argc, char **argv, char **env) { topp->eval(); VerilatedVpi::callValueCbs(); topp->clk = !topp->clk; - //mon_do(); + // mon_do(); #if VM_TRACE - if (tfp) tfp->dump (main_time); + if (tfp) tfp->dump(main_time); #endif } if (!Verilated::gotFinish()) { - vl_fatal(FILENM,__LINE__,"main", "%Error: Timeout; never got a $finish"); + vl_fatal(FILENM, __LINE__, "main", "%Error: Timeout; never got a $finish"); } topp->final(); @@ -285,7 +283,7 @@ int main(int argc, char **argv, char **env) { if (tfp) tfp->close(); #endif - delete topp; topp=NULL; + delete topp; VL_DANGLING(topp); exit(0L); } diff --git a/test_regress/t/t_vpi_memory.cpp b/test_regress/t/t_vpi_memory.cpp index cf499272e..753cc795c 100644 --- a/test_regress/t/t_vpi_memory.cpp +++ b/test_regress/t/t_vpi_memory.cpp @@ -42,7 +42,8 @@ using namespace std; // __FILE__ is too long #define FILENM "t_vpi_memory.cpp" -#define DEBUG if (0) printf +#define DEBUG \ + if (0) printf unsigned int main_time = false; @@ -53,47 +54,43 @@ unsigned int main_time = false; #define CHECK_RESULT_VH(got, exp) \ if ((got) != (exp)) { \ - printf("%%Error: %s:%d: GOT = %p EXP = %p\n", \ - FILENM,__LINE__, (got), (exp)); \ + printf("%%Error: %s:%d: GOT = %p EXP = %p\n", FILENM, __LINE__, (got), (exp)); \ return __LINE__; \ } #define CHECK_RESULT_NZ(got) \ if (!(got)) { \ - printf("%%Error: %s:%d: GOT = NULL EXP = !NULL\n", FILENM,__LINE__); \ + printf("%%Error: %s:%d: GOT = NULL EXP = !NULL\n", FILENM, __LINE__); \ return __LINE__; \ } // Use cout to avoid issues with %d/%lx etc #define CHECK_RESULT(got, exp) \ if ((got) != (exp)) { \ - cout<", (exp)?(exp):""); \ + if (strcmp((got), (exp))) { \ + printf("%%Error: %s:%d: GOT = '%s' EXP = '%s'\n", FILENM, __LINE__, \ + (got) ? (got) : "", (exp) ? (exp) : ""); \ return __LINE__; \ } -#define CHECK_RESULT_CSTR_STRIP(got, exp) \ - CHECK_RESULT_CSTR(got+strspn(got, " "), exp) +#define CHECK_RESULT_CSTR_STRIP(got, exp) CHECK_RESULT_CSTR(got + strspn(got, " "), exp) int _mon_check_range(TestVpiHandle& handle, int size, int left, int right) { TestVpiHandle iter_h, left_h, right_h; - s_vpi_value value = { - vpiIntVal, .value = {.integer = 0} - }; + s_vpi_value value = {vpiIntVal, .value = {.integer = 0}}; // check size of object int vpisize = vpi_get(vpiSize, handle); CHECK_RESULT(vpisize, size); @@ -122,9 +119,7 @@ int _mon_check_memory() { int cnt; TestVpiHandle mem_h, lcl_h; vpiHandle iter_h; // Icarus does not like auto free of iterator handles - s_vpi_value value = { - vpiIntVal, .value = {.integer = 0} - }; + s_vpi_value value = {vpiIntVal, .value = {.integer = 0}}; vpi_printf((PLI_BYTE8*)"Check memory vpi ...\n"); mem_h = vpi_handle_by_name((PLI_BYTE8*)TestSimulator::rooted("mem0"), NULL); CHECK_RESULT_NZ(mem_h); @@ -146,15 +141,16 @@ int _mon_check_memory() { iter_h = vpi_iterate(vpiMemoryWord, mem_h); cnt = 0; while ((lcl_h = vpi_scan(iter_h))) { - ++cnt; - vpi_get_value(lcl_h, &value); - CHECK_RESULT(value.value.integer, cnt); + ++cnt; + vpi_get_value(lcl_h, &value); + CHECK_RESULT(value.value.integer, cnt); } CHECK_RESULT(cnt, 16); // should be 16 addresses // don't care for non verilator // (crashes on Icarus) if (TestSimulator::is_icarus()) { - vpi_printf((PLI_BYTE8*)"Skipping property checks for simulator %s\n", TestSimulator::get_info().product); + vpi_printf((PLI_BYTE8*)"Skipping property checks for simulator %s\n", + TestSimulator::get_info().product); return 0; // Ok } // make sure trying to get properties that don't exist @@ -183,40 +179,35 @@ int mon_check() { #ifdef IS_VPI static int mon_check_vpi() { - vpiHandle href = vpi_handle(vpiSysTfCall, 0); - s_vpi_value vpi_value; + vpiHandle href = vpi_handle(vpiSysTfCall, 0); + s_vpi_value vpi_value; - vpi_value.format = vpiIntVal; - vpi_value.value.integer = mon_check(); - vpi_put_value(href, &vpi_value, NULL, vpiNoDelay); + vpi_value.format = vpiIntVal; + vpi_value.value.integer = mon_check(); + vpi_put_value(href, &vpi_value, NULL, vpiNoDelay); - return 0; + return 0; } -static s_vpi_systf_data vpi_systf_data[] = { - {vpiSysFunc, vpiIntFunc, (PLI_BYTE8*)"$mon_check", (PLI_INT32(*)(PLI_BYTE8*))mon_check_vpi, 0, 0, 0}, - 0 -}; +static s_vpi_systf_data vpi_systf_data[] = {{vpiSysFunc, vpiIntFunc, (PLI_BYTE8*)"$mon_check", + (PLI_INT32(*)(PLI_BYTE8*))mon_check_vpi, 0, 0, 0}, + 0}; // cver entry void vpi_compat_bootstrap(void) { - p_vpi_systf_data systf_data_p; - systf_data_p = &(vpi_systf_data[0]); - while (systf_data_p->type != 0) vpi_register_systf(systf_data_p++); + p_vpi_systf_data systf_data_p; + systf_data_p = &(vpi_systf_data[0]); + while (systf_data_p->type != 0) + vpi_register_systf(systf_data_p++); } // icarus entry -void (*vlog_startup_routines[])() = { - vpi_compat_bootstrap, - 0 -}; +void (*vlog_startup_routines[])() = {vpi_compat_bootstrap, 0}; #else -double sc_time_stamp() { - return main_time; -} -int main(int argc, char **argv, char **env) { +double sc_time_stamp() { return main_time; } +int main(int argc, char** argv, char** env) { double sim_time = 1100; Verilated::commandArgs(argc, argv); Verilated::debug(0); @@ -226,9 +217,9 @@ int main(int argc, char **argv, char **env) { VM_PREFIX* topp = new VM_PREFIX(""); // Note null name - we're flattening it out #ifdef VERILATOR -# ifdef TEST_VERBOSE +#ifdef TEST_VERBOSE Verilated::scopesDump(); -# endif +#endif #endif #if VM_TRACE @@ -248,13 +239,13 @@ int main(int argc, char **argv, char **env) { topp->eval(); VerilatedVpi::callValueCbs(); topp->clk = !topp->clk; - //mon_do(); + // mon_do(); #if VM_TRACE - if (tfp) tfp->dump (main_time); + if (tfp) tfp->dump(main_time); #endif } if (!Verilated::gotFinish()) { - vl_fatal(FILENM,__LINE__,"main", "%Error: Timeout; never got a $finish"); + vl_fatal(FILENM, __LINE__, "main", "%Error: Timeout; never got a $finish"); } topp->final(); @@ -262,7 +253,7 @@ int main(int argc, char **argv, char **env) { if (tfp) tfp->close(); #endif - delete topp; topp=NULL; + delete topp; VL_DANGLING(topp); exit(0L); } diff --git a/test_regress/t/t_vpi_module.cpp b/test_regress/t/t_vpi_module.cpp index 50fe633b9..e34879a85 100644 --- a/test_regress/t/t_vpi_module.cpp +++ b/test_regress/t/t_vpi_module.cpp @@ -42,61 +42,62 @@ using namespace std; // __FILE__ is too long #define FILENM "t_vpi_module.cpp" -#define DEBUG if (0) printf +#define DEBUG \ + if (0) printf unsigned int main_time = false; #define CHECK_RESULT_NZ(got) \ if (!(got)) { \ - printf("%%Error: %s:%d: GOT = NULL EXP = !NULL\n", FILENM,__LINE__); \ + printf("%%Error: %s:%d: GOT = NULL EXP = !NULL\n", FILENM, __LINE__); \ return __LINE__; \ } #define CHECK_RESULT_CSTR(got, exp) \ if (strcmp((got), (exp))) { \ - printf("%%Error: %s:%d: GOT = '%s' EXP = '%s'\n", \ - FILENM, __LINE__, (got)?(got):"", (exp)?(exp):""); \ + printf("%%Error: %s:%d: GOT = '%s' EXP = '%s'\n", FILENM, __LINE__, \ + (got) ? (got) : "", (exp) ? (exp) : ""); \ return __LINE__; \ } extern "C" { - int mon_check() { - vpiHandle it = vpi_iterate(vpiModule, NULL); - CHECK_RESULT_NZ(it); +int mon_check() { + vpiHandle it = vpi_iterate(vpiModule, NULL); + CHECK_RESULT_NZ(it); - vpiHandle topmod = vpi_scan(it); - CHECK_RESULT_NZ(topmod); + vpiHandle topmod = vpi_scan(it); + CHECK_RESULT_NZ(topmod); - char* name = vpi_get_str(vpiName, topmod); - CHECK_RESULT_NZ(name); - CHECK_RESULT_CSTR(name, "t"); + char* name = vpi_get_str(vpiName, topmod); + CHECK_RESULT_NZ(name); + CHECK_RESULT_CSTR(name, "t"); - it = vpi_iterate(vpiModule, topmod); - CHECK_RESULT_NZ(it); + it = vpi_iterate(vpiModule, topmod); + CHECK_RESULT_NZ(it); - vpiHandle mod = vpi_scan(it); - CHECK_RESULT_NZ(mod); + vpiHandle mod = vpi_scan(it); + CHECK_RESULT_NZ(mod); - name = vpi_get_str(vpiName, mod); - CHECK_RESULT_CSTR(name, "mod_a"); + name = vpi_get_str(vpiName, mod); + CHECK_RESULT_CSTR(name, "mod_a"); - it = vpi_iterate(vpiModule, mod); - CHECK_RESULT_NZ(it); + it = vpi_iterate(vpiModule, mod); + CHECK_RESULT_NZ(it); + mod = vpi_scan(it); + CHECK_RESULT_NZ(mod); + + name = vpi_get_str(vpiName, mod); + if (strcmp(name, "mod_b") == 0) { + // Full visibility in other simulators, skip mod_b mod = vpi_scan(it); CHECK_RESULT_NZ(mod); - name = vpi_get_str(vpiName, mod); - if (strcmp(name, "mod_b") == 0) { - // Full visibility in other simulators, skip mod_b - mod = vpi_scan(it); - CHECK_RESULT_NZ(mod); - name = vpi_get_str(vpiName, mod); - } - CHECK_RESULT_CSTR(name, "mod_c."); - - return 0; // Ok } + CHECK_RESULT_CSTR(name, "mod_c."); + + return 0; // Ok +} } //====================================================================== @@ -113,30 +114,25 @@ static int mon_check_vpi() { return 0; } -static s_vpi_systf_data vpi_systf_data[] = { - {vpiSysFunc, vpiIntFunc, (PLI_BYTE8*)"$mon_check", (PLI_INT32(*)(PLI_BYTE8*))mon_check_vpi, 0, 0, 0}, - 0 -}; +static s_vpi_systf_data vpi_systf_data[] = {{vpiSysFunc, vpiIntFunc, (PLI_BYTE8*)"$mon_check", + (PLI_INT32(*)(PLI_BYTE8*))mon_check_vpi, 0, 0, 0}, + 0}; // cver entry void vpi_compat_bootstrap(void) { p_vpi_systf_data systf_data_p; systf_data_p = &(vpi_systf_data[0]); - while (systf_data_p->type != 0) vpi_register_systf(systf_data_p++); + while (systf_data_p->type != 0) + vpi_register_systf(systf_data_p++); } // icarus entry -void (*vlog_startup_routines[])() = { - vpi_compat_bootstrap, - 0 -}; +void (*vlog_startup_routines[])() = {vpi_compat_bootstrap, 0}; #else -double sc_time_stamp() { - return main_time; -} -int main(int argc, char **argv, char **env) { +double sc_time_stamp() { return main_time; } +int main(int argc, char** argv, char** env) { double sim_time = 1100; Verilated::commandArgs(argc, argv); Verilated::debug(0); @@ -146,9 +142,9 @@ int main(int argc, char **argv, char **env) { VM_PREFIX* topp = new VM_PREFIX(""); // Note null name - we're flattening it out #ifdef VERILATOR -# ifdef TEST_VERBOSE +#ifdef TEST_VERBOSE Verilated::scopesDump(); -# endif +#endif #endif #if VM_TRACE @@ -168,9 +164,9 @@ int main(int argc, char **argv, char **env) { topp->eval(); VerilatedVpi::callValueCbs(); topp->clk = !topp->clk; - //mon_do(); + // mon_do(); #if VM_TRACE - if (tfp) tfp->dump (main_time); + if (tfp) tfp->dump(main_time); #endif } if (!Verilated::gotFinish()) { @@ -182,7 +178,7 @@ int main(int argc, char **argv, char **env) { if (tfp) tfp->close(); #endif - delete topp; topp=NULL; + delete topp; VL_DANGLING(topp); exit(0L); } diff --git a/test_regress/t/t_vpi_sc.cpp b/test_regress/t/t_vpi_sc.cpp index 99ef5b08b..e4fca6c38 100644 --- a/test_regress/t/t_vpi_sc.cpp +++ b/test_regress/t/t_vpi_sc.cpp @@ -4,8 +4,8 @@ VM_PREFIX* tb = NULL; -int sc_main(int argc, char *argv[]) { - tb = new VM_PREFIX("tb"); +int sc_main(int argc, char* argv[]) { + tb = new VM_PREFIX("tb"); VL_PRINTF("*-* All Finished *-*\n"); tb->final(); diff --git a/test_regress/t/t_vpi_unimpl.cpp b/test_regress/t/t_vpi_unimpl.cpp index 80546dc17..49e28c548 100644 --- a/test_regress/t/t_vpi_unimpl.cpp +++ b/test_regress/t/t_vpi_unimpl.cpp @@ -29,7 +29,8 @@ // __FILE__ is too long #define FILENM "t_vpi_unimpl.cpp" -#define DEBUG if (0) printf +#define DEBUG \ + if (0) printf unsigned int main_time = false; unsigned int callback_count = false; @@ -41,41 +42,39 @@ unsigned int callback_count = false; #define CHECK_RESULT_VH(got, exp) \ if ((got) != (exp)) { \ - printf("%%Error: %s:%d: GOT = %p EXP = %p\n", \ - FILENM,__LINE__, (got), (exp)); \ + printf("%%Error: %s:%d: GOT = %p EXP = %p\n", FILENM, __LINE__, (got), (exp)); \ return __LINE__; \ } #define CHECK_RESULT_NZ(got) \ if (!(got)) { \ - printf("%%Error: %s:%d: GOT = NULL EXP = !NULL\n", FILENM,__LINE__); \ + printf("%%Error: %s:%d: GOT = NULL EXP = !NULL\n", FILENM, __LINE__); \ return __LINE__; \ } // Use cout to avoid issues with %d/%lx etc #define CHECK_RESULT(got, exp) \ if ((got) != (exp)) { \ - std::cout<", (exp)?(exp):""); \ + if (strcmp((got), (exp))) { \ + printf("%%Error: %s:%d: GOT = '%s' EXP = '%s'\n", FILENM, __LINE__, \ + (got) ? (got) : "", (exp) ? (exp) : ""); \ return __LINE__; \ } -#define CHECK_RESULT_CSTR_STRIP(got, exp) \ - CHECK_RESULT_CSTR(got+strspn(got, " "), exp) +#define CHECK_RESULT_CSTR_STRIP(got, exp) CHECK_RESULT_CSTR(got + strspn(got, " "), exp) int _mon_check_unimpl(p_cb_data cb_data) { static TestVpiHandle cb, clk_h; @@ -143,11 +142,8 @@ int mon_check() { //====================================================================== - -double sc_time_stamp() { - return main_time; -} -int main(int argc, char **argv, char **env) { +double sc_time_stamp() { return main_time; } +int main(int argc, char** argv, char** env) { double sim_time = 1100; Verilated::commandArgs(argc, argv); Verilated::debug(0); @@ -157,9 +153,9 @@ int main(int argc, char **argv, char **env) { VM_PREFIX* topp = new VM_PREFIX(""); // Note null name - we're flattening it out #ifdef VERILATOR -# ifdef TEST_VERBOSE +#ifdef TEST_VERBOSE Verilated::scopesDump(); -# endif +#endif #endif #if VM_TRACE @@ -177,16 +173,16 @@ int main(int argc, char **argv, char **env) { while (sc_time_stamp() < sim_time && !Verilated::gotFinish()) { main_time += 1; topp->eval(); - //VerilatedVpi::callValueCbs(); // Make sure can link without verilated_vpi.h included + // VerilatedVpi::callValueCbs(); // Make sure can link without verilated_vpi.h included topp->clk = !topp->clk; - //mon_do(); + // mon_do(); #if VM_TRACE - if (tfp) tfp->dump (main_time); + if (tfp) tfp->dump(main_time); #endif } CHECK_RESULT(callback_count, 17); if (!Verilated::gotFinish()) { - vl_fatal(FILENM,__LINE__,"main", "%Error: Timeout; never got a $finish"); + vl_fatal(FILENM, __LINE__, "main", "%Error: Timeout; never got a $finish"); } topp->final(); @@ -194,6 +190,6 @@ int main(int argc, char **argv, char **env) { if (tfp) tfp->close(); #endif - delete topp; topp=NULL; + delete topp; VL_DANGLING(topp); exit(0L); } diff --git a/test_regress/t/t_vpi_var.cpp b/test_regress/t/t_vpi_var.cpp index 24003eab4..933f8e9b7 100644 --- a/test_regress/t/t_vpi_var.cpp +++ b/test_regress/t/t_vpi_var.cpp @@ -42,7 +42,8 @@ using namespace std; // __FILE__ is too long #define FILENM "t_vpi_var.cpp" -#define TEST_MSG if (0) printf +#define TEST_MSG \ + if (0) printf unsigned int main_time = false; unsigned int callback_count = false; @@ -55,41 +56,39 @@ unsigned int callback_count_strs_max = 500; #define CHECK_RESULT_VH(got, exp) \ if ((got) != (exp)) { \ - printf("%%Error: %s:%d: GOT = %p EXP = %p\n", \ - FILENM,__LINE__, (got), (exp)); \ + printf("%%Error: %s:%d: GOT = %p EXP = %p\n", FILENM, __LINE__, (got), (exp)); \ return __LINE__; \ } #define CHECK_RESULT_NZ(got) \ if (!(got)) { \ - printf("%%Error: %s:%d: GOT = NULL EXP = !NULL\n", FILENM,__LINE__); \ + printf("%%Error: %s:%d: GOT = NULL EXP = !NULL\n", FILENM, __LINE__); \ return __LINE__; \ } // Use cout to avoid issues with %d/%lx etc #define CHECK_RESULT(got, exp) \ - if ((got) != (exp)) { \ - cout<", (exp)?(exp):""); \ + if (strcmp((got), (exp))) { \ + printf("%%Error: %s:%d: GOT = '%s' EXP = '%s'\n", FILENM, __LINE__, \ + (got) ? (got) : "", (exp) ? (exp) : ""); \ return __LINE__; \ } -#define CHECK_RESULT_CSTR_STRIP(got, exp) \ - CHECK_RESULT_CSTR(got+strspn(got, " "), exp) +#define CHECK_RESULT_CSTR_STRIP(got, exp) CHECK_RESULT_CSTR(got + strspn(got, " "), exp) #define STRINGIFY(x) STRINGIFY2(x) #define STRINGIFY2(x) #x @@ -102,8 +101,8 @@ int _mon_check_mcd() { mcd = vpi_mcd_open(filename); CHECK_RESULT_NZ(mcd); - { // Check it got written - FILE* fp = fopen(filename,"r"); + { // Check it got written + FILE* fp = fopen(filename, "r"); CHECK_RESULT_NZ(fp); fclose(fp); } @@ -149,8 +148,8 @@ int _mon_check_callbacks() { int _value_callback(p_cb_data cb_data) { if (TestSimulator::is_verilator()) { - // this check only makes sense in Verilator - CHECK_RESULT(cb_data->value->value.integer+10, main_time); + // this check only makes sense in Verilator + CHECK_RESULT(cb_data->value->value.integer + 10, main_time); } callback_count++; return 0; @@ -158,17 +157,19 @@ int _value_callback(p_cb_data cb_data) { int _value_callback_half(p_cb_data cb_data) { if (TestSimulator::is_verilator()) { - // this check only makes sense in Verilator - CHECK_RESULT(cb_data->value->value.integer*2+10, main_time); + // this check only makes sense in Verilator + CHECK_RESULT(cb_data->value->value.integer * 2 + 10, main_time); } callback_count_half++; return 0; } int _value_callback_quad(p_cb_data cb_data) { - for (int index=0;index<2;index++) { - CHECK_RESULT_HEX(cb_data->value->value.vector[1].aval, (unsigned long)((index==2)?0x1c77bb9bUL:0x12819213UL)); - CHECK_RESULT_HEX(cb_data->value->value.vector[0].aval, (unsigned long)((index==2)?0x3784ea09UL:0xabd31a1cUL)); + for (int index = 0; index < 2; index++) { + CHECK_RESULT_HEX(cb_data->value->value.vector[1].aval, + (unsigned long)((index == 2) ? 0x1c77bb9bUL : 0x12819213UL)); + CHECK_RESULT_HEX(cb_data->value->value.vector[0].aval, + (unsigned long)((index == 2) ? 0x3784ea09UL : 0xabd31a1cUL)); } callback_count_quad++; return 0; @@ -236,7 +237,7 @@ int _mon_check_var() { p = vpi_get_str(vpiFullName, vh2); CHECK_RESULT_CSTR(p, TestSimulator::top()); p = vpi_get_str(vpiType, vh2); - CHECK_RESULT_CSTR (p, "vpiModule"); + CHECK_RESULT_CSTR(p, "vpiModule"); TestVpiHandle vh3 = vpi_handle_by_name((PLI_BYTE8*)"onebit", vh2); CHECK_RESULT_NZ(vh3); @@ -246,8 +247,8 @@ int _mon_check_var() { d = vpi_get(vpiType, vh3); CHECK_RESULT(d, vpiReg); if (TestSimulator::has_get_scalar()) { - d = vpi_get(vpiVector, vh3); - CHECK_RESULT(d, 0); + d = vpi_get(vpiVector, vh3); + CHECK_RESULT(d, 0); } p = vpi_get_str(vpiName, vh3); @@ -261,10 +262,10 @@ int _mon_check_var() { TestVpiHandle vh4 = VPI_HANDLE("fourthreetwoone"); CHECK_RESULT_NZ(vh4); if (TestSimulator::has_get_scalar()) { - d = vpi_get(vpiVector, vh4); - CHECK_RESULT(d, 1); - p = vpi_get_str(vpiType, vh4); - CHECK_RESULT_CSTR(p, "vpiMemory"); + d = vpi_get(vpiVector, vh4); + CHECK_RESULT(d, 1); + p = vpi_get_str(vpiType, vh4); + CHECK_RESULT_CSTR(p, "vpiMemory"); } t_vpi_value tmpValue; @@ -273,7 +274,7 @@ int _mon_check_var() { TestVpiHandle vh10 = vpi_handle(vpiLeftRange, vh4); CHECK_RESULT_NZ(vh10); vpi_get_value(vh10, &tmpValue); - CHECK_RESULT(tmpValue.value.integer,4); + CHECK_RESULT(tmpValue.value.integer, 4); p = vpi_get_str(vpiType, vh10); CHECK_RESULT_CSTR(p, "*undefined*"); } @@ -281,7 +282,7 @@ int _mon_check_var() { TestVpiHandle vh10 = vpi_handle(vpiRightRange, vh4); CHECK_RESULT_NZ(vh10); vpi_get_value(vh10, &tmpValue); - CHECK_RESULT(tmpValue.value.integer,3); + CHECK_RESULT(tmpValue.value.integer, 3); p = vpi_get_str(vpiType, vh10); CHECK_RESULT_CSTR(p, "*undefined*"); } @@ -297,13 +298,13 @@ int _mon_check_var() { TestVpiHandle vh12 = vpi_handle(vpiLeftRange, vh11); CHECK_RESULT_NZ(vh12); vpi_get_value(vh12, &tmpValue); - CHECK_RESULT(tmpValue.value.integer,2); + CHECK_RESULT(tmpValue.value.integer, 2); p = vpi_get_str(vpiType, vh12); CHECK_RESULT_CSTR(p, "*undefined*"); TestVpiHandle vh13 = vpi_handle(vpiRightRange, vh11); CHECK_RESULT_NZ(vh13); vpi_get_value(vh13, &tmpValue); - CHECK_RESULT(tmpValue.value.integer,1); + CHECK_RESULT(tmpValue.value.integer, 1); p = vpi_get_str(vpiType, vh13); CHECK_RESULT_CSTR(p, "*undefined*"); } @@ -331,7 +332,7 @@ int _mon_check_varlist() { CHECK_RESULT_CSTR(p, TestSimulator::rooted("sub.subsig2")); TestVpiHandle vh13 = vpi_scan(vh10); - CHECK_RESULT(vh13,0); + CHECK_RESULT(vh13, 0); return 0; } @@ -363,7 +364,8 @@ int _mon_check_quad() { CHECK_RESULT_NZ(vh2); s_vpi_value v; - t_vpi_vecval vv[2]; bzero(&vv,sizeof(vv)); + t_vpi_vecval vv[2]; + bzero(&vv, sizeof(vv)); s_vpi_time t; t.type = vpiSimTime; @@ -400,35 +402,33 @@ int _mon_check_quad() { int _mon_check_string() { static struct { - const char *name; - const char *initial; - const char *value; + const char* name; + const char* initial; + const char* value; } text_test_obs[] = { {"text_byte", "B", "xxA"}, // x's dropped {"text_half", "Hf", "xxT2"}, // x's dropped {"text_word", "Word", "Tree"}, {"text_long", "Long64b", "44Four44"}, - {"text" , "Verilog Test module", "lorem ipsum"}, + {"text", "Verilog Test module", "lorem ipsum"}, }; - for (int i=0; i<5; i++) { - TestVpiHandle vh1 = VPI_HANDLE(text_test_obs[i].name); - CHECK_RESULT_NZ(vh1); + for (int i = 0; i < 5; i++) { + TestVpiHandle vh1 = VPI_HANDLE(text_test_obs[i].name); + CHECK_RESULT_NZ(vh1); - s_vpi_value v; - s_vpi_time t = { vpiSimTime, 0, 0, 0.0}; - s_vpi_error_info e; + s_vpi_value v; + s_vpi_time t = {vpiSimTime, 0, 0, 0.0}; + s_vpi_error_info e; - v.format = vpiStringVal; - vpi_get_value(vh1, &v); - if (vpi_chk_error(&e)) { - printf("%%vpi_chk_error : %s\n", e.message); - } + v.format = vpiStringVal; + vpi_get_value(vh1, &v); + if (vpi_chk_error(&e)) { printf("%%vpi_chk_error : %s\n", e.message); } - CHECK_RESULT_CSTR_STRIP(v.value.str, text_test_obs[i].initial); + CHECK_RESULT_CSTR_STRIP(v.value.str, text_test_obs[i].initial); - v.value.str = (PLI_BYTE8*)text_test_obs[i].value; - vpi_put_value(vh1, &v, &t, vpiNoDelay); + v.value.str = (PLI_BYTE8*)text_test_obs[i].value; + vpi_put_value(vh1, &v, &t, vpiNoDelay); } return 0; @@ -438,11 +438,11 @@ int _mon_check_putget_str(p_cb_data cb_data) { static TestVpiHandle cb; static struct { TestVpiHandle scope, sig, rfr, check, verbose; - char str[128+1]; // char per bit plus null terminator + char str[128 + 1]; // char per bit plus null terminator int type; // value type in .str union { - PLI_INT32 integer; - s_vpi_vecval vector[4]; + PLI_INT32 integer; + s_vpi_vecval vector[4]; } value; // reference } data[129]; if (cb_data) { @@ -452,90 +452,92 @@ int _mon_check_putget_str(p_cb_data cb_data) { t.type = vpiSimTime; t.high = 0; t.low = 0; - for (int i=2; i<=128; i++) { - static s_vpi_value v; - int words = (i+31)>>5; - TEST_MSG("========== %d ==========\n", i); - if (callback_count_strs) { - // check persistance - if (data[i].type) { - v.format = data[i].type; - } else { - static PLI_INT32 vals[] = {vpiBinStrVal, vpiOctStrVal, vpiHexStrVal, vpiDecStrVal}; - v.format = vals[rand_r(&seed) % ((words>2)?3:4)]; - TEST_MSG("new format %d\n", v.format); - } - vpi_get_value(data[i].sig, &v); - TEST_MSG("%s\n", v.value.str); - if (data[i].type) { - CHECK_RESULT_CSTR(v.value.str, data[i].str); - } else { - data[i].type = v.format; - strcpy(data[i].str, v.value.str); - } - } + for (int i = 2; i <= 128; i++) { + static s_vpi_value v; + int words = (i + 31) >> 5; + TEST_MSG("========== %d ==========\n", i); + if (callback_count_strs) { + // check persistance + if (data[i].type) { + v.format = data[i].type; + } else { + static PLI_INT32 vals[] + = {vpiBinStrVal, vpiOctStrVal, vpiHexStrVal, vpiDecStrVal}; + v.format = vals[rand_r(&seed) % ((words > 2) ? 3 : 4)]; + TEST_MSG("new format %d\n", v.format); + } + vpi_get_value(data[i].sig, &v); + TEST_MSG("%s\n", v.value.str); + if (data[i].type) { + CHECK_RESULT_CSTR(v.value.str, data[i].str); + } else { + data[i].type = v.format; + strcpy(data[i].str, v.value.str); + } + } - // check for corruption - v.format = (words==1)?vpiIntVal:vpiVectorVal; - vpi_get_value(data[i].sig, &v); - if (v.format == vpiIntVal) { - TEST_MSG("%08x %08x\n", v.value.integer, data[i].value.integer); - CHECK_RESULT(v.value.integer, data[i].value.integer); - } else { - for (int k=0; k < words; k++) { - TEST_MSG("%d %08x %08x\n", k, v.value.vector[k].aval, data[i].value.vector[k].aval); - CHECK_RESULT_HEX(v.value.vector[k].aval, data[i].value.vector[k].aval); - } - } + // check for corruption + v.format = (words == 1) ? vpiIntVal : vpiVectorVal; + vpi_get_value(data[i].sig, &v); + if (v.format == vpiIntVal) { + TEST_MSG("%08x %08x\n", v.value.integer, data[i].value.integer); + CHECK_RESULT(v.value.integer, data[i].value.integer); + } else { + for (int k = 0; k < words; k++) { + TEST_MSG("%d %08x %08x\n", k, v.value.vector[k].aval, + data[i].value.vector[k].aval); + CHECK_RESULT_HEX(v.value.vector[k].aval, data[i].value.vector[k].aval); + } + } - if (callback_count_strs & 7) { - // put same value back - checking encoding/decoding equivalent - v.format = data[i].type; - v.value.str = data[i].str; - vpi_put_value(data[i].sig, &v, &t, vpiNoDelay); - v.format = vpiIntVal; - v.value.integer = 1; - //vpi_put_value(data[i].verbose, &v, &t, vpiNoDelay); - vpi_put_value(data[i].check, &v, &t, vpiNoDelay); - } else { - // stick a new random value in - unsigned int mask = ((i&31)?(1<<(i&31)):0)-1; - if (words == 1) { - v.value.integer = rand_r(&seed); - data[i].value.integer = v.value.integer &= mask; - v.format = vpiIntVal; - TEST_MSG("new value %08x\n", data[i].value.integer); - } else { - TEST_MSG("new value\n"); - for (int j=0; j<4; j++) { - data[i].value.vector[j].aval = rand_r(&seed); - if (j==(words-1)) { - data[i].value.vector[j].aval &= mask; - } - TEST_MSG(" %08x\n", data[i].value.vector[j].aval); - } - v.value.vector = data[i].value.vector; - v.format = vpiVectorVal; - } - vpi_put_value(data[i].sig, &v, &t, vpiNoDelay); - vpi_put_value(data[i].rfr, &v, &t, vpiNoDelay); - } - if ((callback_count_strs & 1) == 0) data[i].type = 0; + if (callback_count_strs & 7) { + // put same value back - checking encoding/decoding equivalent + v.format = data[i].type; + v.value.str = data[i].str; + vpi_put_value(data[i].sig, &v, &t, vpiNoDelay); + v.format = vpiIntVal; + v.value.integer = 1; + // vpi_put_value(data[i].verbose, &v, &t, vpiNoDelay); + vpi_put_value(data[i].check, &v, &t, vpiNoDelay); + } else { + // stick a new random value in + unsigned int mask = ((i & 31) ? (1 << (i & 31)) : 0) - 1; + if (words == 1) { + v.value.integer = rand_r(&seed); + data[i].value.integer = v.value.integer &= mask; + v.format = vpiIntVal; + TEST_MSG("new value %08x\n", data[i].value.integer); + } else { + TEST_MSG("new value\n"); + for (int j = 0; j < 4; j++) { + data[i].value.vector[j].aval = rand_r(&seed); + if (j == (words - 1)) { data[i].value.vector[j].aval &= mask; } + TEST_MSG(" %08x\n", data[i].value.vector[j].aval); + } + v.value.vector = data[i].value.vector; + v.format = vpiVectorVal; + } + vpi_put_value(data[i].sig, &v, &t, vpiNoDelay); + vpi_put_value(data[i].rfr, &v, &t, vpiNoDelay); + } + if ((callback_count_strs & 1) == 0) data[i].type = 0; } if (++callback_count_strs == callback_count_strs_max) { - int success = vpi_remove_cb(cb); - CHECK_RESULT_NZ(success); + int success = vpi_remove_cb(cb); + CHECK_RESULT_NZ(success); }; } else { // setup and install - for (int i=1; i<=128; i++) { + for (int i = 1; i <= 128; i++) { char buf[32]; snprintf(buf, sizeof(buf), TestSimulator::rooted("arr[%d].arr"), i); - CHECK_RESULT_NZ(data[i].scope = vpi_handle_by_name((PLI_BYTE8*)buf, NULL)); - CHECK_RESULT_NZ(data[i].sig = vpi_handle_by_name((PLI_BYTE8*)"sig", data[i].scope)); - CHECK_RESULT_NZ(data[i].rfr = vpi_handle_by_name((PLI_BYTE8*)"rfr", data[i].scope)); - CHECK_RESULT_NZ(data[i].check = vpi_handle_by_name((PLI_BYTE8*)"check", data[i].scope)); - CHECK_RESULT_NZ(data[i].verbose = vpi_handle_by_name((PLI_BYTE8*)"verbose", data[i].scope)); + CHECK_RESULT_NZ(data[i].scope = vpi_handle_by_name((PLI_BYTE8*)buf, NULL)); + CHECK_RESULT_NZ(data[i].sig = vpi_handle_by_name((PLI_BYTE8*)"sig", data[i].scope)); + CHECK_RESULT_NZ(data[i].rfr = vpi_handle_by_name((PLI_BYTE8*)"rfr", data[i].scope)); + CHECK_RESULT_NZ(data[i].check + = vpi_handle_by_name((PLI_BYTE8*)"check", data[i].scope)); + CHECK_RESULT_NZ(data[i].verbose + = vpi_handle_by_name((PLI_BYTE8*)"verbose", data[i].scope)); } static t_cb_data cb_data; @@ -564,8 +566,8 @@ int _mon_check_vlog_info() { CHECK_RESULT_CSTR(vlog_info.argv[2], "+INT=1234"); CHECK_RESULT_CSTR(vlog_info.argv[3], "+STRSTR"); if (TestSimulator::is_verilator()) { - CHECK_RESULT_CSTR(vlog_info.product, "Verilator"); - CHECK_RESULT(strlen(vlog_info.version) > 0, 1); + CHECK_RESULT_CSTR(vlog_info.product, "Verilator"); + CHECK_RESULT(strlen(vlog_info.version) > 0, 1); } return 0; } @@ -593,40 +595,35 @@ int mon_check() { #ifdef IS_VPI static int mon_check_vpi() { - vpiHandle href = vpi_handle(vpiSysTfCall, 0); - s_vpi_value vpi_value; + vpiHandle href = vpi_handle(vpiSysTfCall, 0); + s_vpi_value vpi_value; - vpi_value.format = vpiIntVal; - vpi_value.value.integer = mon_check(); - vpi_put_value(href, &vpi_value, NULL, vpiNoDelay); + vpi_value.format = vpiIntVal; + vpi_value.value.integer = mon_check(); + vpi_put_value(href, &vpi_value, NULL, vpiNoDelay); - return 0; + return 0; } -static s_vpi_systf_data vpi_systf_data[] = { - {vpiSysFunc, vpiIntFunc, (PLI_BYTE8*)"$mon_check", (PLI_INT32(*)(PLI_BYTE8*))mon_check_vpi, 0, 0, 0}, - 0 -}; +static s_vpi_systf_data vpi_systf_data[] = {{vpiSysFunc, vpiIntFunc, (PLI_BYTE8*)"$mon_check", + (PLI_INT32(*)(PLI_BYTE8*))mon_check_vpi, 0, 0, 0}, + 0}; // cver entry void vpi_compat_bootstrap(void) { - p_vpi_systf_data systf_data_p; - systf_data_p = &(vpi_systf_data[0]); - while (systf_data_p->type != 0) vpi_register_systf(systf_data_p++); + p_vpi_systf_data systf_data_p; + systf_data_p = &(vpi_systf_data[0]); + while (systf_data_p->type != 0) + vpi_register_systf(systf_data_p++); } // icarus entry -void (*vlog_startup_routines[])() = { - vpi_compat_bootstrap, - 0 -}; +void (*vlog_startup_routines[])() = {vpi_compat_bootstrap, 0}; #else -double sc_time_stamp() { - return main_time; -} -int main(int argc, char **argv, char **env) { +double sc_time_stamp() { return main_time; } +int main(int argc, char** argv, char** env) { double sim_time = 1100; Verilated::commandArgs(argc, argv); Verilated::debug(0); @@ -634,9 +631,9 @@ int main(int argc, char **argv, char **env) { VM_PREFIX* topp = new VM_PREFIX(""); // Note null name - we're flattening it out #ifdef VERILATOR -# ifdef TEST_VERBOSE +#ifdef TEST_VERBOSE Verilated::scopesDump(); -# endif +#endif #endif #if VM_TRACE @@ -656,9 +653,9 @@ int main(int argc, char **argv, char **env) { topp->eval(); VerilatedVpi::callValueCbs(); topp->clk = !topp->clk; - //mon_do(); + // mon_do(); #if VM_TRACE - if (tfp) tfp->dump (main_time); + if (tfp) tfp->dump(main_time); #endif } CHECK_RESULT(callback_count, 501); @@ -666,7 +663,7 @@ int main(int argc, char **argv, char **env) { CHECK_RESULT(callback_count_quad, 2); CHECK_RESULT(callback_count_strs, callback_count_strs_max); if (!Verilated::gotFinish()) { - vl_fatal(FILENM,__LINE__,"main", "%Error: Timeout; never got a $finish"); + vl_fatal(FILENM, __LINE__, "main", "%Error: Timeout; never got a $finish"); } topp->final(); @@ -674,7 +671,7 @@ int main(int argc, char **argv, char **env) { if (tfp) tfp->close(); #endif - delete topp; topp=NULL; + delete topp; VL_DANGLING(topp); exit(0L); }