This example shows how to extract data from a given file and store it in a queue, on one side, and on the other hand, collect the receiving data with an analysis TLM FIFO.
Using the $fopen() system task, we can either read or write to a certain file. This task returns an integer – file handler. Once the file is closed, no more writes/reads are allowed.
Below is a .hex file given with 32-bit values, followed by needed commands. After loading the file, a 4-byte value is parsed and pushed to an src queue, one byte by one byte.
TLM analysis FIFO allows the storing of transactions instead of one-time-use and can be utilized at any place where a uvm_analysis_import is used. Also, declaration, creation, and methods are implemented in the same way.
The following code collects the received data from the TLM FIFO and stores it to a uart_rx_q queue.
After all the queues are filled, simple comparison between the queue with the data from the file, and the queue with received data is done.