我试图计算4个连续值的信号平均值 . 这个信号是签名的,我真的不确定正确的计算 .
SIGNAL my_signed_signal : std_logic_vector(15 DOWNTO 0) := (OTHERS => '0');
SIGNAL average_sum : signed(17 DOWNTO 0) := (OTHERS => '0');
SIGNAL average_result : signed(15 DOWNTO 0) := (OTHERS => '0');
...
-- within my process
average_sum <= average_sum + signed(my_signed_signal); -- loop 4 times
...
average_result <= average_sum(17 DOWNTO 2); -- how I finally get the result (div by 4)
我知道这应该适用于无符号信号,但我很确定它不会因为有符号位而导致签名 . 但我真的不知道该改变什么 . 有没有人有想法?
1 回答
是的,它也适用于
signed
类型 .