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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With