VHDL中的数据类型

问题描述 投票:0回答:1

我试图在VHDL中实现一个滤波器。所有的输入向量和输出向量都是有符号的16位(1.15格式,第一个位是符号位),我计划将所有的信号变量声明为STD_LOGIC STD_LOGIC_VECTOR类型。我计划将所有信号变量声明为STD_LOGIC STD_LOGIC_VECTOR类型。所有的计算都将基于2的补码。

有一些包(在IEEE中),如std_logic_1164 (std_logic types & related functions), std_logic_arith (arith fuctions), std_logic_signed (signed arithmetic functions), and std_logic_unsigned (unsigned arithmetic functions).

为了在这个基于STD_LOGIC STD_LOGIC_VECTOR类型的过滤器实现中实现所有的2's补码运算,我应该使用哪个库?我应该同时使用std_logic_signed.ALL和std_logic_1164.ALL吗?

filtering vhdl
1个回答
3
投票

std_logic_(un)signed和std_logic_arith不是标准的VHDL包。它们是由Synopsys在近30年前编写的,从来没有成为VHDL标准的一部分。

在这里适合的VHDL标准包是VHDL 93中的n numeric_std (适用于 unsignedsigned 类型)或使用std_logic_vector进行算术运算的 numeric_std_unsigned(从VHDL 2008开始)。在VHDL2008中还提供了fixed_pkg,允许用户定义并使用定点包进行算术运算,例如:这是定点、2s补数、整数算术。

signal a,b : sfixed(0 downto -15); -- 1.15 signed fixed 
signal c   : sfixed(1 downto -15);

....

a <= to_sfixed(0.12345, a);
b <= to_sfixed(-0.54321, b);

c <= a + b;

这是定点的,2s补数,整数算术。

© www.soinside.com 2019 - 2024. All rights reserved.