Altera_Forum
Honored Contributor
12 years agouse of function lpm
Hi to everybody,
i write a small machine state to implement the and product separately.. i use std_logic_vector signal, so in the first state i sum the result of the product state.. but i never use lpm function so i don't know how to istantiate these? i try to do this but the compiler don't accept it.. I want that my program make product a*y and b*x in the state prodotto and the sum Y=pnum+pden in the second state i post my code.. LIBRARY lpm; USE lpm.lpm_components.ALL; LIBRARY ieee; USE ieee.std_logic_1164.ALL; USE ieee.std_logic_arith.ALL; USE ieee.std_logic_unsigned.ALL; ENTITY add_sum IS GENERIC (W1: integer:= 11; -- Input bit width ) ; PORT (CLK : IN STD_logic; x_in : IN STD_LOGIC_VECTOR(W1-1 DOWNTO 0); y_out : OUT STD_LOGIC_VECTOR(W1-1 DOWNTO 0); END add_sum; ARCHITECTURE flex OF add_sum IS SUBTYPE N1BIT IS STD_LOGIC_VECTOR(W1-1 DOWNTO 0); TYPE state_type is (somma,prodotto); SIGNAL stato: state_type :=prodotto; SIGNAL x : N1BIT; SIGNAL y : N1BIT; myprocess: PROCESS BEGIN if (rising_edge(clk)) then case state is when somma => y<=pnum+pden; stato<=prodotto; when prodotto => lpm_mult_ist1: lpm_mult PORT MAP (clock=>clk, dataa=>x, datab=>b, result =>pnum); lpm_mult_ist2: lpm_mult PORT MAP ( clock=>clk, dataa=>a, datab=>y, result =>pden); stato<=somma; end case; end if; end process myprocess; y_out<=y; END flex; Thank for our response and attention! by enrico