2012-04-13 01:08:20 +00:00
|
|
|
|
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
2011-05-21 01:33:31 +00:00
|
|
|
|
//*************************************************************************
|
|
|
|
|
//
|
2019-01-04 00:17:22 +00:00
|
|
|
|
// Copyright 2003-2019 by Wilson Snyder. This program is free software; you can
|
2011-05-21 01:33:31 +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: Common include for all Verilated C files that use DPI
|
|
|
|
|
///
|
2017-10-10 11:18:01 +00:00
|
|
|
|
/// This file is included automatically by Verilator at the top of
|
|
|
|
|
/// all C++ files it generates where DPI is used. It contains
|
|
|
|
|
/// DPI interface functions required by the Verilated code.
|
2011-05-21 01:33:31 +00:00
|
|
|
|
///
|
|
|
|
|
/// Code available from: http://www.veripool.org/verilator
|
|
|
|
|
///
|
|
|
|
|
//*************************************************************************
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _VERILATED_DPI_H_
|
2018-11-29 00:59:10 +00:00
|
|
|
|
#define _VERILATED_DPI_H_ 1 ///< Header Guard
|
2011-05-21 01:33:31 +00:00
|
|
|
|
|
2018-10-14 17:43:24 +00:00
|
|
|
|
#include "verilatedos.h"
|
|
|
|
|
#include "verilated.h" // Also presumably included by caller
|
2017-12-17 21:28:58 +00:00
|
|
|
|
#include "verilated_sym_props.h"
|
2018-10-14 17:43:24 +00:00
|
|
|
|
|
2011-05-21 01:33:31 +00:00
|
|
|
|
#include "svdpi.h"
|
|
|
|
|
|
|
|
|
|
//===================================================================
|
|
|
|
|
// SETTING OPERATORS
|
|
|
|
|
|
2017-12-10 01:17:37 +00:00
|
|
|
|
/// Return WData from svBitVecVal
|
|
|
|
|
static inline void VL_SET_W_SVBV(int obits, WDataOutP owp, const svBitVecVal* lwp) VL_MT_SAFE {
|
2011-05-21 01:33:31 +00:00
|
|
|
|
int words = VL_WORDS_I(obits);
|
2017-06-06 00:16:51 +00:00
|
|
|
|
for (int i=0; i<words-1; ++i) owp[i]=lwp[i];
|
2011-05-21 01:33:31 +00:00
|
|
|
|
owp[words-1] = lwp[words-1] & VL_MASK_I(obits);
|
|
|
|
|
}
|
2017-12-10 01:17:37 +00:00
|
|
|
|
/// Return svBitVecVal from WData
|
2017-10-27 00:05:42 +00:00
|
|
|
|
static inline void VL_SET_SVBV_W(int obits, svBitVecVal* owp, WDataInP lwp) VL_MT_SAFE {
|
2011-05-21 01:33:31 +00:00
|
|
|
|
int words = VL_WORDS_I(obits);
|
2017-06-06 00:16:51 +00:00
|
|
|
|
for (int i=0; i<words-1; ++i) owp[i]=lwp[i];
|
2011-05-21 01:33:31 +00:00
|
|
|
|
owp[words-1] = lwp[words-1] & VL_MASK_I(obits);
|
|
|
|
|
}
|
2017-12-10 01:17:37 +00:00
|
|
|
|
|
|
|
|
|
/// Convert svLogicVecVal to/from WData
|
|
|
|
|
/// 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 {
|
2011-05-21 01:33:31 +00:00
|
|
|
|
int words = VL_WORDS_I(obits);
|
2017-06-06 00:16:51 +00:00
|
|
|
|
for (int i=0; i<words-1; ++i) owp[i]=lwp[i].aval;
|
2011-05-21 01:33:31 +00:00
|
|
|
|
owp[words-1] = lwp[words-1].aval & VL_MASK_I(obits);
|
|
|
|
|
}
|
2017-12-10 01:17:37 +00:00
|
|
|
|
static inline QData VL_SET_Q_SVLV(const svLogicVecVal* lwp) VL_MT_SAFE {
|
|
|
|
|
return _VL_SET_QII(lwp[1].aval, lwp[0].aval);
|
|
|
|
|
}
|
|
|
|
|
static inline IData VL_SET_I_SVLV(const svLogicVecVal* lwp) VL_MT_SAFE {
|
|
|
|
|
return lwp[0].aval;
|
|
|
|
|
}
|
2017-10-27 00:05:42 +00:00
|
|
|
|
static inline void VL_SET_SVLV_W(int obits, svLogicVecVal* owp, WDataInP lwp) VL_MT_SAFE {
|
2011-05-21 01:33:31 +00:00
|
|
|
|
int words = VL_WORDS_I(obits);
|
2017-06-06 00:16:51 +00:00
|
|
|
|
for (int i=0; i<words; ++i) owp[i].bval=0;
|
|
|
|
|
for (int i=0; i<words-1; ++i) owp[i].aval=lwp[i];
|
2011-05-21 01:33:31 +00:00
|
|
|
|
owp[words-1].aval = lwp[words-1] & VL_MASK_I(obits);
|
|
|
|
|
}
|
2017-12-17 23:44:35 +00:00
|
|
|
|
static inline void VL_SET_SVLV_I(int, svLogicVecVal* owp, IData ld) VL_MT_SAFE {
|
2017-12-10 01:17:37 +00:00
|
|
|
|
owp[0].aval=ld; owp[0].bval=0;
|
|
|
|
|
}
|
2017-12-17 23:44:35 +00:00
|
|
|
|
static inline void VL_SET_SVLV_Q(int, svLogicVecVal* owp, QData ld) VL_MT_SAFE {
|
2017-12-10 01:17:37 +00:00
|
|
|
|
WData lwp[2]; VL_SET_WQ(lwp,ld);
|
|
|
|
|
owp[0].aval=lwp[0]; owp[0].bval=0;
|
|
|
|
|
owp[1].aval=lwp[1]; owp[1].bval=0;
|
|
|
|
|
}
|
2011-05-21 01:33:31 +00:00
|
|
|
|
|
|
|
|
|
//======================================================================
|
|
|
|
|
|
2018-11-29 00:59:10 +00:00
|
|
|
|
#endif // Guard
|