Forum Discussion
Altera_Forum
Honored Contributor
18 years agoI 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