【问题标题】:How to truncate 16 bits to 8 bits VHDL?如何将 16 位截断为 8 位 VHDL?
【发布时间】:2020-11-23 01:21:51
【问题描述】:

您好,我有以下代码

 library ieee;
 use ieee.std_logic_1164.all;
 use ieee.numeric_std.all;
 entity mult is 
 PORT (in1, in2 : IN UNSIGNED (7 downto 0);
 product: OUT UNSIGNED (7 downto 0));
 end mult;
 Architecture behaviour of mult is 
 signal prod_sig: UNSIGNED (7 downto 0);
 begin

 product<=in1*in2; --this cause an error because it needs to be truncated to its 8 bit equivalent 

 end behaviour;

请有人帮我理解如何截断产品

【问题讨论】:

    标签: vhdl unsigned


    【解决方案1】:

    在 VHDL 中,您直接使用位,因此没有 C 中的“截断”概念。

    相反,只需选择您想要的位:

    signal full_product: UNSIGNED (15 downto 0);
    

    ...

    full_product <= in1 * in2;
    product <= full_product (7 downto 0);
    

    【讨论】:

    • product &lt;= full_product (15 downto 8);。或者介于两者之间。
    猜你喜欢
    • 2013-07-01
    • 1970-01-01
    • 2014-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-01
    • 2012-10-11
    相关资源
    最近更新 更多