0

Suppose I have variable length string as below:

Write <Address> <Data0> <Data1> <Data2>
Read <Address>
Write <Address> <Data0>
Write <Address> <Data0> <Data1> <Data2> <Data3>

How do I read in SystemVerilog or Verilog using file operations. I know to read when there is fixed length of text

integer file    = $fopen(file_name,"r");
code = $fgets(line, file);
code = $sscanf(line, "%s %h %h %h", txn_type, Address, Data[i]);

1 Answers1

2

You can use $sscanf when the number of fields is not fixed, as long as you supply the maximum possible number of fields. The return value placed in code indicates the actual number of arguments scanned. So just create a dummy list of arguments and copy the ones provided by the line

dave_59
  • 39,096
  • 3
  • 24
  • 63