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.
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:
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.