2012-04-13 03:08:20 +02:00
|
|
|
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
2006-08-26 13:35:28 +02:00
|
|
|
//*************************************************************************
|
|
|
|
|
// DESCRIPTION: Verilator: Inlining of modules
|
|
|
|
|
//
|
2019-11-08 04:33:59 +01:00
|
|
|
// Code available from: https://verilator.org
|
2006-08-26 13:35:28 +02:00
|
|
|
//
|
|
|
|
|
//*************************************************************************
|
|
|
|
|
//
|
2023-01-01 16:18:39 +01:00
|
|
|
// Copyright 2003-2023 by Wilson Snyder. This program is free software; you
|
2020-03-21 16:24:24 +01:00
|
|
|
// can redistribute it and/or modify it under the terms of either the GNU
|
2009-05-04 23:07:57 +02:00
|
|
|
// Lesser General Public License Version 3 or the Perl Artistic License
|
|
|
|
|
// Version 2.0.
|
2020-03-21 16:24:24 +01:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
2006-08-26 13:35:28 +02:00
|
|
|
//
|
|
|
|
|
//*************************************************************************
|
2019-10-05 02:17:11 +02:00
|
|
|
|
2021-03-04 03:57:07 +01:00
|
|
|
#ifndef VERILATOR_V3TASK_H_
|
|
|
|
|
#define VERILATOR_V3TASK_H_
|
2018-10-14 19:43:24 +02:00
|
|
|
|
2006-12-18 20:20:45 +01:00
|
|
|
#include "config_build.h"
|
|
|
|
|
#include "verilatedos.h"
|
2018-10-14 19:43:24 +02:00
|
|
|
|
2006-08-26 13:35:28 +02:00
|
|
|
#include "V3Ast.h"
|
2022-08-05 11:56:57 +02:00
|
|
|
#include "V3Error.h"
|
2018-10-14 19:43:24 +02:00
|
|
|
|
2022-01-08 18:01:39 +01:00
|
|
|
#include <utility>
|
2009-12-01 00:36:31 +01:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
|
2021-03-13 00:10:45 +01:00
|
|
|
using V3TaskConnect = std::pair<AstVar*, AstArg*>; // [port, pin-connects-to]
|
|
|
|
|
using V3TaskConnects = std::vector<V3TaskConnect>; // [ [port, pin-connects-to] ... ]
|
2006-08-26 13:35:28 +02:00
|
|
|
|
2023-09-16 23:37:25 +02:00
|
|
|
class V3TaskConnectState final {
|
|
|
|
|
VNDeleter m_deleter; // Allow delayed deletion of nodes
|
|
|
|
|
bool m_didWrap = false; // Made a wrapper
|
|
|
|
|
using WrapMap = std::map<std::pair<AstNodeFTask*, std::string>, AstNodeFTask*>;
|
|
|
|
|
WrapMap m_wrapMap; // Map of {old function, arguments} -> new function
|
|
|
|
|
public:
|
|
|
|
|
V3TaskConnectState() {}
|
|
|
|
|
~V3TaskConnectState() = default;
|
|
|
|
|
void pushDeletep(AstNode* nodep) { m_deleter.pushDeletep(nodep); }
|
|
|
|
|
bool didWrap() const { return m_didWrap; }
|
|
|
|
|
void setDidWrap() { m_didWrap = true; }
|
|
|
|
|
WrapMap& wrapMap() { return m_wrapMap; }
|
|
|
|
|
};
|
|
|
|
|
|
2006-08-26 13:35:28 +02:00
|
|
|
//============================================================================
|
|
|
|
|
|
2020-11-19 03:32:16 +01:00
|
|
|
class V3Task final {
|
2023-09-11 15:01:09 +02:00
|
|
|
static const char* const s_dpiTemporaryVarSuffix;
|
|
|
|
|
|
2006-08-26 13:35:28 +02:00
|
|
|
public:
|
|
|
|
|
static void taskAll(AstNetlist* nodep);
|
2018-03-10 22:32:04 +01:00
|
|
|
/// Return vector of [port, pin-connects-to] (SLOW)
|
2023-09-16 23:37:25 +02:00
|
|
|
static V3TaskConnects taskConnects(AstNodeFTaskRef* nodep, AstNode* taskStmtsp,
|
|
|
|
|
V3TaskConnectState* statep = nullptr);
|
|
|
|
|
static void taskConnectWrap(AstNodeFTaskRef* nodep, const V3TaskConnects& tconnects,
|
|
|
|
|
V3TaskConnectState* statep,
|
|
|
|
|
const std::set<const AstVar*>& argWrap);
|
|
|
|
|
static AstNodeFTask* taskConnectWrapNew(AstNodeFTask* taskp, const string& newname,
|
|
|
|
|
const V3TaskConnects& tconnects,
|
|
|
|
|
const std::set<const AstVar*>& argWrap);
|
2020-04-08 01:07:47 +02:00
|
|
|
static string assignInternalToDpi(AstVar* portp, bool isPtr, const string& frSuffix,
|
|
|
|
|
const string& toSuffix, const string& frPrefix = "");
|
2020-12-09 00:29:45 +01:00
|
|
|
static string assignDpiToInternal(const string& lhsName, AstVar* rhsp);
|
2023-09-11 15:01:09 +02:00
|
|
|
static const char* dpiTemporaryVarSuffix() VL_MT_SAFE { return s_dpiTemporaryVarSuffix; }
|
2006-08-26 13:35:28 +02:00
|
|
|
};
|
|
|
|
|
|
2019-05-19 22:13:13 +02:00
|
|
|
#endif // Guard
|