如何将 16 位截断为 8 位 VHDL?
How to truncate 16 bits to 8 bits VHDL?
您好,我有以下代码
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 中,您直接使用位,因此没有像 C 中那样的“截断”概念。
而是 select 您想要的位:
signal full_product: UNSIGNED (15 downto 0);
...
full_product <= in1 * in2;
product <= full_product (7 downto 0);
您好,我有以下代码
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 中,您直接使用位,因此没有像 C 中那样的“截断”概念。
而是 select 您想要的位:
signal full_product: UNSIGNED (15 downto 0);
...
full_product <= in1 * in2;
product <= full_product (7 downto 0);