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.
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.
Sagar,
We can do it by using system functions. Steps are below
Create your own sequence which extends from uvm_sequence and should be parameterised by your object.
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.
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.
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.
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!!
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.
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.