niks007 Posted March 3, 2012 Report Share Posted March 3, 2012 (edited) Hi i will start by explaining my requirement first . Using a UVM sequence my objective is to read data patterns from a file in hexadecimal format line by line and then feed/constrain the data field of my "trans" with data i read. I am also unaware of the data length as that too can be variable and has to be determined dynamically here is the code that i have written and that is not working . Need help/hint on same =================================== virtual task body(); integer file_p, temp; integer count =0; reg [7:0] data; string str; file_p = $fopen("file.txt","r"); if (!file_p) begin `uvm_error("ERROR :","FILE OPENED FAILED :: NO SUCH FILE OR BAD FILE NAME"); end else begin while(!$feof) begin temp = $fscanf(file_p,"%s",str); count = count++; end end $display("Value of Count = %d",count); `uvm_do_with(trans, { Addr == addr; Direction == write; Length == count; for (int i = 0; i < count; i++) begin $fscanf(file_p,"%s",data); Data == data; // Data is dynamic array end }) endtask : body =========================== Can anybody tell what is wrong i am doing here i am alos open with same scenario being generated by uvm_create/uvm_send Thanks niks007 Edited March 3, 2012 by niks007 Quote Link to comment Share on other sites More sharing options...
Roman Posted March 4, 2012 Report Share Posted March 4, 2012 Try this one, It should work for (int i = 0; i < count; i++) begin $fscanf(file_p,"%s",data); Data_tmp == data; // Data_tmp is dynamic array end `uvm_do_with(trans, { Addr == addr; Direction == write; Length == count; foreach(Data) Data inside {Data_tmp}; }) Quote Link to comment Share on other sites More sharing options...
niks007 Posted March 4, 2012 Author Report Share Posted March 4, 2012 Roman Thanks for the reply, i thought of this approach, but this approach puts limitation on File Size and memory usage of compiler as i can't use bigger files else my simulator memory will blow up ... niks007 Quote Link to comment Share on other sites More sharing options...
Roman Posted March 4, 2012 Report Share Posted March 4, 2012 (edited) Here is another way to try. Why not initialize one global data_tmp[] in testbench layer? Then your sequence will see the data_tmp[]. Then you need not consume the "$fscanf(file_p,"%s",data);" in body of seq. If your data is very large , and need more time. You also need add sync signal in vbus_if, and do cfg.wait_for_init_competed() before `uvm_do_with in the seq Edited March 4, 2012 by Roman Quote Link to comment Share on other sites More sharing options...
dave_59 Posted March 4, 2012 Report Share Posted March 4, 2012 It would help if you could show the exact format of the file. You say you want to read a hexadecimal formatted file line by line, yet you are reading entire file as a string. Why not use $fgets to read the file a line at a time, and then use $sscanf to convert each line. You can do this just before the `uvm_do Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.