Tuesday, May 12, 2020

Parsing file in systemverilog

We often need to read file generated by tools and use the data in systemverilog task/function to decide pass or fail for many verification tasks.

Systemverilog is not a language that is built for text parsing but it does provide some basic system functions to play with. Key is to read the data which is simple and easy to parse. one way is to pre process the data in external perl script which then be read by systemverilog.

Here is the sample file where the real numbers at the end of the file are to be extracted and result to be used in the task:


Below system tasks are used
$fopen()   Open file for reading
$feof()      Identify end of file
$fgets()    read the line from file
$fscanf() parse a line


Sample Systemverilog Task for parsing :


A snippet of task result:
sub1=sample_checks_184ms,sub2=47166.67
sub1=sample_checks_370ms,sub2=41333.33

No comments:

Post a Comment