2012-04-12 21:08:20 -04:00
|
|
|
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
2010-12-25 14:39:41 -05: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: 2009-2026 Wilson Snyder
|
2020-03-21 11:24:24 -04:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
2010-12-25 14:39:41 -05:00
|
|
|
//
|
|
|
|
|
//=========================================================================
|
|
|
|
|
///
|
|
|
|
|
/// \file
|
2021-03-20 17:46:00 -04:00
|
|
|
/// \brief Verilated VPI header
|
2010-12-25 14:39:41 -05:00
|
|
|
///
|
2021-03-20 17:46:00 -04:00
|
|
|
/// This file contains routines related to using VPI with Verilated models.
|
2010-12-25 14:39:41 -05:00
|
|
|
///
|
2021-03-20 17:46:00 -04:00
|
|
|
/// User wrapper code may need to include this if controlling Verilated
|
|
|
|
|
/// models that use ths VPI.
|
2010-12-25 14:39:41 -05:00
|
|
|
///
|
|
|
|
|
//=========================================================================
|
2019-10-04 20:17:11 -04:00
|
|
|
|
2021-03-03 21:57:07 -05:00
|
|
|
#ifndef VERILATOR_VERILATED_VPI_H_
|
2021-03-20 17:46:00 -04:00
|
|
|
#define VERILATOR_VERILATED_VPI_H_
|
2010-12-25 14:39:41 -05:00
|
|
|
|
2018-10-14 13:43:24 -04:00
|
|
|
#include "verilatedos.h"
|
2022-08-05 10:56:57 +01:00
|
|
|
|
2010-12-25 14:39:41 -05:00
|
|
|
#include "verilated.h"
|
|
|
|
|
#include "verilated_syms.h"
|
|
|
|
|
|
|
|
|
|
//======================================================================
|
2024-03-02 09:05:21 -05:00
|
|
|
// From IEEE 1800-2023 annex M
|
2010-12-25 14:39:41 -05:00
|
|
|
|
2023-10-22 17:41:40 -07:00
|
|
|
#include "vltstd/sv_vpi_user.h"
|
2010-12-25 14:39:41 -05:00
|
|
|
|
2015-09-25 22:57:28 -04:00
|
|
|
//======================================================================
|
2013-01-17 21:40:37 -05:00
|
|
|
|
2022-12-02 15:46:38 -08:00
|
|
|
/// Class for namespace-like grouping of Verilator VPI functions.
|
2021-03-28 11:50:05 -04:00
|
|
|
|
2020-11-18 21:32:16 -05:00
|
|
|
class VerilatedVpi final {
|
2010-12-25 14:39:41 -05:00
|
|
|
public:
|
2021-03-20 21:11:53 -04:00
|
|
|
/// Call timed callbacks.
|
|
|
|
|
/// User wrapper code should call this from their main loops.
|
2017-10-26 21:51:51 -04:00
|
|
|
static void callTimedCbs() VL_MT_UNSAFE_ONE;
|
2021-03-20 21:11:53 -04:00
|
|
|
/// Call value based callbacks.
|
|
|
|
|
/// User wrapper code should call this from their main loops.
|
2020-10-26 18:55:27 -07:00
|
|
|
static bool callValueCbs() VL_MT_UNSAFE_ONE;
|
2021-03-20 21:11:53 -04:00
|
|
|
/// Call callbacks of arbitrary types.
|
|
|
|
|
/// User wrapper code should call this from their main loops.
|
2022-07-30 11:52:35 -04:00
|
|
|
static bool callCbs(uint32_t reason) VL_MT_UNSAFE_ONE;
|
2024-08-27 16:36:51 -05:00
|
|
|
/// Returns true if there are callbacks of the given reason registered.
|
|
|
|
|
/// User wrapper code should call this from their main loops.
|
|
|
|
|
static bool hasCbs(uint32_t reason) VL_MT_UNSAFE_ONE;
|
2020-03-28 13:47:21 -04:00
|
|
|
/// Returns time of the next registered VPI callback, or
|
2021-03-20 21:11:53 -04:00
|
|
|
/// ~(0ULL) if none are registered
|
2020-03-28 13:47:21 -04:00
|
|
|
static QData cbNextDeadline() VL_MT_UNSAFE_ONE;
|
2023-01-21 13:43:27 -05:00
|
|
|
/// Debug dump of callbacks
|
|
|
|
|
static void dumpCbs() VL_MT_UNSAFE_ONE;
|
2024-04-25 09:07:31 -04:00
|
|
|
/// Checks VPI dirty state (i.e. whether vpi_put_value() has
|
|
|
|
|
/// been called since the last clearEvalNeeded())
|
|
|
|
|
static bool evalNeeded() VL_MT_UNSAFE_ONE;
|
|
|
|
|
/// Clears VPI dirty state (see evalNeeded())
|
|
|
|
|
static void clearEvalNeeded() VL_MT_UNSAFE_ONE;
|
2024-05-01 18:56:50 -04:00
|
|
|
/// Perform inertially delayed puts
|
|
|
|
|
static void doInertialPuts() VL_MT_UNSAFE_ONE;
|
2021-03-07 08:28:13 -05:00
|
|
|
|
|
|
|
|
// Self test, for internal use only
|
2017-10-26 21:51:51 -04:00
|
|
|
static void selfTest() VL_MT_UNSAFE_ONE;
|
2010-12-25 14:39:41 -05:00
|
|
|
};
|
|
|
|
|
|
2018-11-28 19:59:10 -05:00
|
|
|
#endif // Guard
|