首先,这是我的目标,使用虚构的VHDL语法...

type type_johns_record is
  first_element : std_logic;
  second_element: std_logic_vector(3 downto 0);
  third_element : boolean;
end record;
....
....

for ii in johns_record'range loop
  if johns_record.type_johns_record'val(ii) = .... then
    exit;
  end if;
end loop;

希望您能看到我正在尝试使用与可用于引用枚举类型的语法相似的语法来引用记录的元素。但是,这(当然)不起作用。有类似的语法可以工作吗?目前,我的解决方案是使用record_info字段,并使用std_logic_vectors进行工作,如下所示。
type type_johns_record is record
    first_element : std_logic;
    second_element : std_logic_vector(3 downto 0);
    third_element : boolean;
    record_info : type_integer_array(2 downto 0);
  end record;

  function type_johns_record2slv(d : type_johns_record) return std_logic_vector is
  begin
    return (d.first_element & d.second_element & bool2sl(d.third_element));
  end function;

  constant johns_record_zero : type_johns_record := (first_element => '0',
                                                     second_element => "0000",
                                                     third_element => false,
                                                     record_info => (1, 4, 1));

  -- can be used with any type for which a record_info is known
  function get_record_element(input : std_logic_vector; element_number : integer; record_info :     type_integer_array) return std_logic_vector is
    variable r : type_slv32_array(record_info'length-1 downto 0);
    variable pos : integer := 0;
  begin
    for ii in record_info'range loop
      r(ii)(record_info(ii)-1 downto 0) := input(pos+record_info(ii)-1 downto pos);
    end loop;
    return r(element_number)(record_info(element_number)-1 downto 0);
  end function;

然后,我可以按以下方式使用这些功能(在包装中)...
 for ii in johns_record.record_info'range loop
   if get_record_element(type_johns_record2slv(johns_record), ii, johns_record.record_info) = conv_std_logic_vector(4, johns_record.record_info(ii)) then
      exit;
   end if;
 end loop;

这确实很糟糕,并且指定record_info容易出错,并且仅逐行写出单个元素比较所花费的时间稍少。请提供更好的解决方案!!!

最佳答案

在IEEE VHDL标准组中,实际上有两个建议与此相关:
http://www.eda.org/twiki/bin/view.cgi/P1076/RecordMemberAttribute

http://www.eda.org/twiki/bin/view.cgi/P1076/RecordIntrospection

这并不意味着放松,其他人将解决该问题。相反,我们需要您对此进行评论和/或提出其他使用模型(以帮助说明理由)。与您一样,我们的所有工作都是由志愿者完成的,基本参与不需要会员资格。我们的许多工作都是在TWIKI和电子邮件反射器上完成的,欢迎所有具有VHDL背景的人员参加。给我发送电子邮件,我将帮助您进行设置-有关详细信息,请参见我的Stack Exchange个人资料。

要参与,请从这里开始:http://www.eda.org/twiki/bin/view.cgi/P1076/

目前的建议:
http://www.eda.org/twiki/bin/view.cgi/P1076/CollectedRequirements

会议信息:
http://www.eda.org/twiki/bin/view.cgi/P1076/MeetingMinutes

10-06 05:39
查看更多