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
- VHDL code for simple calculation: b = 68 - (a/25)

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

Highlighted
##

Altera_Forum

Honored Contributor I

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

10-19-2007
05:26 AM

1,923 Views

VHDL code for simple calculation: b = 68 - (a/25)

I want to do a simple calculation in FPGA:

b = 68 - (a/25) Anyone help me how can I write VHDL code for this calculation? I try write this code but it fails. Can anybody correct this code? signal a: std_logic_vector(10 downto 0); signal b: std_logic_vector(10 downto 0); process(a) variable tmp1: unsigned(10 downto 0); variable tmp2: unsigned(10 downto 0); begin tmp1 := unsigned(a)/25; tmp2 := 68 - tmp1; b<= std_logic_Vector(tmp2); end process;
5 Replies

Highlighted
##

Altera_Forum

Honored Contributor I

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

10-23-2007
04:02 AM

22 Views

I recommend to use package numeric_std from the IEEE library to ease the description of arithmetic calculations. In order to do, use the following clauses:

library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; The source code then becomes: signal a: unsigned(10 downto 0); signal b: unsigned(10 downto 0); process(a) variable tmp1: unsigned(10 downto 0); variable tmp2: unsigned(10 downto 0); begin tmp1 := a / 25; tmp2 := 68 - tmp1; b <= tmp2; end process; One last point: the results of 68-tmp1 may be negative (for example when a=2047). This may be a problem since tmp2 is declared as an unsigned... --jmv
Highlighted
##

I am afraid that the division might not be that easy for synthesis. You should have a look at the MEGA WIZ divider.

Altera_Forum

Honored Contributor I

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

10-23-2007
12:28 PM

22 Views

Highlighted
##

Altera_Forum

Honored Contributor I

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

10-24-2007
07:24 AM

22 Views

The beauty of Quartus II integrated synthesis is that it is actually capable of inferring an lpm_divide megafunction from the VHDL "/" operator.

--jmv
Highlighted
##

Altera_Forum

Honored Contributor I

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

10-24-2007
08:52 AM

22 Views

The question is, how quick it is. I found more than 10clocks delay to be setup in the wizzard for are divider in order to be able to calc with the necessary width (48bits in my app) and meet the reqs of the given clock freq.

I wonder what freq could be achieved with a divider of here 10bits in one clock cycle ?
Highlighted
##

Altera_Forum

Honored Contributor I

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

10-25-2007
07:18 AM

22 Views

Thank you jmv!

Quartus understand the division "\". It takes about some clocks to do this calculation.For more complete information about compiler optimizations, see our Optimization Notice.