2012-04-12 21:08:20 -04:00
|
|
|
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
2010-01-21 06:11:30 -05:00
|
|
|
//*************************************************************************
|
2025-06-27 20:38:01 -04:00
|
|
|
// DESCRIPTION: Verilator: Verilator Control Files (.vlt) handling
|
2010-01-21 06:11:30 -05:00
|
|
|
//
|
2019-11-07 22:33:59 -05:00
|
|
|
// Code available from: https://verilator.org
|
2010-01-21 06:11:30 -05:00
|
|
|
//
|
|
|
|
|
//*************************************************************************
|
|
|
|
|
//
|
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: 2010-2026 Wilson Snyder
|
2020-03-21 11:24:24 -04:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
2010-01-21 06:11:30 -05:00
|
|
|
//
|
|
|
|
|
//*************************************************************************
|
2019-10-04 20:17:11 -04:00
|
|
|
|
2021-03-03 21:57:07 -05:00
|
|
|
#ifndef VERILATOR_V3CONFIG_H_
|
|
|
|
|
#define VERILATOR_V3CONFIG_H_
|
2018-10-14 13:43:24 -04:00
|
|
|
|
2010-01-21 06:11:30 -05:00
|
|
|
#include "config_build.h"
|
|
|
|
|
#include "verilatedos.h"
|
2018-10-14 13:43:24 -04:00
|
|
|
|
2022-08-05 10:56:57 +01:00
|
|
|
#include "V3Ast.h"
|
2010-01-21 06:11:30 -05:00
|
|
|
#include "V3Error.h"
|
2014-11-22 11:48:39 -05:00
|
|
|
#include "V3FileLine.h"
|
2023-04-11 13:23:24 +02:00
|
|
|
#include "V3Mutex.h"
|
2010-01-21 06:11:30 -05:00
|
|
|
|
|
|
|
|
//######################################################################
|
|
|
|
|
|
2025-06-27 20:38:01 -04:00
|
|
|
class V3Control final {
|
2010-01-21 06:11:30 -05:00
|
|
|
public:
|
2026-05-21 17:50:31 +00:00
|
|
|
struct FsmRegisterWrapper final {
|
|
|
|
|
string moduleName;
|
|
|
|
|
string d;
|
|
|
|
|
string q;
|
|
|
|
|
string clock;
|
|
|
|
|
string reset;
|
|
|
|
|
string resetValue;
|
|
|
|
|
};
|
|
|
|
|
|
2026-05-22 17:59:57 -04:00
|
|
|
enum class VarSpecKind : uint8_t {
|
2025-11-13 11:59:02 +00:00
|
|
|
PARAM, // Select only matching parameters
|
|
|
|
|
PORT, // Select only matching ports
|
|
|
|
|
VAR // Select any matching AstVar (including params and ports)
|
|
|
|
|
};
|
|
|
|
|
|
2020-01-12 10:03:17 +01:00
|
|
|
static void addCaseFull(const string& file, int lineno);
|
|
|
|
|
static void addCaseParallel(const string& file, int lineno);
|
|
|
|
|
static void addCoverageBlockOff(const string& file, int lineno);
|
|
|
|
|
static void addCoverageBlockOff(const string& module, const string& blockname);
|
2025-03-24 23:39:29 +01:00
|
|
|
static void addHierWorkers(FileLine* fl, const string& model, int workers);
|
2026-05-21 17:50:31 +00:00
|
|
|
static void addFsmRegisterWrapper(FileLine* fl, const string& module, const string& d,
|
2026-05-21 17:51:28 +00:00
|
|
|
const string& q, const string& clock, const string& reset,
|
|
|
|
|
const string& resetValue);
|
2018-02-07 19:31:21 -05:00
|
|
|
static void addIgnore(V3ErrorCode code, bool on, const string& filename, int min, int max);
|
2024-11-12 20:21:16 -05:00
|
|
|
static void addIgnoreMatch(V3ErrorCode code, const string& filename, const string& contents,
|
|
|
|
|
const string& match);
|
2020-01-12 10:03:17 +01:00
|
|
|
static void addInline(FileLine* fl, const string& module, const string& ftask, bool on);
|
2022-01-02 13:56:40 -05:00
|
|
|
static void addModulePragma(const string& module, VPragmaType pragma);
|
2025-01-20 20:24:09 +01:00
|
|
|
static void addProfileData(FileLine* fl, const string& hierDpi, uint64_t cost);
|
2021-09-26 22:51:11 -04:00
|
|
|
static void addProfileData(FileLine* fl, const string& model, const string& key,
|
2022-03-27 15:27:40 -04:00
|
|
|
uint64_t cost);
|
2022-05-12 22:27:38 -04:00
|
|
|
static void addScopeTraceOn(bool on, const string& scope, int levels);
|
2020-03-15 23:20:33 -04:00
|
|
|
static void addVarAttr(FileLine* fl, const string& module, const string& ftask,
|
2025-11-13 11:59:02 +00:00
|
|
|
VarSpecKind kind, const string& pattern, VAttrType type,
|
|
|
|
|
AstSenTree* nodep);
|
2021-09-26 22:51:11 -04:00
|
|
|
|
2020-01-12 10:03:17 +01:00
|
|
|
static void applyCase(AstCase* nodep);
|
|
|
|
|
static void applyCoverageBlock(AstNodeModule* modulep, AstBegin* nodep);
|
2025-09-23 20:49:01 +02:00
|
|
|
static void applyCoverageBlock(AstNodeModule* modulep, AstGenBlock* nodep);
|
2022-05-11 00:47:52 -04:00
|
|
|
static void applyFTask(AstNodeModule* modulep, AstNodeFTask* ftaskp);
|
2010-01-21 06:11:30 -05:00
|
|
|
static void applyIgnores(FileLine* filelinep);
|
2020-04-15 21:47:37 -04:00
|
|
|
static void applyModule(AstNodeModule* modulep);
|
2025-08-19 22:02:10 +01:00
|
|
|
static void applyVarAttr(const AstNodeModule* modulep, const AstNodeFTask* ftaskp,
|
|
|
|
|
AstVar* varp);
|
2021-09-26 22:51:11 -04:00
|
|
|
|
2025-03-24 23:39:29 +01:00
|
|
|
static int getHierWorkers(const string& model);
|
2025-06-12 13:15:46 +02:00
|
|
|
static FileLine* getHierWorkersFileLine(const string& model);
|
2026-05-21 17:50:31 +00:00
|
|
|
static const FsmRegisterWrapper* getFsmRegisterWrapper(const string& module);
|
2025-01-20 20:24:09 +01:00
|
|
|
static uint64_t getProfileData(const string& hierDpi);
|
2022-03-27 15:27:40 -04:00
|
|
|
static uint64_t getProfileData(const string& model, const string& key);
|
2021-09-26 22:51:11 -04:00
|
|
|
static FileLine* getProfileDataFileLine();
|
2022-05-12 22:27:38 -04:00
|
|
|
static bool getScopeTraceOn(const string& scope);
|
2024-11-12 20:21:16 -05:00
|
|
|
|
|
|
|
|
static void contentsPushText(const string& text);
|
|
|
|
|
|
2025-01-20 20:24:09 +01:00
|
|
|
static bool containsMTaskProfileData();
|
2025-09-13 16:19:00 +02:00
|
|
|
static uint64_t getCurrentHierBlockCost();
|
2025-01-20 20:24:09 +01:00
|
|
|
|
2025-08-19 22:02:10 +01:00
|
|
|
static bool waive(const FileLine* filelinep, V3ErrorCode code, const string& message);
|
2025-12-30 20:31:34 -05:00
|
|
|
|
|
|
|
|
static void selfTest();
|
2010-01-21 06:11:30 -05:00
|
|
|
};
|
|
|
|
|
|
2019-05-19 16:13:13 -04:00
|
|
|
#endif // Guard
|