CIRCT 22.0.0git
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
circt::arc::runtime::impl::VCDTraceEncoder Class Referencefinal

Trace buffer encoder producing a VCD file. More...

#include <VCDTraceEncoder.h>

Inheritance diagram for circt::arc::runtime::impl::VCDTraceEncoder:
Inheritance graph
[legend]
Collaboration diagram for circt::arc::runtime::impl::VCDTraceEncoder:
Collaboration graph
[legend]

Public Member Functions

 VCDTraceEncoder (const ArcRuntimeModelInfo *modelInfo, ArcState *state, const std::filesystem::path &outFilePath, bool debug)
 
- Public Member Functions inherited from circt::arc::runtime::impl::TraceEncoder
 TraceEncoder ()=delete
 
 TraceEncoder (const ArcRuntimeModelInfo *modelInfo, ArcState *state, unsigned numBuffers, bool debug)
 Construct a trace encoder for the given model and the given number of buffers.
 
virtual ~TraceEncoder ()=default
 
void run (ArcState *state)
 Begin tracing.
 
uint64_t * dispatch (uint32_t oldBufferSize)
 Dispatch the currently active trace buffer containing oldBufferSize valid entries to the encoder thread and return the storage of the new active buffer.
 
void step (const ArcState *state)
 Signal the start of a new simulation time step.
 
void finish (const ArcState *state)
 Stop tracing.
 

Static Public Attributes

static constexpr unsigned numTraceBuffers = 4
 

Protected Member Functions

bool initialize (const ArcState *state) override
 Set-up the encoder before starting the worker thread.
 
void startUpWorker () override
 Called by the worker thread before entering the encode loop.
 
void encode (TraceBuffer &work) override
 Encode the given trace buffer. Called by the worker thread.
 
void windDownWorker () override
 Called by the worker thread after leaving the encode loop.
 
void finalize (const ArcState *state) override
 Finish trace encoding. Called by the simulation thread.
 

Private Member Functions

void initSignalTable ()
 Create the table of signals.
 
void createHierarchy ()
 Build and dump the signal hierarchy.
 

Private Attributes

const std::filesystem::path outFilePath
 Path to the output file.
 
std::vector< VCDSignalTableEntrysignalTable
 Table of signals: The index matches their Trace Tap ID.
 
std::ofstream outFile
 Output file stream.
 
std::unique_ptr< char[]> fileBuffer
 Internal buffer of the output stream.
 
std::vector< char > workerOutBuffer
 Concatenation buffer of the worker thread.
 
int64_t workerStep
 Current time step of the worker thread.
 

Additional Inherited Members

- Public Attributes inherited from circt::arc::runtime::impl::TraceEncoder
const unsigned numBuffers
 Number of trace buffers in rotation.
 
- Protected Attributes inherited from circt::arc::runtime::impl::TraceEncoder
const ArcRuntimeModelInfo *const modelInfo
 Metadata of the traced model.
 
const bool debug
 Debug mode flag.
 

Detailed Description

Trace buffer encoder producing a VCD file.

Definition at line 68 of file VCDTraceEncoder.h.

Constructor & Destructor Documentation

◆ VCDTraceEncoder()

circt::arc::runtime::impl::VCDTraceEncoder::VCDTraceEncoder ( const ArcRuntimeModelInfo modelInfo,
ArcState state,
const std::filesystem::path &  outFilePath,
bool  debug 
)

Definition at line 88 of file VCDTraceEncoder.cpp.

Member Function Documentation

◆ createHierarchy()

void circt::arc::runtime::impl::VCDTraceEncoder::createHierarchy ( )
private

◆ encode()

void circt::arc::runtime::impl::VCDTraceEncoder::encode ( TraceBuffer work)
overrideprotectedvirtual

◆ finalize()

void circt::arc::runtime::impl::VCDTraceEncoder::finalize ( const ArcState state)
overrideprotectedvirtual

Finish trace encoding. Called by the simulation thread.

Reimplemented from circt::arc::runtime::impl::TraceEncoder.

Definition at line 298 of file VCDTraceEncoder.cpp.

References outFile.

◆ initialize()

bool circt::arc::runtime::impl::VCDTraceEncoder::initialize ( const ArcState state)
overrideprotectedvirtual

Set-up the encoder before starting the worker thread.

May return false to indicate failure. In this case, no worker thread will be created. Called by the simulation thread.

Implements circt::arc::runtime::impl::TraceEncoder.

Definition at line 209 of file VCDTraceEncoder.cpp.

References assert(), createHierarchy(), fileBuffer, initSignalTable(), circt::arc::runtime::impl::TraceEncoder::modelInfo, ArcRuntimeModelInfo::modelName, ArcState::modelState, ArcRuntimeModelInfo::numStateBytes, outFile, outFilePath, and signalTable.

◆ initSignalTable()

void circt::arc::runtime::impl::VCDTraceEncoder::initSignalTable ( )
private

Create the table of signals.

Definition at line 95 of file VCDTraceEncoder.cpp.

References circt::arc::runtime::impl::TraceEncoder::modelInfo, signalTable, and ArcRuntimeModelInfo::traceInfo.

Referenced by initialize().

◆ startUpWorker()

void circt::arc::runtime::impl::VCDTraceEncoder::startUpWorker ( )
overrideprotectedvirtual

Called by the worker thread before entering the encode loop.

Reimplemented from circt::arc::runtime::impl::TraceEncoder.

Definition at line 247 of file VCDTraceEncoder.cpp.

References workerStep.

◆ windDownWorker()

void circt::arc::runtime::impl::VCDTraceEncoder::windDownWorker ( )
overrideprotectedvirtual

Called by the worker thread after leaving the encode loop.

Reimplemented from circt::arc::runtime::impl::TraceEncoder.

Definition at line 288 of file VCDTraceEncoder.cpp.

References assert(), outFile, workerOutBuffer, workerStep, and circt::arc::runtime::impl::writeTimestepToBuffer().

Member Data Documentation

◆ fileBuffer

std::unique_ptr<char[]> circt::arc::runtime::impl::VCDTraceEncoder::fileBuffer
private

Internal buffer of the output stream.

Do not access directly. Do not release until outFile is closed.

Definition at line 96 of file VCDTraceEncoder.h.

Referenced by initialize().

◆ numTraceBuffers

constexpr unsigned circt::arc::runtime::impl::VCDTraceEncoder::numTraceBuffers = 4
staticconstexpr

Definition at line 70 of file VCDTraceEncoder.h.

◆ outFile

std::ofstream circt::arc::runtime::impl::VCDTraceEncoder::outFile
private

Output file stream.

Definition at line 93 of file VCDTraceEncoder.h.

Referenced by createHierarchy(), encode(), finalize(), initialize(), and windDownWorker().

◆ outFilePath

const std::filesystem::path circt::arc::runtime::impl::VCDTraceEncoder::outFilePath
private

Path to the output file.

Definition at line 89 of file VCDTraceEncoder.h.

Referenced by initialize().

◆ signalTable

std::vector<VCDSignalTableEntry> circt::arc::runtime::impl::VCDTraceEncoder::signalTable
private

Table of signals: The index matches their Trace Tap ID.

Definition at line 91 of file VCDTraceEncoder.h.

Referenced by createHierarchy(), encode(), initialize(), and initSignalTable().

◆ workerOutBuffer

std::vector<char> circt::arc::runtime::impl::VCDTraceEncoder::workerOutBuffer
private

Concatenation buffer of the worker thread.

Definition at line 98 of file VCDTraceEncoder.h.

Referenced by encode(), and windDownWorker().

◆ workerStep

int64_t circt::arc::runtime::impl::VCDTraceEncoder::workerStep
private

Current time step of the worker thread.

Definition at line 100 of file VCDTraceEncoder.h.

Referenced by encode(), startUpWorker(), and windDownWorker().


The documentation for this class was generated from the following files: