|
CIRCT 23.0.0git
|
#include "circt/Dialect/Arc/Runtime/ArcRuntime.h"#include "circt/Dialect/Arc/Runtime/Common.h"#include "circt/Dialect/Arc/Runtime/FmtDescriptor.h"#include "circt/Dialect/Arc/Runtime/IRInterface.h"#include "circt/Dialect/Arc/Runtime/Internal.h"#include "circt/Dialect/Arc/Runtime/ModelInstance.h"#include "circt/Support/FormatInteger.h"#include "llvm/ADT/APInt.h"#include "llvm/ADT/ArrayRef.h"#include "llvm/ADT/SmallVector.h"#include "llvm/Support/raw_ostream.h"#include <cassert>#include <cstdarg>#include <cstdint>#include <cstdlib>#include <iostream>
Go to the source code of this file.
Macros | |
| #define | ARC_RUNTIME_ENABLE_EXPORT |
Functions | |
| static impl::ModelInstance * | getModelInstance (const ArcState *instance) |
| ArcState * | arcRuntimeAllocateInstance (const ArcRuntimeModelInfo *model, const char *args) |
| void | arcRuntimeDeleteInstance (ArcState *instance) |
| Destroy and deallocate the state of a model instance. | |
| uint64_t | arcRuntimeGetAPIVersion () |
| Return the API version of the runtime library. | |
| void | arcRuntimeOnEval (ArcState *instance) |
Pre-Eval hook. Must be called by the driver once before every eval step. | |
| void | arcRuntimeOnInitialized (ArcState *instance) |
Must be called by the driver after the model's initial function and before the first onEval call. | |
| ArcState * | arcRuntimeGetStateFromModelState (uint8_t *modelState, uint64_t offset) |
| Project a pointer to the model state to its ArcState container. | |
| uint8_t * | arcRuntimeIR_allocInstance (const ArcRuntimeModelInfo *model, const char *args) |
| Allocate and initialize the state for a new instance of the given hardware model. | |
| void | arcRuntimeIR_onEval (uint8_t *modelState) |
| Pre-Eval hook of the runtime library. | |
| void | arcRuntimeIR_onInitialized (uint8_t *modelState) |
| Post-initialization hook of the runtime library. | |
| void | arcRuntimeIR_deleteInstance (uint8_t *modelState) |
| Destroy and deallocate the state of a model instance. | |
| void | arcRuntimeIR_format (const FmtDescriptor *fmt,...) |
| Prints a formatted string to stdout. | |
| uint64_t * | arcRuntimeIR_swapTraceBuffer (const uint8_t *modelState) |
| Release the active trace buffer and request an empty new buffer. | |
| #define ARC_RUNTIME_ENABLE_EXPORT |
Definition at line 14 of file ArcRuntime.cpp.
| ArcState * arcRuntimeAllocateInstance | ( | const ArcRuntimeModelInfo * | model, |
| const char * | args | ||
| ) |
Definition at line 46 of file ArcRuntime.cpp.
References ArcRuntimeModelInfo::apiVersion, ARC_RUNTIME_API_VERSION, ARC_RUNTIME_MAGIC, assert(), and ArcRuntimeModelInfo::numStateBytes.
Referenced by arcRuntimeIR_allocInstance().
| void arcRuntimeDeleteInstance | ( | ArcState * | instance | ) |
Destroy and deallocate the state of a model instance.
Definition at line 64 of file ArcRuntime.cpp.
References ArcState::impl.
Referenced by arcRuntimeIR_deleteInstance().
| uint64_t arcRuntimeGetAPIVersion | ( | ) |
Return the API version of the runtime library.
Definition at line 70 of file ArcRuntime.cpp.
References ARC_RUNTIME_API_VERSION.
| ArcState * arcRuntimeGetStateFromModelState | ( | uint8_t * | modelState, |
| uint64_t | offset | ||
| ) |
Project a pointer to the model state to its ArcState container.
offset is the byte offset of the given pointer within the model state.
Definition at line 80 of file ArcRuntime.cpp.
References ARC_RUNTIME_MAGIC, and ArcState::magic.
Referenced by arcRuntimeIR_deleteInstance(), arcRuntimeIR_onEval(), and arcRuntimeIR_onInitialized().
| uint8_t * arcRuntimeIR_allocInstance | ( | const ArcRuntimeModelInfo * | model, |
| const char * | args | ||
| ) |
Allocate and initialize the state for a new instance of the given hardware model.
This function must allocate an ArcState struct with at least model->numStateBytes bytes provided for the modelState array. It must return the pointer to the zero initialized model state which is required to be 16-byte-aligned.
args is a zero terminated string containing implementation specific options for the new instance or null.
Definition at line 93 of file ArcRuntime.cpp.
References arcRuntimeAllocateInstance(), and ArcState::modelState.
| void arcRuntimeIR_deleteInstance | ( | uint8_t * | modelState | ) |
Destroy and deallocate the state of a model instance.
This function is responsible for releasing all resources that previously have been allocated by arcRuntimeIR_allocInstance.
Definition at line 107 of file ArcRuntime.cpp.
References arcRuntimeDeleteInstance(), and arcRuntimeGetStateFromModelState().
| void arcRuntimeIR_format | ( | const circt::arc::runtime::FmtDescriptor * | fmt, |
| ... | |||
| ) |
Prints a formatted string to stdout.
fmt is an array of FmtDescriptor objects, ending in a descriptor with action Action_End.
The values to format are passed as variadic arguments.
Definition at line 111 of file ArcRuntime.cpp.
References circt::arc::runtime::FmtDescriptor::action, circt::arc::runtime::FmtDescriptor::Action_Char, circt::arc::runtime::FmtDescriptor::Action_End, circt::arc::runtime::FmtDescriptor::Action_Int, circt::arc::runtime::FmtDescriptor::Action_Literal, circt::arc::runtime::FmtDescriptor::Action_LiteralSmall, circt::arc::runtime::FmtDescriptor::IntFmt::bitwidth, circt::arc::runtime::FmtDescriptor::SmallLiteral::data, circt::formatInteger(), circt::arc::runtime::FmtDescriptor::intFmt, circt::arc::runtime::FmtDescriptor::IntFmt::isLeftAligned, circt::arc::runtime::FmtDescriptor::IntFmt::isSigned, circt::arc::runtime::FmtDescriptor::IntFmt::isUpperCase, circt::arc::runtime::FmtDescriptor::literal, circt::arc::runtime::FmtDescriptor::IntFmt::paddingChar, circt::arc::runtime::FmtDescriptor::IntFmt::radix, circt::arc::runtime::FmtDescriptor::smallLiteral, circt::arc::runtime::FmtDescriptor::IntFmt::specifierWidth, and circt::arc::runtime::FmtDescriptor::LiteralFmt::width.
| void arcRuntimeIR_onEval | ( | uint8_t * | modelState | ) |
Pre-Eval hook of the runtime library.
Simulation drivers must call this once before every invocation of the model's eval function.
Definition at line 99 of file ArcRuntime.cpp.
References arcRuntimeGetStateFromModelState(), and arcRuntimeOnEval().
| void arcRuntimeIR_onInitialized | ( | uint8_t * | modelState | ) |
Post-initialization hook of the runtime library.
Simulation drivers must call this once after the invocation of the model's initial function.
Definition at line 103 of file ArcRuntime.cpp.
References arcRuntimeGetStateFromModelState(), and arcRuntimeOnInitialized().
| uint64_t * arcRuntimeIR_swapTraceBuffer | ( | const uint8_t * | modelState | ) |
Release the active trace buffer and request an empty new buffer.
Invoked by the model to signal that the currently active trace buffer, referenced by modelState->traceBuffer is ready for processing and contains modelState->traceBufferSize valid uint64_t words.
The runtime must return a pointer to a valid storage of at least traceBufferCapacity x uint64_t size, which will become the new active trace buffer.
Definition at line 153 of file ArcRuntime.cpp.
References ARC_RUNTIME_MAGIC, and getModelInstance().
| void arcRuntimeOnEval | ( | ArcState * | instance | ) |
Pre-Eval hook. Must be called by the driver once before every eval step.
Definition at line 72 of file ArcRuntime.cpp.
References getModelInstance().
Referenced by arcRuntimeIR_onEval().
| void arcRuntimeOnInitialized | ( | ArcState * | instance | ) |
Must be called by the driver after the model's initial function and before the first onEval call.
Definition at line 76 of file ArcRuntime.cpp.
References getModelInstance().
Referenced by arcRuntimeIR_onInitialized().
|
inlinestatic |
Definition at line 41 of file ArcRuntime.cpp.
References assert(), and ArcState::impl.
Referenced by arcRuntimeIR_swapTraceBuffer(), arcRuntimeOnEval(), and arcRuntimeOnInitialized().