Forum Discussion
Altera_Forum
Honored Contributor
12 years ago --- Quote Start --- yes y are right ,first i want to count the number of input samples,so i need a counter then when samples terminated and distances calculated i use the accumulator ,for example if distances are 1+3+6+3=7 and the number of samples be 4 should i use another entity to make this ? --- Quote End --- well just a clocked process will do.
process(clk)
begin
if rising_edge(clk) then
if clear = '1' then
sum <= accum;
accum <= (others => '0');
else
accum <= accum +distance;
end if;
end if;
end process;
assuming distance is an incoming stream of samples, one per clock period. you control the clear signal using a counter for your samples.