Information about saving the time in a file in Verilog.

Status
Not open for further replies.

always84

Member level 1
Joined
Feb 24, 2010
Messages
39
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
italy
Activity points
1,567
Hy I have to save some metrics about my design. I want to save the istant of a particular event on a file, my code is write in Verilog and I'm using modelsim. I was thinking to use the istruction $time to capture a particular istant of time, and if it's possible to save it on a file. How can I do this? is it possible? Could I use $time and $writmemb (or $writememh) to solve my problem.

Thx for helping me.
 

Yes it is possible and it's not hard to do.

You can get the simulation time using this:
reg time;
$monitor($time,,"set=%b",time);

And then save it in a file using this:
integer file_ptr; // file pointer

file_ptr <= $fopen("C:\\...whatever...\\your_file.txt", "wb");
$fwrite(file_ptr,"%d \n",time);

I don't recomend using $writememh or $writememb because they only store data as hex or binary. Verilog as other functions such as $fwrite and $fread which are very similar to C programming and easier to use.

Hope it helped.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…