Forum Discussion
Altera_Forum
Honored Contributor
8 years agoI've found one possible workaround, how to round real data type down to nearest integer:
1) Create a constant function that will convert real to nearest integer (up or down):function integer rtoi;
input integer x;
begin
rtoi = x;
end
endfunction 2) Create a macro that will round real down to integer: `define FLOOR(x) ((rtoi(x) > x) ? rtoi(x) - 1 : rtoi(x)) 3) Use the macro: localparam real R_TEST = 0.785398163 * SOME_CONSTANT;
integer floor_int = `FLOOR(R_TEST);
Best regards!