Internals: clang-format cleanups. No functional change.
This commit is contained in:
parent
e07e9390f6
commit
5302a9d0e6
|
|
@ -10,7 +10,6 @@ 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_heavy.h
|
|
||||||
clang-format -i include/verilated_imp.h
|
clang-format -i include/verilated_imp.h
|
||||||
clang-format -i include/verilated_unordered_set_map.h
|
clang-format -i include/verilated_unordered_set_map.h
|
||||||
clang-format -i include/verilatedos.h
|
clang-format -i include/verilatedos.h
|
||||||
|
|
|
||||||
|
|
@ -35,22 +35,28 @@
|
||||||
/// Return WData from svBitVecVal
|
/// Return WData from svBitVecVal
|
||||||
static inline void VL_SET_W_SVBV(int obits, WDataOutP owp, const svBitVecVal* lwp) VL_MT_SAFE {
|
static inline void VL_SET_W_SVBV(int obits, WDataOutP owp, const svBitVecVal* lwp) VL_MT_SAFE {
|
||||||
int words = VL_WORDS_I(obits);
|
int words = VL_WORDS_I(obits);
|
||||||
for (int i=0; i<words-1; ++i) owp[i]=lwp[i];
|
for (int i = 0; i < words - 1; ++i) {
|
||||||
owp[words-1] = lwp[words-1] & VL_MASK_I(obits);
|
owp[i] = lwp[i];
|
||||||
|
}
|
||||||
|
owp[words - 1] = lwp[words - 1] & VL_MASK_I(obits);
|
||||||
}
|
}
|
||||||
/// Return svBitVecVal from WData
|
/// Return svBitVecVal from WData
|
||||||
static inline void VL_SET_SVBV_W(int obits, svBitVecVal* owp, WDataInP lwp) VL_MT_SAFE {
|
static inline void VL_SET_SVBV_W(int obits, svBitVecVal* owp, WDataInP lwp) VL_MT_SAFE {
|
||||||
int words = VL_WORDS_I(obits);
|
int words = VL_WORDS_I(obits);
|
||||||
for (int i=0; i<words-1; ++i) owp[i]=lwp[i];
|
for (int i = 0; i < words - 1; ++i) {
|
||||||
owp[words-1] = lwp[words-1] & VL_MASK_I(obits);
|
owp[i] = lwp[i];
|
||||||
|
}
|
||||||
|
owp[words - 1] = lwp[words - 1] & VL_MASK_I(obits);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert svLogicVecVal to/from WData
|
/// Convert svLogicVecVal to/from WData
|
||||||
/// Note these functions ignore X/Z in svLogicVecVal
|
/// Note these functions ignore X/Z in svLogicVecVal
|
||||||
static inline void VL_SET_W_SVLV(int obits, WDataOutP owp, const svLogicVecVal* lwp) VL_MT_SAFE {
|
static inline void VL_SET_W_SVLV(int obits, WDataOutP owp, const svLogicVecVal* lwp) VL_MT_SAFE {
|
||||||
int words = VL_WORDS_I(obits);
|
int words = VL_WORDS_I(obits);
|
||||||
for (int i=0; i<words-1; ++i) owp[i]=lwp[i].aval;
|
for (int i = 0; i < words - 1; ++i) {
|
||||||
owp[words-1] = lwp[words-1].aval & VL_MASK_I(obits);
|
owp[i] = lwp[i].aval;
|
||||||
|
}
|
||||||
|
owp[words - 1] = lwp[words - 1].aval & VL_MASK_I(obits);
|
||||||
}
|
}
|
||||||
static inline QData VL_SET_Q_SVLV(const svLogicVecVal* lwp) VL_MT_SAFE {
|
static inline QData VL_SET_Q_SVLV(const svLogicVecVal* lwp) VL_MT_SAFE {
|
||||||
return _VL_SET_QII(lwp[1].aval, lwp[0].aval);
|
return _VL_SET_QII(lwp[1].aval, lwp[0].aval);
|
||||||
|
|
@ -60,17 +66,25 @@ static inline IData VL_SET_I_SVLV(const svLogicVecVal* lwp) VL_MT_SAFE {
|
||||||
}
|
}
|
||||||
static inline void VL_SET_SVLV_W(int obits, svLogicVecVal* owp, WDataInP lwp) VL_MT_SAFE {
|
static inline void VL_SET_SVLV_W(int obits, svLogicVecVal* owp, WDataInP lwp) VL_MT_SAFE {
|
||||||
int words = VL_WORDS_I(obits);
|
int words = VL_WORDS_I(obits);
|
||||||
for (int i=0; i<words; ++i) owp[i].bval=0;
|
for (int i = 0; i < words; ++i) {
|
||||||
for (int i=0; i<words-1; ++i) owp[i].aval=lwp[i];
|
owp[i].bval = 0;
|
||||||
owp[words-1].aval = lwp[words-1] & VL_MASK_I(obits);
|
}
|
||||||
|
for (int i = 0; i < words - 1; ++i) {
|
||||||
|
owp[i].aval = lwp[i];
|
||||||
|
}
|
||||||
|
owp[words - 1].aval = lwp[words - 1] & VL_MASK_I(obits);
|
||||||
}
|
}
|
||||||
static inline void VL_SET_SVLV_I(int, svLogicVecVal* owp, IData ld) VL_MT_SAFE {
|
static inline void VL_SET_SVLV_I(int, svLogicVecVal* owp, IData ld) VL_MT_SAFE {
|
||||||
owp[0].aval=ld; owp[0].bval=0;
|
owp[0].aval = ld;
|
||||||
|
owp[0].bval = 0;
|
||||||
}
|
}
|
||||||
static inline void VL_SET_SVLV_Q(int, svLogicVecVal* owp, QData ld) VL_MT_SAFE {
|
static inline void VL_SET_SVLV_Q(int, svLogicVecVal* owp, QData ld) VL_MT_SAFE {
|
||||||
WData lwp[2]; VL_SET_WQ(lwp,ld);
|
WData lwp[2];
|
||||||
owp[0].aval=lwp[0]; owp[0].bval=0;
|
VL_SET_WQ(lwp, ld);
|
||||||
owp[1].aval=lwp[1]; owp[1].bval=0;
|
owp[0].aval = lwp[0];
|
||||||
|
owp[0].bval = 0;
|
||||||
|
owp[1].aval = lwp[1];
|
||||||
|
owp[1].bval = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//======================================================================
|
//======================================================================
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,7 @@ public:
|
||||||
|
|
||||||
template <std::size_t T_Words> class VlWide {
|
template <std::size_t T_Words> class VlWide {
|
||||||
WData m_storage[T_Words];
|
WData m_storage[T_Words];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Default constructor/destructor/copy are fine
|
// Default constructor/destructor/copy are fine
|
||||||
const WData& at(size_t index) const { return m_storage[index]; }
|
const WData& at(size_t index) const { return m_storage[index]; }
|
||||||
|
|
@ -95,13 +96,11 @@ public:
|
||||||
|
|
||||||
// Convert a C array to std::array reference by pointer magic, without copy.
|
// Convert a C array to std::array reference by pointer magic, without copy.
|
||||||
// Data type (second argument) is so the function template can automatically generate.
|
// Data type (second argument) is so the function template can automatically generate.
|
||||||
template <std::size_t T_Words>
|
template <std::size_t T_Words> VlWide<T_Words>& VL_CVT_W_A(WDataInP inp, const VlWide<T_Words>&) {
|
||||||
VlWide<T_Words>& VL_CVT_W_A(WDataInP inp, const VlWide<T_Words>&) {
|
|
||||||
return *((VlWide<T_Words>*)inp);
|
return *((VlWide<T_Words>*)inp);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <std::size_t T_Words>
|
template <std::size_t T_Words> std::string VL_TO_STRING(const VlWide<T_Words>& obj) {
|
||||||
std::string VL_TO_STRING(const VlWide<T_Words>& obj) {
|
|
||||||
return VL_TO_STRING_W(T_Words, obj.data());
|
return VL_TO_STRING_W(T_Words, obj.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -114,6 +113,7 @@ template <class T_Key, class T_Value> class VlAssocArray {
|
||||||
private:
|
private:
|
||||||
// TYPES
|
// TYPES
|
||||||
typedef std::map<T_Key, T_Value> Map;
|
typedef std::map<T_Key, T_Value> Map;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename Map::const_iterator const_iterator;
|
typedef typename Map::const_iterator const_iterator;
|
||||||
|
|
||||||
|
|
@ -187,8 +187,11 @@ public:
|
||||||
// Accessing. Verilog: v = assoc[index]
|
// Accessing. Verilog: v = assoc[index]
|
||||||
const T_Value& at(const T_Key& index) const {
|
const T_Value& at(const T_Key& index) const {
|
||||||
typename Map::iterator it = m_map.find(index);
|
typename Map::iterator it = m_map.find(index);
|
||||||
if (it == m_map.end()) return m_defaultValue;
|
if (it == m_map.end()) {
|
||||||
else return it->second;
|
return m_defaultValue;
|
||||||
|
} else {
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// For save/restore
|
// For save/restore
|
||||||
const_iterator begin() const { return m_map.begin(); }
|
const_iterator begin() const { return m_map.begin(); }
|
||||||
|
|
@ -251,6 +254,7 @@ template <class T_Value, size_t T_MaxSize = 0> class VlQueue {
|
||||||
private:
|
private:
|
||||||
// TYPES
|
// TYPES
|
||||||
typedef std::deque<T_Value> Deque;
|
typedef std::deque<T_Value> Deque;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename Deque::const_iterator const_iterator;
|
typedef typename Deque::const_iterator const_iterator;
|
||||||
|
|
||||||
|
|
@ -274,7 +278,9 @@ public:
|
||||||
int size() const { return m_deque.size(); }
|
int size() const { return m_deque.size(); }
|
||||||
// Clear array. Verilog: function void delete([input index])
|
// Clear array. Verilog: function void delete([input index])
|
||||||
void clear() { m_deque.clear(); }
|
void clear() { m_deque.clear(); }
|
||||||
void erase(size_t index) { if (VL_LIKELY(index < m_deque.size())) m_deque.erase(index); }
|
void erase(size_t index) {
|
||||||
|
if (VL_LIKELY(index < m_deque.size())) m_deque.erase(index);
|
||||||
|
}
|
||||||
|
|
||||||
// Dynamic array new[] becomes a renew()
|
// Dynamic array new[] becomes a renew()
|
||||||
void renew(size_t size) {
|
void renew(size_t size) {
|
||||||
|
|
@ -282,7 +288,7 @@ public:
|
||||||
m_deque.resize(size, atDefault());
|
m_deque.resize(size, atDefault());
|
||||||
}
|
}
|
||||||
// Dynamic array new[]() becomes a renew_copy()
|
// Dynamic array new[]() becomes a renew_copy()
|
||||||
void renew_copy(size_t size, const VlQueue<T_Value,T_MaxSize>& rhs) {
|
void renew_copy(size_t size, const VlQueue<T_Value, T_MaxSize>& rhs) {
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
clear();
|
clear();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -303,12 +309,16 @@ public:
|
||||||
// function value_t q.pop_front();
|
// function value_t q.pop_front();
|
||||||
T_Value pop_front() {
|
T_Value pop_front() {
|
||||||
if (m_deque.empty()) return m_defaultValue;
|
if (m_deque.empty()) return m_defaultValue;
|
||||||
T_Value v = m_deque.front(); m_deque.pop_front(); return v;
|
T_Value v = m_deque.front();
|
||||||
|
m_deque.pop_front();
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
// function value_t q.pop_back();
|
// function value_t q.pop_back();
|
||||||
T_Value pop_back() {
|
T_Value pop_back() {
|
||||||
if (m_deque.empty()) return m_defaultValue;
|
if (m_deque.empty()) return m_defaultValue;
|
||||||
T_Value v = m_deque.back(); m_deque.pop_back(); return v;
|
T_Value v = m_deque.back();
|
||||||
|
m_deque.pop_back();
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setting. Verilog: assoc[index] = v
|
// Setting. Verilog: assoc[index] = v
|
||||||
|
|
@ -320,15 +330,19 @@ public:
|
||||||
if (VL_UNLIKELY(index >= m_deque.size())) {
|
if (VL_UNLIKELY(index >= m_deque.size())) {
|
||||||
s_throwAway = atDefault();
|
s_throwAway = atDefault();
|
||||||
return s_throwAway;
|
return s_throwAway;
|
||||||
|
} else {
|
||||||
|
return m_deque[index];
|
||||||
}
|
}
|
||||||
else return m_deque[index];
|
|
||||||
}
|
}
|
||||||
// Accessing. Verilog: v = assoc[index]
|
// Accessing. Verilog: v = assoc[index]
|
||||||
const T_Value& at(size_t index) const {
|
const T_Value& at(size_t index) const {
|
||||||
static T_Value s_throwAway;
|
static T_Value s_throwAway;
|
||||||
// Needs to work for dynamic arrays, so does not use T_MaxSize
|
// Needs to work for dynamic arrays, so does not use T_MaxSize
|
||||||
if (VL_UNLIKELY(index >= m_deque.size())) return atDefault();
|
if (VL_UNLIKELY(index >= m_deque.size())) {
|
||||||
else return m_deque[index];
|
return atDefault();
|
||||||
|
} else {
|
||||||
|
return m_deque[index];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// function void q.insert(index, value);
|
// function void q.insert(index, value);
|
||||||
void insert(size_t index, const T_Value& value) {
|
void insert(size_t index, const T_Value& value) {
|
||||||
|
|
@ -352,8 +366,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T_Value>
|
template <class T_Value> std::string VL_TO_STRING(const VlQueue<T_Value>& obj) {
|
||||||
std::string VL_TO_STRING(const VlQueue<T_Value>& obj) {
|
|
||||||
return obj.to_string();
|
return obj.to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -362,26 +375,29 @@ std::string VL_TO_STRING(const VlQueue<T_Value>& obj) {
|
||||||
|
|
||||||
extern std::string VL_CVT_PACK_STR_NW(int lwords, WDataInP lwp) VL_MT_SAFE;
|
extern std::string VL_CVT_PACK_STR_NW(int lwords, WDataInP lwp) VL_MT_SAFE;
|
||||||
inline std::string VL_CVT_PACK_STR_NQ(QData lhs) VL_PURE {
|
inline std::string VL_CVT_PACK_STR_NQ(QData lhs) VL_PURE {
|
||||||
WData lw[VL_WQ_WORDS_E]; VL_SET_WQ(lw, lhs);
|
WData lw[VL_WQ_WORDS_E];
|
||||||
|
VL_SET_WQ(lw, lhs);
|
||||||
return VL_CVT_PACK_STR_NW(VL_WQ_WORDS_E, lw);
|
return VL_CVT_PACK_STR_NW(VL_WQ_WORDS_E, lw);
|
||||||
}
|
}
|
||||||
inline std::string VL_CVT_PACK_STR_NN(const std::string& lhs) VL_PURE {
|
inline std::string VL_CVT_PACK_STR_NN(const std::string& lhs) VL_PURE { return lhs; }
|
||||||
return lhs;
|
|
||||||
}
|
|
||||||
inline std::string VL_CVT_PACK_STR_NI(IData lhs) VL_PURE {
|
inline std::string VL_CVT_PACK_STR_NI(IData lhs) VL_PURE {
|
||||||
WData lw[VL_WQ_WORDS_E]; VL_SET_WI(lw, lhs);
|
WData lw[VL_WQ_WORDS_E];
|
||||||
|
VL_SET_WI(lw, lhs);
|
||||||
return VL_CVT_PACK_STR_NW(1, lw);
|
return VL_CVT_PACK_STR_NW(1, lw);
|
||||||
}
|
}
|
||||||
inline std::string VL_CONCATN_NNN(const std::string& lhs, const std::string& rhs) VL_PURE {
|
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 {
|
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);
|
std::string out;
|
||||||
for (unsigned times=0; times<rep; ++times) out += lhs;
|
out.reserve(lhs.length() * rep);
|
||||||
|
for (unsigned times = 0; times < rep; ++times) {
|
||||||
|
out += lhs;
|
||||||
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
inline std::string VL_REPLICATEN_NNI(int obits,int lbits,int rbits,
|
inline std::string VL_REPLICATEN_NNI(int obits, int lbits, int rbits, const std::string& lhs,
|
||||||
const std::string& lhs, IData rep) VL_PURE {
|
IData rep) VL_PURE {
|
||||||
return VL_REPLICATEN_NNQ(obits, lbits, rbits, lhs, rep);
|
return VL_REPLICATEN_NNQ(obits, lbits, rbits, lhs, rep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -396,10 +412,9 @@ extern void VL_READMEM_N(bool hex, int bits, QData depth, int array_lsb,
|
||||||
extern void VL_WRITEMEM_N(bool hex, int bits, QData depth, int array_lsb,
|
extern void VL_WRITEMEM_N(bool hex, int bits, QData depth, int array_lsb,
|
||||||
const std::string& filename, const void* memp, QData start,
|
const std::string& filename, const void* memp, QData start,
|
||||||
QData end) VL_MT_SAFE;
|
QData end) VL_MT_SAFE;
|
||||||
extern IData VL_SSCANF_INX(int lbits, const std::string& ld,
|
extern IData VL_SSCANF_INX(int lbits, const std::string& ld, const char* formatp, ...) VL_MT_SAFE;
|
||||||
const char* formatp, ...) VL_MT_SAFE;
|
extern void VL_SFORMAT_X(int obits_ignored, std::string& output, const char* formatp,
|
||||||
extern void VL_SFORMAT_X(int obits_ignored, std::string& output,
|
...) VL_MT_SAFE;
|
||||||
const char* formatp, ...) VL_MT_SAFE;
|
|
||||||
extern std::string VL_SFORMATF_NX(const char* formatp, ...) VL_MT_SAFE;
|
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;
|
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, CData& rdr) VL_MT_SAFE {
|
inline IData VL_VALUEPLUSARGS_INI(int rbits, const std::string& ld, CData& rdr) VL_MT_SAFE {
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@
|
||||||
///
|
///
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
|
|
||||||
|
|
||||||
#ifndef _VERILATEDOS_H_
|
#ifndef _VERILATEDOS_H_
|
||||||
#define _VERILATEDOS_H_ 1 ///< Header Guard
|
#define _VERILATEDOS_H_ 1 ///< Header Guard
|
||||||
|
|
||||||
|
|
@ -378,8 +377,8 @@ typedef unsigned long long vluint64_t; ///< 64-bit unsigned type
|
||||||
//=========================================================================
|
//=========================================================================
|
||||||
// Verilated function size macros
|
// Verilated function size macros
|
||||||
|
|
||||||
#define VL_MULS_MAX_WORDS 16 ///< Max size in words of MULS operation
|
#define VL_MULS_MAX_WORDS 16 ///< Max size in words of MULS operation
|
||||||
#define VL_TO_STRING_MAX_WORDS 64 ///< Max size in words of String conversion operation
|
#define VL_TO_STRING_MAX_WORDS 64 ///< Max size in words of String conversion operation
|
||||||
|
|
||||||
//=========================================================================
|
//=========================================================================
|
||||||
// Base macros
|
// Base macros
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue