2

I am striving to implement an entity whose ports depend on a generic package, which in turn depends in the generics of the entity. The trick is that I want to have a record for the ports.

At first I tried putting the record in a generic package and instantiate the generic package from the entity. (I did not start with records and asked a question regarding this).

The problem is that modelsim complains about the following order:

entity myEntity is
    generic()
    -- problem 1 package before port causes errors in modelsim
    package myInstance is new genericPackage generic map ...
    -- problem 2, "use" may appparently  not be used here
    port( p1 : in myInstance.genericRecord )
end entity;

is there an elegant way to solve this with the features of VHDL 2008?

Community
  • 1
  • 1
ted
  • 4,791
  • 5
  • 38
  • 84

1 Answers1

1

As I understand it, the package instance has to come outside the entity. I don't think you can have the dependencies in the order you would like.

The other approach to this sort of problem (think unconstrained vectors for example) is to "push things down" into entities on instantation. Could you use type generics like this?

entity myEntity is
    generic (type myRecord);
    port (p1 : in myRecord);
end entity;

then when you instantiate it, you create the type you need:

package myInstance is new genericPackage generic map ...
...
inst:entity work.myEntity
  signal recordSig : myInstance.genericRecord;
...
  generic map (type => myInstance.genericRecord)
  port map (p1 => recordSig);
Martin Thompson
  • 16,395
  • 1
  • 38
  • 56
  • I dont know if you read the question and solution I refered, but some [Martin Thompson](http://stackoverflow.com/users/106092/martin-thompson) gave me [this excellent awnser](http://stackoverflow.com/a/16078428/258418), where an instanciation inside an entity was used... . The Idea is that the record depends on what is inside `generic(...)` – ted Apr 29 '13 at 17:26
  • I know that it would work in the way you suggest, but then there would be no way to instantiate the generic Package based on the values mapped to the geneircs of the entitiy on instantiation. – ted Apr 29 '13 at 17:28
  • this looks prommising, I will vote as soon as I had time to test this (I am not quite sure about the modelsim support for generics but I think generic types was there while passing functions via generics wasn't), thank you and I will comment once more/vote when I tested this. – ted Apr 30 '13 at 10:12
  • I finally got arround to try this, however modelsim (10.1d) fails `Vcom: (vcom-1440) Language feature INTERFACE TYPES IN ENTITY DECLARATIONS is not supported yet.` – ted May 14 '13 at 14:11
  • ...another bug report for Mentor :) Can you get an eval of Aldec? I hear their 2008 support is much better than Modelsim's – Martin Thompson May 14 '13 at 15:45
  • right now I am bugging synopsis about a per file option for vhdl2008 / 93, as for mentor we have some issues the maintainer is gone and we need to recover an account first, install and confirm this with the latest modelsim and check their vhdl compability list. Since the error message states that it is not supported yet and there are deadlines at universities as well I am afraid I can't wait for them to fix it. (One advantage of modelsim over simplify is that i can simulate the programs isnce i can sleect the vhdl standard per file(we have a large 93' lib that uses `default` as instance name)) – ted May 14 '13 at 16:13
  • @ted - sure, waiting for a fix is often not an option, but every bug report raised increases the pressure on them to fix it faster... – Martin Thompson May 15 '13 at 08:45
  • point taken, I will raise the issue, once we have restored access to the site license/service account. Do you mind that I won't accept the awnser until I have managed to apply this in practice? – ted May 15 '13 at 09:25
  • "Do you mind that I won't accept the awnser until I have managed to apply this in practice?" - not at all, that's fine! – Martin Thompson May 15 '13 at 15:54
  • I just tested with modelsim 10.2a, works like a charm. I would have prefered something closer to the former solution since I also need some of the information used to instantiate the record inside the componenent but I think/hope that I can figure that out myslef – ted May 16 '13 at 08:47