2012-04-12 21:08:20 -04:00
|
|
|
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
2011-05-20 21:33:31 -04:00
|
|
|
//*************************************************************************
|
|
|
|
|
//
|
2021-03-20 17:46:00 -04:00
|
|
|
// Code available from: https://verilator.org
|
|
|
|
|
//
|
2026-01-26 20:24:34 -05:00
|
|
|
// This program is free software; you can 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.
|
|
|
|
|
// SPDX-FileCopyrightText: 2003-2026 Wilson Snyder
|
2020-03-21 11:24:24 -04:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
2011-05-20 21:33:31 -04:00
|
|
|
//
|
|
|
|
|
//*************************************************************************
|
|
|
|
|
///
|
|
|
|
|
/// \file
|
2021-03-20 17:46:00 -04:00
|
|
|
/// \brief Verilated DPI header
|
2011-05-20 21:33:31 -04:00
|
|
|
///
|
2021-03-20 17:46:00 -04: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-20 21:33:31 -04:00
|
|
|
///
|
2021-03-20 17:46:00 -04:00
|
|
|
/// This file is not part of the Verilated public-facing API.
|
|
|
|
|
/// It is only for internal use.
|
2011-05-20 21:33:31 -04:00
|
|
|
///
|
|
|
|
|
//*************************************************************************
|
2019-10-04 20:17:11 -04:00
|
|
|
|
2021-03-03 21:57:07 -05:00
|
|
|
#ifndef VERILATOR_VERILATED_DPI_H_
|
2021-03-20 17:46:00 -04:00
|
|
|
#define VERILATOR_VERILATED_DPI_H_
|
2011-05-20 21:33:31 -04:00
|
|
|
|
2018-10-14 13:43:24 -04:00
|
|
|
#include "verilatedos.h"
|
2022-08-05 10:56:57 +01:00
|
|
|
|
2018-10-14 13:43:24 -04:00
|
|
|
#include "verilated.h" // Also presumably included by caller
|
2017-12-17 16:28:58 -05:00
|
|
|
#include "verilated_sym_props.h"
|
2018-10-14 13:43:24 -04:00
|
|
|
|
2011-05-20 21:33:31 -04:00
|
|
|
#include "svdpi.h"
|
|
|
|
|
|
|
|
|
|
//===================================================================
|
|
|
|
|
// SETTING OPERATORS
|
|
|
|
|
|
2021-03-07 08:28:13 -05:00
|
|
|
// Convert svBitVecVal to Verilator internal data
|
2026-07-30 18:14:40 +08:00
|
|
|
inline void VL_SET_W_SVBV(int obits, WDataOutP owp, const svBitVecVal* lwp) VL_MT_SAFE {
|
2021-06-18 22:19:35 -04:00
|
|
|
const int words = VL_WORDS_I(obits);
|
2020-04-13 22:51:35 -04:00
|
|
|
for (int i = 0; i < words - 1; ++i) owp[i] = lwp[i];
|
2020-04-04 17:55:37 -04:00
|
|
|
owp[words - 1] = lwp[words - 1] & VL_MASK_I(obits);
|
2011-05-20 21:33:31 -04:00
|
|
|
}
|
2026-07-30 18:14:40 +08:00
|
|
|
inline void VL_SET_Q_SVBV(int obits, QData& out, const svBitVecVal* lwp) VL_MT_SAFE {
|
2025-10-19 10:44:33 +02:00
|
|
|
out = VL_MASK_Q(obits) & VL_SET_QII(lwp[1], lwp[0]);
|
|
|
|
|
}
|
2026-07-30 18:14:40 +08:00
|
|
|
inline void VL_SET_I_SVBV(int obits, IData& out, const svBitVecVal* lwp) VL_MT_SAFE {
|
2025-10-19 10:44:33 +02:00
|
|
|
out = VL_MASK_I(obits) & lwp[0];
|
|
|
|
|
}
|
2026-07-30 18:14:40 +08:00
|
|
|
inline void VL_SET_S_SVBV(int obits, SData& out, const svBitVecVal* lwp) VL_MT_SAFE {
|
2025-10-19 10:44:33 +02:00
|
|
|
out = VL_MASK_I(obits) & lwp[0];
|
|
|
|
|
}
|
2026-07-30 18:14:40 +08:00
|
|
|
inline void VL_SET_C_SVBV(int obits, CData& out, const svBitVecVal* lwp) VL_MT_SAFE {
|
2025-10-19 10:44:33 +02:00
|
|
|
out = VL_MASK_I(obits) & lwp[0];
|
2020-04-07 19:07:47 -04:00
|
|
|
}
|
|
|
|
|
|
2021-03-07 08:28:13 -05:00
|
|
|
// Convert Verilator internal data to svBitVecVal
|
2026-07-30 18:14:40 +08:00
|
|
|
inline void VL_SET_SVBV_W(int obits, svBitVecVal* owp, const WDataInP lwp) VL_MT_SAFE {
|
2021-06-18 22:19:35 -04:00
|
|
|
const int words = VL_WORDS_I(obits);
|
2020-04-13 22:51:35 -04:00
|
|
|
for (int i = 0; i < words - 1; ++i) owp[i] = lwp[i];
|
2020-04-04 17:55:37 -04:00
|
|
|
owp[words - 1] = lwp[words - 1] & VL_MASK_I(obits);
|
2011-05-20 21:33:31 -04:00
|
|
|
}
|
2026-07-30 18:14:40 +08:00
|
|
|
inline void VL_SET_SVBV_I(int, svBitVecVal* owp, const IData ld) VL_MT_SAFE { owp[0] = ld; }
|
|
|
|
|
inline void VL_SET_SVBV_Q(int, svBitVecVal* owp, const QData ld) VL_MT_SAFE {
|
2026-05-22 20:05:08 +01:00
|
|
|
VL_SET_WQ(WDataOutP::external(owp), ld);
|
2020-04-07 19:07:47 -04:00
|
|
|
}
|
2017-12-09 20:17:37 -05:00
|
|
|
|
2021-03-07 08:28:13 -05:00
|
|
|
// Convert svLogicVecVal to Verilator internal data
|
|
|
|
|
// Note these functions ignore X/Z in svLogicVecVal
|
2026-07-30 18:14:40 +08:00
|
|
|
inline void VL_SET_W_SVLV(int obits, WDataOutP owp, const svLogicVecVal* lwp) VL_MT_SAFE {
|
2021-06-18 22:19:35 -04:00
|
|
|
const int words = VL_WORDS_I(obits);
|
2020-04-13 22:51:35 -04:00
|
|
|
for (int i = 0; i < words - 1; ++i) owp[i] = lwp[i].aval;
|
2020-04-04 17:55:37 -04:00
|
|
|
owp[words - 1] = lwp[words - 1].aval & VL_MASK_I(obits);
|
2011-05-20 21:33:31 -04:00
|
|
|
}
|
2026-07-30 18:14:40 +08:00
|
|
|
inline void VL_SET_Q_SVLV(int obits, QData& out, const svLogicVecVal* lwp) VL_MT_SAFE {
|
2025-10-19 10:44:33 +02:00
|
|
|
out = VL_MASK_Q(obits) & VL_SET_QII(lwp[1].aval, lwp[0].aval);
|
|
|
|
|
}
|
2026-07-30 18:14:40 +08:00
|
|
|
inline void VL_SET_I_SVLV(int obits, IData& out, const svLogicVecVal* lwp) VL_MT_SAFE {
|
2025-10-19 10:44:33 +02:00
|
|
|
out = VL_MASK_I(obits) & lwp[0].aval;
|
|
|
|
|
}
|
2026-07-30 18:14:40 +08:00
|
|
|
inline void VL_SET_S_SVLV(int obits, SData& out, const svLogicVecVal* lwp) VL_MT_SAFE {
|
2025-10-19 10:44:33 +02:00
|
|
|
out = VL_MASK_I(obits) & lwp[0].aval;
|
|
|
|
|
}
|
2026-07-30 18:14:40 +08:00
|
|
|
inline void VL_SET_C_SVLV(int obits, CData& out, const svLogicVecVal* lwp) VL_MT_SAFE {
|
2025-10-19 10:44:33 +02:00
|
|
|
out = VL_MASK_I(obits) & lwp[0].aval;
|
2017-12-09 20:17:37 -05:00
|
|
|
}
|
2020-04-07 19:07:47 -04:00
|
|
|
|
2021-03-07 08:28:13 -05:00
|
|
|
// Convert Verilator internal data to svLogicVecVal
|
|
|
|
|
// Note these functions never create X/Z in svLogicVecVal
|
2026-07-30 18:14:40 +08:00
|
|
|
inline void VL_SET_SVLV_W(int obits, svLogicVecVal* owp, const WDataInP lwp) VL_MT_SAFE {
|
2021-06-18 22:19:35 -04:00
|
|
|
const int words = VL_WORDS_I(obits);
|
2020-04-13 22:51:35 -04: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];
|
2020-04-04 17:55:37 -04:00
|
|
|
owp[words - 1].aval = lwp[words - 1] & VL_MASK_I(obits);
|
2011-05-20 21:33:31 -04:00
|
|
|
}
|
2026-07-30 18:14:40 +08:00
|
|
|
inline void VL_SET_SVLV_I(int, svLogicVecVal* owp, const IData ld) VL_MT_SAFE {
|
2020-04-04 17:55:37 -04:00
|
|
|
owp[0].aval = ld;
|
|
|
|
|
owp[0].bval = 0;
|
2017-12-09 20:17:37 -05:00
|
|
|
}
|
2026-07-30 18:14:40 +08:00
|
|
|
inline void VL_SET_SVLV_Q(int, svLogicVecVal* owp, const QData ld) VL_MT_SAFE {
|
2021-06-17 21:17:15 -04:00
|
|
|
VlWide<2> lwp;
|
2020-04-04 17:55:37 -04:00
|
|
|
VL_SET_WQ(lwp, ld);
|
|
|
|
|
owp[0].aval = lwp[0];
|
|
|
|
|
owp[0].bval = 0;
|
|
|
|
|
owp[1].aval = lwp[1];
|
|
|
|
|
owp[1].bval = 0;
|
2017-12-09 20:17:37 -05:00
|
|
|
}
|
2011-05-20 21:33:31 -04:00
|
|
|
|
|
|
|
|
//======================================================================
|
|
|
|
|
|
2018-11-28 19:59:10 -05:00
|
|
|
#endif // Guard
|