请考虑以下VHDL记录:
type big_record_t is record
field_a : unsigned(15 downto 0);
field_b : unsigned(23 downto 0);
end record;
是否可以在不实例化记录本身的情况下获取记录字段上的属性?例如
signal ex : unsigned(big_record_t.field_a'range);
modelsim报告以下错误:
(vcom-1260) Type mark (big_record_t) cannot be prefix of selected name.
我知道可以获取实例化信号的属性,但是对于这种特定情况,我想从类型本身获取类型属性。
您不能'range
在类型 †上使用该属性,这是您在代码中尝试执行的操作。如果您要执行以下操作:
signal big_record_instance : big_record_t;
signal ex : unsigned(big_record_instance.field_a'range);
它应该起作用,因为您现在正在尝试获取实例的范围,而不是类型。
如果没有实例,另一种选择是根据定义记录类型的同一包中的常量来确定宽度,如下所示:
constant field_a_width : integer := 16;
type big_record_t is record
field_a : std_logic_vector(field_a_width-1 downto 0);
field_b : std_logic_vector(23 downto 0);
end record;
signal ex : std_logic_vector(field_a_width-1 downto 0);
也许
constant field_a_width : integer := 16;
subtype field_a_type is std_logic_vector(field_a_width-1 downto 0);
type big_record_t is record
field_a : field_a_type;
field_b : std_logic_vector(23 downto 0);
end record;
signal ex : field_a_type;
†参见注释中的例外
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句