How to send .txt file (contains random data of 1kb) to UVM Driver

I have generated 1kb of random data & saved in one text file called data.txt, Now I need to pass this .txt file to UVM driver OR I need to read this .txt file in the UVM driver code.
Please can some one suggest how to approach this issue.

data.txt
1234
5678
9abc

till 1kb.

Your driver should work independently of how the data was generated. A driver simply converts a procedural method call from your testbench (a transaction) to pin wiggles that communicate with your DUT through an interface.

In the UVM, we use sequences to generate transactions that are sent to your driver. You just need to write a sequence that reads the file and converts it to items sent to the driver.

In reply to dave_59:

Hi dave,

How to write a sequence to read the file??
can i have example?

Thanks,
sagar

In reply to sagar@aceic.com:

Sagar,
We can do it by using system functions. Steps are below

  1. Create your own sequence which extends from uvm_sequence and should be parameterised by your object.
  2. Inside the body task use the system functions to read the text file.
    fopen, fgetc,fscanf using these u can read the data & assing to some reg or int(2 state) variable.
  3. Now you have sampled data from the text file. Ex: You can pass these sampled data to the APB write task to write in to reg or memory.
  4. Use uvm macro like `uvm_do_with (addr ,data,sel_line). U can cnstraint radimazation by assigning sampled value to the item
    ex: req.DATA = data(smpled).
    It worked for us.

Regards,
Sharana

In reply to Sharana Basava:

Hi Sharana,

Thanks for the added points:

It would be very helpful if you give the example…!!
i mean how you are assigning…
and why you are saying it to assign the variables to reg or int type!!

Thanks,
sagar

In reply to sagar@aceic.com:

Ex: a1.txt file contains
APB_W 0x23 0x2222
APB_R 0x25

Steps:
1.$fopen: open d file
2. $fscanf: read the first string word. Based on string read the data
3. case (string )
APB_W: $fscanf(“%h %h”, addr,data);
APB_R : $fscanf(“%h”,addr);
4.based on read or write, assing to transcation variables,
req= xx_transction::type_id ::create(req);
`uvm_do_with(req.addr == addr, req.data==data);

** In my case data is like 0x32, so while reading i should decode it as hex 32. So if i assigning to integer it is reading as “0x32” including x also.but i wan it as only 32. so i used 2 state int variable to assign.

Regards,
Sharana

In reply to Sharana Basava:

You should not be using the `uvm_do_* macros. If you are reading known values, you should be using direct assignments as well, unless there are additional fields that need to be randomized.


req = xx_transaction_type::type_id::create("req");
start_item(req);
req.addr = address_from_file;
req.data = data_from_file;
finish_item(req);

In reply to cgales:

Yes we can do without `uvm_do_* macros also by doing direct assignment as cgales told.
Thanks cgales.

In reply to Sharana Basava:

Thank u for the help…!!!