Pointer to a Pointer


A customer asked me whether it was possible to have a pointer to a pointer in VHDL. In other words, is it possible to have an access type that points to another access type?

I did a little experiment on EDA Playground and it turns out that it is.

Here's an access type to an integer:

    type ai is access integer;

and here's an access type to that access type:

    type aai is access ai;

and here are variables to both:

    variable aiv : ai;
    variable aaiv : aai;

So, let's allocate memory for both:

    aiv := new integer'(6);
    aaiv:= new ai'(aiv);

and then dereference each:

    report "aiv.all= " & integer'image(aiv.all);
    report "aaiv.all.all= " & integer'image(aaiv.all.all);

Yes, aaiv.all.all !

Here's all the code and the EDA Playground link:

https://www.edaplayground.com/x/4USx

entity E is
end entity ;

architecture A of E is
begin

  process
    type ai is access integer;
    type aai is access ai;
    variable aiv : ai;
    variable aaiv : aai;
  begin
    aiv := new integer'(6);
    aaiv:= new ai'(aiv);
    report "aiv.all= " & integer'image(aiv.all);
    report "aaiv.all.all= " & integer'image(aaiv.all.all);
    wait;
  end process;

end architecture A;

A customer asked me about this. I didn't know the answer, so I wrote a few lines of code on EDA Playground. EDA Playground is great for that, because it's always on. You don't have to queue for licences, wait for EDA tools to start, create new files, fire up editors...

Comments

  1. A guide to how strong is titanium? - TitaniumArts
    TitaniumSports is a sports game camillus titanium designed trekz titanium in titanium bar stock the vein titanium post earrings of traditional ice skating seiko titanium and utilizes technology like a virtual stick and a stick.

    ReplyDelete

Post a Comment

Popular posts from this blog

Bit Width Casting in SystemVerilog

How to convert a std_logic_vector to a hex string?

Can you add/remove more than 1 item from a queue?