2012-04-13 01:08:20 +00:00
|
|
|
|
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
2010-03-17 12:22:49 +00:00
|
|
|
|
//*************************************************************************
|
|
|
|
|
//
|
2013-01-01 14:42:59 +00:00
|
|
|
|
// Copyright 2003-2013 by Wilson Snyder. This program is free software; you can
|
2010-03-17 12:22:49 +00:00
|
|
|
|
// redistribute it and/or modify it under the terms of either the GNU
|
|
|
|
|
// Lesser General Public License Version 3 or the Perl Artistic License.
|
|
|
|
|
// Version 2.0.
|
|
|
|
|
//
|
|
|
|
|
// Verilator is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
//*************************************************************************
|
|
|
|
|
///
|
|
|
|
|
/// \file
|
|
|
|
|
/// \brief Verilator: Include to allow symbol inspection
|
|
|
|
|
///
|
|
|
|
|
/// This file is for inclusion by files that need to inspect
|
|
|
|
|
/// the symbol table. It is not included in verilated.h
|
|
|
|
|
/// as it requires some heavyweight C++ classes.
|
|
|
|
|
///
|
|
|
|
|
/// Code available from: http://www.veripool.org/verilator
|
|
|
|
|
///
|
|
|
|
|
//*************************************************************************
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _VERILATED_SYMS_H_
|
|
|
|
|
#define _VERILATED_SYMS_H_ 1 ///< Header Guard
|
|
|
|
|
|
|
|
|
|
#include "verilated_heavy.h"
|
|
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
|
|
//======================================================================
|
|
|
|
|
// Types
|
|
|
|
|
|
|
|
|
|
struct VerilatedCStrCmp {
|
|
|
|
|
/// Ordering maps keyed by const char*'s
|
|
|
|
|
bool operator() (const char *a, const char *b) const {
|
|
|
|
|
return std::strcmp(a, b) < 0;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
/// Verilator range
|
|
|
|
|
|
2013-06-13 12:05:38 +00:00
|
|
|
|
// See also V3Ast::VNumRange
|
2010-03-17 12:22:49 +00:00
|
|
|
|
class VerilatedRange {
|
2013-06-13 12:05:38 +00:00
|
|
|
|
int m_left;
|
|
|
|
|
int m_right;
|
2010-03-17 12:22:49 +00:00
|
|
|
|
protected:
|
|
|
|
|
friend class VerilatedVar;
|
|
|
|
|
friend class VerilatedScope;
|
2013-06-13 12:05:38 +00:00
|
|
|
|
VerilatedRange() : m_left(0), m_right(0) {}
|
|
|
|
|
void sets(int left, int right) { m_left=left; m_right=right; }
|
2010-03-17 12:22:49 +00:00
|
|
|
|
public:
|
|
|
|
|
~VerilatedRange() {}
|
2013-06-13 12:05:38 +00:00
|
|
|
|
int left() const { return m_left; }
|
|
|
|
|
int right() const { return m_right; }
|
|
|
|
|
int elements() const { return (VL_LIKELY(m_left>=m_right)?(m_left-m_right+1):(m_right-m_left+1)); }
|
2010-03-17 12:22:49 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
/// Verilator variable
|
|
|
|
|
|
|
|
|
|
class VerilatedVar {
|
|
|
|
|
void* m_datap; // Location of data
|
|
|
|
|
VerilatedVarType m_vltype; // Data type
|
2010-04-06 00:01:17 +00:00
|
|
|
|
VerilatedVarFlags m_vlflags; // Direction
|
2010-03-17 12:22:49 +00:00
|
|
|
|
VerilatedRange m_range; // First range
|
|
|
|
|
VerilatedRange m_array; // Array
|
2010-04-06 00:01:17 +00:00
|
|
|
|
int m_dims; // Dimensions
|
2010-03-17 12:22:49 +00:00
|
|
|
|
const char* m_namep; // Name - slowpath
|
|
|
|
|
protected:
|
|
|
|
|
friend class VerilatedScope;
|
2010-04-06 00:01:17 +00:00
|
|
|
|
VerilatedVar(const char* namep, void* datap,
|
|
|
|
|
VerilatedVarType vltype, VerilatedVarFlags vlflags, int dims)
|
|
|
|
|
: m_datap(datap), m_vltype(vltype), m_vlflags(vlflags), m_dims(dims), m_namep(namep) {}
|
2010-03-17 12:22:49 +00:00
|
|
|
|
public:
|
|
|
|
|
~VerilatedVar() {}
|
|
|
|
|
void* datap() const { return m_datap; }
|
|
|
|
|
VerilatedVarType vltype() const { return m_vltype; }
|
2010-04-06 00:01:17 +00:00
|
|
|
|
VerilatedVarFlags vldir() const { return (VerilatedVarFlags)((int)m_vlflags & VLVF_MASK_DIR); }
|
|
|
|
|
vluint32_t entSize() const;
|
|
|
|
|
bool isPublicRW() const { return ((m_vlflags & VLVF_PUB_RW) != 0); }
|
2010-03-17 12:22:49 +00:00
|
|
|
|
const VerilatedRange& range() const { return m_range; }
|
|
|
|
|
const VerilatedRange& array() const { return m_array; }
|
2010-04-06 00:01:17 +00:00
|
|
|
|
const char* name() const { return m_namep; }
|
|
|
|
|
int dims() const { return m_dims; }
|
2010-03-17 12:22:49 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//======================================================================
|
|
|
|
|
/// Types
|
|
|
|
|
|
|
|
|
|
struct VerilatedVarNameMap : public map<const char*, VerilatedVar, VerilatedCStrCmp> {
|
|
|
|
|
VerilatedVarNameMap() {}
|
|
|
|
|
~VerilatedVarNameMap() {}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // Guard
|