CIRCT 23.0.0git
Loading...
Searching...
No Matches
ModelInstance.h
Go to the documentation of this file.
1//===- ModelInstance.h - Instance of a model in the ArcRuntime ------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This declares the context for a model instance in the default implementation
10// of the ArcRuntime library.
11//
12// This file is implementation specific and not part of the ArcRuntime's API.
13//
14//===----------------------------------------------------------------------===//
15
16#ifndef CIRCT_DIALECT_ARC_RUNTIME_MODELINSTANCE_H
17#define CIRCT_DIALECT_ARC_RUNTIME_MODELINSTANCE_H
18
22
23#include <filesystem>
24#include <map>
25#include <memory>
26#include <optional>
27#include <string>
28
29namespace circt {
30namespace arc {
31namespace runtime {
32namespace impl {
33
35public:
36 ModelInstance() = delete;
37 ModelInstance(const ArcRuntimeModelInfo *modelInfo, const char *args,
40
41 const char *getModelName() const {
42 return !!modelInfo->modelName ? modelInfo->modelName : "<NULL>";
43 }
44
45 void onInitialized(ArcState *mutableState);
46 void onEval(ArcState *mutableState);
47 uint64_t *swapTraceBuffer();
48
49private:
50 // Runtime argument keys
51 /// Enable verbose debug output
52 inline static const std::string kArgKeyDebug = "debug";
53 /// Select FST trace mode
54 inline static const std::string kArgKeyFst = "fst";
55 /// Workdir-relative or absolute path to trace file
56 inline static const std::string kArgKeyTraceFile = "traceFile";
57 /// Select VCD trace mode
58 inline static const std::string kArgKeyVcd = "vcd";
59 /// Instance's working directory. Absolute or relative to process workdir.
60 inline static const std::string kArgKeyWorkDir = "workDir";
61
62 /// Parse and initialize the instance settings from the given argument string.
63 void parseArgs(const char *args);
64 /// Get the path to the output trace file. Creates a default file name with
65 /// the given suffix within the working directory if not explicitly set by the
66 /// runtime arguments.
67 std::filesystem::path getTraceFilePath(const std::string &suffix);
68
69 const uint64_t instanceID;
71 const ArcState *const state;
72 std::map<std::string, std::optional<std::string>> arguments;
73 /// The path to the instance's working directory. Matches the process
74 /// working directory if not provided by a runtime argument.
75 std::filesystem::path workDir;
76 // FST is always in the enum so headers don't depend on build configuration.
77 // If FST is selected at runtime but not compiled in, an error is emitted.
78 enum class TraceMode { DUMMY, VCD, FST };
80 std::unique_ptr<TraceEncoder> traceEncoder;
81 bool verbose = false;
82 uint64_t stepCounter = 0;
83};
84
85} // namespace impl
86} // namespace runtime
87} // namespace arc
88} // namespace circt
89
90#endif // CIRCT_DIALECT_ARC_RUNTIME_MODELINSTANCE_H
std::filesystem::path getTraceFilePath(const std::string &suffix)
Get the path to the output trace file.
static const std::string kArgKeyTraceFile
Workdir-relative or absolute path to trace file.
void onEval(ArcState *mutableState)
void parseArgs(const char *args)
Parse and initialize the instance settings from the given argument string.
static const std::string kArgKeyDebug
Enable verbose debug output.
static const std::string kArgKeyVcd
Select VCD trace mode.
std::unique_ptr< TraceEncoder > traceEncoder
std::map< std::string, std::optional< std::string > > arguments
std::filesystem::path workDir
The path to the instance's working directory.
static const std::string kArgKeyFst
Select FST trace mode.
void onInitialized(ArcState *mutableState)
static const std::string kArgKeyWorkDir
Instance's working directory. Absolute or relative to process workdir.
const ArcRuntimeModelInfo *const modelInfo
Definition arc.py:1
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Static information for a compiled hardware model, generated by the MLIR lowering.
Definition Common.h:70
const char * modelName
Name of the compiled model.
Definition Common.h:76
Combined runtime and model state for a hardware model instance.
Definition Common.h:44