在其他泛型中使用VHDL通用值

时间:2014-01-30 07:51:25

标签: vhdl

我希望能够将多个通道指定为通用通道,并使用它来指定包含其他参数的数组的范围。在编译时,我的Aldec编译告诉我在接口列表完成之前无法引用'num_chan'。

有谁知道实现这个目标的方法?

ENTITY deframer IS
    generic (
      num_chan : integer                      := 2;            
      ch_low   : int_arr(num_chan-1 downto 0) := (  1, 189);   
      ch_hi    : int_arr(num_chan-1 downto 0) := (127, 189));

1 个答案:

答案 0 :(得分:3)

在VHDL-2002(及更早版本)中,在给定泛型中声明的正式泛型 list不能用于声明该列表中的其他泛型,也就是说 你看到错误的原因。

在VHDL-2008中是可能的,所以如果所需的工具支持VHDL-2008和 该功能(“在通用列表中引用泛型”),然后您可以指出 使用VHDL-2008的工具。

VHDL-2002的解决方案是使ch_lowch_hi数组变大 足以容纳num_chan的任何值,然后用a填充未使用的值 虚拟值,如(假设num_chan最多为10,使用-1作为虚拟值):

generic(
  num_chan : integer            := 2;
  ch_low   : int_arr_t(1 to 10) := (  1, 189, others => -1);
  ch_hi    : int_arr_t(1 to 10) := (127, 189, others => -1));
相关问题