Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Modelsim simulation time instant as a string variable?

Tags:

vhdl

I know when using report and severity Modelsim displays the simulation time instant as part of its message to the console. Is there anyway to "get" this time instant as a string variable so I can print my own message with this "time" string?

like image 545
bFig8 Avatar asked Aug 23 '13 02:08

bFig8


1 Answers

The simulation time is available through the now function, which will a return the value as time type. The image attribute of the time type can be used to convert this to string with time'image(now). So you can print the simulation time in your own message with:

report "This is the time: " & time'image(now);

Addition: If additional string manipulation is needed, then the simulation time string can be represented in a variable with code like:

process is
  variable sim_time_str_v : string(1 to 30);  -- 30 chars should be enough
  variable sim_time_len_v : natural;
begin
  ...
  sim_time_len_v := time'image(now)'length;
  sim_time_str_v := (others => ' ');
  sim_time_str_v(1 to sim_time_len_v) := time'image(now);
  report "Sim time string length: " & integer'image(sim_time_len_v);
  report "Sim time string.......:'" & sim_time_str_v & "'";
  ...

However, VHDL is cumbersome when it comes to text string manipulation, since storing the result of some manipulation requires that the length is known. For more advanced string manipulations, then access type in combination with functions can be used in simulation.

like image 163
Morten Zilmer Avatar answered Sep 20 '22 22:09

Morten Zilmer