Transaction Recording Databases

The UVM “Transaction Recording Database” classes are an abstract representation of the backend tool which is recording information for the user.  Usually this tool would be dumping information such that it can be viewed with the waves of the DUT.

Contents
Transaction Recording DatabasesThe UVM “Transaction Recording Database” classes are an abstract representation of the backend tool which is recording information for the user.
uvm_tr_databaseThe uvm_tr_database class is intended to hide the underlying database implementation from the end user, as these details are often vendor or tool-specific.
uvm_text_tr_databaseThe uvm_text_tr_database is the default implementation for the uvm_tr_database.

uvm_tr_database

The uvm_tr_database class is intended to hide the underlying database implementation from the end user, as these details are often vendor or tool-specific.

The uvm_tr_database class is pure virtual, and must be extended with an implementation.  A default text-based implementation is provided via the uvm_text_tr_database class.

Summary
uvm_tr_database
The uvm_tr_database class is intended to hide the underlying database implementation from the end user, as these details are often vendor or tool-specific.
Class Hierarchy
uvm_tr_database
Class Declaration
virtual class uvm_tr_database extends uvm_object
newConstructor
Database API
open_dbOpen the backend connection to the database.
close_dbCloses the backend connection to the database.
is_openReturns the open/closed status of the database.
Stream API
open_streamProvides a reference to a stream within the database.
get_streamsProvides a queue of all streams within the database.
Link API
establish_linkEstablishes a link between two elements in the database
Implementation Agnostic API
do_open_dbBackend implementation of open_db
do_close_dbBackend implementation of close_db
do_open_streamBackend implementation of open_stream
do_establish_linkBackend implementation of establish_link

new

function new(
    string  name  =  "unnamed-uvm_tr_database"
)

Constructor

Parameters

nameInstance name

open_db

function bit open_db()

Open the backend connection to the database.

If the database is already open, then this method will return 1.

Otherwise, the method will call do_open_db, and return the result.

close_db

function bit close_db()

Closes the backend connection to the database.

Closing a database implicitly closes and frees all uvm_tr_streams within the database.

If the database is already closed, then this method will return 1.

Otherwise, this method will trigger a do_close_db call, and return the result.

is_open

function bit is_open()

Returns the open/closed status of the database.

This method returns 1 if the database has been successfully opened, but not yet closed.

open_stream

function uvm_tr_stream open_stream(
    string  name,   
    string  scope  =  "",
    string  type_name  =  ""
)

Provides a reference to a stream within the database.

Parameters

nameA string name for the stream.  This is the name associated with the stream in the database.
scopeAn optional scope for the stream.
type_nameAn optional name describing the type of records which will be created in this stream.

The method returns a reference to a uvm_tr_stream object if successful, null otherwise.

This method will trigger a do_open_stream call, and if a non null stream is returned, then uvm_tr_stream::do_open will be called.

Streams can only be opened if the database is open (per is_open).  Otherwise the request will be ignored, and null will be returned.

get_streams

function unsigned get_streams(
    ref  uvm_tr_stream  q[$]
)

Provides a queue of all streams within the database.

Parameters

qA reference to a queue of uvm_tr_streams

The get_streams method returns the size of the queue, such that the user can conditionally process the elements.

uvm_tr_stream stream_q[$];
if (my_db.get_streams(stream_q)) begin
  // Process the queue...
end

establish_link

function void establish_link(
    uvm_link_base  link
)

Establishes a link between two elements in the database

Links are only supported between streams and records within a single database.

This method will trigger a do_establish_link call.

do_open_db

pure virtual protected function bit do_open_db()

Backend implementation of open_db

do_close_db

pure virtual protected function bit do_close_db()

Backend implementation of close_db

do_open_stream

pure virtual protected function uvm_tr_stream do_open_stream(
    string  name,
    string  scope,
    string  type_name
)

Backend implementation of open_stream

do_establish_link

pure virtual protected function void do_establish_link(
    uvm_link_base  link
)

Backend implementation of establish_link

uvm_text_tr_database

The uvm_text_tr_database is the default implementation for the uvm_tr_database.  It provides the ability to store recording information into a textual log file.

Summary
uvm_text_tr_database
The uvm_text_tr_database is the default implementation for the uvm_tr_database.
Class Hierarchy
uvm_text_tr_database
Class Declaration
class uvm_text_tr_database extends uvm_tr_database
newConstructor
Implementation Agnostic API
do_open_dbOpen the backend connection to the database.
do_close_dbClose the backend connection to the database.
do_open_streamProvides a reference to a stream within the database.
do_establish_linkEstablishes a link between two elements in the database
Implementation Specific API
set_file_nameSets the file name which will be used for output.

new

function new(
    string  name  =  "unnamed-uvm_text_tr_database"
)

Constructor

Parameters

nameInstance name

do_open_db

protected virtual function bit do_open_db()

Open the backend connection to the database.

Text-Backend implementation of uvm_tr_database::open_db.

The text-backend will open a text file to dump all records in to.  The name of this text file is controlled via set_file_name.

This will also lock the file_name, so that it cannot be modified while the connection is open.

do_close_db

protected virtual function bit do_close_db()

Close the backend connection to the database.

Text-Backend implementation of uvm_tr_database::close_db.

The text-backend will close the text file used to dump all records in to, if it is currently opened.

This unlocks the file_name, allowing it to be modified again.

do_open_stream

protected virtual function uvm_tr_stream do_open_stream(
    string  name,
    string  scope,
    string  type_name
)

Provides a reference to a stream within the database.

Text-Backend implementation of uvm_tr_database::open_stream

do_establish_link

protected virtual function void do_establish_link(
    uvm_link_base  link
)

Establishes a link between two elements in the database

Text-Backend implementation of uvm_tr_database::establish_link.

set_file_name

function void set_file_name(
    string  filename
)

Sets the file name which will be used for output.

The set_file_name method can only be called prior to open_db.

By default, the database will use a file named “tr_db.log”.

virtual class uvm_tr_database extends uvm_object
The uvm_tr_database class is intended to hide the underlying database implementation from the end user, as these details are often vendor or tool-specific.
class uvm_text_tr_database extends uvm_tr_database
The uvm_text_tr_database is the default implementation for the uvm_tr_database.
virtual class uvm_void
The uvm_void class is the base class for all UVM classes.
virtual class uvm_object extends uvm_void
The uvm_object class is the base class for all UVM data and hierarchical classes.
function new(
    string  name  =  "unnamed-uvm_tr_database"
)
Constructor
function bit open_db()
Open the backend connection to the database.
function bit close_db()
Closes the backend connection to the database.
function bit is_open()
Returns the open/closed status of the database.
function uvm_tr_stream open_stream(
    string  name,   
    string  scope  =  "",
    string  type_name  =  ""
)
Provides a reference to a stream within the database.
function unsigned get_streams(
    ref  uvm_tr_stream  q[$]
)
Provides a queue of all streams within the database.
function void establish_link(
    uvm_link_base  link
)
Establishes a link between two elements in the database
pure virtual protected function bit do_open_db()
Backend implementation of open_db
pure virtual protected function bit do_close_db()
Backend implementation of close_db
pure virtual protected function uvm_tr_stream do_open_stream(
    string  name,
    string  scope,
    string  type_name
)
Backend implementation of open_stream
pure virtual protected function void do_establish_link(
    uvm_link_base  link
)
Backend implementation of establish_link
virtual class uvm_tr_stream extends uvm_object
The uvm_tr_stream base class is a representation of a stream of records within a uvm_tr_database.
protected virtual function void do_open(
    uvm_tr_database  db,
    string  scope,
    string  stream_type_name
)
Callback triggered via uvm_tr_database::open_stream.
function new(
    string  name  =  "unnamed-uvm_text_tr_database"
)
Constructor
protected virtual function bit do_open_db()
Open the backend connection to the database.
protected virtual function bit do_close_db()
Close the backend connection to the database.
protected virtual function uvm_tr_stream do_open_stream(
    string  name,
    string  scope,
    string  type_name
)
Provides a reference to a stream within the database.
protected virtual function void do_establish_link(
    uvm_link_base  link
)
Establishes a link between two elements in the database
function void set_file_name(
    string  filename
)
Sets the file name which will be used for output.