Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Intel Community
- FPGAs and Programmable Solutions
- Intel® Quartus® Prime Software
- Quartus Prime complete lack of real data type support?

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Altera_Forum

Honored Contributor I

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

08-09-2017
12:23 PM

1,157 Views

Quartus Prime complete lack of real data type support?

Hi,

I have a function (basicaly implements a LUT) something like the following:```
function integer gen_lut;
input integer addr;
localparam SOME_CONSTANT = 418.39; // Gets calculated at runtime.
localparam D0 = 0.785398163 * SOME_CONSTANT;
localparam D1 = 0.463647609 * SOME_CONSTANT;
...
begin
case (addr)
0: gen_lut = D0;
1: gen_lut = D1;
...
endcase
end
endfunction
```

The thing is I need to convert ```
function integer floor;
input real x;
integer int_part;
begin
int_part = x;
if (int_part > x) begin floor = int_part - 1; end
else begin floor = int_part; end
end
endfunction
```

And the tool complains again: Link Copied

1 Reply

Altera_Forum

Honored Contributor I

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

08-09-2017
01:24 PM

166 Views

I'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!
For more complete information about compiler optimizations, see our Optimization Notice.