Tests etc: Cleanup some clang-format suggestions. No functional change.
This commit is contained in:
parent
cf9f466f0a
commit
f87107e757
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
||||
//=============================================================================
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@
|
|||
///
|
||||
//*************************************************************************
|
||||
|
||||
|
||||
#ifndef _VERILATED_DPI_H_
|
||||
#define _VERILATED_DPI_H_ 1 ///< Header Guard
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<void()>& 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<VerilatedMsg, VerilatedMsg::Cmp> VerilatedThreadQueue;
|
||||
|
||||
std::atomic<vluint64_t> 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<VerilatedMsg> 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<std::string> ArgVec;
|
||||
typedef std::map<std::pair<const void*,void*>,void*> UserMap;
|
||||
typedef std::map<const char*, int, VerilatedCStrCmp> ExportNameMap;
|
||||
typedef std::map<std::pair<const void*, void*>, void*> UserMap;
|
||||
typedef std::map<const char*, int, VerilatedCStrCmp> 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*";
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@
|
|||
///
|
||||
//*************************************************************************
|
||||
|
||||
|
||||
#ifndef _VERILATED_SC_H_
|
||||
#define _VERILATED_SC_H_ 1 ///< Header Guard
|
||||
|
||||
|
|
|
|||
|
|
@ -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<VerilatedVarFlags>(static_cast<int>(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<void*>(datap)) {}
|
||||
: m_propsp(propsp)
|
||||
, m_datap(const_cast<void*>(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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -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<T_Key> Bucket;
|
||||
enum RehashType {GROW, SHRINK};
|
||||
enum RehashType { GROW, SHRINK };
|
||||
|
||||
template <class KK, class VV,
|
||||
class HH, class EQ> 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<iterator, bool> insert(const T_Key &val) {
|
||||
std::pair<iterator, bool> 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<numBuckets(); i++) {
|
||||
for (size_t i = 0; i < numBuckets(); i++) {
|
||||
while (!m_bucketsp[i].empty()) {
|
||||
typename Bucket::iterator bit = m_bucketsp[i].begin();
|
||||
size_t hash = m_hash.operator()(*bit);
|
||||
|
|
|
|||
|
|
@ -112,9 +112,7 @@ private:
|
|||
inline void bufferCheck() {
|
||||
// Flush the write buffer if there's not enough space left for new information
|
||||
// We only call this once per vector, so we need enough slop for a very wide "b###" line
|
||||
if (VL_UNLIKELY(m_writep > 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<<bits)-1) ))) {
|
||||
if (VL_UNLIKELY(bits == 32 || (diff & ((1U << bits) - 1)))) {
|
||||
fullBus(code, newval, bits);
|
||||
}
|
||||
}
|
||||
|
|
@ -339,15 +337,15 @@ public:
|
|||
inline void chgQuad(vluint32_t code, const vluint64_t newval, int bits) {
|
||||
vluint64_t diff = (*(reinterpret_cast<vluint64_t*>(&m_sigs_oldvalp[code]))) ^ newval;
|
||||
if (VL_UNLIKELY(diff)) {
|
||||
if (VL_UNLIKELY(bits==64 || (diff & ((1ULL<<bits)-1) ))) {
|
||||
if (VL_UNLIKELY(bits == 64 || (diff & ((1ULL << bits) - 1)))) {
|
||||
fullQuad(code, newval, bits);
|
||||
}
|
||||
}
|
||||
}
|
||||
inline void chgArray(vluint32_t code, const vluint32_t* newval, int bits) {
|
||||
for (int word=0; word<(((bits-1)/32)+1); ++word) {
|
||||
if (VL_UNLIKELY(m_sigs_oldvalp[code+word] ^ newval[word])) {
|
||||
fullArray(code,newval,bits);
|
||||
for (int word = 0; word < (((bits - 1) / 32) + 1); ++word) {
|
||||
if (VL_UNLIKELY(m_sigs_oldvalp[code + word] ^ newval[word])) {
|
||||
fullArray(code, newval, bits);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -379,7 +377,7 @@ public:
|
|||
vluint64_t diff = ( ((*(reinterpret_cast<vluint64_t*>(&m_sigs_oldvalp[code]))) ^ newval)
|
||||
| ((*(reinterpret_cast<vluint64_t*>(&m_sigs_oldvalp[code+1]))) ^ newtri));
|
||||
if (VL_UNLIKELY(diff)) {
|
||||
if (VL_UNLIKELY(bits==64 || (diff & ((1ULL<<bits)-1) ))) {
|
||||
if (VL_UNLIKELY(bits == 64 || (diff & ((1ULL << bits) - 1)))) {
|
||||
fullTriQuad(code, newval, newtri, bits);
|
||||
}
|
||||
}
|
||||
|
|
@ -424,7 +422,8 @@ class VerilatedVcdC {
|
|||
// CONSTRUCTORS
|
||||
VL_UNCOPYABLE(VerilatedVcdC);
|
||||
public:
|
||||
explicit VerilatedVcdC(VerilatedVcdFile* filep=NULL) : m_sptrace(filep) {}
|
||||
explicit VerilatedVcdC(VerilatedVcdFile* filep = NULL)
|
||||
: m_sptrace(filep) {}
|
||||
~VerilatedVcdC() {}
|
||||
public:
|
||||
// ACCESSORS
|
||||
|
|
@ -438,7 +437,7 @@ public:
|
|||
/// Continue a VCD dump by rotating to a new file name
|
||||
/// The header is only in the first file created, this allows
|
||||
/// "cat" to be used to combine the header plus any number of data files.
|
||||
void openNext(bool incFilename=true) VL_MT_UNSAFE_ONE { m_sptrace.openNext(incFilename); }
|
||||
void openNext(bool incFilename = true) VL_MT_UNSAFE_ONE { m_sptrace.openNext(incFilename); }
|
||||
/// Set size in megabytes after which new file should be created
|
||||
void rolloverMB(size_t rolloverMB) { m_sptrace.rolloverMB(rolloverMB); }
|
||||
/// Close dump
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
// SystemC 2.1.v1
|
||||
// cppcheck-suppress unusedFunction
|
||||
void VerilatedVcdSc::write_comment(const std::string &) {}
|
||||
void VerilatedVcdSc::trace(const unsigned int &, const std::string &, const char **) {}
|
||||
void VerilatedVcdSc::trace(const unsigned int &, const std::string &, const char**) {}
|
||||
|
||||
# define DECL_TRACE_METHOD_A(tp) \
|
||||
void VerilatedVcdSc::trace( const tp& object, const std::string& name ) {}
|
||||
|
|
@ -82,7 +82,7 @@ void VerilatedVcdSc::trace(const unsigned int &, const std::string &, const char
|
|||
// SystemC 2.0.1
|
||||
// cppcheck-suppress unusedFunction
|
||||
void VerilatedVcdSc::write_comment(const sc_string &) {}
|
||||
void VerilatedVcdSc::trace(const unsigned int &, const sc_string &, const char **) {}
|
||||
void VerilatedVcdSc::trace(const unsigned int&, const sc_string&, const char**) {}
|
||||
|
||||
#define DECL_TRACE_METHOD_A(tp) \
|
||||
void VerilatedVcdSc::trace( const tp& object, const sc_string& name ) {}
|
||||
|
|
@ -125,7 +125,7 @@ void VerilatedVcdSc::trace(const unsigned int &, const sc_string &, const char *
|
|||
// SystemC 1.2.1beta
|
||||
// cppcheck-suppress unusedFunction
|
||||
void VerilatedVcdSc::write_comment(const sc_string &) {}
|
||||
void VerilatedVcdSc::trace(const unsigned int &, const sc_string &, const char **) {}
|
||||
void VerilatedVcdSc::trace(const unsigned int&, const sc_string&, const char**) {}
|
||||
|
||||
#define DECL_TRACE_METHOD_A(tp) \
|
||||
void VerilatedVcdSc::trace( const tp& object, const sc_string& name ) {}
|
||||
|
|
|
|||
|
|
@ -96,8 +96,8 @@ private:
|
|||
# define DECL_TRACE_METHOD_B(tp) \
|
||||
virtual void trace(const tp& object, const std::string& name, int width);
|
||||
|
||||
virtual void write_comment(const std::string &);
|
||||
virtual void trace(const unsigned int &, const std::string &, const char **);
|
||||
virtual void write_comment(const std::string&);
|
||||
virtual void trace(const unsigned int&, const std::string&, const char**);
|
||||
|
||||
#if (SYSTEMC_VERSION>=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 )
|
||||
|
|
|
|||
|
|
@ -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) \
|
||||
|
|
|
|||
|
|
@ -307,8 +307,11 @@ inline void v3errorEndFatal(std::ostringstream& sstr) {
|
|||
::v3errorEndFatal((V3Error::v3errorPrep(V3ErrorCode::EC_FATAL), \
|
||||
(V3Error::v3errorStr()<<msg), V3Error::v3errorStr()));
|
||||
|
||||
#define UINFO(level,stmsg) {if (VL_UNCOVERABLE(debug()>=(level))) { cout<<"- "<<V3Error::lineStr(__FILE__,__LINE__)<<stmsg; }}
|
||||
#define UINFONL(level,stmsg) {if (VL_UNCOVERABLE(debug()>=(level))) { cout<<stmsg; } }
|
||||
#define UINFO(level, stmsg) \
|
||||
{ if (VL_UNCOVERABLE(debug() >= (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}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -683,7 +683,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
|||
for (int i=0; i<argc; ) {
|
||||
UINFO(9, " Option: "<<argv[i]<<endl);
|
||||
if (argv[i][0]=='+') {
|
||||
char *sw = argv[i];
|
||||
char* sw = argv[i];
|
||||
if (!strncmp (sw, "+define+", 8)) {
|
||||
addDefine(string(sw+strlen("+define+")), true);
|
||||
}
|
||||
|
|
@ -722,7 +722,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
|||
shift;
|
||||
} // + options
|
||||
else if (argv[i][0]=='-') {
|
||||
const char *sw = argv[i];
|
||||
const char* sw = argv[i];
|
||||
bool flag = true;
|
||||
VOptionBool bflag;
|
||||
// Allow gnu -- switches
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ void VlcOptions::parseOptsList(int argc, char** argv) {
|
|||
for (int i=0; i<argc; ) {
|
||||
UINFO(9, " Option: "<<argv[i]<<endl);
|
||||
if (argv[i][0]=='-') {
|
||||
const char *sw = argv[i];
|
||||
const char* sw = argv[i];
|
||||
bool flag = true;
|
||||
// Allow gnu -- switches
|
||||
if (sw[0]=='-' && sw[1]=='-') ++sw;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ private:
|
|||
// MEMBERS
|
||||
int m_lineno; ///< Line number
|
||||
int m_column; ///< Column number
|
||||
vluint64_t m_count; ///< Count
|
||||
vluint64_t m_count; ///< Count
|
||||
bool m_ok; ///< Coverage is above threshold
|
||||
|
||||
public:
|
||||
|
|
@ -67,8 +67,8 @@ public:
|
|||
class VlcSource {
|
||||
public:
|
||||
// TYPES
|
||||
typedef std::map<int,VlcSourceCount> ColumnMap; // Map of {column}
|
||||
typedef std::map<int,ColumnMap> LinenoMap; // Map of {lineno}{column}
|
||||
typedef std::map<int, VlcSourceCount> ColumnMap; // Map of {column}
|
||||
typedef std::map<int, ColumnMap> LinenoMap; // Map of {lineno}{column}
|
||||
|
||||
private:
|
||||
// MEMBERS
|
||||
|
|
@ -112,7 +112,8 @@ public:
|
|||
class VlcSources {
|
||||
public:
|
||||
// TYPES
|
||||
typedef std::map<string,VlcSource> NameMap;
|
||||
typedef std::map<string, VlcSource> 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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<<top()<<"."<<obj;
|
||||
|
|
|
|||
|
|
@ -20,13 +20,25 @@
|
|||
class TestVpiHandle {
|
||||
/// For testing, etc, wrap vpiHandle in an auto-releasing class
|
||||
vpiHandle m_handle;
|
||||
bool m_free;
|
||||
bool m_free;
|
||||
|
||||
public:
|
||||
TestVpiHandle() : m_handle(NULL), m_free(true) { }
|
||||
TestVpiHandle(vpiHandle h) : m_handle(h), m_free(true) { }
|
||||
~TestVpiHandle() { if (m_handle && m_free) { vpi_free_object(m_handle); m_handle=NULL; } }
|
||||
TestVpiHandle()
|
||||
: m_handle(NULL)
|
||||
, m_free(true) {}
|
||||
TestVpiHandle(vpiHandle h)
|
||||
: m_handle(h)
|
||||
, m_free(true) {}
|
||||
~TestVpiHandle() {
|
||||
if (m_handle && m_free) {
|
||||
{ vpi_free_object(m_handle); m_handle = NULL; }
|
||||
}
|
||||
}
|
||||
operator vpiHandle() const { return m_handle; }
|
||||
inline TestVpiHandle& operator= (vpiHandle h) { m_handle = h; return *this; }
|
||||
inline TestVpiHandle& operator=(vpiHandle h) {
|
||||
m_handle = h;
|
||||
return *this;
|
||||
}
|
||||
TestVpiHandle& nofree() {
|
||||
m_free = false;
|
||||
return *this;
|
||||
|
|
|
|||
|
|
@ -10,14 +10,12 @@
|
|||
|
||||
unsigned int main_time = false;
|
||||
|
||||
double sc_time_stamp() {
|
||||
return main_time;
|
||||
}
|
||||
double sc_time_stamp() { return main_time; }
|
||||
|
||||
VM_PREFIX* topp = NULL;
|
||||
|
||||
void clockit(int clk1, int clk0) {
|
||||
topp->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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
|
|
|
|||
|
|
@ -46,16 +46,18 @@ int failure = 0;
|
|||
int dpii_failure() { return failure; }
|
||||
|
||||
#define CHECK_RESULT_HEX(got, exp) \
|
||||
do { if ((got) != (exp)) { \
|
||||
std::cout<<std::dec<<"%Error: "<<__FILE__<<":"<<__LINE__<<std::hex \
|
||||
<<": GOT="<<(got)<<" EXP="<<(exp)<<std::endl; \
|
||||
failure = __LINE__; \
|
||||
}} while(0)
|
||||
do { \
|
||||
if ((got) != (exp)) { \
|
||||
std::cout << std::dec << "%Error: " << __FILE__ << ":" << __LINE__ << std::hex \
|
||||
<< ": GOT=" << (got) << " EXP=" << (exp) << std::endl; \
|
||||
failure = __LINE__; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
//======================================================================
|
||||
|
||||
void dpii_lib_bit_check() {
|
||||
svBitVecVal bv [3];
|
||||
svBitVecVal bv[3];
|
||||
bv[0] = 0xa3a2a1a0; // 31..0
|
||||
bv[1] = 0xa7a6a5a4; // 63..32
|
||||
bv[2] = 0xabaaa9a8; // 95..64
|
||||
|
|
@ -76,7 +78,7 @@ void dpii_lib_bit_check() {
|
|||
CHECK_RESULT_HEX(bv[1], 0xa7a6a5ad);
|
||||
CHECK_RESULT_HEX(bv[2], 0xabaaa9a8);
|
||||
|
||||
svBitVecVal btmp [1];
|
||||
svBitVecVal btmp[1];
|
||||
svGetPartselBit(btmp, bv, 40, 8);
|
||||
CHECK_RESULT_HEX(btmp[0], 0xa5);
|
||||
|
||||
|
|
@ -87,7 +89,7 @@ void dpii_lib_bit_check() {
|
|||
}
|
||||
|
||||
void dpii_lib_logic_check() {
|
||||
svLogicVecVal lv [3];
|
||||
svLogicVecVal lv[3];
|
||||
lv[0].aval = 0xb3b2b1b0; // 31..0
|
||||
lv[1].aval = 0xb7b6b5b4; // 63..32
|
||||
lv[2].aval = 0xbbbab9b8; // 95..64
|
||||
|
|
@ -114,7 +116,7 @@ void dpii_lib_logic_check() {
|
|||
CHECK_RESULT_HEX(lv[1].bval, 0xc7c6c5c8);
|
||||
CHECK_RESULT_HEX(lv[2].bval, 0xcbcac9c8);
|
||||
|
||||
svLogicVecVal ltmp [1];
|
||||
svLogicVecVal ltmp[1];
|
||||
svGetPartselLogic(ltmp, lv, 40, 8);
|
||||
CHECK_RESULT_HEX(ltmp[0].aval, 0xb5);
|
||||
CHECK_RESULT_HEX(ltmp[0].bval, 0xc5);
|
||||
|
|
|
|||
|
|
@ -60,23 +60,23 @@ extern "C" {
|
|||
//======================================================================
|
||||
|
||||
// Untested:
|
||||
//void *svGetArrElemPtr(const svOpenArrayHandle, int indx1, ...);
|
||||
//void svPutBitArrElemVecVal(const svOpenArrayHandle d, const svBitVecVal* s, int indx1, ...);
|
||||
//void svPutBitArrElem1VecVal(const svOpenArrayHandle d, const svBitVecVal* s, int indx1);
|
||||
//void svPutLogicArrElemVecVal(const svOpenArrayHandle d, const svLogicVecVal* s, int indx1, ...);
|
||||
//void svPutLogicArrElem1VecVal(const svOpenArrayHandle d, const svLogicVecVal* s, int indx1);
|
||||
//void svGetBitArrElemVecVal(svBitVecVal* d, const svOpenArrayHandle s, int indx1, ...);
|
||||
//void svGetBitArrElem1VecVal(svBitVecVal* d, const svOpenArrayHandle s, int indx1);
|
||||
//void svGetLogicArrElemVecVal(svLogicVecVal* d, const svOpenArrayHandle s, int indx1, ...);
|
||||
//void svGetLogicArrElem1VecVal(svLogicVecVal* d, const svOpenArrayHandle s, int indx1);
|
||||
//svBit svGetBitArrElem(const svOpenArrayHandle s, int indx1, ...);
|
||||
//svBit svGetBitArrElem1(const svOpenArrayHandle s, int indx1);
|
||||
//svLogic svGetLogicArrElem(const svOpenArrayHandle s, int indx1, ...);
|
||||
//svLogic svGetLogicArrElem1(const svOpenArrayHandle s, int indx1);
|
||||
//void svPutBitArrElem(const svOpenArrayHandle d, svBit value, int indx1, ...);
|
||||
//void svPutBitArrElem1(const svOpenArrayHandle d, svBit value, int indx1);
|
||||
//void svPutLogicArrElem(const svOpenArrayHandle d, svLogic value, int indx1, ...);
|
||||
//void svPutLogicArrElem1(const svOpenArrayHandle d, svLogic value, int indx1);
|
||||
// void *svGetArrElemPtr(const svOpenArrayHandle, int indx1, ...);
|
||||
// void svPutBitArrElemVecVal(const svOpenArrayHandle d, const svBitVecVal* s, int indx1, ...);
|
||||
// void svPutBitArrElem1VecVal(const svOpenArrayHandle d, const svBitVecVal* s, int indx1);
|
||||
// void svPutLogicArrElemVecVal(const svOpenArrayHandle d, const svLogicVecVal* s, int indx1, ...);
|
||||
// void svPutLogicArrElem1VecVal(const svOpenArrayHandle d, const svLogicVecVal* s, int indx1);
|
||||
// void svGetBitArrElemVecVal(svBitVecVal* d, const svOpenArrayHandle s, int indx1, ...);
|
||||
// void svGetBitArrElem1VecVal(svBitVecVal* d, const svOpenArrayHandle s, int indx1);
|
||||
// void svGetLogicArrElemVecVal(svLogicVecVal* d, const svOpenArrayHandle s, int indx1, ...);
|
||||
// void svGetLogicArrElem1VecVal(svLogicVecVal* d, const svOpenArrayHandle s, int indx1);
|
||||
// svBit svGetBitArrElem(const svOpenArrayHandle s, int indx1, ...);
|
||||
// svBit svGetBitArrElem1(const svOpenArrayHandle s, int indx1);
|
||||
// svLogic svGetLogicArrElem(const svOpenArrayHandle s, int indx1, ...);
|
||||
// svLogic svGetLogicArrElem1(const svOpenArrayHandle s, int indx1);
|
||||
// void svPutBitArrElem(const svOpenArrayHandle d, svBit value, int indx1, ...);
|
||||
// void svPutBitArrElem1(const svOpenArrayHandle d, svBit value, int indx1);
|
||||
// void svPutLogicArrElem(const svOpenArrayHandle d, svLogic value, int indx1, ...);
|
||||
// void svPutLogicArrElem1(const svOpenArrayHandle d, svLogic value, int indx1);
|
||||
|
||||
//======================================================================
|
||||
|
||||
|
|
@ -90,102 +90,105 @@ int dpii_failure() { return failure; }
|
|||
#endif
|
||||
|
||||
#define CHECK_RESULT_HEX(got, exp) \
|
||||
do { if ((got) != (exp)) { \
|
||||
std::cout<<std::dec<<"%Error: "<<__FILE__<<":"<<__LINE__<<std::hex \
|
||||
<<": GOT="<<(got)<<" EXP="<<(exp)<<std::endl; \
|
||||
failure = __LINE__; \
|
||||
}} while(0)
|
||||
do { \
|
||||
if ((got) != (exp)) { \
|
||||
std::cout << std::dec << "%Error: " << __FILE__ << ":" << __LINE__ << std::hex \
|
||||
<< ": GOT=" << (got) << " EXP=" << (exp) << std::endl; \
|
||||
failure = __LINE__; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
void dpii_unused(const svOpenArrayHandle u) {}
|
||||
|
||||
void _dpii_all(int c, int p, int u, const svOpenArrayHandle i, const svOpenArrayHandle o) {
|
||||
#ifdef TEST_VERBOSE
|
||||
printf("-:%s:%d: For case c=%d p=%d u=%d data=%p\n", __FILE__,__LINE__, c, p, u, svGetArrayPtr(i));
|
||||
printf("-:%s:%d: For case c=%d p=%d u=%d data=%p\n",
|
||||
__FILE__, __LINE__, c, p, u, svGetArrayPtr(i));
|
||||
#endif
|
||||
(void)svGetArrayPtr(i);
|
||||
// NC always returns zero and warns
|
||||
//(void)svSizeOfArray(i);
|
||||
#ifndef VCS // VCS does not support dimension 0 query
|
||||
if (p) {
|
||||
int d=0;
|
||||
if (c==0 || c==1) {
|
||||
int d = 0;
|
||||
if (c == 0 || c == 1) {
|
||||
CHECK_RESULT_HEX(svLeft(i, d), 1);
|
||||
CHECK_RESULT_HEX(svRight(i, d), -1);
|
||||
CHECK_RESULT_HEX(svLow(i, d), -1);
|
||||
CHECK_RESULT_HEX(svHigh(i, d), 1);
|
||||
//CHECK_RESULT_HEX(svIncrement(i, d), 0);
|
||||
// CHECK_RESULT_HEX(svIncrement(i, d), 0);
|
||||
CHECK_RESULT_HEX(svSize(i, d), 3);
|
||||
} else if (c==2) {
|
||||
} else if (c == 2) {
|
||||
CHECK_RESULT_HEX(svLeft(i, d), 95);
|
||||
CHECK_RESULT_HEX(svRight(i, d), 1);
|
||||
CHECK_RESULT_HEX(svLow(i, d), 1);
|
||||
CHECK_RESULT_HEX(svHigh(i, d), 95);
|
||||
//CHECK_RESULT_HEX(svIncrement(i, d), 0);
|
||||
// CHECK_RESULT_HEX(svIncrement(i, d), 0);
|
||||
CHECK_RESULT_HEX(svSize(i, d), 95);
|
||||
} else {
|
||||
CHECK_RESULT_HEX(0,1);
|
||||
CHECK_RESULT_HEX(0, 1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (u>=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; }
|
||||
|
|
|
|||
|
|
@ -46,29 +46,31 @@ int failure = 0;
|
|||
int dpii_failure() { return failure; }
|
||||
|
||||
#define CHECK_RESULT_HEX(got, exp) \
|
||||
do { if ((got) != (exp)) { \
|
||||
std::cout<<std::dec<<"%Error: "<<__FILE__<<":"<<__LINE__<<std::hex \
|
||||
<<": GOT="<<(got)<<" EXP="<<(exp)<<std::endl; \
|
||||
failure = __LINE__; \
|
||||
}} while(0)
|
||||
do { \
|
||||
if ((got) != (exp)) { \
|
||||
std::cout << std::dec << "%Error: " << __FILE__ << ":" << __LINE__ << std::hex \
|
||||
<< ": GOT=" << (got) << " EXP=" << (exp) << std::endl; \
|
||||
failure = __LINE__; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
//======================================================================
|
||||
|
||||
void dpii_open_i(const svOpenArrayHandle i, const svOpenArrayHandle o) {
|
||||
// Illegal in VCS:
|
||||
//CHECK_RESULT_HEX(svLeft(i, 0), 2);
|
||||
//CHECK_RESULT_HEX(svRight(i, 0), 0);
|
||||
//CHECK_RESULT_HEX(svLow(i, 0), 0);
|
||||
//CHECK_RESULT_HEX(svHigh(i, 0), 2);
|
||||
// CHECK_RESULT_HEX(svLeft(i, 0), 2);
|
||||
// CHECK_RESULT_HEX(svRight(i, 0), 0);
|
||||
// CHECK_RESULT_HEX(svLow(i, 0), 0);
|
||||
// CHECK_RESULT_HEX(svHigh(i, 0), 2);
|
||||
//
|
||||
CHECK_RESULT_HEX(svDimensions(i), 1);
|
||||
CHECK_RESULT_HEX(svLeft(i, 1), 2);
|
||||
CHECK_RESULT_HEX(svRight(i, 1), 0);
|
||||
CHECK_RESULT_HEX(svLow(i, 1), 0);
|
||||
CHECK_RESULT_HEX(svHigh(i, 1), 2);
|
||||
//CHECK_RESULT_HEX(svIncrement(i, 1), 0);
|
||||
// CHECK_RESULT_HEX(svIncrement(i, 1), 0);
|
||||
CHECK_RESULT_HEX(svSize(i, 1), 3);
|
||||
for (int a=0; a<3; ++a) {
|
||||
for (int a = 0; a < 3; ++a) {
|
||||
svBitVecVal vec[1];
|
||||
svGetBitArrElemVecVal(vec, i, a);
|
||||
vec[0] = ~vec[0];
|
||||
|
|
|
|||
|
|
@ -51,15 +51,15 @@ extern "C" {
|
|||
static int global_count[COUNTERS];
|
||||
|
||||
int dpii_clear() {
|
||||
for (int i=0; i<COUNTERS; ++i) global_count[i] = 0;
|
||||
for (int i = 0; i < COUNTERS; ++i) global_count[i] = 0;
|
||||
return 0;
|
||||
}
|
||||
int dpii_count(int idx) {
|
||||
return (idx >= 0 && idx<COUNTERS) ? global_count[idx] : -1;
|
||||
return (idx >= 0 && idx < COUNTERS) ? global_count[idx] : -1;
|
||||
}
|
||||
unsigned char dpii_incx(int idx, unsigned char value) {
|
||||
if (idx >= 0 && idx<COUNTERS) global_count[idx]++;
|
||||
if (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); }
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
|
|
|
|||
|
|
@ -47,8 +47,9 @@ extern "C" {
|
|||
struct state {
|
||||
std::atomic<bool> task_is_running;
|
||||
std::atomic<int> 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; }
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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],
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -14,5 +14,5 @@
|
|||
//*************************************************************************
|
||||
|
||||
extern "C" {
|
||||
void dpii_a_library() {}
|
||||
void dpii_a_library() {}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,5 +14,5 @@
|
|||
//*************************************************************************
|
||||
|
||||
extern "C" {
|
||||
void dpii_so_library() {}
|
||||
void dpii_so_library() {}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@
|
|||
#include <verilated.h>
|
||||
#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");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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<vluint32_t> i3;
|
||||
sc_signal<vluint32_t> o3;
|
||||
sc_signal<vluint32_t> i34[4];
|
||||
sc_signal<vluint32_t> o34[4];
|
||||
sc_signal<vluint32_t> i345[4][5];
|
||||
sc_signal<vluint32_t> o345[4][5];
|
||||
sc_signal<vluint32_t> i3;
|
||||
sc_signal<vluint32_t> o3;
|
||||
sc_signal<vluint32_t> i34[4];
|
||||
sc_signal<vluint32_t> o34[4];
|
||||
sc_signal<vluint32_t> i345[4][5];
|
||||
sc_signal<vluint32_t> 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -9,18 +9,16 @@
|
|||
#include <verilated.h>
|
||||
#include "Vt_multitop_sig.h"
|
||||
|
||||
|
||||
// Use cout to avoid issues with %d/%lx etc
|
||||
#define CHECK_RESULT(got, exp) \
|
||||
if ((got) != (exp)) { \
|
||||
std::cout<<std::dec<<"%Error: "<<__FILE__<<":"<<__LINE__ \
|
||||
<<": GOT = "<<(got)<<" EXP = "<<(exp)<<std::endl; \
|
||||
return __LINE__; \
|
||||
#define CHECK_RESULT(got, exp) \
|
||||
if ((got) != (exp)) { \
|
||||
std::cout << std::dec << "%Error: " << __FILE__ << ":" << __LINE__ << ": GOT = " << (got) \
|
||||
<< " EXP = " << (exp) << std::endl; \
|
||||
return __LINE__; \
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
Vt_multitop_sig *topp = new Vt_multitop_sig("");
|
||||
int main(int argc, char* argv[]) {
|
||||
Vt_multitop_sig* topp = new Vt_multitop_sig("");
|
||||
|
||||
Verilated::debug(0);
|
||||
|
||||
|
|
|
|||
|
|
@ -8,52 +8,52 @@
|
|||
#define STRINGIFY(x) STRINGIFY2(x)
|
||||
#define STRINGIFY2(x) #x
|
||||
|
||||
Vt_order_multidriven * vcore;
|
||||
VerilatedVcdC * vcd;
|
||||
vluint64_t vtime;
|
||||
Vt_order_multidriven* vcore;
|
||||
VerilatedVcdC* vcd;
|
||||
vluint64_t vtime;
|
||||
|
||||
#define PHASE_90
|
||||
|
||||
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;
|
||||
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");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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<vluint8_t *>(var->datap());
|
||||
vluint8_t* varData = reinterpret_cast<vluint8_t*>(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<vluint8_t *>(var->datap());
|
||||
vluint8_t* varData = reinterpret_cast<vluint8_t*>(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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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<<dec<<"%Error: "<<FILENM<<":"<<__LINE__ \
|
||||
<<": GOT = "<<(got)<<" EXP = "<<(exp)<<endl; \
|
||||
if ((got) != (exp)) { \
|
||||
cout << dec << "%Error: " << FILENM << ":" << __LINE__ << ": GOT = " << (got) \
|
||||
<< " EXP = " << (exp) << endl; \
|
||||
return __LINE__; \
|
||||
}
|
||||
|
||||
#define CHECK_RESULT_HEX(got, exp) \
|
||||
if ((got) != (exp)) { \
|
||||
cout<<dec<<"%Error: "<<FILENM<<":"<<__LINE__<<hex \
|
||||
<<": GOT = "<<(got)<<" EXP = "<<(exp)<<endl; \
|
||||
if ((got) != (exp)) { \
|
||||
cout << dec << "%Error: " << FILENM << ":" << __LINE__ << hex << ": GOT = " << (got) \
|
||||
<< " EXP = " << (exp) << endl; \
|
||||
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):"<null>", (exp)?(exp):"<null>"); \
|
||||
if (strcmp((got), (exp))) { \
|
||||
printf("%%Error: %s:%d: GOT = '%s' EXP = '%s'\n", FILENM, __LINE__, \
|
||||
(got) ? (got) : "<null>", (exp) ? (exp) : "<null>"); \
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<<dec<<"%Error: "<<FILENM<<":"<<__LINE__ \
|
||||
<<": GOT = "<<(got)<<" EXP = "<<(exp)<<endl; \
|
||||
cout << dec << "%Error: " << FILENM << ":" << __LINE__ << ": GOT = " << (got) \
|
||||
<< " EXP = " << (exp) << endl; \
|
||||
return __LINE__; \
|
||||
}
|
||||
|
||||
#define CHECK_RESULT_HEX(got, exp) \
|
||||
if ((got) != (exp)) { \
|
||||
cout<<dec<<"%Error: "<<FILENM<<":"<<__LINE__<<hex \
|
||||
<<": GOT = "<<(got)<<" EXP = "<<(exp)<<endl; \
|
||||
cout << dec << "%Error: " << FILENM << ":" << __LINE__ << hex << ": GOT = " << (got) \
|
||||
<< " EXP = " << (exp) << endl; \
|
||||
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):"<null>", (exp)?(exp):"<null>"); \
|
||||
if (strcmp((got), (exp))) { \
|
||||
printf("%%Error: %s:%d: GOT = '%s' EXP = '%s'\n", FILENM, __LINE__, \
|
||||
(got) ? (got) : "<null>", (exp) ? (exp) : "<null>"); \
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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):"<null>", (exp)?(exp):"<null>"); \
|
||||
printf("%%Error: %s:%d: GOT = '%s' EXP = '%s'\n", FILENM, __LINE__, \
|
||||
(got) ? (got) : "<null>", (exp) ? (exp) : "<null>"); \
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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<<std::dec<<"%Error: "<<FILENM<<":"<<__LINE__ \
|
||||
<<": GOT = "<<(got)<<" EXP = "<<(exp)<<std::endl; \
|
||||
std::cout << std::dec << "%Error: " << FILENM << ":" << __LINE__ << ": GOT = " << (got) \
|
||||
<< " EXP = " << (exp) << std::endl; \
|
||||
return __LINE__; \
|
||||
}
|
||||
|
||||
#define CHECK_RESULT_HEX(got, exp) \
|
||||
if ((got) != (exp)) { \
|
||||
std::cout<<std::dec<<"%Error: "<<FILENM<<":"<<__LINE__<<std::hex \
|
||||
<<": GOT = "<<(got)<<" EXP = "<<(exp)<<std::endl; \
|
||||
std::cout << std::dec << "%Error: " << FILENM << ":" << __LINE__ << std::hex \
|
||||
<< ": GOT = " << (got) << " EXP = " << (exp) << std::endl; \
|
||||
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):"<null>", (exp)?(exp):"<null>"); \
|
||||
if (strcmp((got), (exp))) { \
|
||||
printf("%%Error: %s:%d: GOT = '%s' EXP = '%s'\n", FILENM, __LINE__, \
|
||||
(got) ? (got) : "<null>", (exp) ? (exp) : "<null>"); \
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<<dec<<"%Error: "<<FILENM<<":"<<__LINE__ \
|
||||
<<": GOT = "<<(got)<<" EXP = "<<(exp)<<endl; \
|
||||
if ((got) != (exp)) { \
|
||||
cout << dec << "%Error: " << FILENM << ":" << __LINE__ << ": GOT = " << (got) \
|
||||
<< " EXP = " << (exp) << endl; \
|
||||
return __LINE__; \
|
||||
}
|
||||
|
||||
#define CHECK_RESULT_HEX(got, exp) \
|
||||
if ((got) != (exp)) { \
|
||||
cout<<dec<<"%Error: "<<FILENM<<":"<<__LINE__<<hex \
|
||||
<<": GOT = "<<(got)<<" EXP = "<<(exp)<<endl; \
|
||||
if ((got) != (exp)) { \
|
||||
cout << dec << "%Error: " << FILENM << ":" << __LINE__ << hex << ": GOT = " << (got) \
|
||||
<< " EXP = " << (exp) << endl; \
|
||||
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):"<null>", (exp)?(exp):"<null>"); \
|
||||
if (strcmp((got), (exp))) { \
|
||||
printf("%%Error: %s:%d: GOT = '%s' EXP = '%s'\n", FILENM, __LINE__, \
|
||||
(got) ? (got) : "<null>", (exp) ? (exp) : "<null>"); \
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue