0
計數器計數輸入樣本的數量。然後計數器輸出(n),我想檢查樣本數是否爲偶數,那麼n_of_samples =(n * n)否則如果奇數使得((n * n)-1) 將是類似的東西最後一次輸出的分區
signal dis : integer range 0 to 255 := 0;
signal n : integer range 0 to 255 :=0;
if n mod 2=1 then
n_of samples<= ((n*n)-1);
else
n_of_samples <= n*n;
end if;
norm_dis <= dis/n_of_samples ;
這兩個信號將具有(1,6,9,8,... 100)和(0,2,8,9 .......,200) 和i想要從兩個信號(100,200) 中取出最後兩個輸出併除以100/200。我可以在vhdl中寫出它,以及如何克服除以零的錯誤。