我试图计算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)
我知道这应该适用于无符号信号,但由于有符号位,我很确定它不适用于有符号信号。但我真的不知道该改变什么。有没有人有想法?
答案 0 :(得分:1)
是的,它也适用于15:51:55,662 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/ebook].[ebookDispatcher]] (ajp-/127.0.0.1:8009-5) Servlet.service() for servlet ebookDispatcher threw exception: javax.el.ELException: Cannot convert _ of type class java.lang.String to int
at org.apache.el.lang.ELSupport.coerceToNumber(ELSupport.java:312) [jbossweb-7.0.17.Final.jar:]
at org.apache.el.lang.ELSupport.coerceToNumber(ELSupport.java:283) [jbossweb-7.0.17.Final.jar:]
at org.apache.el.lang.ELSupport.coerceToType(ELSupport.java:396) [jbossweb-7.0.17.Final.jar:]
at org.apache.el.ExpressionFactoryImpl.coerceToType(ExpressionFactoryImpl.java:47) [jbossweb-7.0.17.Final.jar:]
at javax.el.BeanELResolver.invokeMethod(BeanELResolver.java:729) [jboss-el-api_2.2_spec-1.0.2.Final.jar:1.0.2.Final]
at javax.el.BeanELResolver.invoke(BeanELResolver.java:467) [jboss-el-api_2.2_spec-1.0.2.Final.jar:1.0.2.Final]
at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:246) [jboss-el-api_2.2_spec-1.0.2.Final.jar:1.0.2.Final]
at org.apache.el.parser.AstValue.getValue(AstValue.java:159) [jbossweb-7.0.17.Final.jar:]
at org.apache.el.parser.AstNotEqual.getValue(AstNotEqual.java:38) [jbossweb-7.0.17.Final.jar:]
at org.apache.el.parser.AstAnd.getValue(AstAnd.java:43) [jbossweb-7.0.17.Final.jar:]
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189) [jbossweb-7.0.17.Final.jar:]
类型。