Skip to content

Commit

Permalink
Worked around Questa warning.
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsAsplund committed Aug 12, 2024
1 parent 404f779 commit 08d4fa3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
27 changes: 17 additions & 10 deletions vunit/vhdl/logging/src/log_handler_pkg-body.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,27 @@
-- Copyright (c) 2014-2024, Lars Asplund lars.anders.asplund@gmail.com

package body log_handler_pkg is
-- Questa will issue warnings if the code contains time units lower than
-- the resolution even if that code isn't executed. To avoid that is most
-- cases a number of replacement constants are defined as fractions of us.
constant femtosecond : time := us / 1000000000;
constant picosecond : time := us / 1000000;
constant nanosecond : time := us / 1000;

function resolution_limit return delay_length is
constant t : string := time'image(time'high);
constant signature : character := t(t'length - 1);
begin
case signature is
when 'f' => return fs;
when 'p' => return ps;
when 'n' => return ns;
when 'f' => return femtosecond;
when 'p' => return picosecond;
when 'n' => return nanosecond;
when 'u' => return us;
when 'm' => return ms;
when others =>
report "Only resolution limits in the fs to ms range are supported. " &
"Only native simulation time formatting is supported" severity warning;
return ps;
return picosecond;
end case;
end;

Expand Down Expand Up @@ -136,11 +143,11 @@ package body log_handler_pkg is
set(log_handler.p_data, log_time_unit_idx, -3);
elsif log_time_unit = us then
set(log_handler.p_data, log_time_unit_idx, -6);
elsif log_time_unit = ns then
elsif log_time_unit = nanosecond then
set(log_handler.p_data, log_time_unit_idx, -9);
elsif log_time_unit = ps then
elsif log_time_unit = picosecond then
set(log_handler.p_data, log_time_unit_idx, -12);
elsif log_time_unit = fs then
elsif log_time_unit = femtosecond then
set(log_handler.p_data, log_time_unit_idx, -15);
else
report "Illegal log_time_unit: " & time'image(log_time_unit) severity failure;
Expand All @@ -162,9 +169,9 @@ package body log_handler_pkg is
when 0 => log_time_unit := sec;
when -3 => log_time_unit := ms;
when -6 => log_time_unit := us;
when -9 => log_time_unit := ns;
when -12 => log_time_unit := ps;
when -15 => log_time_unit := fs;
when -9 => log_time_unit := nanosecond;
when -12 => log_time_unit := picosecond;
when -15 => log_time_unit := femtosecond;
when others =>
report "Illegal internal log_time_unit representation: " &
integer'image(get(log_handler.p_data, log_time_unit_idx)) severity failure;
Expand Down
2 changes: 1 addition & 1 deletion vunit/vhdl/logging/test/tb_sim_time_formatting.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ begin

elsif run("Test image performance") then
for iter in 1 to n_performance_iterations loop
report time'image(123456 ns);
report time'image(123456 ps);
end loop;

elsif run("Test VUnit to_string performance") then
Expand Down

0 comments on commit 08d4fa3

Please sign in to comment.