Skip to content

Fix RANGE_ASSERTIONS handling of logic delays #16

@sgherbst

Description

@sgherbst

At the moment, defining RANGE_ASSERTIONS will cause svreal to fail with a fatal error whenever a real value is outside of the range of the signal to which it is being assigned. As currently implemented, though, this is pickier than necessary -- logic delays may cause values to temporarily exceed the allowed range, without causing any issues. Something like this might work:

`ifdef RANGE_ASSERTIONS
    `undef RANGE_ASSERTIONS
    `COPY_FORMAT_REAL(in, in_inertial);
    `define RANGE_ASSERTIONS
`else
    `COPY_FORMAT_REAL(in, in_inertial);
`endif
assign #(1ns) in_inertial = in;

always @(in_inertial) begin
    if (!((min <= `TO_REAL(in_inertial)) && (`TO_REAL(in_inertial) <= max))) begin
        $display("Real number %s with value %f out of range (%e to %e).", name, `TO_REAL(in_inertial), min, max);
        $fatal;
    end  
end  

We might want to make that inertial delay of 1ns user-adjustable, and maybe also have a flag for if range assertions should be fatal errors or just warnings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions