mirror of
https://github.com/verilator/verilator.git
synced 2025-01-01 04:07:34 +00:00
Internals: Add VL_UNCOPYABLE to make classes uncopyable. No functional change intended.
This commit is contained in:
parent
2a4e830bee
commit
add5cc8b56
@ -127,8 +127,7 @@ class VL_CAPABILITY("mutex") VerilatedMutex {
|
||||
|
||||
/// Lock guard for mutex (ala std::lock_guard), wrapped to allow -fthread_safety checks
|
||||
class VL_SCOPED_CAPABILITY VerilatedLockGuard {
|
||||
VerilatedLockGuard(); ///< N/A, always use named constructor below
|
||||
VerilatedLockGuard(const VerilatedLockGuard&); ///< N/A, no copy constructor
|
||||
VL_UNCOPYABLE(VerilatedLockGuard);
|
||||
private:
|
||||
VerilatedMutex& m_mutexr;
|
||||
public:
|
||||
@ -182,10 +181,9 @@ public:
|
||||
/// Base class for all Verilated module classes
|
||||
|
||||
class VerilatedModule {
|
||||
VL_UNCOPYABLE(VerilatedModule);
|
||||
private:
|
||||
const char* m_namep; ///< Module name
|
||||
VerilatedModule() VL_EQ_DELETE; ///< N/A, always use named constructor below
|
||||
VerilatedModule(const VerilatedModule& ) VL_EQ_DELETE; ///< N/A, no copy constructor
|
||||
public:
|
||||
explicit VerilatedModule(const char* namep); ///< Create module with given hierarchy name
|
||||
~VerilatedModule();
|
||||
@ -346,8 +344,11 @@ class Verilated {
|
||||
~ThreadLocal();
|
||||
} t_s;
|
||||
|
||||
public:
|
||||
private:
|
||||
// CONSTRUCTORS
|
||||
VL_UNCOPYABLE(Verilated);
|
||||
|
||||
public:
|
||||
// METHODS - User called
|
||||
|
||||
/// Select initial value of otherwise uninitialized signals.
|
||||
|
@ -111,6 +111,7 @@ private:
|
||||
m_insertFilenamep = NULL;
|
||||
m_insertLineno = 0;
|
||||
}
|
||||
VL_UNCOPYABLE(VerilatedCovImp);
|
||||
public:
|
||||
~VerilatedCovImp() { clearGuts(); }
|
||||
static VerilatedCovImp& imp() VL_MT_SAFE {
|
||||
|
@ -85,6 +85,7 @@ template< class T> std::string vlCovCvtToStr (const T& t) VL_PURE {
|
||||
/// All public methods in this class are thread safe.
|
||||
|
||||
class VerilatedCov {
|
||||
VL_UNCOPYABLE(VerilatedCov);
|
||||
public:
|
||||
// GLOBAL METHODS
|
||||
/// Return default filename
|
||||
|
@ -86,8 +86,8 @@ public:
|
||||
// CONSTRUCTORS
|
||||
VerilatedEvalMsgQueue() : m_depth(0) { }
|
||||
~VerilatedEvalMsgQueue() { }
|
||||
VerilatedEvalMsgQueue(const VerilatedEvalMsgQueue&) = delete;
|
||||
VerilatedEvalMsgQueue& operator=(const VerilatedEvalMsgQueue&) = delete;
|
||||
private:
|
||||
VL_UNCOPYABLE(VerilatedEvalMsgQueue);
|
||||
public:
|
||||
// METHODS
|
||||
//// Add message to queue (called by producer)
|
||||
@ -133,9 +133,8 @@ public:
|
||||
// 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.
|
||||
}
|
||||
VerilatedThreadMsgQueue(const VerilatedThreadMsgQueue&) = delete;
|
||||
VerilatedThreadMsgQueue& operator=(const VerilatedThreadMsgQueue&) = delete;
|
||||
private:
|
||||
VL_UNCOPYABLE(VerilatedThreadMsgQueue);
|
||||
// METHODS
|
||||
static VerilatedThreadMsgQueue& threadton() {
|
||||
static VL_THREAD_LOCAL VerilatedThreadMsgQueue t_s;
|
||||
@ -207,6 +206,9 @@ public: // But only for verilated*.cpp
|
||||
m_fdps[2] = stderr;
|
||||
}
|
||||
~VerilatedImp() {}
|
||||
private:
|
||||
VL_UNCOPYABLE(VerilatedImp);
|
||||
public:
|
||||
static void internalsDump() VL_MT_SAFE {
|
||||
VerilatedLockGuard guard(s_s.m_argMutex);
|
||||
VL_PRINTF_MT("internalsDump:\n");
|
||||
|
@ -45,8 +45,10 @@ protected:
|
||||
|
||||
void header() VL_MT_UNSAFE_ONE;
|
||||
void trailer() VL_MT_UNSAFE_ONE;
|
||||
|
||||
// CONSTRUCTORS
|
||||
VL_UNCOPYABLE(VerilatedSerialize);
|
||||
public:
|
||||
// CREATORS
|
||||
VerilatedSerialize() {
|
||||
m_isOpen = false;
|
||||
m_bufp = new vluint8_t [bufferSize()];
|
||||
@ -73,7 +75,6 @@ public:
|
||||
return *this; // For function chaining
|
||||
}
|
||||
private:
|
||||
VerilatedSerialize(const VerilatedSerialize&) VL_EQ_DELETE; ///< N/A, no copy constructor
|
||||
VerilatedSerialize& bufferCheck() VL_MT_UNSAFE_ONE {
|
||||
// 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
|
||||
@ -105,8 +106,10 @@ protected:
|
||||
virtual void fill() = 0;
|
||||
void header() VL_MT_UNSAFE_ONE;
|
||||
void trailer() VL_MT_UNSAFE_ONE;
|
||||
|
||||
// CONSTRUCTORS
|
||||
VL_UNCOPYABLE(VerilatedDeserialize);
|
||||
public:
|
||||
// CREATORS
|
||||
VerilatedDeserialize() {
|
||||
m_isOpen = false;
|
||||
m_bufp = new vluint8_t [bufferSize()];
|
||||
@ -137,7 +140,6 @@ public:
|
||||
VerilatedDeserialize& readAssert(const void* __restrict datap, size_t size) VL_MT_UNSAFE_ONE;
|
||||
VerilatedDeserialize& readAssert(vluint64_t data) VL_MT_UNSAFE_ONE { return readAssert(&data, sizeof(data)); }
|
||||
private:
|
||||
VerilatedDeserialize(const VerilatedDeserialize&) VL_EQ_DELETE; ///< N/A, no copy constructor
|
||||
bool readDiffers(const void* __restrict datap, size_t size) VL_MT_UNSAFE_ONE;
|
||||
VerilatedDeserialize& bufferCheck() VL_MT_UNSAFE_ONE {
|
||||
// Flush the write buffer if there's not enough space left for new information
|
||||
@ -158,7 +160,7 @@ private:
|
||||
int m_fd; ///< File descriptor we're writing to
|
||||
|
||||
public:
|
||||
// CREATORS
|
||||
// CONSTRUCTORS
|
||||
VerilatedSave() { m_fd=-1; }
|
||||
virtual ~VerilatedSave() { close(); }
|
||||
// METHODS
|
||||
@ -177,7 +179,7 @@ private:
|
||||
int m_fd; ///< File descriptor we're writing to
|
||||
|
||||
public:
|
||||
// CREATORS
|
||||
// CONSTRUCTORS
|
||||
VerilatedRestore() { m_fd=-1; }
|
||||
virtual ~VerilatedRestore() { close(); }
|
||||
|
||||
|
@ -96,7 +96,7 @@ protected:
|
||||
VerilatedVcdCallback_t m_changecb; ///< Incremental Dumping Callback function
|
||||
void* m_userthis; ///< Fake "this" for caller
|
||||
vluint32_t m_code; ///< Starting code number
|
||||
// CREATORS
|
||||
// CONSTRUCTORS
|
||||
VerilatedVcdCallInfo (VerilatedVcdCallback_t icb, VerilatedVcdCallback_t fcb,
|
||||
VerilatedVcdCallback_t changecb,
|
||||
void* ut, vluint32_t code)
|
||||
|
@ -147,14 +147,9 @@ private:
|
||||
return out + static_cast<char>((code)%94+33);
|
||||
}
|
||||
|
||||
VerilatedVcd(const VerilatedVcd&) VL_EQ_DELETE; ///< N/A, no copy constructor
|
||||
|
||||
protected:
|
||||
// METHODS
|
||||
void evcd(bool flag) { m_evcd = flag; }
|
||||
|
||||
// CONSTRUCTORS
|
||||
VL_UNCOPYABLE(VerilatedVcd);
|
||||
public:
|
||||
// CREATORS
|
||||
explicit VerilatedVcd(VerilatedVcdFile* filep=NULL);
|
||||
~VerilatedVcd();
|
||||
|
||||
@ -396,6 +391,10 @@ public:
|
||||
fullFloat (code, newval);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
// METHODS
|
||||
void evcd(bool flag) { m_evcd = flag; }
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
@ -406,10 +405,13 @@ public:
|
||||
|
||||
class VerilatedVcdC {
|
||||
VerilatedVcd m_sptrace; ///< Trace file being created
|
||||
public:
|
||||
|
||||
// CONSTRUCTORS
|
||||
VL_UNCOPYABLE(VerilatedVcdC);
|
||||
public:
|
||||
explicit VerilatedVcdC(VerilatedVcdFile* filep=NULL) : m_sptrace(filep) {}
|
||||
~VerilatedVcdC() {}
|
||||
public:
|
||||
// ACCESSORS
|
||||
/// Is file open?
|
||||
bool isOpen() const { return m_sptrace.isOpen(); }
|
||||
|
@ -39,6 +39,8 @@ class VerilatedVcdSc
|
||||
: sc_trace_file
|
||||
, public VerilatedVcdC
|
||||
{
|
||||
// CONSTRUCTORS
|
||||
VL_UNCOPYABLE(VerilatedVcdSc);
|
||||
public:
|
||||
VerilatedVcdSc() {
|
||||
sc_get_curr_simcontext()->add_trace_file(this);
|
||||
@ -58,8 +60,9 @@ public:
|
||||
spTrace()->set_time_resolution(sc_get_time_resolution().to_string());
|
||||
# endif
|
||||
}
|
||||
|
||||
virtual ~VerilatedVcdSc() {}
|
||||
|
||||
// METHODS
|
||||
/// Called by SystemC simulate()
|
||||
virtual void cycle (bool delta_cycle) {
|
||||
# if (SYSTEMC_VERSION>20011000)
|
||||
|
@ -311,6 +311,14 @@ typedef unsigned long long vluint64_t; ///< 64-bit unsigned type
|
||||
/// Words this number of bits needs (1 bit=1 word)
|
||||
#define VL_WORDS_I(nbits) (((nbits)+(VL_WORDSIZE-1))/VL_WORDSIZE)
|
||||
|
||||
//=========================================================================
|
||||
// Class definition helpers
|
||||
|
||||
// Used to declare a class as uncopyable; put after a private:
|
||||
#define VL_UNCOPYABLE(Type) \
|
||||
Type(const Type& other) VL_EQ_DELETE; \
|
||||
Type& operator= (const Type&) VL_EQ_DELETE
|
||||
|
||||
//=========================================================================
|
||||
// Verilated function size macros
|
||||
|
||||
|
@ -942,7 +942,7 @@ public:
|
||||
inline bool operator== (const V3Hash& rh) const { return m_both==rh.m_both; }
|
||||
inline bool operator!= (const V3Hash& rh) const { return m_both!=rh.m_both; }
|
||||
inline bool operator< (const V3Hash& rh) const { return m_both<rh.m_both; }
|
||||
// CREATORS
|
||||
// CONSTRUCTORS
|
||||
class Illegal {}; // for creator type-overload selection
|
||||
class FullValue {}; // for creator type-overload selection
|
||||
explicit V3Hash(Illegal) { m_both=0; }
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
class V3Branch {
|
||||
public:
|
||||
// CREATORS
|
||||
// CONSTRUCTORS
|
||||
static void branchAll(AstNetlist* rootp);
|
||||
};
|
||||
|
||||
|
@ -96,7 +96,7 @@ public:
|
||||
}
|
||||
~V3CCtorsVisitor() {}
|
||||
private:
|
||||
explicit V3CCtorsVisitor(const V3CCtorsVisitor&) VL_EQ_DELETE; ///< N/A, no copy constructor
|
||||
VL_UNCOPYABLE(V3CCtorsVisitor);
|
||||
};
|
||||
|
||||
//######################################################################
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
class V3Coverage {
|
||||
public:
|
||||
// CREATORS
|
||||
// CONSTRUCTORS
|
||||
static void coverage(AstNetlist* rootp);
|
||||
};
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
class V3CoverageJoin {
|
||||
public:
|
||||
// CREATORS
|
||||
// CONSTRUCTORS
|
||||
static void coverageJoin(AstNetlist* rootp);
|
||||
};
|
||||
|
||||
|
@ -215,7 +215,7 @@ class V3Error {
|
||||
V3Error() { cerr<<("Static class"); abort(); }
|
||||
|
||||
public:
|
||||
// CREATORS
|
||||
// CONSTRUCTORS
|
||||
// ACCESSORS
|
||||
static void debugDefault(int level) { s_debugDefault = level; }
|
||||
static int debugDefault() { return s_debugDefault; }
|
||||
|
15
src/V3File.h
15
src/V3File.h
@ -76,19 +76,22 @@ public:
|
||||
class V3InFilterImp;
|
||||
|
||||
class V3InFilter {
|
||||
V3InFilterImp* m_impp;
|
||||
V3InFilter(const V3InFilter&) VL_EQ_DELETE; ///< N/A, no copy constructor
|
||||
public:
|
||||
// TYPES
|
||||
typedef list<string> StrList;
|
||||
|
||||
private:
|
||||
V3InFilterImp* m_impp;
|
||||
|
||||
// CONSTRUCTORS
|
||||
VL_UNCOPYABLE(V3InFilter);
|
||||
public:
|
||||
explicit V3InFilter(const string& command);
|
||||
~V3InFilter();
|
||||
|
||||
// METHODS
|
||||
// Read file contents and return it. Return true on success.
|
||||
bool readWholefile(const string& filename, StrList& outl);
|
||||
|
||||
// CONSTRUCTORS
|
||||
explicit V3InFilter(const string& command);
|
||||
~V3InFilter();
|
||||
};
|
||||
|
||||
//============================================================================
|
||||
|
@ -75,7 +75,7 @@ public:
|
||||
V3Options opt; // All options; let user see them directly
|
||||
|
||||
public:
|
||||
// CREATORS
|
||||
// CONSTRUCTORS
|
||||
V3Global() {
|
||||
m_debugFileNumber = 0;
|
||||
m_widthMinUsage = VWidthMinUsage::LINT_WIDTH;
|
||||
|
@ -180,10 +180,9 @@ class V3Options {
|
||||
bool parseLangExt(const char* swp, const char* langswp, const V3LangCode& lc);
|
||||
string filePathCheckOneDir(const string& modname, const string& dirname);
|
||||
|
||||
V3Options(const V3Options&) VL_EQ_DELETE; ///< N/A, no copy constructor
|
||||
|
||||
// CONSTRUCTORS
|
||||
VL_UNCOPYABLE(V3Options);
|
||||
public:
|
||||
// CREATORS
|
||||
V3Options();
|
||||
~V3Options();
|
||||
void setDebugMode(int level);
|
||||
|
@ -36,9 +36,9 @@ class V3Parse {
|
||||
private:
|
||||
V3ParseImp* m_impp;
|
||||
|
||||
V3Parse(const V3Parse&) VL_EQ_DELETE; ///< N/A, no copy constructor
|
||||
public:
|
||||
// CONSTRUCTORS
|
||||
VL_UNCOPYABLE(V3Parse);
|
||||
public:
|
||||
// We must allow reading multiple files into one parser
|
||||
V3Parse(AstNetlist* rootp, V3InFilter* filterp, V3ParseSym* symp);
|
||||
~V3Parse();
|
||||
|
@ -210,7 +210,7 @@ public:
|
||||
V3ParseSym* symp() { return m_symp; }
|
||||
|
||||
public:
|
||||
// CREATORS
|
||||
// CONSTRUCTORS
|
||||
V3ParseImp(AstNetlist* rootp, V3InFilter* filterp, V3ParseSym* parserSymp)
|
||||
: m_rootp(rootp), m_filterp(filterp), m_symp(parserSymp) {
|
||||
m_fileline = NULL;
|
||||
|
@ -43,6 +43,17 @@ private:
|
||||
VSymEnt* m_symCurrentp; // Active symbol table for additions/lookups
|
||||
SymStack m_sympStack; // Stack of upper nodes with pending symbol tables
|
||||
|
||||
public:
|
||||
// CONSTRUCTORS
|
||||
explicit V3ParseSym(AstNetlist* rootp)
|
||||
: m_syms(rootp) {
|
||||
s_anonNum = 0; // Number of next anonymous object
|
||||
pushScope(findNewTable(rootp));
|
||||
m_symTableNextId = NULL;
|
||||
m_symCurrentp = symCurrentp();
|
||||
}
|
||||
~V3ParseSym() {}
|
||||
|
||||
private:
|
||||
// METHODS
|
||||
static VSymEnt* getTable(AstNode* nodep) {
|
||||
@ -146,16 +157,6 @@ public:
|
||||
// Export *::* from remote packages
|
||||
symCurrentp()->exportStarStar(&m_syms);
|
||||
}
|
||||
public:
|
||||
// CREATORS
|
||||
explicit V3ParseSym(AstNetlist* rootp)
|
||||
: m_syms(rootp) {
|
||||
s_anonNum = 0; // Number of next anonymous object
|
||||
pushScope(findNewTable(rootp));
|
||||
m_symTableNextId = NULL;
|
||||
m_symCurrentp = symCurrentp();
|
||||
}
|
||||
~V3ParseSym() {}
|
||||
};
|
||||
|
||||
#endif // Guard
|
||||
|
@ -245,18 +245,24 @@ class VSymGraph {
|
||||
// TYPES
|
||||
typedef vector<VSymEnt*> SymStack;
|
||||
|
||||
private:
|
||||
// MEMBERS
|
||||
VSymEnt* m_symRootp; // Root symbol table
|
||||
SymStack m_symsp; // All symbol tables, to cleanup
|
||||
|
||||
VSymGraph(const VSymGraph&) VL_EQ_DELETE; ///< N/A, no copy constructor
|
||||
|
||||
protected:
|
||||
friend class VSymEnt;
|
||||
void pushNewEnt(VSymEnt* entp) { m_symsp.push_back(entp); }
|
||||
// CONSTRUCTORS
|
||||
VL_UNCOPYABLE(VSymGraph);
|
||||
public:
|
||||
explicit VSymGraph(AstNetlist* nodep) {
|
||||
m_symRootp = new VSymEnt(this, nodep);
|
||||
}
|
||||
~VSymGraph() {
|
||||
for (SymStack::iterator it = m_symsp.begin(); it != m_symsp.end(); ++it) {
|
||||
delete (*it);
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
// METHODS
|
||||
VSymEnt* rootp() const { return m_symRootp; }
|
||||
// Debug
|
||||
void dump(ostream& os, const string& indent="") {
|
||||
@ -280,16 +286,10 @@ public:
|
||||
dump(*logp, "");
|
||||
}
|
||||
}
|
||||
public:
|
||||
// CREATORS
|
||||
explicit VSymGraph(AstNetlist* nodep) {
|
||||
m_symRootp = new VSymEnt(this, nodep);
|
||||
}
|
||||
~VSymGraph() {
|
||||
for (SymStack::iterator it = m_symsp.begin(); it != m_symsp.end(); ++it) {
|
||||
delete (*it);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
friend class VSymEnt;
|
||||
void pushNewEnt(VSymEnt* entp) { m_symsp.push_back(entp); }
|
||||
};
|
||||
|
||||
//######################################################################
|
||||
|
@ -52,7 +52,7 @@ private:
|
||||
bool onoff(const char* sw, const char* arg, bool& flag);
|
||||
|
||||
public:
|
||||
// CREATORS
|
||||
// CONSTRUCTORS
|
||||
VlcOptions() {
|
||||
m_annotateAll = false;
|
||||
m_annotateMin = 10;
|
||||
|
Loading…
Reference in New Issue
Block a user