Flo_C
Flo_C

Reputation: 23

Add the date of creation to a filename in SystemVerilog

I need to create a report(.txt) and I want to reference each sessions of tests, so I wanted that for each simulations, I add the date to name of my report. Like Report_01-19-2017-12:53.txt So far I have been able to create either a file with the date inside with :

$system("date > sDate");

or display it on my simulation software with :

$system("date");

So far,My code look like :

 string     filename;
 reg [8*30:1]   data; // the date is of 29 characters in size
 string     sDate;
 integer    scan_file,data_file    ;
 initial begin
      $system("date > data");
      data_file = $fopen("data", "r");
      scan_file = $fscanf(sDate,"%s", data); 
      $fclose("data"); 
      [...]
      filename = {filename,sDate};
     Report_Task = $fopen(filename,"a");   [...]
   end

sDate contains nothing, date contains the date... I tried string and reg for filename and sDate

Upvotes: 2

Views: 1083

Answers (2)

Tudor Timi
Tudor Timi

Reputation: 7573

Instead of going through files to get the date, you could use svlib. Chapter 9 of the documentation illustrates how to get information about the current time.

Upvotes: 3

Matthew
Matthew

Reputation: 13987

Don't you mean

scan_file = $fscanf(data_file, "%s", sDate);

where, if the read is successful, scan_file will be equal to 1 (the number of items read). (So, you probably didn't want to call it scan_file.)

Upvotes: 2

Related Questions