mirror of
https://github.com/verilator/verilator.git
synced 2025-05-03 22:16:53 +00:00
Internals: Favor std::array where easy. No functional change intended.
This commit is contained in:
parent
f6f7684ccd
commit
f4ef4ad9f3
@ -133,7 +133,7 @@ private:
|
||||
int m_caseItems = 0; // Number of caseItem unique values
|
||||
bool m_caseNoOverlapsAllCovered = false; // Proven to be synopsys parallel_case compliant
|
||||
// For each possible value, the case branch we need
|
||||
AstNode* m_valueItem[1 << CASE_OVERLAP_WIDTH];
|
||||
std::array<AstNode*, 1 << CASE_OVERLAP_WIDTH> m_valueItem;
|
||||
|
||||
// METHODS
|
||||
VL_DEBUG_FUNC; // Declare debug()
|
||||
|
@ -36,9 +36,9 @@ std::ostringstream V3Error::s_errorStr; // Error string being formed
|
||||
V3ErrorCode V3Error::s_errorCode = V3ErrorCode::EC_FATAL;
|
||||
bool V3Error::s_errorContexted = false;
|
||||
bool V3Error::s_errorSuppressed = false;
|
||||
bool V3Error::s_describedEachWarn[V3ErrorCode::_ENUM_MAX];
|
||||
std::array<bool, V3ErrorCode::_ENUM_MAX> V3Error::s_describedEachWarn;
|
||||
std::array<bool, V3ErrorCode::_ENUM_MAX> V3Error::s_pretendError;
|
||||
bool V3Error::s_describedWarnings = false;
|
||||
bool V3Error::s_pretendError[V3ErrorCode::_ENUM_MAX];
|
||||
V3Error::MessagesSet V3Error::s_messages;
|
||||
V3Error::ErrorExitCb V3Error::s_errorExitCb = nullptr;
|
||||
|
||||
|
@ -224,9 +224,10 @@ class V3Error {
|
||||
|
||||
private:
|
||||
static bool s_describedWarnings; // Told user how to disable warns
|
||||
static bool
|
||||
s_describedEachWarn[V3ErrorCode::_ENUM_MAX]; // Told user specifics about this warning
|
||||
static bool s_pretendError[V3ErrorCode::_ENUM_MAX]; // Pretend this warning is an error
|
||||
static std::array<bool, V3ErrorCode::_ENUM_MAX>
|
||||
s_describedEachWarn; // Told user specifics about this warning
|
||||
static std::array<bool, V3ErrorCode::_ENUM_MAX>
|
||||
s_pretendError; // Pretend this warning is an error
|
||||
static int s_debugDefault; // Option: --debugi Default debugging level
|
||||
static int s_errorLimit; // Option: --error-limit Number of errors before exit
|
||||
static bool s_warnFatal; // Option: --warnFatal Warnings are fatal
|
||||
|
@ -32,7 +32,7 @@ struct GraphPCNode {
|
||||
//
|
||||
// Unlike the LogicMTasks's, we have no cost info for the generic graph
|
||||
// accepted by GraphPathChecker, so assume each node has unit cost.
|
||||
vluint32_t m_cp[GraphWay::NUM_WAYS];
|
||||
std::array<vluint32_t, GraphWay::NUM_WAYS> m_cp;
|
||||
|
||||
// Detect if we've seen this node before in a given recursive
|
||||
// operation. We'll use this in pathExistsInternal() to avoid checking
|
||||
|
@ -153,7 +153,7 @@ private:
|
||||
VSymEnt* m_dunitEntp; // $unit entry
|
||||
NameScopeSymMap m_nameScopeSymMap; // Map of scope referenced by non-pretty textual name
|
||||
ImplicitNameSet m_implicitNameSet; // For [module][signalname] if we can implicitly create it
|
||||
ScopeAliasMap m_scopeAliasMap[SAMN__MAX]; // Map of <lhs,rhs> aliases
|
||||
std::array<ScopeAliasMap, SAMN__MAX> m_scopeAliasMap; // Map of <lhs,rhs> aliases
|
||||
IfaceVarSyms m_ifaceVarSyms; // List of AstIfaceRefDType's to be imported
|
||||
IfaceModSyms m_ifaceModSyms; // List of AstIface+Symbols to be processed
|
||||
bool m_forPrimary; // First link
|
||||
|
@ -190,7 +190,7 @@ class OrderUser {
|
||||
// Stored in AstVarScope::user1p, a list of all the various vertices
|
||||
// that can exist for one given variable
|
||||
private:
|
||||
OrderVarVertex* m_vertexp[WV_MAX]; // Vertex of each type (if non nullptr)
|
||||
std::array<OrderVarVertex*, WV_MAX> m_vertexp; // Vertex of each type (if non nullptr)
|
||||
public:
|
||||
// METHODS
|
||||
OrderVarVertex* newVarUserVertex(V3Graph* graphp, AstScope* scopep, AstVarScope* varscp,
|
||||
@ -686,7 +686,7 @@ protected:
|
||||
|
||||
private:
|
||||
// STATS
|
||||
VDouble0 m_statCut[OrderVEdgeType::_ENUM_END]; // Count of each edge type cut
|
||||
std::array<VDouble0, OrderVEdgeType::_ENUM_END> m_statCut; // Count of each edge type cut
|
||||
|
||||
// TYPES
|
||||
enum VarUsage : uint8_t { VU_NONE = 0, VU_CON = 1, VU_GEN = 2 };
|
||||
|
10
src/V3Os.cpp
10
src/V3Os.cpp
@ -252,12 +252,12 @@ void V3Os::unlinkRegexp(const string& dir, const string& regexp) {
|
||||
//######################################################################
|
||||
// METHODS (random)
|
||||
|
||||
vluint64_t V3Os::rand64(vluint64_t* statep) {
|
||||
vluint64_t V3Os::rand64(std::array<vluint64_t, 2>& stater) {
|
||||
// Xoroshiro128+ algorithm
|
||||
vluint64_t result = statep[0] + statep[1];
|
||||
statep[1] ^= statep[0];
|
||||
statep[0] = (((statep[0] << 55) | (statep[0] >> 9)) ^ statep[1] ^ (statep[1] << 14));
|
||||
statep[1] = (statep[1] << 36) | (statep[1] >> 28);
|
||||
vluint64_t result = stater[0] + stater[1];
|
||||
stater[1] ^= stater[0];
|
||||
stater[0] = (((stater[0] << 55) | (stater[0] >> 9)) ^ stater[1] ^ (stater[1] << 14));
|
||||
stater[1] = (stater[1] << 36) | (stater[1] >> 28);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
static void unlinkRegexp(const string& dir, const string& regexp);
|
||||
|
||||
// METHODS (random)
|
||||
static vluint64_t rand64(vluint64_t* statep);
|
||||
static vluint64_t rand64(std::array<vluint64_t, 2>& stater);
|
||||
static string trueRandom(size_t size);
|
||||
|
||||
// METHODS (time & performance)
|
||||
|
@ -306,7 +306,7 @@ private:
|
||||
}
|
||||
void go() {
|
||||
// Generate a pseudo-random graph
|
||||
vluint64_t rngState[2] = {0x12345678ULL, 0x9abcdef0ULL};
|
||||
std::array<vluint64_t, 2> rngState = {0x12345678ULL, 0x9abcdef0ULL};
|
||||
// Create 50 vertices
|
||||
for (auto& i : m_vx) i = new V3GraphVertex(&m_graph);
|
||||
// Create 250 edges at random. Edges must go from
|
||||
@ -425,7 +425,7 @@ private:
|
||||
// Cost of critical paths going FORWARD from graph-start to the start
|
||||
// of this vertex, and also going REVERSE from the end of the graph to
|
||||
// the end of the vertex. Same units as m_cost.
|
||||
uint32_t m_critPathCost[GraphWay::NUM_WAYS];
|
||||
std::array<uint32_t, GraphWay::NUM_WAYS> m_critPathCost;
|
||||
|
||||
uint32_t m_serialId; // Unique MTask ID number
|
||||
|
||||
@ -443,7 +443,7 @@ private:
|
||||
// relatives in longest-to-shortest CP order. We rely on this ordering
|
||||
// in more than one place.
|
||||
typedef SortByValueMap<LogicMTask*, uint32_t, CmpLogicMTask> EdgeSet;
|
||||
EdgeSet m_edges[GraphWay::NUM_WAYS];
|
||||
std::array<EdgeSet, GraphWay::NUM_WAYS> m_edges;
|
||||
|
||||
public:
|
||||
// CONSTRUCTORS
|
||||
@ -2252,8 +2252,8 @@ void V3Partition::debugMTaskGraphStats(const V3Graph* graphp, const string& stag
|
||||
UINFO(4, " Stats for " << stage << endl);
|
||||
uint32_t mtaskCount = 0;
|
||||
uint32_t totalCost = 0;
|
||||
uint32_t mtaskCostHist[32];
|
||||
memset(mtaskCostHist, 0, sizeof(mtaskCostHist));
|
||||
std::array<uint32_t, 32> mtaskCostHist;
|
||||
mtaskCostHist.fill(0);
|
||||
|
||||
for (const V3GraphVertex* mtaskp = graphp->verticesBeginp(); mtaskp;
|
||||
mtaskp = mtaskp->verticesNextp()) {
|
||||
|
@ -1005,7 +1005,8 @@ class SplitPackedVarVisitor : public AstNVisitor, public SplitVarImpl {
|
||||
}
|
||||
UASSERT_OBJ(varp->attrSplitVar(), varp, "split_var attribute must be attached");
|
||||
|
||||
AstConst* consts[2] = {VN_CAST(nodep->lsbp(), Const), VN_CAST(nodep->widthp(), Const)};
|
||||
std::array<AstConst*, 2> consts
|
||||
= {VN_CAST(nodep->lsbp(), Const), VN_CAST(nodep->widthp(), Const)};
|
||||
if (consts[0] && consts[1]) { // OK
|
||||
refit->second.append(
|
||||
PackedVarRefEntry(nodep, consts[0]->toSInt() + refit->second.basicp()->lsb(),
|
||||
|
@ -49,7 +49,7 @@ private:
|
||||
|
||||
std::vector<VDouble0> m_statTypeCount; // Nodes of given type
|
||||
VDouble0 m_statAbove[AstType::_ENUM_END][AstType::_ENUM_END]; // Nodes of given type
|
||||
VDouble0 m_statPred[VBranchPred::_ENUM_END]; // Nodes of given type
|
||||
std::array<VDouble0, VBranchPred::_ENUM_END> m_statPred; // Nodes of given type
|
||||
VDouble0 m_statInstr; // Instruction count
|
||||
VDouble0 m_statInstrFast; // Instruction count, non-slow() eval functions only
|
||||
std::vector<VDouble0> m_statVarWidths; // Variables of given width
|
||||
|
@ -306,7 +306,7 @@ uint64_t VHashSha256::digestUInt64() {
|
||||
}
|
||||
|
||||
string VHashSha256::digestHex() {
|
||||
static const char digits[16 + 1] = "0123456789abcdef";
|
||||
static const char* digits = "0123456789abcdef";
|
||||
const string& binhash = digestBinary();
|
||||
string out;
|
||||
out.reserve(70);
|
||||
@ -322,8 +322,7 @@ string VHashSha256::digestSymbol() {
|
||||
// has + and / for last two digits, but need C symbol, and we also
|
||||
// avoid conflicts with use of _, so use "AB" at the end.
|
||||
// Thus this function is non-reversible.
|
||||
static const char digits[64 + 1]
|
||||
= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789AB";
|
||||
static const char* digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789AB";
|
||||
const string& binhash = digestBinary();
|
||||
string out;
|
||||
out.reserve(28);
|
||||
@ -408,9 +407,9 @@ VSpellCheck::EditDistance VSpellCheck::editDistance(const string& s, const strin
|
||||
if (sLen >= LENGTH_LIMIT) return sLen;
|
||||
if (tLen >= LENGTH_LIMIT) return tLen;
|
||||
|
||||
static EditDistance s_v_two_ago[LENGTH_LIMIT + 1];
|
||||
static EditDistance s_v_one_ago[LENGTH_LIMIT + 1];
|
||||
static EditDistance s_v_next[LENGTH_LIMIT + 1];
|
||||
static std::array<EditDistance, LENGTH_LIMIT + 1> s_v_two_ago;
|
||||
static std::array<EditDistance, LENGTH_LIMIT + 1> s_v_one_ago;
|
||||
static std::array<EditDistance, LENGTH_LIMIT + 1> s_v_next;
|
||||
|
||||
for (size_t i = 0; i < sLen + 1; i++) s_v_one_ago[i] = i;
|
||||
|
||||
|
@ -1580,7 +1580,7 @@ bool V3Task::dpiToInternalFrStmt(AstVar* portp, const string& frName, string& fr
|
||||
}
|
||||
|
||||
const char* V3Task::dpiTemporaryVarSuffix() {
|
||||
static const char suffix[] = "__Vcvt";
|
||||
static const char* suffix = "__Vcvt";
|
||||
return suffix;
|
||||
}
|
||||
|
||||
|
@ -237,7 +237,7 @@ private:
|
||||
AstUser2InUse m_inuser2;
|
||||
|
||||
// STATE
|
||||
std::vector<UndrivenVarEntry*> m_entryps[3]; // Nodes to delete when we are finished
|
||||
std::array<std::vector<UndrivenVarEntry*>, 3> m_entryps; // Nodes to delete when finished
|
||||
bool m_inBBox = false; // In black box; mark as driven+used
|
||||
bool m_inContAssign = false; // In continuous assignment
|
||||
bool m_inProcAssign = false; // In procedural assignment
|
||||
|
Loading…
Reference in New Issue
Block a user