17#ifdef CIRCT_LIBFST_ENABLED
34 const char *args,
ArcState *mutableState)
42 std::cout <<
"[ArcRuntime] "
46 std::cout <<
"[ArcRuntime] Model \"" <<
getModelName() <<
"\"";
47 if (hasTraceInstrumentation)
48 std::cout <<
" has trace instrumentation." << std::endl;
50 std::cout <<
" does not have trace instrumentation." << std::endl;
55 <<
"[ArcRuntime] WARNING: "
56 <<
"Tracing has been requested but model \"" <<
getModelName()
57 <<
"\" contains no instrumentation."
58 <<
" No trace will be produced.\n\t\tMake sure to compile the model"
59 " with tracing enabled and that it contains observed signals."
62 if (hasTraceInstrumentation) {
66 std::make_unique<DummyTraceEncoder>(
modelInfo, mutableState);
73#ifdef CIRCT_LIBFST_ENABLED
77 std::cerr <<
"[ArcRuntime] ERROR: FST tracing was requested but CIRCT "
78 "was not built with FST support (CIRCT_LIBFST_ENABLED=OFF)."
81 std::make_unique<DummyTraceEncoder>(
modelInfo, mutableState);
92 std::cout <<
"[ArcRuntime] "
93 <<
"Deleting instance"
96 <<
" step(s)" << std::endl;
98 assert(
state->
impl ==
static_cast<void *
>(
this) &&
"Inconsistent ArcState");
108 std::string saneName;
111 for (
auto &c : saneName) {
112 if (c ==
' ' || c ==
'/' || c ==
'\\')
118 return std::filesystem::current_path() / std::filesystem::path(saneName);
134 std::cout <<
"[ArcRuntime] "
135 <<
"Instance with ID " <<
instanceID <<
" initialized"
143 "swapTraceBuffer called on model without trace instrumentation");
145 std::cout <<
"[ArcRuntime] Consuming trace buffer of size "
153 std::string &value) {
156 auto eqPos = input.find(
'=');
157 if (eqPos == std::string_view::npos || eqPos == 0)
159 key = input.substr(0, eqPos);
160 value = input.substr(eqPos + 1);
169 auto argStr = std::string_view(args);
172 std::vector<std::string_view> options;
176 while ((end = argStr.find(
";", start)) != std::string_view::npos) {
177 options.push_back(argStr.substr(start, end - start));
180 if (start <= argStr.size())
181 options.push_back(argStr.substr(start));
187 for (
auto &option : options) {
189 if (option ==
"debug") {
191 }
else if (option ==
"vcd") {
193 }
else if (option ==
"fst") {
196 if (key ==
"traceFile")
assert(baseType &&"element must be base type")
std::filesystem::path getTraceFilePath(const std::string &suffix)
void onEval(ArcState *mutableState)
void parseArgs(const char *args)
std::optional< std::string > traceFileArg
std::unique_ptr< TraceEncoder > traceEncoder
const ArcState *const state
const uint64_t instanceID
void onInitialized(ArcState *mutableState)
const char * getModelName() const
uint64_t * swapTraceBuffer()
const ArcRuntimeModelInfo *const modelInfo
static void fatalError(const char *message)
Raise an irrecoverable error.
static uint64_t instanceIDsGlobal
static bool parseKeyValueArg(const std::string_view &input, std::string &key, std::string &value)
Static information for a compiled hardware model, generated by the MLIR lowering.
struct ArcModelTraceInfo * traceInfo
Signal tracing information. NULL iff the model is not trace instrumented.
const char * modelName
Name of the compiled model.
Combined runtime and model state for a hardware model instance.
void * impl
Runtime implementation specific data. Usually points to a custom struct.
uint32_t traceBufferSize
Number of valid elements in the active trace buffer.