-------------------------------------- -- generate squares -- using a counter and multiplier -- test of simulation time pre- and post- synthesis package square_pkg is constant counterWidth : positive :=16; end square_pkg; library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; library work; use work.square_pkg.all; entity squares is port( reset, clock : in std_logic; square : out unsigned(2*counterWidth-1 downto 0)); end entity; architecture rtl of squares is begin doSquares: process is variable count: natural range 0 to 2**counterWidth-1; begin wait until rising_edge(clock); if reset = '1' then count := 0; square <= (others=>'-'); else count := count + 1; -- without magic numbers -- square <= conv_unsigned(count * count,2*counterWidth); -- type conversion -- and compatible with all versions of maxplus2 -- the second parameter to conv_unsigned() should equal 2*counterWidth square <= conv_unsigned(count * count,32); -- type conversion end if; end process doSquares; end architecture rtl;