31 const char *args,
ArcState *mutableState)
39 std::cout <<
"[ArcRuntime] "
43 std::cout <<
"[ArcRuntime] Model \"" <<
getModelName() <<
"\"";
44 if (hasTraceInstrumentation)
45 std::cout <<
" has trace instrumentation." << std::endl;
47 std::cout <<
" does not have trace instrumentation." << std::endl;
52 <<
"[ArcRuntime] WARNING: "
53 <<
"Tracing has been requested but model \"" <<
getModelName()
54 <<
"\" contains no instrumentation."
55 <<
" No trace will be produced.\n\t\tMake sure to compile the model"
56 " with tracing enabled and that it contains observed signals."
59 if (hasTraceInstrumentation) {
63 std::make_unique<DummyTraceEncoder>(
modelInfo, mutableState);
77 std::cout <<
"[ArcRuntime] "
78 <<
"Deleting instance"
81 <<
" step(s)" << std::endl;
83 assert(
state->
impl ==
static_cast<void *
>(
this) &&
"Inconsistent ArcState");
96 for (
auto &c : saneName) {
97 if (c ==
' ' || c ==
'/' || c ==
'\\')
103 return std::filesystem::current_path() / std::filesystem::path(saneName);
119 std::cout <<
"[ArcRuntime] "
120 <<
"Instance with ID " <<
instanceID <<
" initialized"
128 "swapTraceBuffer called on model without trace instrumentation");
130 std::cout <<
"[ArcRuntime] Consuming trace buffer of size "
138 std::string &value) {
141 auto eqPos = input.find(
'=');
142 if (eqPos == std::string_view::npos || eqPos == 0)
144 key = input.substr(0, eqPos);
145 value = input.substr(eqPos + 1);
154 auto argStr = std::string_view(args);
157 std::vector<std::string_view> options;
161 while ((end = argStr.find(
";", start)) != std::string_view::npos) {
162 options.push_back(argStr.substr(start, end - start));
165 if (start <= argStr.size())
166 options.push_back(argStr.substr(start));
172 for (
auto &option : options) {
174 if (option ==
"debug") {
176 }
else if (option ==
"vcd") {
179 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.