CIRCT 23.0.0git
Loading...
Searching...
No Matches
Macros | Functions
ArcRuntime.cpp File Reference
#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 "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>
Include dependency graph for ArcRuntime.cpp:

Go to the source code of this file.

Macros

#define ARC_RUNTIME_ENABLE_EXPORT
 

Functions

static impl::ModelInstance * getModelInstance (const ArcState *instance)
 
ArcStatearcRuntimeAllocateInstance (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.
 
ArcStatearcRuntimeGetStateFromModelState (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)
 
void arcRuntimeIR_deleteInstance (uint8_t *modelState)
 Destroy and deallocate the state of a model instance.
 
static void formatIntegersByRadix (llvm::raw_ostream &os, int width, int radix, const llvm::APInt &value, bool isUpperCase, bool isLeftAligned, char paddingChar, int specifierWidth, bool isSigned)
 
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.
 

Macro Definition Documentation

◆ ARC_RUNTIME_ENABLE_EXPORT

#define ARC_RUNTIME_ENABLE_EXPORT

Definition at line 14 of file ArcRuntime.cpp.

Function Documentation

◆ arcRuntimeAllocateInstance()

ArcState * arcRuntimeAllocateInstance ( const ArcRuntimeModelInfo model,
const char *  args 
)

◆ arcRuntimeDeleteInstance()

void arcRuntimeDeleteInstance ( ArcState instance)

Destroy and deallocate the state of a model instance.

Definition at line 63 of file ArcRuntime.cpp.

References ArcState::impl.

Referenced by arcRuntimeIR_deleteInstance().

◆ arcRuntimeGetAPIVersion()

uint64_t arcRuntimeGetAPIVersion ( )

Return the API version of the runtime library.

Definition at line 69 of file ArcRuntime.cpp.

References ARC_RUNTIME_API_VERSION.

◆ arcRuntimeGetStateFromModelState()

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 79 of file ArcRuntime.cpp.

References ARC_RUNTIME_MAGIC, and ArcState::magic.

Referenced by arcRuntimeIR_deleteInstance(), arcRuntimeIR_onEval(), and arcRuntimeIR_onInitialized().

◆ arcRuntimeIR_allocInstance()

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 92 of file ArcRuntime.cpp.

References arcRuntimeAllocateInstance(), and ArcState::modelState.

◆ arcRuntimeIR_deleteInstance()

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 106 of file ArcRuntime.cpp.

References arcRuntimeDeleteInstance(), and arcRuntimeGetStateFromModelState().

◆ arcRuntimeIR_format()

void arcRuntimeIR_format ( const circt::arc::runtime::FmtDescriptor fmt,
  ... 
)

◆ arcRuntimeIR_onEval()

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 98 of file ArcRuntime.cpp.

References arcRuntimeGetStateFromModelState(), and arcRuntimeOnEval().

◆ arcRuntimeIR_onInitialized()

void arcRuntimeIR_onInitialized ( uint8_t *  modelState)

◆ arcRuntimeIR_swapTraceBuffer()

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 195 of file ArcRuntime.cpp.

References ARC_RUNTIME_MAGIC, and getModelInstance().

◆ arcRuntimeOnEval()

void arcRuntimeOnEval ( ArcState instance)

Pre-Eval hook. Must be called by the driver once before every eval step.

Definition at line 71 of file ArcRuntime.cpp.

References getModelInstance().

Referenced by arcRuntimeIR_onEval().

◆ arcRuntimeOnInitialized()

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 75 of file ArcRuntime.cpp.

References getModelInstance().

Referenced by arcRuntimeIR_onInitialized().

◆ formatIntegersByRadix()

static void formatIntegersByRadix ( llvm::raw_ostream &  os,
int  width,
int  radix,
const llvm::APInt &  value,
bool  isUpperCase,
bool  isLeftAligned,
char  paddingChar,
int  specifierWidth,
bool  isSigned 
)
static

Definition at line 113 of file ArcRuntime.cpp.

Referenced by arcRuntimeIR_format().

◆ getModelInstance()

static impl::ModelInstance * getModelInstance ( const ArcState instance)
inlinestatic

Definition at line 40 of file ArcRuntime.cpp.

References assert(), and ArcState::impl.

Referenced by arcRuntimeIR_swapTraceBuffer(), arcRuntimeOnEval(), and arcRuntimeOnInitialized().