2012-04-13 03:08:20 +02:00
|
|
|
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
2010-12-25 20:39:41 +01:00
|
|
|
//*************************************************************************
|
|
|
|
|
//
|
2021-03-20 22:46:00 +01:00
|
|
|
// Code available from: https://verilator.org
|
|
|
|
|
//
|
2025-01-01 14:30:25 +01:00
|
|
|
// Copyright 2009-2025 by Wilson Snyder. This program is free software; you can
|
2010-12-25 20:39:41 +01:00
|
|
|
// redistribute it and/or modify it under the terms of either the GNU
|
2020-03-21 16:24:24 +01:00
|
|
|
// Lesser General Public License Version 3 or the Perl Artistic License
|
2010-12-25 20:39:41 +01:00
|
|
|
// Version 2.0.
|
2020-03-21 16:24:24 +01:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
2010-12-25 20:39:41 +01:00
|
|
|
//
|
|
|
|
|
//=========================================================================
|
|
|
|
|
///
|
|
|
|
|
/// \file
|
2021-03-20 22:46:00 +01:00
|
|
|
/// \brief Verilated VPI header
|
2010-12-25 20:39:41 +01:00
|
|
|
///
|
2021-03-20 22:46:00 +01:00
|
|
|
/// This file contains routines related to using VPI with Verilated models.
|
2010-12-25 20:39:41 +01:00
|
|
|
///
|
2021-03-20 22:46:00 +01:00
|
|
|
/// User wrapper code may need to include this if controlling Verilated
|
|
|
|
|
/// models that use ths VPI.
|
2010-12-25 20:39:41 +01:00
|
|
|
///
|
|
|
|
|
//=========================================================================
|
2019-10-05 02:17:11 +02:00
|
|
|
|
2021-03-04 03:57:07 +01:00
|
|
|
#ifndef VERILATOR_VERILATED_VPI_H_
|
2021-03-20 22:46:00 +01:00
|
|
|
#define VERILATOR_VERILATED_VPI_H_
|
2010-12-25 20:39:41 +01:00
|
|
|
|
2018-10-14 19:43:24 +02:00
|
|
|
#include "verilatedos.h"
|
2022-08-05 11:56:57 +02:00
|
|
|
|
2010-12-25 20:39:41 +01:00
|
|
|
#include "verilated.h"
|
|
|
|
|
#include "verilated_syms.h"
|
|
|
|
|
|
|
|
|
|
//======================================================================
|
2024-03-02 15:05:21 +01:00
|
|
|
// From IEEE 1800-2023 annex M
|
2010-12-25 20:39:41 +01:00
|
|
|
|
2023-10-23 02:41:40 +02:00
|
|
|
#include "vltstd/sv_vpi_user.h"
|
2010-12-25 20:39:41 +01:00
|
|
|
|
2015-09-26 04:57:28 +02:00
|
|
|
//======================================================================
|
2013-01-18 03:40:37 +01:00
|
|
|
|
2022-12-03 00:46:38 +01:00
|
|
|
/// Class for namespace-like grouping of Verilator VPI functions.
|
2021-03-28 17:50:05 +02:00
|
|
|
|
2020-11-19 03:32:16 +01:00
|
|
|
class VerilatedVpi final {
|
2010-12-25 20:39:41 +01:00
|
|
|
public:
|
2021-03-21 02:11:53 +01:00
|
|
|
/// Call timed callbacks.
|
|
|
|
|
/// User wrapper code should call this from their main loops.
|
2017-10-27 03:51:51 +02:00
|
|
|
static void callTimedCbs() VL_MT_UNSAFE_ONE;
|
2021-03-21 02:11:53 +01:00
|
|
|
/// Call value based callbacks.
|
|
|
|
|
/// User wrapper code should call this from their main loops.
|
2020-10-27 02:55:27 +01:00
|
|
|
static bool callValueCbs() VL_MT_UNSAFE_ONE;
|
2021-03-21 02:11:53 +01:00
|
|
|
/// Call callbacks of arbitrary types.
|
|
|
|
|
/// User wrapper code should call this from their main loops.
|
2022-07-30 17:52:35 +02:00
|
|
|
static bool callCbs(uint32_t reason) VL_MT_UNSAFE_ONE;
|
2024-08-27 23:36:51 +02: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 18:47:21 +01:00
|
|
|
/// Returns time of the next registered VPI callback, or
|
2021-03-21 02:11:53 +01:00
|
|
|
/// ~(0ULL) if none are registered
|
2020-03-28 18:47:21 +01:00
|
|
|
static QData cbNextDeadline() VL_MT_UNSAFE_ONE;
|
2023-01-21 19:43:27 +01:00
|
|
|
/// Debug dump of callbacks
|
|
|
|
|
static void dumpCbs() VL_MT_UNSAFE_ONE;
|
2024-04-25 15:07:31 +02: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-02 00:56:50 +02:00
|
|
|
/// Perform inertially delayed puts
|
|
|
|
|
static void doInertialPuts() VL_MT_UNSAFE_ONE;
|
2021-03-07 14:28:13 +01:00
|
|
|
|
|
|
|
|
// Self test, for internal use only
|
2017-10-27 03:51:51 +02:00
|
|
|
static void selfTest() VL_MT_UNSAFE_ONE;
|
2010-12-25 20:39:41 +01:00
|
|
|
};
|
|
|
|
|
|
2018-11-29 01:59:10 +01:00
|
|
|
#endif // Guard
|