Internals: clang-format cleanups. No functional change.
This commit is contained in:
parent
a13eab55f5
commit
e07e9390f6
|
|
@ -10,22 +10,14 @@ be made to a file. The following files are not yet clang-format clean:
|
||||||
|
|
||||||
clang-format -i include/verilated.h
|
clang-format -i include/verilated.h
|
||||||
clang-format -i include/verilated_dpi.h
|
clang-format -i include/verilated_dpi.h
|
||||||
clang-format -i include/verilated_fst_c.h
|
|
||||||
clang-format -i include/verilated_heavy.h
|
clang-format -i include/verilated_heavy.h
|
||||||
clang-format -i include/verilated_imp.h
|
clang-format -i include/verilated_imp.h
|
||||||
clang-format -i include/verilated_save.h
|
|
||||||
clang-format -i include/verilated_sym_props.h
|
|
||||||
clang-format -i include/verilated_unordered_set_map.h
|
clang-format -i include/verilated_unordered_set_map.h
|
||||||
clang-format -i include/verilated_vcd_c.h
|
|
||||||
clang-format -i include/verilatedos.h
|
clang-format -i include/verilatedos.h
|
||||||
|
|
||||||
clang-format -i include/verilated.cpp
|
clang-format -i include/verilated.cpp
|
||||||
clang-format -i include/verilated_cov.cpp
|
clang-format -i include/verilated_cov.cpp
|
||||||
clang-format -i include/verilated_dpi.cpp
|
clang-format -i include/verilated_dpi.cpp
|
||||||
clang-format -i include/verilated_fst_c.cpp
|
|
||||||
clang-format -i include/verilated_save.cpp
|
|
||||||
clang-format -i include/verilated_threads.cpp
|
|
||||||
clang-format -i include/verilated_vcd_c.cpp
|
|
||||||
clang-format -i include/verilated_vpi.cpp
|
clang-format -i include/verilated_vpi.cpp
|
||||||
|
|
||||||
clang-format -i src/V3Ast.h
|
clang-format -i src/V3Ast.h
|
||||||
|
|
|
||||||
|
|
@ -106,18 +106,16 @@ void VerilatedFst::open(const char* filename) VL_MT_UNSAFE {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerilatedFst::module(const std::string& name) {
|
void VerilatedFst::module(const std::string& name) { m_module = name; }
|
||||||
m_module = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// Decl
|
// Decl
|
||||||
|
|
||||||
void VerilatedFst::declDTypeEnum(int dtypenum, const char* name, vluint32_t elements,
|
void VerilatedFst::declDTypeEnum(int dtypenum, const char* name, vluint32_t elements,
|
||||||
unsigned int minValbits,
|
unsigned int minValbits, const char** itemNamesp,
|
||||||
const char** itemNamesp, const char** itemValuesp) {
|
const char** itemValuesp) {
|
||||||
fstEnumHandle enumNum = fstWriterCreateEnumTable(m_fst, name, elements,
|
fstEnumHandle enumNum
|
||||||
minValbits, itemNamesp, itemValuesp);
|
= fstWriterCreateEnumTable(m_fst, name, elements, minValbits, itemNamesp, itemValuesp);
|
||||||
m_local2fstdtype[dtypenum] = enumNum;
|
m_local2fstdtype[dtypenum] = enumNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -143,8 +141,7 @@ void VerilatedFst::declSymbol(vluint32_t code, const char* name, int dtypenum, f
|
||||||
std::list<std::string>::iterator cur_it = m_curScope.begin();
|
std::list<std::string>::iterator cur_it = m_curScope.begin();
|
||||||
std::list<std::string>::iterator new_it = tokens.begin();
|
std::list<std::string>::iterator new_it = tokens.begin();
|
||||||
while (cur_it != m_curScope.end() && new_it != tokens.end()) {
|
while (cur_it != m_curScope.end() && new_it != tokens.end()) {
|
||||||
if (*cur_it != *new_it)
|
if (*cur_it != *new_it) break;
|
||||||
break;
|
|
||||||
++cur_it;
|
++cur_it;
|
||||||
++new_it;
|
++new_it;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ class VerilatedFst {
|
||||||
typedef std::map<vluint32_t, fstHandle> Code2SymbolType;
|
typedef std::map<vluint32_t, fstHandle> Code2SymbolType;
|
||||||
typedef std::map<int, fstEnumHandle> Local2FstDtype;
|
typedef std::map<int, fstEnumHandle> Local2FstDtype;
|
||||||
typedef std::vector<VerilatedFstCallInfo*> CallbackVec;
|
typedef std::vector<VerilatedFstCallInfo*> CallbackVec;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void* m_fst;
|
void* m_fst;
|
||||||
VerilatedAssertOneThread m_assertOne; ///< Assert only called from single thread
|
VerilatedAssertOneThread m_assertOne; ///< Assert only called from single thread
|
||||||
|
|
@ -61,9 +62,12 @@ private:
|
||||||
bool array, int arraynum, vluint32_t len, vluint32_t bits);
|
bool array, int arraynum, vluint32_t len, vluint32_t bits);
|
||||||
// helpers
|
// helpers
|
||||||
std::vector<char> m_valueStrBuffer;
|
std::vector<char> m_valueStrBuffer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit VerilatedFst(void* fst = NULL);
|
explicit VerilatedFst(void* fst = NULL);
|
||||||
~VerilatedFst() { if (m_fst == NULL) { fstWriterClose(m_fst); } }
|
~VerilatedFst() {
|
||||||
|
if (m_fst == NULL) { fstWriterClose(m_fst); }
|
||||||
|
}
|
||||||
void changeThread() { m_assertOne.changeThread(); }
|
void changeThread() { m_assertOne.changeThread(); }
|
||||||
bool isOpen() const { return m_fst != NULL; }
|
bool isOpen() const { return m_fst != NULL; }
|
||||||
void open(const char* filename) VL_MT_UNSAFE;
|
void open(const char* filename) VL_MT_UNSAFE;
|
||||||
|
|
@ -76,7 +80,7 @@ public:
|
||||||
void set_time_unit(const char* unitp) { fstWriterSetTimescaleFromString(m_fst, unitp); }
|
void set_time_unit(const char* unitp) { fstWriterSetTimescaleFromString(m_fst, unitp); }
|
||||||
void set_time_unit(const std::string& unit) { set_time_unit(unit.c_str()); }
|
void set_time_unit(const std::string& unit) { set_time_unit(unit.c_str()); }
|
||||||
|
|
||||||
void set_time_resolution(const char* unitp) { if (unitp) {} }
|
void set_time_resolution(const char*) {}
|
||||||
void set_time_resolution(const std::string& unit) { set_time_resolution(unit.c_str()); }
|
void set_time_resolution(const std::string& unit) { set_time_resolution(unit.c_str()); }
|
||||||
|
|
||||||
// double timescaleToDouble(const char* unitp);
|
// double timescaleToDouble(const char* unitp);
|
||||||
|
|
@ -156,18 +160,18 @@ public:
|
||||||
fstWriterEmitValueChangeVec32(m_fst, m_code2symbol[code], bits, newval);
|
fstWriterEmitValueChangeVec32(m_fst, m_code2symbol[code], bits, newval);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fullBit(vluint32_t code, const vluint32_t newval) {
|
void fullBit(vluint32_t code, const vluint32_t newval) { chgBit(code, newval); }
|
||||||
chgBit(code, newval); }
|
|
||||||
void fullBus(vluint32_t code, const vluint32_t newval, int bits) {
|
void fullBus(vluint32_t code, const vluint32_t newval, int bits) {
|
||||||
chgBus(code, newval, bits); }
|
chgBus(code, newval, bits);
|
||||||
void fullDouble(vluint32_t code, const double newval) {
|
}
|
||||||
chgDouble(code, newval); }
|
void fullDouble(vluint32_t code, const double newval) { chgDouble(code, newval); }
|
||||||
void fullFloat(vluint32_t code, const float newval) {
|
void fullFloat(vluint32_t code, const float newval) { chgFloat(code, newval); }
|
||||||
chgFloat(code, newval); }
|
|
||||||
void fullQuad(vluint32_t code, const vluint64_t newval, int bits) {
|
void fullQuad(vluint32_t code, const vluint64_t newval, int bits) {
|
||||||
chgQuad(code, newval, bits); }
|
chgQuad(code, newval, bits);
|
||||||
|
}
|
||||||
void fullArray(vluint32_t code, const vluint32_t* newval, int bits) {
|
void fullArray(vluint32_t code, const vluint32_t* newval, int bits) {
|
||||||
chgArray(code, newval, bits); }
|
chgArray(code, newval, bits);
|
||||||
|
}
|
||||||
|
|
||||||
void declTriBit(vluint32_t code, const char* name, int arraynum);
|
void declTriBit(vluint32_t code, const char* name, int arraynum);
|
||||||
void declTriBus(vluint32_t code, const char* name, int arraynum, int msb, int lsb);
|
void declTriBus(vluint32_t code, const char* name, int arraynum, int msb, int lsb);
|
||||||
|
|
@ -198,12 +202,14 @@ class VerilatedFstC {
|
||||||
|
|
||||||
// CONSTRUCTORS
|
// CONSTRUCTORS
|
||||||
VL_UNCOPYABLE(VerilatedFstC);
|
VL_UNCOPYABLE(VerilatedFstC);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit VerilatedFstC(void* filep=NULL) : m_sptrace(filep) {}
|
explicit VerilatedFstC(void* filep = NULL)
|
||||||
|
: m_sptrace(filep) {}
|
||||||
~VerilatedFstC() { close(); }
|
~VerilatedFstC() { close(); }
|
||||||
/// Routines can only be called from one thread; allow next call from different thread
|
/// Routines can only be called from one thread; allow next call from different thread
|
||||||
void changeThread() { spTrace()->changeThread(); }
|
void changeThread() { spTrace()->changeThread(); }
|
||||||
public:
|
|
||||||
// ACCESSORS
|
// ACCESSORS
|
||||||
/// Is file open?
|
/// Is file open?
|
||||||
bool isOpen() const { return m_sptrace.isOpen(); }
|
bool isOpen() const { return m_sptrace.isOpen(); }
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,8 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// CONSTANTS
|
// CONSTANTS
|
||||||
static const char* const VLTSAVE_HEADER_STR = "verilatorsave01\n"; ///< Value of first bytes of each file
|
static const char* const VLTSAVE_HEADER_STR
|
||||||
|
= "verilatorsave01\n"; ///< Value of first bytes of each file
|
||||||
static const char* const VLTSAVE_TRAILER_STR = "vltsaved"; ///< Value of last bytes of each file
|
static const char* const VLTSAVE_TRAILER_STR = "vltsaved"; ///< Value of last bytes of each file
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
@ -48,7 +49,8 @@ static const char* const VLTSAVE_TRAILER_STR = "vltsaved"; ///< Value of last b
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// Searalization
|
// Searalization
|
||||||
|
|
||||||
bool VerilatedDeserialize::readDiffers(const void* __restrict datap, size_t size) VL_MT_UNSAFE_ONE {
|
bool VerilatedDeserialize::readDiffers(const void* __restrict datap,
|
||||||
|
size_t size) VL_MT_UNSAFE_ONE {
|
||||||
bufferCheck();
|
bufferCheck();
|
||||||
const vluint8_t* __restrict dp = static_cast<const vluint8_t* __restrict>(datap);
|
const vluint8_t* __restrict dp = static_cast<const vluint8_t* __restrict>(datap);
|
||||||
vluint8_t miss = 0;
|
vluint8_t miss = 0;
|
||||||
|
|
@ -62,8 +64,8 @@ VerilatedDeserialize& VerilatedDeserialize::readAssert(const void* __restrict da
|
||||||
size_t size) VL_MT_UNSAFE_ONE {
|
size_t size) VL_MT_UNSAFE_ONE {
|
||||||
if (VL_UNLIKELY(readDiffers(datap, size))) {
|
if (VL_UNLIKELY(readDiffers(datap, size))) {
|
||||||
std::string fn = filename();
|
std::string fn = filename();
|
||||||
std::string msg = "Can't deserialize save-restore file as was made from different model:"
|
std::string msg
|
||||||
+filename();
|
= "Can't deserialize save-restore file as was made from different model:" + filename();
|
||||||
VL_FATAL_MT(fn.c_str(), 0, "", msg.c_str());
|
VL_FATAL_MT(fn.c_str(), 0, "", msg.c_str());
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
@ -84,8 +86,8 @@ void VerilatedDeserialize::header() VL_MT_UNSAFE_ONE {
|
||||||
VerilatedDeserialize& os = *this; // So can cut and paste standard >> code below
|
VerilatedDeserialize& os = *this; // So can cut and paste standard >> code below
|
||||||
if (VL_UNLIKELY(os.readDiffers(VLTSAVE_HEADER_STR, strlen(VLTSAVE_HEADER_STR)))) {
|
if (VL_UNLIKELY(os.readDiffers(VLTSAVE_HEADER_STR, strlen(VLTSAVE_HEADER_STR)))) {
|
||||||
std::string fn = filename();
|
std::string fn = filename();
|
||||||
std::string msg = std::string("Can't deserialize; file has wrong header signature: ")
|
std::string msg
|
||||||
+filename();
|
= std::string("Can't deserialize; file has wrong header signature: ") + filename();
|
||||||
VL_FATAL_MT(fn.c_str(), 0, "", msg.c_str());
|
VL_FATAL_MT(fn.c_str(), 0, "", msg.c_str());
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
@ -123,8 +125,8 @@ void VerilatedSave::open(const char* filenamep) VL_MT_UNSAFE_ONE {
|
||||||
assert(0); // Not supported yet.
|
assert(0); // Not supported yet.
|
||||||
} else {
|
} else {
|
||||||
// cppcheck-suppress duplicateExpression
|
// cppcheck-suppress duplicateExpression
|
||||||
m_fd = ::open(filenamep, O_CREAT|O_WRONLY|O_TRUNC|O_LARGEFILE|O_NONBLOCK|O_CLOEXEC
|
m_fd = ::open(filenamep,
|
||||||
, 0666);
|
O_CREAT | O_WRONLY | O_TRUNC | O_LARGEFILE | O_NONBLOCK | O_CLOEXEC, 0666);
|
||||||
if (m_fd < 0) {
|
if (m_fd < 0) {
|
||||||
// User code can check isOpen()
|
// User code can check isOpen()
|
||||||
m_isOpen = false;
|
m_isOpen = false;
|
||||||
|
|
@ -146,8 +148,7 @@ void VerilatedRestore::open(const char* filenamep) VL_MT_UNSAFE_ONE {
|
||||||
assert(0); // Not supported yet.
|
assert(0); // Not supported yet.
|
||||||
} else {
|
} else {
|
||||||
// cppcheck-suppress duplicateExpression
|
// cppcheck-suppress duplicateExpression
|
||||||
m_fd = ::open(filenamep, O_CREAT|O_RDONLY|O_LARGEFILE|O_CLOEXEC
|
m_fd = ::open(filenamep, O_CREAT | O_RDONLY | O_LARGEFILE | O_CLOEXEC, 0666);
|
||||||
, 0666);
|
|
||||||
if (m_fd < 0) {
|
if (m_fd < 0) {
|
||||||
// User code can check isOpen()
|
// User code can check isOpen()
|
||||||
m_isOpen = false;
|
m_isOpen = false;
|
||||||
|
|
@ -209,7 +210,7 @@ void VerilatedRestore::fill() VL_MT_UNSAFE_ONE {
|
||||||
if (VL_UNLIKELY(!isOpen())) return;
|
if (VL_UNLIKELY(!isOpen())) return;
|
||||||
// Move remaining characters down to start of buffer. (No memcpy, overlaps allowed)
|
// Move remaining characters down to start of buffer. (No memcpy, overlaps allowed)
|
||||||
vluint8_t* rp = m_bufp;
|
vluint8_t* rp = m_bufp;
|
||||||
for (vluint8_t* sp=m_cp; sp < m_endp;) *rp++ = *sp++; // Overlaps
|
for (vluint8_t* sp = m_cp; sp < m_endp; *rp++ = *sp++) {} // Overlaps
|
||||||
m_endp = m_bufp + (m_endp - m_cp);
|
m_endp = m_bufp + (m_endp - m_cp);
|
||||||
m_cp = m_bufp; // Reset buffer
|
m_cp = m_bufp; // Reset buffer
|
||||||
// Read into buffer starting at m_endp
|
// Read into buffer starting at m_endp
|
||||||
|
|
@ -231,7 +232,9 @@ void VerilatedRestore::fill() VL_MT_UNSAFE_ONE {
|
||||||
} else { // got==0, EOF
|
} else { // got==0, EOF
|
||||||
// Fill buffer from here to end with NULLs so reader's don't
|
// Fill buffer from here to end with NULLs so reader's don't
|
||||||
// need to check eof each character.
|
// need to check eof each character.
|
||||||
while (m_endp < m_bufp+bufferSize()) *m_endp++ = '\0';
|
while (m_endp < m_bufp + bufferSize()) {
|
||||||
|
*m_endp++ = '\0';
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ protected:
|
||||||
|
|
||||||
// CONSTRUCTORS
|
// CONSTRUCTORS
|
||||||
VL_UNCOPYABLE(VerilatedSerialize);
|
VL_UNCOPYABLE(VerilatedSerialize);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VerilatedSerialize() {
|
VerilatedSerialize() {
|
||||||
m_isOpen = false;
|
m_isOpen = false;
|
||||||
|
|
@ -65,20 +66,20 @@ public:
|
||||||
const vluint8_t* __restrict dp = (const vluint8_t* __restrict)datap;
|
const vluint8_t* __restrict dp = (const vluint8_t* __restrict)datap;
|
||||||
while (size) {
|
while (size) {
|
||||||
bufferCheck();
|
bufferCheck();
|
||||||
size_t blk = size; if (blk>bufferInsertSize()) blk = bufferInsertSize();
|
size_t blk = size;
|
||||||
|
if (blk > bufferInsertSize()) blk = bufferInsertSize();
|
||||||
const vluint8_t* __restrict maxp = dp + blk;
|
const vluint8_t* __restrict maxp = dp + blk;
|
||||||
while (dp < maxp) *m_cp++ = *dp++;
|
for (; dp < maxp; *m_cp++ = *dp++) {}
|
||||||
size -= blk;
|
size -= blk;
|
||||||
}
|
}
|
||||||
return *this; // For function chaining
|
return *this; // For function chaining
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VerilatedSerialize& bufferCheck() VL_MT_UNSAFE_ONE {
|
VerilatedSerialize& bufferCheck() VL_MT_UNSAFE_ONE {
|
||||||
// Flush the write buffer if there's not enough space left for new information
|
// 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
|
// We only call this once per vector, so we need enough slop for a very wide "b###" line
|
||||||
if (VL_UNLIKELY(m_cp > (m_bufp+(bufferSize()-bufferInsertSize())))) {
|
if (VL_UNLIKELY(m_cp > (m_bufp + (bufferSize() - bufferInsertSize())))) flush();
|
||||||
flush();
|
|
||||||
}
|
|
||||||
return *this; // For function chaining
|
return *this; // For function chaining
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -125,12 +126,13 @@ public:
|
||||||
virtual void close() VL_MT_UNSAFE_ONE { flush(); }
|
virtual void close() VL_MT_UNSAFE_ONE { flush(); }
|
||||||
virtual void flush() VL_MT_UNSAFE_ONE {}
|
virtual void flush() VL_MT_UNSAFE_ONE {}
|
||||||
inline VerilatedDeserialize& read(void* __restrict datap, size_t size) VL_MT_UNSAFE_ONE {
|
inline VerilatedDeserialize& read(void* __restrict datap, size_t size) VL_MT_UNSAFE_ONE {
|
||||||
vluint8_t* __restrict dp = (vluint8_t* __restrict)datap;
|
vluint8_t* __restrict dp = static_cast<vluint8_t* __restrict>(datap);
|
||||||
while (size) {
|
while (size) {
|
||||||
bufferCheck();
|
bufferCheck();
|
||||||
size_t blk = size; if (blk>bufferInsertSize()) blk = bufferInsertSize();
|
size_t blk = size;
|
||||||
|
if (blk > bufferInsertSize()) blk = bufferInsertSize();
|
||||||
const vluint8_t* __restrict maxp = dp + blk;
|
const vluint8_t* __restrict maxp = dp + blk;
|
||||||
while (dp < maxp) *dp++ = *m_cp++;
|
for (; dp < maxp; *dp++ = *m_cp++);
|
||||||
size -= blk;
|
size -= blk;
|
||||||
}
|
}
|
||||||
return *this; // For function chaining
|
return *this; // For function chaining
|
||||||
|
|
@ -138,15 +140,15 @@ public:
|
||||||
// Read a datum and compare with expected value
|
// Read a datum and compare with expected value
|
||||||
VerilatedDeserialize& readAssert(const void* __restrict datap, size_t size) VL_MT_UNSAFE_ONE;
|
VerilatedDeserialize& readAssert(const void* __restrict datap, size_t size) VL_MT_UNSAFE_ONE;
|
||||||
VerilatedDeserialize& readAssert(vluint64_t data) VL_MT_UNSAFE_ONE {
|
VerilatedDeserialize& readAssert(vluint64_t data) VL_MT_UNSAFE_ONE {
|
||||||
return readAssert(&data, sizeof(data)); }
|
return readAssert(&data, sizeof(data));
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool readDiffers(const void* __restrict datap, size_t size) VL_MT_UNSAFE_ONE;
|
bool readDiffers(const void* __restrict datap, size_t size) VL_MT_UNSAFE_ONE;
|
||||||
VerilatedDeserialize& bufferCheck() VL_MT_UNSAFE_ONE {
|
VerilatedDeserialize& bufferCheck() VL_MT_UNSAFE_ONE {
|
||||||
// Flush the write buffer if there's not enough space left for new information
|
// 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
|
// We only call this once per vector, so we need enough slop for a very wide "b###" line
|
||||||
if (VL_UNLIKELY((m_cp+bufferInsertSize()) > m_endp)) {
|
if (VL_UNLIKELY((m_cp + bufferInsertSize()) > m_endp)) fill();
|
||||||
fill();
|
|
||||||
}
|
|
||||||
return *this; // For function chaining
|
return *this; // For function chaining
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -187,7 +189,8 @@ public:
|
||||||
virtual ~VerilatedRestore() VL_OVERRIDE { close(); }
|
virtual ~VerilatedRestore() VL_OVERRIDE { close(); }
|
||||||
|
|
||||||
// METHODS
|
// METHODS
|
||||||
void open(const char* filenamep) VL_MT_UNSAFE_ONE; ///< Open the file; call isOpen() to see if errors
|
/// Open the file; call isOpen() to see if errors
|
||||||
|
void open(const char* filenamep) VL_MT_UNSAFE_ONE;
|
||||||
void open(const std::string& filename) VL_MT_UNSAFE_ONE { open(filename.c_str()); }
|
void open(const std::string& filename) VL_MT_UNSAFE_ONE { open(filename.c_str()); }
|
||||||
virtual void close() VL_OVERRIDE VL_MT_UNSAFE_ONE;
|
virtual void close() VL_OVERRIDE VL_MT_UNSAFE_ONE;
|
||||||
virtual void flush() VL_OVERRIDE VL_MT_UNSAFE_ONE {}
|
virtual void flush() VL_OVERRIDE VL_MT_UNSAFE_ONE {}
|
||||||
|
|
|
||||||
|
|
@ -37,12 +37,17 @@
|
||||||
class VerilatedRange {
|
class VerilatedRange {
|
||||||
int m_left;
|
int m_left;
|
||||||
int m_right;
|
int m_right;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class VerilatedVarProps;
|
friend class VerilatedVarProps;
|
||||||
friend class VerilatedScope;
|
friend class VerilatedScope;
|
||||||
VerilatedRange() : m_left(0), m_right(0) {}
|
VerilatedRange() : m_left(0), m_right(0) {}
|
||||||
VerilatedRange(int left, int right) : m_left(left), m_right(right) {}
|
VerilatedRange(int left, int right) : m_left(left), m_right(right) {}
|
||||||
void init(int left, int right) { m_left=left; m_right=right; }
|
void init(int left, int right) {
|
||||||
|
m_left = left;
|
||||||
|
m_right = right;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~VerilatedRange() {}
|
~VerilatedRange() {}
|
||||||
int left() const { return m_left; }
|
int left() const { return m_left; }
|
||||||
|
|
@ -50,7 +55,8 @@ public:
|
||||||
int low() const { return (m_left < m_right) ? m_left : m_right; }
|
int low() const { return (m_left < m_right) ? m_left : m_right; }
|
||||||
int high() const { return (m_left > m_right) ? m_left : m_right; }
|
int high() const { return (m_left > m_right) ? m_left : m_right; }
|
||||||
int elements() const {
|
int elements() const {
|
||||||
return (VL_LIKELY(m_left>=m_right) ? (m_left-m_right+1) : (m_right-m_left+1)); }
|
return (VL_LIKELY(m_left >= m_right) ? (m_left - m_right + 1) : (m_right - m_left + 1));
|
||||||
|
}
|
||||||
int increment() const { return (m_left >= m_right) ? 1 : -1; }
|
int increment() const { return (m_left >= m_right) ? 1 : -1; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -75,6 +81,7 @@ protected:
|
||||||
VerilatedVarProps(VerilatedVarType vltype, VerilatedVarFlags vlflags,
|
VerilatedVarProps(VerilatedVarType vltype, VerilatedVarFlags vlflags,
|
||||||
int pdims, int udims)
|
int pdims, int udims)
|
||||||
: m_magic(MAGIC), m_vltype(vltype), m_vlflags(vlflags), m_pdims(pdims), m_udims(udims) {}
|
: m_magic(MAGIC), m_vltype(vltype), m_vlflags(vlflags), m_pdims(pdims), m_udims(udims) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class Unpacked {};
|
class Unpacked {};
|
||||||
// Without packed
|
// Without packed
|
||||||
|
|
@ -85,17 +92,23 @@ public:
|
||||||
Unpacked, int u0l, int u0r)
|
Unpacked, int u0l, int u0r)
|
||||||
: m_magic(MAGIC), m_vltype(vltype),
|
: m_magic(MAGIC), m_vltype(vltype),
|
||||||
m_vlflags(VerilatedVarFlags(vlflags)), m_pdims(0), m_udims(1) {
|
m_vlflags(VerilatedVarFlags(vlflags)), m_pdims(0), m_udims(1) {
|
||||||
m_unpacked[0].init(u0l, u0r); }
|
m_unpacked[0].init(u0l, u0r);
|
||||||
|
}
|
||||||
VerilatedVarProps(VerilatedVarType vltype, int vlflags,
|
VerilatedVarProps(VerilatedVarType vltype, int vlflags,
|
||||||
Unpacked, int u0l, int u0r, int u1l, int u1r)
|
Unpacked, int u0l, int u0r, int u1l, int u1r)
|
||||||
: m_magic(MAGIC), m_vltype(vltype),
|
: m_magic(MAGIC), m_vltype(vltype),
|
||||||
m_vlflags(VerilatedVarFlags(vlflags)), m_pdims(0), m_udims(2) {
|
m_vlflags(VerilatedVarFlags(vlflags)), m_pdims(0), m_udims(2) {
|
||||||
m_unpacked[0].init(u0l, u0r); m_unpacked[1].init(u1l, u1r); }
|
m_unpacked[0].init(u0l, u0r);
|
||||||
|
m_unpacked[1].init(u1l, u1r);
|
||||||
|
}
|
||||||
VerilatedVarProps(VerilatedVarType vltype, int vlflags,
|
VerilatedVarProps(VerilatedVarType vltype, int vlflags,
|
||||||
Unpacked, int u0l, int u0r, int u1l, int u1r, int u2l, int u2r)
|
Unpacked, int u0l, int u0r, int u1l, int u1r, int u2l, int u2r)
|
||||||
: m_magic(MAGIC), m_vltype(vltype),
|
: m_magic(MAGIC), m_vltype(vltype),
|
||||||
m_vlflags(VerilatedVarFlags(vlflags)), m_pdims(0), m_udims(3) {
|
m_vlflags(VerilatedVarFlags(vlflags)), m_pdims(0), m_udims(3) {
|
||||||
m_unpacked[0].init(u0l, u0r); m_unpacked[1].init(u1l, u1r); m_unpacked[2].init(u2l, u2r); }
|
m_unpacked[0].init(u0l, u0r);
|
||||||
|
m_unpacked[1].init(u1l, u1r);
|
||||||
|
m_unpacked[2].init(u2l, u2r);
|
||||||
|
}
|
||||||
// With packed
|
// With packed
|
||||||
class Packed {};
|
class Packed {};
|
||||||
VerilatedVarProps(VerilatedVarType vltype, int vlflags,
|
VerilatedVarProps(VerilatedVarType vltype, int vlflags,
|
||||||
|
|
@ -107,26 +120,34 @@ public:
|
||||||
Unpacked, int u0l, int u0r)
|
Unpacked, int u0l, int u0r)
|
||||||
: m_magic(MAGIC), m_vltype(vltype),
|
: m_magic(MAGIC), m_vltype(vltype),
|
||||||
m_vlflags(VerilatedVarFlags(vlflags)), m_pdims(1), m_udims(1), m_packed(pl,pr) {
|
m_vlflags(VerilatedVarFlags(vlflags)), m_pdims(1), m_udims(1), m_packed(pl,pr) {
|
||||||
m_unpacked[0].init(u0l, u0r); }
|
m_unpacked[0].init(u0l, u0r);
|
||||||
|
}
|
||||||
VerilatedVarProps(VerilatedVarType vltype, int vlflags,
|
VerilatedVarProps(VerilatedVarType vltype, int vlflags,
|
||||||
Packed, int pl, int pr,
|
Packed, int pl, int pr,
|
||||||
Unpacked, int u0l, int u0r, int u1l, int u1r)
|
Unpacked, int u0l, int u0r, int u1l, int u1r)
|
||||||
: m_magic(MAGIC), m_vltype(vltype), m_vlflags(VerilatedVarFlags(vlflags)),
|
: m_magic(MAGIC), m_vltype(vltype), m_vlflags(VerilatedVarFlags(vlflags)),
|
||||||
m_pdims(1), m_udims(2), m_packed(pl,pr) {
|
m_pdims(1), m_udims(2), m_packed(pl,pr) {
|
||||||
m_unpacked[0].init(u0l, u0r); m_unpacked[1].init(u1l, u1r); }
|
m_unpacked[0].init(u0l, u0r);
|
||||||
|
m_unpacked[1].init(u1l, u1r);
|
||||||
|
}
|
||||||
VerilatedVarProps(VerilatedVarType vltype, int vlflags,
|
VerilatedVarProps(VerilatedVarType vltype, int vlflags,
|
||||||
Packed, int pl, int pr,
|
Packed, int pl, int pr,
|
||||||
Unpacked, int u0l, int u0r, int u1l, int u1r, int u2l, int u2r)
|
Unpacked, int u0l, int u0r, int u1l, int u1r, int u2l, int u2r)
|
||||||
: m_magic(MAGIC), m_vltype(vltype),
|
: m_magic(MAGIC), m_vltype(vltype),
|
||||||
m_vlflags(VerilatedVarFlags(vlflags)), m_pdims(1), m_udims(3), m_packed(pl,pr) {
|
m_vlflags(VerilatedVarFlags(vlflags)), m_pdims(1), m_udims(3), m_packed(pl,pr) {
|
||||||
m_unpacked[0].init(u0l, u0r); m_unpacked[1].init(u1l, u1r); m_unpacked[2].init(u2l, u2r); }
|
m_unpacked[0].init(u0l, u0r);
|
||||||
|
m_unpacked[1].init(u1l, u1r);
|
||||||
|
m_unpacked[2].init(u2l, u2r);
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~VerilatedVarProps() {}
|
~VerilatedVarProps() {}
|
||||||
// METHODS
|
// METHODS
|
||||||
bool magicOk() const { return m_magic == MAGIC; }
|
bool magicOk() const { return m_magic == MAGIC; }
|
||||||
VerilatedVarType vltype() const { return m_vltype; }
|
VerilatedVarType vltype() const { return m_vltype; }
|
||||||
VerilatedVarFlags vldir() const {
|
VerilatedVarFlags vldir() const {
|
||||||
return static_cast<VerilatedVarFlags>(static_cast<int>(m_vlflags) & VLVF_MASK_DIR); }
|
return static_cast<VerilatedVarFlags>(static_cast<int>(m_vlflags) & VLVF_MASK_DIR);
|
||||||
|
}
|
||||||
vluint32_t entSize() const;
|
vluint32_t entSize() const;
|
||||||
bool isPublicRW() const { return ((m_vlflags & VLVF_PUB_RW) != 0); }
|
bool isPublicRW() const { return ((m_vlflags & VLVF_PUB_RW) != 0); }
|
||||||
/// DPI compatible C standard layout
|
/// DPI compatible C standard layout
|
||||||
|
|
@ -199,7 +220,8 @@ public:
|
||||||
int elements(int dim) const { return m_propsp->elements(dim); }
|
int elements(int dim) const { return m_propsp->elements(dim); }
|
||||||
size_t totalSize() const { return m_propsp->totalSize(); }
|
size_t totalSize() const { return m_propsp->totalSize(); }
|
||||||
void* datapAdjustIndex(void* datap, int dim, int indx) const {
|
void* datapAdjustIndex(void* datap, int dim, int indx) const {
|
||||||
return m_propsp->datapAdjustIndex(datap, dim, indx); }
|
return m_propsp->datapAdjustIndex(datap, dim, indx);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
@ -213,10 +235,12 @@ class VerilatedVar : public VerilatedVarProps {
|
||||||
protected:
|
protected:
|
||||||
friend class VerilatedScope;
|
friend class VerilatedScope;
|
||||||
// CONSTRUCTORS
|
// CONSTRUCTORS
|
||||||
VerilatedVar(const char* namep, void* datap,
|
VerilatedVar(const char* namep, void* datap, VerilatedVarType vltype,
|
||||||
VerilatedVarType vltype, VerilatedVarFlags vlflags, int dims)
|
VerilatedVarFlags vlflags, int dims)
|
||||||
: VerilatedVarProps(vltype, vlflags, (dims > 0 ? 1 : 0), ((dims > 1) ? dims - 1 : 0))
|
: VerilatedVarProps(vltype, vlflags, (dims > 0 ? 1 : 0), ((dims > 1) ? dims - 1 : 0))
|
||||||
, m_datap(datap), m_namep(namep) {}
|
, m_datap(datap)
|
||||||
|
, m_namep(namep) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~VerilatedVar() {}
|
~VerilatedVar() {}
|
||||||
// ACCESSORS
|
// ACCESSORS
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,8 @@ VL_THREAD_LOCAL VlThreadPool::ProfileTrace* VlThreadPool::t_profilep = NULL;
|
||||||
// VlMTaskVertex
|
// VlMTaskVertex
|
||||||
|
|
||||||
VlMTaskVertex::VlMTaskVertex(vluint32_t upstreamDepCount)
|
VlMTaskVertex::VlMTaskVertex(vluint32_t upstreamDepCount)
|
||||||
: m_upstreamDepsDone(0),
|
: m_upstreamDepsDone(0)
|
||||||
m_upstreamDepCount(upstreamDepCount) {
|
, m_upstreamDepCount(upstreamDepCount) {
|
||||||
assert(atomic_is_lock_free(&m_upstreamDepsDone));
|
assert(atomic_is_lock_free(&m_upstreamDepsDone));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -52,17 +52,13 @@ VlWorkerThread::~VlWorkerThread() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void VlWorkerThread::workerLoop() {
|
void VlWorkerThread::workerLoop() {
|
||||||
if (VL_UNLIKELY(m_profiling)) {
|
if (VL_UNLIKELY(m_profiling)) m_poolp->setupProfilingClientThread();
|
||||||
m_poolp->setupProfilingClientThread();
|
|
||||||
}
|
|
||||||
|
|
||||||
ExecRec work;
|
ExecRec work;
|
||||||
work.m_fnp = NULL;
|
work.m_fnp = NULL;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (VL_LIKELY(!work.m_fnp)) {
|
if (VL_LIKELY(!work.m_fnp)) dequeWork(&work);
|
||||||
dequeWork(&work);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do this here, not above, to avoid a race with the destructor.
|
// Do this here, not above, to avoid a race with the destructor.
|
||||||
if (VL_UNLIKELY(m_exiting.load(std::memory_order_acquire)))
|
if (VL_UNLIKELY(m_exiting.load(std::memory_order_acquire)))
|
||||||
|
|
@ -74,14 +70,10 @@ void VlWorkerThread::workerLoop() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VL_UNLIKELY(m_profiling)) {
|
if (VL_UNLIKELY(m_profiling)) m_poolp->tearDownProfilingClientThread();
|
||||||
m_poolp->tearDownProfilingClientThread();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VlWorkerThread::startWorker(VlWorkerThread* workerp) {
|
void VlWorkerThread::startWorker(VlWorkerThread* workerp) { workerp->workerLoop(); }
|
||||||
workerp->workerLoop();
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// VlThreadPool
|
// VlThreadPool
|
||||||
|
|
@ -94,7 +86,8 @@ VlThreadPool::VlThreadPool(int nThreads, bool profiling)
|
||||||
static int warnedOnce = 0;
|
static int warnedOnce = 0;
|
||||||
if (!warnedOnce++) {
|
if (!warnedOnce++) {
|
||||||
VL_PRINTF_MT("%%Warning: System has %u CPUs but model Verilated with"
|
VL_PRINTF_MT("%%Warning: System has %u CPUs but model Verilated with"
|
||||||
" --threads %d; may run slow.\n", cpus, nThreads+1);
|
" --threads %d; may run slow.\n",
|
||||||
|
cpus, nThreads + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Create'em
|
// Create'em
|
||||||
|
|
@ -104,9 +97,7 @@ VlThreadPool::VlThreadPool(int nThreads, bool profiling)
|
||||||
// Set up a profile buffer for the current thread too -- on the
|
// Set up a profile buffer for the current thread too -- on the
|
||||||
// assumption that it's the same thread that calls eval and may be
|
// assumption that it's the same thread that calls eval and may be
|
||||||
// donated to run mtasks during the eval.
|
// donated to run mtasks during the eval.
|
||||||
if (VL_UNLIKELY(m_profiling)) {
|
if (VL_UNLIKELY(m_profiling)) setupProfilingClientThread();
|
||||||
setupProfilingClientThread();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VlThreadPool::~VlThreadPool() {
|
VlThreadPool::~VlThreadPool() {
|
||||||
|
|
@ -114,9 +105,7 @@ VlThreadPool::~VlThreadPool() {
|
||||||
// Each ~WorkerThread will wait for its thread to exit.
|
// Each ~WorkerThread will wait for its thread to exit.
|
||||||
delete m_workers[i];
|
delete m_workers[i];
|
||||||
}
|
}
|
||||||
if (VL_UNLIKELY(m_profiling)) {
|
if (VL_UNLIKELY(m_profiling)) tearDownProfilingClientThread();
|
||||||
tearDownProfilingClientThread();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VlThreadPool::tearDownProfilingClientThread() {
|
void VlThreadPool::tearDownProfilingClientThread() {
|
||||||
|
|
@ -159,14 +148,11 @@ void VlThreadPool::profileDump(const char* filenamep, vluint64_t ticksElapsed) {
|
||||||
// TODO Perhaps merge with verilated_coverage output format, so can
|
// TODO Perhaps merge with verilated_coverage output format, so can
|
||||||
// have a common merging and reporting tool, etc.
|
// have a common merging and reporting tool, etc.
|
||||||
fprintf(fp, "VLPROFTHREAD 1.0 # Verilator thread profile dump version 1.0\n");
|
fprintf(fp, "VLPROFTHREAD 1.0 # Verilator thread profile dump version 1.0\n");
|
||||||
fprintf(fp, "VLPROF arg --threads %" VL_PRI64 "u\n",
|
fprintf(fp, "VLPROF arg --threads %" VL_PRI64 "u\n", vluint64_t(m_workers.size() + 1));
|
||||||
vluint64_t(m_workers.size()+1));
|
|
||||||
fprintf(fp, "VLPROF arg +verilator+prof+threads+start+%" VL_PRI64 "u\n",
|
fprintf(fp, "VLPROF arg +verilator+prof+threads+start+%" VL_PRI64 "u\n",
|
||||||
Verilated::profThreadsStart());
|
Verilated::profThreadsStart());
|
||||||
fprintf(fp, "VLPROF arg +verilator+prof+threads+window+%u\n",
|
fprintf(fp, "VLPROF arg +verilator+prof+threads+window+%u\n", Verilated::profThreadsWindow());
|
||||||
Verilated::profThreadsWindow());
|
fprintf(fp, "VLPROF stat yields %" VL_PRI64 "u\n", VlMTaskVertex::yields());
|
||||||
fprintf(fp, "VLPROF stat yields %" VL_PRI64 "u\n",
|
|
||||||
VlMTaskVertex::yields());
|
|
||||||
|
|
||||||
vluint32_t thread_id = 0;
|
vluint32_t thread_id = 0;
|
||||||
for (ProfileSet::const_iterator pit = m_allProfiles.begin();
|
for (ProfileSet::const_iterator pit = m_allProfiles.begin();
|
||||||
|
|
@ -174,31 +160,26 @@ void VlThreadPool::profileDump(const char* filenamep, vluint64_t ticksElapsed) {
|
||||||
++thread_id;
|
++thread_id;
|
||||||
|
|
||||||
bool printing = false; // False while in warmup phase
|
bool printing = false; // False while in warmup phase
|
||||||
for (ProfileTrace::const_iterator eit = (*pit)->begin();
|
for (ProfileTrace::const_iterator eit = (*pit)->begin(); eit != (*pit)->end(); ++eit) {
|
||||||
eit != (*pit)->end(); ++eit) {
|
|
||||||
switch (eit->m_type) {
|
switch (eit->m_type) {
|
||||||
case VlProfileRec::TYPE_BARRIER:
|
case VlProfileRec::TYPE_BARRIER:
|
||||||
printing = true;
|
printing = true;
|
||||||
break;
|
break;
|
||||||
case VlProfileRec::TYPE_MTASK_RUN:
|
case VlProfileRec::TYPE_MTASK_RUN:
|
||||||
if (!printing) break;
|
if (!printing) break;
|
||||||
fprintf(fp, "VLPROF mtask %d"
|
fprintf(fp,
|
||||||
|
"VLPROF mtask %d"
|
||||||
" start %" VL_PRI64 "u end %" VL_PRI64 "u elapsed %" VL_PRI64 "u"
|
" start %" VL_PRI64 "u end %" VL_PRI64 "u elapsed %" VL_PRI64 "u"
|
||||||
" predict_time %u cpu %u on thread %u\n",
|
" predict_time %u cpu %u on thread %u\n",
|
||||||
eit->m_mtaskId,
|
eit->m_mtaskId, eit->m_startTime, eit->m_endTime,
|
||||||
eit->m_startTime,
|
(eit->m_endTime - eit->m_startTime), eit->m_predictTime, eit->m_cpu,
|
||||||
eit->m_endTime,
|
|
||||||
(eit->m_endTime - eit->m_startTime),
|
|
||||||
eit->m_predictTime,
|
|
||||||
eit->m_cpu,
|
|
||||||
thread_id);
|
thread_id);
|
||||||
break;
|
break;
|
||||||
default: assert(false); break; // LCOV_EXCL_LINE
|
default: assert(false); break; // LCOV_EXCL_LINE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf(fp, "VLPROF stat ticks %" VL_PRI64 "u\n",
|
fprintf(fp, "VLPROF stat ticks %" VL_PRI64 "u\n", ticksElapsed);
|
||||||
ticksElapsed);
|
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -284,6 +284,7 @@ public:
|
||||||
// this once to setup profiling state:
|
// this once to setup profiling state:
|
||||||
void setupProfilingClientThread();
|
void setupProfilingClientThread();
|
||||||
void tearDownProfilingClientThread();
|
void tearDownProfilingClientThread();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VL_UNCOPYABLE(VlThreadPool);
|
VL_UNCOPYABLE(VlThreadPool);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ private:
|
||||||
VcdVec s_vcdVecp VL_GUARDED_BY(s_vcdMutex); ///< List of all created traces
|
VcdVec s_vcdVecp VL_GUARDED_BY(s_vcdMutex); ///< List of all created traces
|
||||||
};
|
};
|
||||||
static Singleton& singleton() { static Singleton s; return s; }
|
static Singleton& singleton() { static Singleton s; return s; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void pushVcd(VerilatedVcd* vcdp) VL_EXCLUDES(singleton().s_vcdMutex) {
|
static void pushVcd(VerilatedVcd* vcdp) VL_EXCLUDES(singleton().s_vcdMutex) {
|
||||||
VerilatedLockGuard lock(singleton().s_vcdMutex);
|
VerilatedLockGuard lock(singleton().s_vcdMutex);
|
||||||
|
|
@ -65,8 +66,8 @@ public:
|
||||||
}
|
}
|
||||||
static void removeVcd(const VerilatedVcd* vcdp) VL_EXCLUDES(singleton().s_vcdMutex) {
|
static void removeVcd(const VerilatedVcd* vcdp) VL_EXCLUDES(singleton().s_vcdMutex) {
|
||||||
VerilatedLockGuard lock(singleton().s_vcdMutex);
|
VerilatedLockGuard lock(singleton().s_vcdMutex);
|
||||||
VcdVec::iterator pos = find(singleton().s_vcdVecp.begin(),
|
VcdVec::iterator pos
|
||||||
singleton().s_vcdVecp.end(), vcdp);
|
= find(singleton().s_vcdVecp.begin(), singleton().s_vcdVecp.end(), vcdp);
|
||||||
if (pos != singleton().s_vcdVecp.end()) { singleton().s_vcdVecp.erase(pos); }
|
if (pos != singleton().s_vcdVecp.end()) { singleton().s_vcdVecp.erase(pos); }
|
||||||
}
|
}
|
||||||
static void flush_all() VL_EXCLUDES(singleton().s_vcdMutex) VL_MT_UNSAFE_ONE {
|
static void flush_all() VL_EXCLUDES(singleton().s_vcdMutex) VL_MT_UNSAFE_ONE {
|
||||||
|
|
@ -115,13 +116,12 @@ protected:
|
||||||
// VerilatedVcdFile
|
// VerilatedVcdFile
|
||||||
|
|
||||||
bool VerilatedVcdFile::open(const std::string& name) VL_MT_UNSAFE {
|
bool VerilatedVcdFile::open(const std::string& name) VL_MT_UNSAFE {
|
||||||
m_fd = ::open(name.c_str(), O_CREAT|O_WRONLY|O_TRUNC|O_LARGEFILE|O_NONBLOCK|O_CLOEXEC, 0666);
|
m_fd = ::open(name.c_str(),
|
||||||
|
O_CREAT | O_WRONLY | O_TRUNC | O_LARGEFILE | O_NONBLOCK | O_CLOEXEC, 0666);
|
||||||
return m_fd >= 0;
|
return m_fd >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerilatedVcdFile::close() VL_MT_UNSAFE {
|
void VerilatedVcdFile::close() VL_MT_UNSAFE { ::close(m_fd); }
|
||||||
::close(m_fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
ssize_t VerilatedVcdFile::write(const char* bufp, ssize_t len) VL_MT_UNSAFE {
|
ssize_t VerilatedVcdFile::write(const char* bufp, ssize_t len) VL_MT_UNSAFE {
|
||||||
return ::write(m_fd, bufp, len);
|
return ::write(m_fd, bufp, len);
|
||||||
|
|
@ -173,9 +173,7 @@ void VerilatedVcd::open(const char* filename) {
|
||||||
dumpHeader();
|
dumpHeader();
|
||||||
|
|
||||||
// Allocate space now we know the number of codes
|
// Allocate space now we know the number of codes
|
||||||
if (!m_sigs_oldvalp) {
|
if (!m_sigs_oldvalp) m_sigs_oldvalp = new vluint32_t[m_nextCode + 10];
|
||||||
m_sigs_oldvalp = new vluint32_t [m_nextCode+10];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_rolloverMB) {
|
if (m_rolloverMB) {
|
||||||
openNext(true);
|
openNext(true);
|
||||||
|
|
@ -204,9 +202,10 @@ void VerilatedVcd::openNext(bool incFilename) {
|
||||||
name[pos - 2] = '0';
|
name[pos - 2] = '0';
|
||||||
if ((++(name[pos - 3])) > '9') {
|
if ((++(name[pos - 3])) > '9') {
|
||||||
name[pos - 3] = '0';
|
name[pos - 3] = '0';
|
||||||
if ((++(name[pos-4])) > '9') {
|
if ((++(name[pos - 4])) > '9') { name[pos - 4] = '0'; }
|
||||||
name[pos-4] = '0';
|
}
|
||||||
}}}}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Append _cat0000
|
// Append _cat0000
|
||||||
name.insert(pos, "_cat0000");
|
name.insert(pos, "_cat0000");
|
||||||
|
|
@ -407,7 +406,7 @@ double VerilatedVcd::timescaleToDouble(const char* unitp) {
|
||||||
double value = strtod(unitp, &endp);
|
double value = strtod(unitp, &endp);
|
||||||
if (value == 0.0 && endp == unitp) value = 1; // On error so we allow just "ns" to return 1e-9.
|
if (value == 0.0 && endp == unitp) value = 1; // On error so we allow just "ns" to return 1e-9.
|
||||||
unitp = endp;
|
unitp = endp;
|
||||||
while (*unitp && isspace(*unitp)) unitp++;
|
for (; *unitp && isspace(*unitp); unitp++) {}
|
||||||
switch (*unitp) {
|
switch (*unitp) {
|
||||||
case 's': value *= 1e1; break;
|
case 's': value *= 1e1; break;
|
||||||
case 'm': value *= 1e-3; break;
|
case 'm': value *= 1e-3; break;
|
||||||
|
|
@ -429,7 +428,8 @@ std::string VerilatedVcd::doubleToTimescale(double value) {
|
||||||
else if (value>=1e-12) { suffixp="ps"; value *= 1e12; }
|
else if (value>=1e-12) { suffixp="ps"; value *= 1e12; }
|
||||||
else if (value>=1e-15) { suffixp="fs"; value *= 1e15; }
|
else if (value>=1e-15) { suffixp="fs"; value *= 1e15; }
|
||||||
else if (value>=1e-18) { suffixp="as"; value *= 1e18; }
|
else if (value>=1e-18) { suffixp="as"; value *= 1e18; }
|
||||||
char valuestr[100]; sprintf(valuestr,"%3.0f%s", value, suffixp);
|
char valuestr[100];
|
||||||
|
sprintf(valuestr, "%3.0f%s", value, suffixp);
|
||||||
return valuestr; // Gets converted to string, so no ref to stack
|
return valuestr; // Gets converted to string, so no ref to stack
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -439,14 +439,18 @@ std::string VerilatedVcd::doubleToTimescale(double value) {
|
||||||
void VerilatedVcd::printIndent(int level_change) {
|
void VerilatedVcd::printIndent(int level_change) {
|
||||||
if (level_change < 0) m_modDepth += level_change;
|
if (level_change < 0) m_modDepth += level_change;
|
||||||
assert(m_modDepth >= 0);
|
assert(m_modDepth >= 0);
|
||||||
for (int i=0; i<m_modDepth; i++) printStr(" ");
|
for (int i = 0; i < m_modDepth; i++) {
|
||||||
|
printStr(" ");
|
||||||
|
}
|
||||||
if (level_change > 0) m_modDepth += level_change;
|
if (level_change > 0) m_modDepth += level_change;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerilatedVcd::dumpHeader() {
|
void VerilatedVcd::dumpHeader() {
|
||||||
printStr("$version Generated by VerilatedVcd $end\n");
|
printStr("$version Generated by VerilatedVcd $end\n");
|
||||||
time_t time_str = time(NULL);
|
time_t time_str = time(NULL);
|
||||||
printStr("$date "); printStr(ctime(&time_str)); printStr(" $end\n");
|
printStr("$date ");
|
||||||
|
printStr(ctime(&time_str));
|
||||||
|
printStr(" $end\n");
|
||||||
|
|
||||||
printStr("$timescale ");
|
printStr("$timescale ");
|
||||||
const std::string& timeResStr = doubleToTimescale(m_timeRes);
|
const std::string& timeResStr = doubleToTimescale(m_timeRes);
|
||||||
|
|
@ -479,7 +483,10 @@ void VerilatedVcd::dumpHeader() {
|
||||||
|
|
||||||
// Skip common prefix, it must break at a space or tab
|
// Skip common prefix, it must break at a space or tab
|
||||||
for (; *np && (*np == *lp); np++, lp++) {}
|
for (; *np && (*np == *lp); np++, lp++) {}
|
||||||
while (np!=hiername && *np && *np!=' ' && *np!='\t') { np--; lp--; }
|
while (np != hiername && *np && *np != ' ' && *np != '\t') {
|
||||||
|
np--;
|
||||||
|
lp--;
|
||||||
|
}
|
||||||
// printf("hier %s\n lp=%s\n np=%s\n",hiername,lp,np);
|
// printf("hier %s\n lp=%s\n np=%s\n",hiername,lp,np);
|
||||||
|
|
||||||
// Any extra spaces in last name are scope ups we need to do
|
// Any extra spaces in last name are scope ups we need to do
|
||||||
|
|
@ -499,9 +506,13 @@ void VerilatedVcd::dumpHeader() {
|
||||||
printIndent(1);
|
printIndent(1);
|
||||||
printStr("$scope module ");
|
printStr("$scope module ");
|
||||||
for (; *np && *np != ' ' && *np != '\t'; np++) {
|
for (; *np && *np != ' ' && *np != '\t'; np++) {
|
||||||
if (*np=='[') printStr("(");
|
if (*np == '[') {
|
||||||
else if (*np==']') printStr(")");
|
printStr("(");
|
||||||
else *m_writep++=*np;
|
} else if (*np == ']') {
|
||||||
|
printStr(")");
|
||||||
|
} else {
|
||||||
|
*m_writep++ = *np;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
printStr(" $end\n");
|
printStr(" $end\n");
|
||||||
}
|
}
|
||||||
|
|
@ -530,8 +541,9 @@ void VerilatedVcd::module(const std::string& name) {
|
||||||
|
|
||||||
void VerilatedVcd::declare(vluint32_t code, const char* name, const char* wirep,
|
void VerilatedVcd::declare(vluint32_t code, const char* name, const char* wirep,
|
||||||
bool array, int arraynum, bool tri, bool bussed, int msb, int lsb) {
|
bool array, int arraynum, bool tri, bool bussed, int msb, int lsb) {
|
||||||
if (!code) { VL_FATAL_MT(__FILE__, __LINE__, "",
|
if (!code) {
|
||||||
"Internal: internal trace problem, code 0 is illegal"); }
|
VL_FATAL_MT(__FILE__, __LINE__, "", "Internal: internal trace problem, code 0 is illegal");
|
||||||
|
}
|
||||||
|
|
||||||
int bits = ((msb > lsb) ? (msb - lsb) : (lsb - msb)) + 1;
|
int bits = ((msb > lsb) ? (msb - lsb) : (lsb - msb)) + 1;
|
||||||
int codesNeeded = 1 + int(bits / 32);
|
int codesNeeded = 1 + int(bits / 32);
|
||||||
|
|
@ -576,7 +588,12 @@ void VerilatedVcd::declare(vluint32_t code, const char* name, const char* wirep,
|
||||||
|
|
||||||
// Print reference
|
// Print reference
|
||||||
std::string decl = "$var ";
|
std::string decl = "$var ";
|
||||||
if (m_evcd) decl += "port"; else decl += wirep; // usually "wire"
|
if (m_evcd) {
|
||||||
|
decl += "port";
|
||||||
|
} else {
|
||||||
|
decl += wirep; // usually "wire"
|
||||||
|
}
|
||||||
|
|
||||||
char buf[1000];
|
char buf[1000];
|
||||||
sprintf(buf, " %2d ", bits);
|
sprintf(buf, " %2d ", bits);
|
||||||
decl += buf;
|
decl += buf;
|
||||||
|
|
@ -646,7 +663,9 @@ void VerilatedVcd::fullDouble(vluint32_t code, const double newval) {
|
||||||
// Buffer can't overflow before sprintf; we sized during declaration
|
// Buffer can't overflow before sprintf; we sized during declaration
|
||||||
sprintf(m_writep, "r%.16g", newval);
|
sprintf(m_writep, "r%.16g", newval);
|
||||||
m_writep += strlen(m_writep);
|
m_writep += strlen(m_writep);
|
||||||
*m_writep++=' '; printCode(code); *m_writep++='\n';
|
*m_writep++ = ' ';
|
||||||
|
printCode(code);
|
||||||
|
*m_writep++ = '\n';
|
||||||
bufferCheck();
|
bufferCheck();
|
||||||
}
|
}
|
||||||
void VerilatedVcd::fullFloat(vluint32_t code, const float newval) {
|
void VerilatedVcd::fullFloat(vluint32_t code, const float newval) {
|
||||||
|
|
@ -655,7 +674,9 @@ void VerilatedVcd::fullFloat(vluint32_t code, const float newval) {
|
||||||
// Buffer can't overflow before sprintf; we sized during declaration
|
// Buffer can't overflow before sprintf; we sized during declaration
|
||||||
sprintf(m_writep, "r%.16g", static_cast<double>(newval));
|
sprintf(m_writep, "r%.16g", static_cast<double>(newval));
|
||||||
m_writep += strlen(m_writep);
|
m_writep += strlen(m_writep);
|
||||||
*m_writep++=' '; printCode(code); *m_writep++='\n';
|
*m_writep++ = ' ';
|
||||||
|
printCode(code);
|
||||||
|
*m_writep++ = '\n';
|
||||||
bufferCheck();
|
bufferCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -716,9 +737,7 @@ void VerilatedVcd::dumpPrep(vluint64_t timeui) {
|
||||||
//======================================================================
|
//======================================================================
|
||||||
// Static members
|
// Static members
|
||||||
|
|
||||||
void VerilatedVcd::flush_all() VL_MT_UNSAFE_ONE {
|
void VerilatedVcd::flush_all() VL_MT_UNSAFE_ONE { VerilatedVcdSingleton::flush_all(); }
|
||||||
VerilatedVcdSingleton::flush_all();
|
|
||||||
}
|
|
||||||
|
|
||||||
//======================================================================
|
//======================================================================
|
||||||
//======================================================================
|
//======================================================================
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ protected:
|
||||||
VerilatedVcdSig(vluint32_t code, int bits)
|
VerilatedVcdSig(vluint32_t code, int bits)
|
||||||
: m_code(code)
|
: m_code(code)
|
||||||
, m_bits(bits) {}
|
, m_bits(bits) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~VerilatedVcdSig() {}
|
~VerilatedVcdSig() {}
|
||||||
};
|
};
|
||||||
|
|
@ -153,6 +154,7 @@ private:
|
||||||
|
|
||||||
// CONSTRUCTORS
|
// CONSTRUCTORS
|
||||||
VL_UNCOPYABLE(VerilatedVcd);
|
VL_UNCOPYABLE(VerilatedVcd);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit VerilatedVcd(VerilatedVcdFile* filep = NULL);
|
explicit VerilatedVcd(VerilatedVcdFile* filep = NULL);
|
||||||
~VerilatedVcd();
|
~VerilatedVcd();
|
||||||
|
|
@ -170,7 +172,8 @@ public:
|
||||||
inline bool isScopeEscape(char c) { return isspace(c) || c == m_scopeEscape; }
|
inline bool isScopeEscape(char c) { return isspace(c) || c == m_scopeEscape; }
|
||||||
|
|
||||||
// METHODS
|
// METHODS
|
||||||
void open(const char* filename) VL_MT_UNSAFE_ONE; ///< Open the file; call isOpen() to see if errors
|
/// Open the file; call isOpen() to see if errors
|
||||||
|
void open(const char* filename) VL_MT_UNSAFE_ONE;
|
||||||
void openNext(bool incFilename); ///< Open next data-only file
|
void openNext(bool incFilename); ///< Open next data-only file
|
||||||
void close() VL_MT_UNSAFE_ONE; ///< Close the file
|
void close() VL_MT_UNSAFE_ONE; ///< Close the file
|
||||||
/// Flush any remaining data to this file
|
/// Flush any remaining data to this file
|
||||||
|
|
@ -194,8 +197,7 @@ public:
|
||||||
|
|
||||||
/// Inside dumping routines, declare callbacks for tracings
|
/// Inside dumping routines, declare callbacks for tracings
|
||||||
void addCallback(VerilatedVcdCallback_t initcb, VerilatedVcdCallback_t fullcb,
|
void addCallback(VerilatedVcdCallback_t initcb, VerilatedVcdCallback_t fullcb,
|
||||||
VerilatedVcdCallback_t changecb,
|
VerilatedVcdCallback_t changecb, void* userthis) VL_MT_UNSAFE_ONE;
|
||||||
void* userthis) VL_MT_UNSAFE_ONE;
|
|
||||||
|
|
||||||
/// Inside dumping routines, declare a module
|
/// Inside dumping routines, declare a module
|
||||||
void module(const std::string& name);
|
void module(const std::string& name);
|
||||||
|
|
@ -206,8 +208,10 @@ public:
|
||||||
void declArray(vluint32_t code, const char* name, bool array, int arraynum, int msb, int lsb);
|
void declArray(vluint32_t code, const char* name, bool array, int arraynum, int msb, int lsb);
|
||||||
void declTriBit(vluint32_t code, const char* name, bool array, int arraynum);
|
void declTriBit(vluint32_t code, const char* name, bool array, int arraynum);
|
||||||
void declTriBus(vluint32_t code, const char* name, bool array, int arraynum, int msb, int lsb);
|
void declTriBus(vluint32_t code, const char* name, bool array, int arraynum, int msb, int lsb);
|
||||||
void declTriQuad( vluint32_t code, const char* name, bool array, int arraynum, int msb, int lsb);
|
void declTriQuad(vluint32_t code, const char* name, bool array, int arraynum, int msb,
|
||||||
void declTriArray(vluint32_t code, const char* name, bool array, int arraynum, int msb, int lsb);
|
int lsb);
|
||||||
|
void declTriArray(vluint32_t code, const char* name, bool array, int arraynum, int msb,
|
||||||
|
int lsb);
|
||||||
void declDouble(vluint32_t code, const char* name, bool array, int arraynum);
|
void declDouble(vluint32_t code, const char* name, bool array, int arraynum);
|
||||||
void declFloat(vluint32_t code, const char* name, bool array, int arraynum);
|
void declFloat(vluint32_t code, const char* name, bool array, int arraynum);
|
||||||
// ... other module_start for submodules (based on cell name)
|
// ... other module_start for submodules (based on cell name)
|
||||||
|
|
@ -216,7 +220,9 @@ public:
|
||||||
void fullBit(vluint32_t code, const vluint32_t newval) {
|
void fullBit(vluint32_t code, const vluint32_t newval) {
|
||||||
// Note the &1, so we don't require clean input -- makes more common no change case faster
|
// Note the &1, so we don't require clean input -- makes more common no change case faster
|
||||||
m_sigs_oldvalp[code] = newval;
|
m_sigs_oldvalp[code] = newval;
|
||||||
*m_writep++=('0'+static_cast<char>(newval&1)); printCode(code); *m_writep++='\n';
|
*m_writep++ = ('0' + static_cast<char>(newval & 1));
|
||||||
|
printCode(code);
|
||||||
|
*m_writep++ = '\n';
|
||||||
bufferCheck();
|
bufferCheck();
|
||||||
}
|
}
|
||||||
void fullBus(vluint32_t code, const vluint32_t newval, int bits) {
|
void fullBus(vluint32_t code, const vluint32_t newval, int bits) {
|
||||||
|
|
@ -225,7 +231,9 @@ public:
|
||||||
for (int bit = bits - 1; bit >= 0; --bit) {
|
for (int bit = bits - 1; bit >= 0; --bit) {
|
||||||
*m_writep++ = ((newval & (1L << bit)) ? '1' : '0');
|
*m_writep++ = ((newval & (1L << bit)) ? '1' : '0');
|
||||||
}
|
}
|
||||||
*m_writep++=' '; printCode(code); *m_writep++='\n';
|
*m_writep++ = ' ';
|
||||||
|
printCode(code);
|
||||||
|
*m_writep++ = '\n';
|
||||||
bufferCheck();
|
bufferCheck();
|
||||||
}
|
}
|
||||||
void fullQuad(vluint32_t code, const vluint64_t newval, int bits) {
|
void fullQuad(vluint32_t code, const vluint64_t newval, int bits) {
|
||||||
|
|
@ -234,7 +242,9 @@ public:
|
||||||
for (int bit = bits - 1; bit >= 0; --bit) {
|
for (int bit = bits - 1; bit >= 0; --bit) {
|
||||||
*m_writep++ = ((newval & (VL_ULL(1) << bit)) ? '1' : '0');
|
*m_writep++ = ((newval & (VL_ULL(1) << bit)) ? '1' : '0');
|
||||||
}
|
}
|
||||||
*m_writep++=' '; printCode(code); *m_writep++='\n';
|
*m_writep++ = ' ';
|
||||||
|
printCode(code);
|
||||||
|
*m_writep++ = '\n';
|
||||||
bufferCheck();
|
bufferCheck();
|
||||||
}
|
}
|
||||||
void fullArray(vluint32_t code, const vluint32_t* newval, int bits) {
|
void fullArray(vluint32_t code, const vluint32_t* newval, int bits) {
|
||||||
|
|
@ -245,7 +255,9 @@ public:
|
||||||
for (int bit = bits - 1; bit >= 0; --bit) {
|
for (int bit = bits - 1; bit >= 0; --bit) {
|
||||||
*m_writep++ = ((newval[(bit / 32)] & (1L << (bit & 0x1f))) ? '1' : '0');
|
*m_writep++ = ((newval[(bit / 32)] & (1L << (bit & 0x1f))) ? '1' : '0');
|
||||||
}
|
}
|
||||||
*m_writep ++= ' '; printCode(code); *m_writep ++= '\n';
|
*m_writep++ = ' ';
|
||||||
|
printCode(code);
|
||||||
|
*m_writep++ = '\n';
|
||||||
bufferCheck();
|
bufferCheck();
|
||||||
}
|
}
|
||||||
void fullArray(vluint32_t code, const vluint64_t* newval, int bits) {
|
void fullArray(vluint32_t code, const vluint64_t* newval, int bits) {
|
||||||
|
|
@ -256,15 +268,17 @@ public:
|
||||||
for (int bit = bits - 1; bit >= 0; --bit) {
|
for (int bit = bits - 1; bit >= 0; --bit) {
|
||||||
*m_writep++ = ((newval[(bit / 64)] & (VL_ULL(1) << (bit & 0x3f))) ? '1' : '0');
|
*m_writep++ = ((newval[(bit / 64)] & (VL_ULL(1) << (bit & 0x3f))) ? '1' : '0');
|
||||||
}
|
}
|
||||||
*m_writep ++= ' '; printCode(code); *m_writep ++= '\n';
|
*m_writep++ = ' ';
|
||||||
|
printCode(code);
|
||||||
|
*m_writep++ = '\n';
|
||||||
bufferCheck();
|
bufferCheck();
|
||||||
}
|
}
|
||||||
void fullTriBit(vluint32_t code, const vluint32_t newval, const vluint32_t newtri) {
|
void fullTriBit(vluint32_t code, const vluint32_t newval, const vluint32_t newtri) {
|
||||||
m_sigs_oldvalp[code] = newval;
|
m_sigs_oldvalp[code] = newval;
|
||||||
m_sigs_oldvalp[code + 1] = newtri;
|
m_sigs_oldvalp[code + 1] = newtri;
|
||||||
*m_writep++ = "01zz"[m_sigs_oldvalp[code]
|
*m_writep++ = "01zz"[m_sigs_oldvalp[code] | (m_sigs_oldvalp[code + 1] << 1)];
|
||||||
| (m_sigs_oldvalp[code+1]<<1)];
|
printCode(code);
|
||||||
printCode(code); *m_writep++='\n';
|
*m_writep++ = '\n';
|
||||||
bufferCheck();
|
bufferCheck();
|
||||||
}
|
}
|
||||||
void fullTriBus(vluint32_t code, const vluint32_t newval, const vluint32_t newtri, int bits) {
|
void fullTriBus(vluint32_t code, const vluint32_t newval, const vluint32_t newtri, int bits) {
|
||||||
|
|
@ -272,14 +286,14 @@ public:
|
||||||
m_sigs_oldvalp[code + 1] = newtri;
|
m_sigs_oldvalp[code + 1] = newtri;
|
||||||
*m_writep++ = 'b';
|
*m_writep++ = 'b';
|
||||||
for (int bit = bits - 1; bit >= 0; --bit) {
|
for (int bit = bits - 1; bit >= 0; --bit) {
|
||||||
*m_writep++ = "01zz"[((newval >> bit)&1)
|
*m_writep++ = "01zz"[((newval >> bit) & 1) | (((newtri >> bit) & 1) << 1)];
|
||||||
| (((newtri >> bit)&1)<<1)];
|
|
||||||
}
|
}
|
||||||
*m_writep++=' '; printCode(code); *m_writep++='\n';
|
*m_writep++ = ' ';
|
||||||
|
printCode(code);
|
||||||
|
*m_writep++ = '\n';
|
||||||
bufferCheck();
|
bufferCheck();
|
||||||
}
|
}
|
||||||
void fullTriQuad(vluint32_t code, const vluint64_t newval,
|
void fullTriQuad(vluint32_t code, const vluint64_t newval, const vluint32_t newtri, int bits) {
|
||||||
const vluint32_t newtri, int bits) {
|
|
||||||
(*(reinterpret_cast<vluint64_t*>(&m_sigs_oldvalp[code]))) = newval;
|
(*(reinterpret_cast<vluint64_t*>(&m_sigs_oldvalp[code]))) = newval;
|
||||||
(*(reinterpret_cast<vluint64_t*>(&m_sigs_oldvalp[code + 1]))) = newtri;
|
(*(reinterpret_cast<vluint64_t*>(&m_sigs_oldvalp[code + 1]))) = newtri;
|
||||||
*m_writep++ = 'b';
|
*m_writep++ = 'b';
|
||||||
|
|
@ -287,11 +301,13 @@ public:
|
||||||
*m_writep++ = "01zz"[((newval >> bit) & VL_ULL(1))
|
*m_writep++ = "01zz"[((newval >> bit) & VL_ULL(1))
|
||||||
| (((newtri >> bit) & VL_ULL(1)) << VL_ULL(1))];
|
| (((newtri >> bit) & VL_ULL(1)) << VL_ULL(1))];
|
||||||
}
|
}
|
||||||
*m_writep++=' '; printCode(code); *m_writep++='\n';
|
*m_writep++ = ' ';
|
||||||
|
printCode(code);
|
||||||
|
*m_writep++ = '\n';
|
||||||
bufferCheck();
|
bufferCheck();
|
||||||
}
|
}
|
||||||
void fullTriArray(vluint32_t code, const vluint32_t* newvalp,
|
void fullTriArray(vluint32_t code, const vluint32_t* newvalp, const vluint32_t* newtrip,
|
||||||
const vluint32_t* newtrip, int bits) {
|
int bits) {
|
||||||
for (int word = 0; word < (((bits - 1) / 32) + 1); ++word) {
|
for (int word = 0; word < (((bits - 1) / 32) + 1); ++word) {
|
||||||
m_sigs_oldvalp[code + word * 2] = newvalp[word];
|
m_sigs_oldvalp[code + word * 2] = newvalp[word];
|
||||||
m_sigs_oldvalp[code + word * 2 + 1] = newtrip[word];
|
m_sigs_oldvalp[code + word * 2 + 1] = newtrip[word];
|
||||||
|
|
@ -302,7 +318,9 @@ public:
|
||||||
vluint32_t tribit = (newtrip[(bit / 32)] >> (bit & 0x1f)) & 1;
|
vluint32_t tribit = (newtrip[(bit / 32)] >> (bit & 0x1f)) & 1;
|
||||||
*m_writep++ = "01zz"[valbit | (tribit << 1)];
|
*m_writep++ = "01zz"[valbit | (tribit << 1)];
|
||||||
}
|
}
|
||||||
*m_writep++=' '; printCode(code); *m_writep++='\n';
|
*m_writep++ = ' ';
|
||||||
|
printCode(code);
|
||||||
|
*m_writep++ = '\n';
|
||||||
bufferCheck();
|
bufferCheck();
|
||||||
}
|
}
|
||||||
void fullDouble(vluint32_t code, const double newval);
|
void fullDouble(vluint32_t code, const double newval);
|
||||||
|
|
@ -313,7 +331,9 @@ public:
|
||||||
/// Thus this is for special standalone applications that after calling
|
/// Thus this is for special standalone applications that after calling
|
||||||
/// fullBitX, must when then value goes non-X call fullBit.
|
/// fullBitX, must when then value goes non-X call fullBit.
|
||||||
inline void fullBitX(vluint32_t code) {
|
inline void fullBitX(vluint32_t code) {
|
||||||
*m_writep++='x'; printCode(code); *m_writep++='\n';
|
*m_writep++ = 'x';
|
||||||
|
printCode(code);
|
||||||
|
*m_writep++ = '\n';
|
||||||
bufferCheck();
|
bufferCheck();
|
||||||
}
|
}
|
||||||
inline void fullBusX(vluint32_t code, int bits) {
|
inline void fullBusX(vluint32_t code, int bits) {
|
||||||
|
|
@ -321,7 +341,9 @@ public:
|
||||||
for (int bit = bits - 1; bit >= 0; --bit) {
|
for (int bit = bits - 1; bit >= 0; --bit) {
|
||||||
*m_writep++ = 'x';
|
*m_writep++ = 'x';
|
||||||
}
|
}
|
||||||
*m_writep++=' '; printCode(code); *m_writep++='\n';
|
*m_writep++ = ' ';
|
||||||
|
printCode(code);
|
||||||
|
*m_writep++ = '\n';
|
||||||
bufferCheck();
|
bufferCheck();
|
||||||
}
|
}
|
||||||
inline void fullQuadX(vluint32_t code, int bits) { fullBusX(code, bits); }
|
inline void fullQuadX(vluint32_t code, int bits) { fullBusX(code, bits); }
|
||||||
|
|
@ -370,10 +392,8 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inline void chgTriBit(vluint32_t code, const vluint32_t newval,
|
inline void chgTriBit(vluint32_t code, const vluint32_t newval, const vluint32_t newtri) {
|
||||||
const vluint32_t newtri) {
|
vluint32_t diff = ((m_sigs_oldvalp[code] ^ newval) | (m_sigs_oldvalp[code + 1] ^ newtri));
|
||||||
vluint32_t diff = ((m_sigs_oldvalp[code] ^ newval)
|
|
||||||
| (m_sigs_oldvalp[code+1] ^ newtri));
|
|
||||||
if (VL_UNLIKELY(diff)) {
|
if (VL_UNLIKELY(diff)) {
|
||||||
// Verilator 3.510 and newer provide clean input, so the below
|
// Verilator 3.510 and newer provide clean input, so the below
|
||||||
// is only for back compatibility
|
// is only for back compatibility
|
||||||
|
|
@ -382,19 +402,19 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inline void chgTriBus(vluint32_t code, const vluint32_t newval,
|
inline void chgTriBus(vluint32_t code, const vluint32_t newval, const vluint32_t newtri,
|
||||||
const vluint32_t newtri, int bits) {
|
int bits) {
|
||||||
vluint32_t diff = ((m_sigs_oldvalp[code] ^ newval)
|
vluint32_t diff = ((m_sigs_oldvalp[code] ^ newval) | (m_sigs_oldvalp[code + 1] ^ newtri));
|
||||||
| (m_sigs_oldvalp[code+1] ^ newtri));
|
|
||||||
if (VL_UNLIKELY(diff)) {
|
if (VL_UNLIKELY(diff)) {
|
||||||
if (VL_UNLIKELY(bits == 32 || (diff & ((1U << bits) - 1)))) {
|
if (VL_UNLIKELY(bits == 32 || (diff & ((1U << bits) - 1)))) {
|
||||||
fullTriBus(code, newval, newtri, bits);
|
fullTriBus(code, newval, newtri, bits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inline void chgTriQuad(vluint32_t code, const vluint64_t newval,
|
inline void chgTriQuad(vluint32_t code, const vluint64_t newval, const vluint32_t newtri,
|
||||||
const vluint32_t newtri, int bits) {
|
int bits) {
|
||||||
vluint64_t diff = ( ((*(reinterpret_cast<vluint64_t*>(&m_sigs_oldvalp[code]))) ^ newval)
|
vluint64_t diff
|
||||||
|
= (((*(reinterpret_cast<vluint64_t*>(&m_sigs_oldvalp[code]))) ^ newval)
|
||||||
| ((*(reinterpret_cast<vluint64_t*>(&m_sigs_oldvalp[code + 1]))) ^ newtri));
|
| ((*(reinterpret_cast<vluint64_t*>(&m_sigs_oldvalp[code + 1]))) ^ newtri));
|
||||||
if (VL_UNLIKELY(diff)) {
|
if (VL_UNLIKELY(diff)) {
|
||||||
if (VL_UNLIKELY(bits == 64 || (diff & ((VL_ULL(1) << bits) - 1)))) {
|
if (VL_UNLIKELY(bits == 64 || (diff & ((VL_ULL(1) << bits) - 1)))) {
|
||||||
|
|
@ -402,8 +422,8 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inline void chgTriArray(vluint32_t code, const vluint32_t* newvalp,
|
inline void chgTriArray(vluint32_t code, const vluint32_t* newvalp, const vluint32_t* newtrip,
|
||||||
const vluint32_t* newtrip, int bits) {
|
int bits) {
|
||||||
for (int word = 0; word < (((bits - 1) / 32) + 1); ++word) {
|
for (int word = 0; word < (((bits - 1) / 32) + 1); ++word) {
|
||||||
if (VL_UNLIKELY((m_sigs_oldvalp[code + word * 2] ^ newvalp[word])
|
if (VL_UNLIKELY((m_sigs_oldvalp[code + word * 2] ^ newvalp[word])
|
||||||
| (m_sigs_oldvalp[code + word * 2 + 1] ^ newtrip[word]))) {
|
| (m_sigs_oldvalp[code + word * 2 + 1] ^ newtrip[word]))) {
|
||||||
|
|
@ -441,12 +461,14 @@ class VerilatedVcdC {
|
||||||
|
|
||||||
// CONSTRUCTORS
|
// CONSTRUCTORS
|
||||||
VL_UNCOPYABLE(VerilatedVcdC);
|
VL_UNCOPYABLE(VerilatedVcdC);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit VerilatedVcdC(VerilatedVcdFile* filep = NULL)
|
explicit VerilatedVcdC(VerilatedVcdFile* filep = NULL)
|
||||||
: m_sptrace(filep) {}
|
: m_sptrace(filep) {}
|
||||||
~VerilatedVcdC() { close(); }
|
~VerilatedVcdC() { close(); }
|
||||||
/// Routines can only be called from one thread; allow next call from different thread
|
/// Routines can only be called from one thread; allow next call from different thread
|
||||||
void changeThread() { spTrace()->changeThread(); }
|
void changeThread() { spTrace()->changeThread(); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// ACCESSORS
|
// ACCESSORS
|
||||||
/// Is file open?
|
/// Is file open?
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue