2012-04-13 01:08:20 +00:00
|
|
|
|
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
2009-12-03 11:55:29 +00:00
|
|
|
|
//*************************************************************************
|
|
|
|
|
//
|
2017-01-15 17:09:59 +00:00
|
|
|
|
// Copyright 2009-2017 by Wilson Snyder. This program is free software; you can
|
2009-12-03 11:55:29 +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: DPI implementation code
|
|
|
|
|
///
|
2017-12-09 22:01:53 +00:00
|
|
|
|
/// This file must be compiled and linked against all objects
|
|
|
|
|
/// created from Verilator or called by Verilator that use the DPI.
|
2009-12-03 11:55:29 +00:00
|
|
|
|
///
|
|
|
|
|
/// Code available from: http://www.veripool.org/verilator
|
|
|
|
|
///
|
|
|
|
|
//=========================================================================
|
|
|
|
|
|
2010-01-24 13:38:17 +00:00
|
|
|
|
#define _VERILATED_DPI_CPP_
|
2009-12-03 11:55:29 +00:00
|
|
|
|
#include "verilatedos.h"
|
2011-05-21 01:33:31 +00:00
|
|
|
|
#include "verilated_dpi.h"
|
2010-01-24 13:38:17 +00:00
|
|
|
|
#include "verilated_imp.h"
|
2010-01-24 11:20:10 +00:00
|
|
|
|
|
|
|
|
|
// On MSVC++ we need svdpi.h to declare exports, not imports
|
|
|
|
|
#define DPI_PROTOTYPES
|
2017-10-08 01:21:12 +00:00
|
|
|
|
#undef XXTERN
|
2010-01-24 11:20:10 +00:00
|
|
|
|
#define XXTERN DPI_EXTERN DPI_DLLESPEC
|
2017-10-08 01:21:12 +00:00
|
|
|
|
#undef EETERN
|
2010-01-24 11:20:10 +00:00
|
|
|
|
#define EETERN DPI_EXTERN DPI_DLLESPEC
|
|
|
|
|
|
2010-02-02 02:39:50 +00:00
|
|
|
|
#include "vltstd/svdpi.h"
|
2009-12-03 11:55:29 +00:00
|
|
|
|
|
|
|
|
|
//======================================================================
|
|
|
|
|
// Internal macros
|
|
|
|
|
|
2009-12-05 15:38:49 +00:00
|
|
|
|
// Not supported yet
|
|
|
|
|
#define _VL_SVDPI_UNIMP() \
|
2017-10-19 23:40:51 +00:00
|
|
|
|
VL_FATAL_MT(__FILE__,__LINE__,"",(std::string("%%Error: Unsupported DPI function: ")+VL_FUNC).c_str())
|
2009-12-03 11:55:29 +00:00
|
|
|
|
|
|
|
|
|
// Function requires a "context" in the import declaration
|
2009-12-05 15:38:49 +00:00
|
|
|
|
#define _VL_SVDPI_CONTEXT_WARN() \
|
2017-10-19 23:40:51 +00:00
|
|
|
|
VL_PRINTF_MT("%%Warning: DPI C Function called by Verilog DPI import with missing 'context' keyword.\n");
|
2009-12-03 11:55:29 +00:00
|
|
|
|
|
2017-12-10 01:17:37 +00:00
|
|
|
|
// Function requires svOpenArrayHandle dimensionality
|
|
|
|
|
#define _VL_SVDPI_DIMENSION_CHECK(d, dimensions) \
|
|
|
|
|
do { if (VL_UNLIKELY(svDimensions(d) != (dimensions))) { \
|
|
|
|
|
VL_PRINTF_MT("%%Warning: %s called on array that is not %d dimensional.\n", __FUNCTION__, dimensions); \
|
|
|
|
|
} } while(0)
|
|
|
|
|
|
2009-12-03 11:55:29 +00:00
|
|
|
|
//======================================================================
|
2009-12-05 15:38:49 +00:00
|
|
|
|
//======================================================================
|
|
|
|
|
//======================================================================
|
|
|
|
|
// DPI ROUTINES
|
|
|
|
|
|
2009-12-03 11:55:29 +00:00
|
|
|
|
const char* svDpiVersion() {
|
2010-01-22 03:17:43 +00:00
|
|
|
|
return "1800-2005";
|
2009-12-03 11:55:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//======================================================================
|
|
|
|
|
// Bit-select utility functions.
|
|
|
|
|
|
2017-08-29 02:41:38 +00:00
|
|
|
|
svBit svGetBitselBit(const svBitVecVal* sp, int bit) {
|
2017-12-09 22:01:53 +00:00
|
|
|
|
return VL_BITRSHIFT_W(sp,bit) & 1;
|
2009-12-03 11:55:29 +00:00
|
|
|
|
}
|
2017-08-29 02:41:38 +00:00
|
|
|
|
svLogic svGetBitselLogic(const svLogicVecVal* sp, int bit) {
|
2017-12-09 22:01:53 +00:00
|
|
|
|
// Not VL_BITRSHIFT_W as sp is a different structure type
|
|
|
|
|
// Verilator doesn't support X/Z so only aval
|
|
|
|
|
return (sp[VL_BITWORD_I(bit)].aval >> VL_BITBIT_I(bit)) & 1;
|
2009-12-03 11:55:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-29 02:41:38 +00:00
|
|
|
|
void svPutBitselBit(svBitVecVal* dp, int bit, svBit s) {
|
|
|
|
|
VL_ASSIGNBIT_WI(32, bit, dp, s);
|
2009-12-03 11:55:29 +00:00
|
|
|
|
}
|
2017-08-29 02:41:38 +00:00
|
|
|
|
void svPutBitselLogic(svLogicVecVal* dp, int bit, svLogic s) {
|
2017-12-09 22:01:53 +00:00
|
|
|
|
// Verilator doesn't support X/Z so only aval
|
|
|
|
|
dp[VL_BITWORD_I(bit)].aval
|
|
|
|
|
= ((dp[VL_BITWORD_I(bit)].aval & ~(VL_UL(1)<<VL_BITBIT_I(bit)))
|
|
|
|
|
| ((s&1)<<VL_BITBIT_I(bit)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void svGetPartselBit(svBitVecVal* dp, const svBitVecVal* sp, int lsb, int width) {
|
|
|
|
|
// See also VL_SEL_WWI
|
|
|
|
|
int msb = lsb+width-1;
|
|
|
|
|
int word_shift = VL_BITWORD_I(lsb);
|
|
|
|
|
if (VL_BITBIT_I(lsb)==0) {
|
|
|
|
|
// Just a word extract
|
|
|
|
|
for (int i=0; i<VL_WORDS_I(width); ++i) dp[i] = sp[i+word_shift];
|
|
|
|
|
} else {
|
|
|
|
|
int loffset = lsb & VL_SIZEBITS_I;
|
|
|
|
|
int nbitsfromlow = 32-loffset; // bits that end up in lword (know loffset!=0)
|
|
|
|
|
// Middle words
|
|
|
|
|
int words = VL_WORDS_I(msb-lsb+1);
|
|
|
|
|
for (int i=0; i<words; ++i) {
|
|
|
|
|
dp[i] = sp[i+word_shift]>>loffset;
|
|
|
|
|
int upperword = i+word_shift+1;
|
|
|
|
|
if (upperword <= static_cast<int>(VL_BITWORD_I(msb))) {
|
|
|
|
|
dp[i] |= sp[upperword] << nbitsfromlow;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Clean result
|
|
|
|
|
dp[VL_WORDS_I(width)-1] &= VL_MASK_I(width);
|
|
|
|
|
}
|
|
|
|
|
void svGetPartselLogic(svLogicVecVal* dp, const svLogicVecVal* sp, int lsb, int width) {
|
|
|
|
|
int msb = lsb+width-1;
|
|
|
|
|
int word_shift = VL_BITWORD_I(lsb);
|
|
|
|
|
if (VL_BITBIT_I(lsb)==0) {
|
|
|
|
|
// Just a word extract
|
|
|
|
|
for (int i=0; i<VL_WORDS_I(width); ++i) dp[i] = sp[i+word_shift];
|
|
|
|
|
} else {
|
|
|
|
|
int loffset = lsb & VL_SIZEBITS_I;
|
|
|
|
|
int nbitsfromlow = 32-loffset; // bits that end up in lword (know loffset!=0)
|
|
|
|
|
// Middle words
|
|
|
|
|
int words = VL_WORDS_I(msb-lsb+1);
|
|
|
|
|
for (int i=0; i<words; ++i) {
|
|
|
|
|
dp[i].aval = sp[i+word_shift].aval >> loffset;
|
|
|
|
|
dp[i].bval = sp[i+word_shift].bval >> loffset;
|
|
|
|
|
int upperword = i+word_shift+1;
|
|
|
|
|
if (upperword <= static_cast<int>(VL_BITWORD_I(msb))) {
|
|
|
|
|
dp[i].aval |= sp[upperword].aval << nbitsfromlow;
|
|
|
|
|
dp[i].bval |= sp[upperword].bval << nbitsfromlow;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Clean result
|
|
|
|
|
dp[VL_WORDS_I(width)-1].aval &= VL_MASK_I(width);
|
|
|
|
|
dp[VL_WORDS_I(width)-1].bval &= VL_MASK_I(width);
|
|
|
|
|
}
|
|
|
|
|
void svPutPartselBit(svBitVecVal* dp, const svBitVecVal* sp, int lbit, int width) {
|
|
|
|
|
// See also _VL_INSERT_WW
|
|
|
|
|
int hbit = lbit+width-1;
|
|
|
|
|
int hoffset = hbit & VL_SIZEBITS_I;
|
|
|
|
|
int loffset = lbit & VL_SIZEBITS_I;
|
|
|
|
|
int lword = VL_BITWORD_I(lbit);
|
|
|
|
|
int words = VL_WORDS_I(hbit-lbit+1);
|
|
|
|
|
if (hoffset==VL_SIZEBITS_I && loffset==0) {
|
|
|
|
|
// Fast and common case, word based insertion
|
|
|
|
|
for (int i=0; i<words; ++i) {
|
|
|
|
|
dp[lword+i] = sp[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (loffset==0) {
|
|
|
|
|
// Non-32bit, but nicely aligned, so stuff all but the last word
|
|
|
|
|
for (int i=0; i<(words-1); ++i) {
|
|
|
|
|
dp[lword+i] = sp[i];
|
|
|
|
|
}
|
|
|
|
|
IData hinsmask = (VL_MASK_I(hoffset-0+1)); // Know it's not a full word as above fast case handled it
|
|
|
|
|
dp[lword+words-1] = (dp[words+lword-1] & ~hinsmask) | (sp[words-1] & hinsmask);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
IData hinsmask = (VL_MASK_I(hoffset-0+1))<<0;
|
|
|
|
|
IData linsmask = (VL_MASK_I(31-loffset+1))<<loffset;
|
|
|
|
|
int nbitsonright = 32-loffset; // bits that end up in lword (know loffset!=0)
|
|
|
|
|
// Middle words
|
|
|
|
|
int hword = VL_BITWORD_I(hbit);
|
|
|
|
|
for (int i=0; i<words; ++i) {
|
|
|
|
|
{ // Lower word
|
|
|
|
|
int oword = lword+i;
|
|
|
|
|
IData d = sp[i]<<loffset;
|
|
|
|
|
IData od = (dp[oword] & ~linsmask) | (d & linsmask);
|
|
|
|
|
if (oword==hword) dp[oword] = (dp[oword] & ~hinsmask) | (od & hinsmask);
|
|
|
|
|
else dp[oword] = od;
|
|
|
|
|
}
|
|
|
|
|
{ // Upper word
|
|
|
|
|
int oword = lword+i+1;
|
|
|
|
|
if (oword <= hword) {
|
|
|
|
|
IData d = sp[i]>>nbitsonright;
|
|
|
|
|
IData od = (d & ~linsmask) | (dp[oword] & linsmask);
|
|
|
|
|
if (oword==hword) dp[oword] = (dp[oword] & ~hinsmask) | (od & hinsmask);
|
|
|
|
|
else dp[oword] = od;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void svPutPartselLogic(svLogicVecVal* dp, const svLogicVecVal* sp, int lbit, int width) {
|
|
|
|
|
int hbit = lbit+width-1;
|
|
|
|
|
int hoffset = hbit & VL_SIZEBITS_I;
|
|
|
|
|
int loffset = lbit & VL_SIZEBITS_I;
|
|
|
|
|
int lword = VL_BITWORD_I(lbit);
|
|
|
|
|
int words = VL_WORDS_I(hbit-lbit+1);
|
|
|
|
|
if (hoffset==VL_SIZEBITS_I && loffset==0) {
|
|
|
|
|
// Fast and common case, word based insertion
|
|
|
|
|
for (int i=0; i<words; ++i) {
|
|
|
|
|
dp[lword+i].aval = sp[i].aval;
|
|
|
|
|
dp[lword+i].bval = sp[i].bval;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (loffset==0) {
|
|
|
|
|
// Non-32bit, but nicely aligned, so stuff all but the last word
|
|
|
|
|
for (int i=0; i<(words-1); ++i) {
|
|
|
|
|
dp[lword+i].aval = sp[i].aval;
|
|
|
|
|
dp[lword+i].bval = sp[i].bval;
|
|
|
|
|
}
|
|
|
|
|
IData hinsmask = (VL_MASK_I(hoffset-0+1)); // Know it's not a full word as above fast case handled it
|
|
|
|
|
dp[lword+words-1].aval = (dp[words+lword-1].aval & ~hinsmask) | (sp[words-1].aval & hinsmask);
|
|
|
|
|
dp[lword+words-1].bval = (dp[words+lword-1].bval & ~hinsmask) | (sp[words-1].bval & hinsmask);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
IData hinsmask = (VL_MASK_I(hoffset-0+1))<<0;
|
|
|
|
|
IData linsmask = (VL_MASK_I(31-loffset+1))<<loffset;
|
|
|
|
|
int nbitsonright = 32-loffset; // bits that end up in lword (know loffset!=0)
|
|
|
|
|
// Middle words
|
|
|
|
|
int hword = VL_BITWORD_I(hbit);
|
|
|
|
|
for (int i=0; i<words; ++i) {
|
|
|
|
|
{ // Lower word
|
|
|
|
|
int oword = lword+i;
|
|
|
|
|
IData d_a = sp[i].aval << loffset;
|
|
|
|
|
IData d_b = sp[i].bval << loffset;
|
|
|
|
|
IData od_a = (dp[oword].aval & ~linsmask) | (d_a & linsmask);
|
|
|
|
|
IData od_b = (dp[oword].bval & ~linsmask) | (d_b & linsmask);
|
|
|
|
|
if (oword==hword) {
|
|
|
|
|
dp[oword].aval = (dp[oword].aval & ~hinsmask) | (od_a & hinsmask);
|
|
|
|
|
dp[oword].bval = (dp[oword].bval & ~hinsmask) | (od_b & hinsmask);
|
|
|
|
|
} else {
|
|
|
|
|
dp[oword].aval = od_a;
|
|
|
|
|
dp[oword].bval = od_b;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
{ // Upper word
|
|
|
|
|
int oword = lword+i+1;
|
|
|
|
|
if (oword <= hword) {
|
|
|
|
|
IData d_a = sp[i].aval >> nbitsonright;
|
|
|
|
|
IData d_b = sp[i].bval >> nbitsonright;
|
|
|
|
|
IData od_a = (d_a & ~linsmask) | (dp[oword].aval & linsmask);
|
|
|
|
|
IData od_b = (d_b & ~linsmask) | (dp[oword].bval & linsmask);
|
|
|
|
|
if (oword==hword) {
|
|
|
|
|
dp[oword].aval = (dp[oword].aval & ~hinsmask) | (od_a & hinsmask);
|
|
|
|
|
dp[oword].bval = (dp[oword].bval & ~hinsmask) | (od_b & hinsmask);
|
|
|
|
|
} else {
|
|
|
|
|
dp[oword].aval = od_a;
|
|
|
|
|
dp[oword].bval = od_b;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-12-03 11:55:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//======================================================================
|
|
|
|
|
// Open array querying functions
|
|
|
|
|
|
|
|
|
|
int svLeft(const svOpenArrayHandle h, int d) {
|
|
|
|
|
_VL_SVDPI_UNIMP(); return 0;
|
|
|
|
|
}
|
|
|
|
|
int svRight(const svOpenArrayHandle h, int d) {
|
|
|
|
|
_VL_SVDPI_UNIMP(); return 0;
|
|
|
|
|
}
|
|
|
|
|
int svLow(const svOpenArrayHandle h, int d) {
|
|
|
|
|
_VL_SVDPI_UNIMP(); return 0;
|
|
|
|
|
}
|
|
|
|
|
int svHigh(const svOpenArrayHandle h, int d) {
|
|
|
|
|
_VL_SVDPI_UNIMP(); return 0;
|
|
|
|
|
}
|
|
|
|
|
int svIncrement(const svOpenArrayHandle h, int d) {
|
|
|
|
|
_VL_SVDPI_UNIMP(); return 0;
|
|
|
|
|
}
|
2017-12-09 22:01:53 +00:00
|
|
|
|
int svSize(const svOpenArrayHandle h, int d) {
|
|
|
|
|
_VL_SVDPI_UNIMP(); return 0;
|
|
|
|
|
}
|
2009-12-03 11:55:29 +00:00
|
|
|
|
int svDimensions(const svOpenArrayHandle h) {
|
|
|
|
|
_VL_SVDPI_UNIMP(); return 0;
|
|
|
|
|
}
|
2017-12-09 22:01:53 +00:00
|
|
|
|
void* svGetArrayPtr(const svOpenArrayHandle h) {
|
2009-12-03 11:55:29 +00:00
|
|
|
|
_VL_SVDPI_UNIMP(); return NULL;
|
|
|
|
|
}
|
2017-12-09 22:01:53 +00:00
|
|
|
|
int svSizeOfArray(const svOpenArrayHandle h) {
|
2009-12-03 11:55:29 +00:00
|
|
|
|
_VL_SVDPI_UNIMP(); return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-09 22:01:53 +00:00
|
|
|
|
void* svGetArrElemPtr(const svOpenArrayHandle h, int indx1, ...) {
|
2009-12-03 11:55:29 +00:00
|
|
|
|
_VL_SVDPI_UNIMP(); return NULL;
|
|
|
|
|
}
|
2017-12-09 22:01:53 +00:00
|
|
|
|
void* svGetArrElemPtr1(const svOpenArrayHandle h, int indx1) {
|
2009-12-03 11:55:29 +00:00
|
|
|
|
_VL_SVDPI_UNIMP(); return NULL;
|
|
|
|
|
}
|
2017-12-09 22:01:53 +00:00
|
|
|
|
void* svGetArrElemPtr2(const svOpenArrayHandle h, int indx1, int indx2) {
|
2009-12-03 11:55:29 +00:00
|
|
|
|
_VL_SVDPI_UNIMP(); return NULL;
|
|
|
|
|
}
|
2017-12-09 22:01:53 +00:00
|
|
|
|
void* svGetArrElemPtr3(const svOpenArrayHandle h, int indx1, int indx2, int indx3) {
|
2009-12-03 11:55:29 +00:00
|
|
|
|
_VL_SVDPI_UNIMP(); return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//======================================================================
|
|
|
|
|
// s=source, d=destination
|
|
|
|
|
// From user space into simulator storage
|
|
|
|
|
|
|
|
|
|
void svPutBitArrElemVecVal(const svOpenArrayHandle d, const svBitVecVal* s,
|
2017-12-09 22:01:53 +00:00
|
|
|
|
int indx1, ...) {
|
2009-12-03 11:55:29 +00:00
|
|
|
|
_VL_SVDPI_UNIMP();
|
|
|
|
|
}
|
|
|
|
|
void svPutBitArrElem1VecVal(const svOpenArrayHandle d, const svBitVecVal* s,
|
2017-12-09 22:01:53 +00:00
|
|
|
|
int indx1) {
|
2009-12-03 11:55:29 +00:00
|
|
|
|
_VL_SVDPI_UNIMP();
|
|
|
|
|
}
|
|
|
|
|
void svPutBitArrElem2VecVal(const svOpenArrayHandle d, const svBitVecVal* s,
|
2017-12-09 22:01:53 +00:00
|
|
|
|
int indx1, int indx2) {
|
2009-12-03 11:55:29 +00:00
|
|
|
|
_VL_SVDPI_UNIMP();
|
|
|
|
|
}
|
|
|
|
|
void svPutBitArrElem3VecVal(const svOpenArrayHandle d, const svBitVecVal* s,
|
2017-12-09 22:01:53 +00:00
|
|
|
|
int indx1, int indx2, int indx3) {
|
2009-12-03 11:55:29 +00:00
|
|
|
|
_VL_SVDPI_UNIMP();
|
|
|
|
|
}
|
|
|
|
|
void svPutLogicArrElemVecVal(const svOpenArrayHandle d, const svLogicVecVal* s,
|
2017-12-09 22:01:53 +00:00
|
|
|
|
int indx1, ...) {
|
2009-12-03 11:55:29 +00:00
|
|
|
|
_VL_SVDPI_UNIMP();
|
|
|
|
|
}
|
|
|
|
|
void svPutLogicArrElem1VecVal(const svOpenArrayHandle d, const svLogicVecVal* s,
|
2017-12-09 22:01:53 +00:00
|
|
|
|
int indx1) {
|
2009-12-03 11:55:29 +00:00
|
|
|
|
_VL_SVDPI_UNIMP();
|
|
|
|
|
}
|
|
|
|
|
void svPutLogicArrElem2VecVal(const svOpenArrayHandle d, const svLogicVecVal* s,
|
2017-12-09 22:01:53 +00:00
|
|
|
|
int indx1, int indx2) {
|
2009-12-03 11:55:29 +00:00
|
|
|
|
_VL_SVDPI_UNIMP();
|
|
|
|
|
}
|
|
|
|
|
void svPutLogicArrElem3VecVal(const svOpenArrayHandle d, const svLogicVecVal* s,
|
2017-12-09 22:01:53 +00:00
|
|
|
|
int indx1, int indx2, int indx3) {
|
2009-12-03 11:55:29 +00:00
|
|
|
|
_VL_SVDPI_UNIMP();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//======================================================================
|
|
|
|
|
// From simulator storage into user space
|
|
|
|
|
|
|
|
|
|
void svGetBitArrElemVecVal(svBitVecVal* d, const svOpenArrayHandle s,
|
2017-12-09 22:01:53 +00:00
|
|
|
|
int indx1, ...) {
|
2009-12-03 11:55:29 +00:00
|
|
|
|
_VL_SVDPI_UNIMP();
|
|
|
|
|
}
|
|
|
|
|
void svGetBitArrElem1VecVal(svBitVecVal* d, const svOpenArrayHandle s,
|
2017-12-09 22:01:53 +00:00
|
|
|
|
int indx1) {
|
2009-12-03 11:55:29 +00:00
|
|
|
|
_VL_SVDPI_UNIMP();
|
|
|
|
|
}
|
|
|
|
|
void svGetBitArrElem2VecVal(svBitVecVal* d, const svOpenArrayHandle s,
|
2017-12-09 22:01:53 +00:00
|
|
|
|
int indx1, int indx2) {
|
2009-12-03 11:55:29 +00:00
|
|
|
|
_VL_SVDPI_UNIMP();
|
|
|
|
|
}
|
|
|
|
|
void svGetBitArrElem3VecVal(svBitVecVal* d, const svOpenArrayHandle s,
|
2017-12-09 22:01:53 +00:00
|
|
|
|
int indx1, int indx2, int indx3) {
|
2009-12-03 11:55:29 +00:00
|
|
|
|
_VL_SVDPI_UNIMP();
|
|
|
|
|
}
|
|
|
|
|
void svGetLogicArrElemVecVal(svLogicVecVal* d, const svOpenArrayHandle s,
|
2017-12-09 22:01:53 +00:00
|
|
|
|
int indx1, ...) {
|
2009-12-03 11:55:29 +00:00
|
|
|
|
_VL_SVDPI_UNIMP();
|
|
|
|
|
}
|
|
|
|
|
void svGetLogicArrElem1VecVal(svLogicVecVal* d, const svOpenArrayHandle s,
|
2017-12-09 22:01:53 +00:00
|
|
|
|
int indx1) {
|
2009-12-03 11:55:29 +00:00
|
|
|
|
_VL_SVDPI_UNIMP();
|
|
|
|
|
}
|
|
|
|
|
void svGetLogicArrElem2VecVal(svLogicVecVal* d, const svOpenArrayHandle s,
|
2017-12-09 22:01:53 +00:00
|
|
|
|
int indx1, int indx2) {
|
2009-12-03 11:55:29 +00:00
|
|
|
|
_VL_SVDPI_UNIMP();
|
|
|
|
|
}
|
|
|
|
|
void svGetLogicArrElem3VecVal(svLogicVecVal* d, const svOpenArrayHandle s,
|
2017-12-09 22:01:53 +00:00
|
|
|
|
int indx1, int indx2, int indx3) {
|
2009-12-03 11:55:29 +00:00
|
|
|
|
_VL_SVDPI_UNIMP();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
svBit svGetBitArrElem(const svOpenArrayHandle s, int indx1, ...) {
|
|
|
|
|
_VL_SVDPI_UNIMP(); return 0;
|
|
|
|
|
}
|
|
|
|
|
svBit svGetBitArrElem1(const svOpenArrayHandle s, int indx1) {
|
|
|
|
|
_VL_SVDPI_UNIMP(); return 0;
|
|
|
|
|
}
|
|
|
|
|
svBit svGetBitArrElem2(const svOpenArrayHandle s, int indx1, int indx2) {
|
|
|
|
|
_VL_SVDPI_UNIMP(); return 0;
|
|
|
|
|
}
|
|
|
|
|
svBit svGetBitArrElem3(const svOpenArrayHandle s, int indx1, int indx2, int indx3) {
|
|
|
|
|
_VL_SVDPI_UNIMP(); return 0;
|
|
|
|
|
}
|
|
|
|
|
svLogic svGetLogicArrElem(const svOpenArrayHandle s, int indx1, ...) {
|
|
|
|
|
_VL_SVDPI_UNIMP(); return sv_x;
|
|
|
|
|
}
|
|
|
|
|
svLogic svGetLogicArrElem1(const svOpenArrayHandle s, int indx1) {
|
2017-12-10 01:17:37 +00:00
|
|
|
|
// Verilator doesn't support X/Z so can just call Bit version
|
|
|
|
|
return svGetBitArrElem1(s, indx1);
|
2009-12-03 11:55:29 +00:00
|
|
|
|
}
|
|
|
|
|
svLogic svGetLogicArrElem2(const svOpenArrayHandle s, int indx1, int indx2) {
|
2017-12-10 01:17:37 +00:00
|
|
|
|
// Verilator doesn't support X/Z so can just call Bit version
|
|
|
|
|
return svGetBitArrElem2(s, indx1, indx2);
|
2009-12-03 11:55:29 +00:00
|
|
|
|
}
|
|
|
|
|
svLogic svGetLogicArrElem3(const svOpenArrayHandle s, int indx1, int indx2, int indx3) {
|
2017-12-10 01:17:37 +00:00
|
|
|
|
// Verilator doesn't support X/Z so can just call Bit version
|
|
|
|
|
return svGetBitArrElem3(s, indx1, indx2, indx3);
|
2009-12-03 11:55:29 +00:00
|
|
|
|
}
|
2017-12-10 01:17:37 +00:00
|
|
|
|
|
|
|
|
|
void svPutBitArrElem(const svOpenArrayHandle d, svBit value, int indx1, ...) {
|
2009-12-03 11:55:29 +00:00
|
|
|
|
_VL_SVDPI_UNIMP();
|
|
|
|
|
}
|
2017-12-10 01:17:37 +00:00
|
|
|
|
void svPutBitArrElem1(const svOpenArrayHandle d, svBit value, int indx1) {
|
2009-12-03 11:55:29 +00:00
|
|
|
|
_VL_SVDPI_UNIMP();
|
|
|
|
|
}
|
2017-12-10 01:17:37 +00:00
|
|
|
|
void svPutBitArrElem2(const svOpenArrayHandle d, svBit value, int indx1, int indx2) {
|
2009-12-03 11:55:29 +00:00
|
|
|
|
_VL_SVDPI_UNIMP();
|
|
|
|
|
}
|
2017-12-10 01:17:37 +00:00
|
|
|
|
void svPutBitArrElem3(const svOpenArrayHandle d, svBit value, int indx1, int indx2, int indx3) {
|
2009-12-03 11:55:29 +00:00
|
|
|
|
_VL_SVDPI_UNIMP();
|
|
|
|
|
}
|
2017-12-10 01:17:37 +00:00
|
|
|
|
void svPutLogicArrElem(const svOpenArrayHandle d, svLogic value, int indx1, ...) {
|
2009-12-03 11:55:29 +00:00
|
|
|
|
_VL_SVDPI_UNIMP();
|
|
|
|
|
}
|
2017-12-10 01:17:37 +00:00
|
|
|
|
void svPutLogicArrElem1(const svOpenArrayHandle d, svLogic value, int indx1) {
|
|
|
|
|
// Verilator doesn't support X/Z so can just call Bit version
|
|
|
|
|
svPutBitArrElem1(d, value, indx1);
|
2009-12-03 11:55:29 +00:00
|
|
|
|
}
|
2017-12-10 01:17:37 +00:00
|
|
|
|
void svPutLogicArrElem2(const svOpenArrayHandle d, svLogic value, int indx1, int indx2) {
|
|
|
|
|
// Verilator doesn't support X/Z so can just call Bit version
|
|
|
|
|
svPutBitArrElem2(d, value, indx1, indx2);
|
2009-12-03 11:55:29 +00:00
|
|
|
|
}
|
2017-12-10 01:17:37 +00:00
|
|
|
|
void svPutLogicArrElem3(const svOpenArrayHandle d, svLogic value, int indx1, int indx2, int indx3) {
|
|
|
|
|
// Verilator doesn't support X/Z so can just call Bit version
|
|
|
|
|
svPutBitArrElem3(d, value, indx1, indx2, indx3);
|
2009-12-03 11:55:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//======================================================================
|
|
|
|
|
// Functions for working with DPI context
|
|
|
|
|
|
|
|
|
|
svScope svGetScope() {
|
2009-12-05 15:38:49 +00:00
|
|
|
|
if (VL_UNLIKELY(!Verilated::dpiInContext())) { _VL_SVDPI_CONTEXT_WARN(); return NULL; }
|
|
|
|
|
return (svScope)Verilated::dpiScope();
|
2009-12-03 11:55:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
svScope svSetScope(const svScope scope) {
|
2009-12-09 02:35:15 +00:00
|
|
|
|
const VerilatedScope* prevScopep = Verilated::dpiScope();
|
2017-10-14 17:00:42 +00:00
|
|
|
|
const VerilatedScope* vscopep = reinterpret_cast<const VerilatedScope*>(scope);
|
2009-12-05 15:38:49 +00:00
|
|
|
|
Verilated::dpiScope(vscopep);
|
2009-12-09 02:35:15 +00:00
|
|
|
|
return (svScope)prevScopep;
|
2009-12-03 11:55:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-12-05 15:38:49 +00:00
|
|
|
|
const char* svGetNameFromScope(const svScope scope) {
|
2017-10-14 17:00:42 +00:00
|
|
|
|
const VerilatedScope* vscopep = reinterpret_cast<const VerilatedScope*>(scope);
|
2009-12-05 15:38:49 +00:00
|
|
|
|
return vscopep->name();
|
2009-12-03 11:55:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
svScope svGetScopeFromName(const char* scopeName) {
|
2009-12-05 15:38:49 +00:00
|
|
|
|
return (svScope)VerilatedImp::scopeFind(scopeName);
|
2009-12-03 11:55:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-12-09 22:01:53 +00:00
|
|
|
|
int svPutUserData(const svScope scope, void* userKey, void* userData) {
|
2009-12-05 15:38:49 +00:00
|
|
|
|
VerilatedImp::userInsert(scope,userKey,userData);
|
|
|
|
|
return 0;
|
2009-12-03 11:55:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void* svGetUserData(const svScope scope, void* userKey) {
|
2009-12-05 15:38:49 +00:00
|
|
|
|
return VerilatedImp::userFind(scope,userKey);
|
2009-12-03 11:55:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int svGetCallerInfo(const char** fileNamepp, int *lineNumberp) {
|
2009-12-05 15:38:49 +00:00
|
|
|
|
if (VL_UNLIKELY(!Verilated::dpiInContext())) { _VL_SVDPI_CONTEXT_WARN(); return false; }
|
|
|
|
|
if (VL_LIKELY(fileNamepp)) *fileNamepp = Verilated::dpiFilenamep(); // thread local
|
|
|
|
|
if (VL_LIKELY(lineNumberp)) *lineNumberp = Verilated::dpiLineno(); // thread local
|
|
|
|
|
return true;
|
2009-12-03 11:55:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//======================================================================
|
|
|
|
|
// Disables
|
|
|
|
|
|
|
|
|
|
int svIsDisabledState() {
|
|
|
|
|
return 0; // Disables not implemented
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void svAckDisabledState() {
|
|
|
|
|
// Disables not implemented
|
|
|
|
|
}
|