std.env.resolution_limit - explicitly disallow 0 fs as a valid value

Is your capability/feature request related to a problem?

Some simulators (e.g. XSIM 2025.2) that ostensibly support std.env.resolution_limit simply return the value 0 fs rather than the actual simulator resolution.

My uses for std.env.resolution_limit involve dividing a time by std.env.resolution_limit [during either elaboration or simulation], and that gives a divide by 0 error.

Jim seems to have a similar problem with XSIM and std.env.resolution_limit returning 0 (https://osvvm.org/archives/2624).

LRM 16.5.2 defines the function: function RESOLUTION_LIMIT return DELAY_LENGTH;

DELAY_LENGTH is defined elsewhere as 0 fs to TIME'HIGH.

16.5.3 says "The function RESOLUTION_LIMIT returns the value of the resolution limit (see 5.2.4.2)."

5.2.4.2 says "By default, the primary unit of type TIME (1 fs) is the resolution limit for type TIME."

I didn't spot anything the explicitly disallows the value 0 for resolution_limit.

Describe the solution you'd like

  • Add an explicit statement disallowing the value 0 fs for the resolution limit and the return value of the function std.env.resolution_limit.
  • Don't change the type (currently DELAY_LENGTH) returned by std.env.resolution_limit though, as doing so may break existing code [although I couldn't come up with an example of something actually breaking]. EDIT: would it make more sense to create a subtype of DELAY_LENGTH that started at 1 fs rather than 0 fs, and that wouldn't break existing code because it's a subtype?
  • 16.5.3 or 5.2.4.2 would possibly be the right places for this change.

Describe alternatives you've considered

Here's a workaround that I've been using since the turn of the century (well before std.env.resolution_limit existed).

  pure function resolution_limit_workaround return time is
        constant max_time_resolution    : time := 1 us;
        variable new_time_resolution    : time := max_time_resolution;
        variable last_time_resolution   : time;
    begin
        loop
            last_time_resolution := new_time_resolution;
            new_time_resolution := new_time_resolution / 10;  -- try the next smallest size
            -- Check that time_resolution is not less than the simulation resolution
            -- (the division will underflow if it is)
            exit when new_time_resolution = 0 fs;
        end loop;
        return last_time_resolution;
    end resolution_limit_workaround;

Additional context

This XSIM bug report: https://adaptivesupport.amd.com/s/question/0D5Pd000018g4etKAA/bug-report-xsim-20252-vhdl-2008-stdenvresolutionlimit-shouldnt-return-0?language=en_US

It includes a test case.

This Reddit thread (that was actually about something else but the discussion drifted): https://www.reddit.com/r/VHDL/comments/1pov8rx/how_to_convert_time_into_bit_vector641_downto_0/

Edited Jan 13, 2026 by Allan Herriman
Assignee Loading
Time tracking Loading