Home

Awesome

LWTR4SC - Lightweight transaction recording for SystemC

LWTR4SC is inspired by the transaction recoridng facilities of the SystemC Verification Library (SCV). It follows the approach there but implements it using modern C++. Therefore it requires at least C++11.

Structure

LWTR4SC provides an API to define what to record (the "frontend") and how to record it (the "backend").

The frontend classes and functions to define what to record are defined in lwtr.h and is located in the namespace lwtr. The hierarchy is as follows:

The API on how to record transactions is realized using callback functions. Those are registered using the static register_* functions of the respective frontend classes. In particular:

The library supports recording transactions in two formats. The first is a simple text format that can be found at lwtr/lwtr_text.cpp. The second is a new binary format called 'Fast Transaction Recording'.

Fast Transaction Recording (FTR) format description

FTR uses Concise Binary Object Representation (CBOR) according to RFC 8949 as the storage encoding. CBOR documentation and related information can be found at cbor.io.

FTR consists of a seqence of chunks starting with an info chunk. Each chunk consists of a CBOR tag, a header and a payload where the payload may be compressed using lz4.

The following chunks are used within a FTR database.

info chunk

The info chunk is denoted by CBOR tag 6 followed by an array having 2 entries:

dictionary chunk

The dictionary chunk provides a mapping between numeric ids and strings to save space. There can be several dictionary chunks in a file since strings need to be defined before referencing them. All chunks form a single map, keys are guaranteedt to be unique, they might be consecutive numbers.

The uncompressed dictionary chunk is denoted be CBOR tag 8 followed by an encoded CBOR data item.

The compressed dictionary chunk is denoted by CBOR tag 9 followed by an array having 2 entries:

The data item itself is an indefinite length map (major type 5) having a pairs of unsigned and string as entries.

directory chunk

The uncompressed directory chunk is denoted be CBOR tag 10 followed by an encoded CBOR data item holding the content.

The compressed directory chunk is denoted by CBOR tag 11 followed by an array having 2 entries:

The directory content itself is structured as an indefinite-length array conisting of:

tx block chunk

The uncompressed tx block chunk is denoted be CBOR tag 12 followed by an array having 4 entries:

The compressed tx block chunk is denoted by CBOR tag 13 followed by an array having 5 entries:

Indicating the stream id, start, and end time allows to quickly skip over the tx blocks if only a specific stream is of interest.

The tx block content itself is structured as an indefinite-length array conisting of:

The data type is encoded as follows:

idnameC++/SystemC data typerepresented as
0BOOLEANboolunsigned int
1ENUMERATIONenumunsigned int (string id)
2INTEGERchar, short, int, long, long long, sc_int, sc_bigintunsigned int
3UNSIGNEDunsigned [char, short, int, long, long long], sc_uint, sc_biguintunsigned int
4FLOATING_POINT_NUMBERfloat, doubledouble
5BIT_VECTORsc_bit, sc_bvunsigned int (string id)
6LOGIC_VECTORsc_logic, sc_lvunsigned int (string id)
7FIXED_POINT_INTEGERsc_fixeddouble
8UNSIGNED_FIXED_POINT_INTEGERsc_ufixeddouble
9POINTERvoid*unsigned int
10STRINGstring, std::stringunsigned int (string id)
11TIMEsc_timeunsigned int (time stamp)

relationship chunk

The uncompressed relationship chunk is denoted be CBOR tag 14 followed by an encoded CBOR data item holding the content.

The compressed relationship chunk is denoted by CBOR tag 15 followed by an array having 2 entries:

The relationship content itself is structured as an indefinite-length array consisting of: