Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RANGE_ASSERTIONS handling of logic delays #16

Open
sgherbst opened this issue Mar 7, 2021 · 0 comments
Open

Fix RANGE_ASSERTIONS handling of logic delays #16

sgherbst opened this issue Mar 7, 2021 · 0 comments

Comments

@sgherbst
Copy link
Owner

sgherbst commented Mar 7, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant