Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to write type-generic entities in VHDL?

So, I recently inherited some VHDL code, and my first reaction was, "VHDL has structs, why do they use bit-vectors everywhere?" And then I realized this is because there does not seem to be any way to write anything like this:

entity Queue is
    generic (
        EL : type
    );
    port (
        data_in  : EL;
        data_out : EL;
        ...
    );
end entity Queue;

I really wish this were possible. Is there anything even remotely approximating it? Even if I have to retype the entity or component declarations, just some way to avoid retyping the architecture definition for every (modulo a generic width) type?

like image 355
Owen Avatar asked Oct 07 '22 15:10

Owen


2 Answers

Yes, and implementing a Queue is one of the classic reasons to do it!

This has been in VHDL since VHDL-2008. Tool support is variable as of mid-2012. Talk about a slow-moving industry!

  • Aldec supports it completely.
  • Modelsim has partial support - can't find a public link to their capabilities. If you have it installed, it's in /technotes/vhdl2008.note
  • Xilinx (XST/ISIM) doesn't support it, or even VHDL-2002. I can't find a simple link, but these PDFs have sections on VHDL compatibility, which only talk of VHDL-1993.
  • Altera's tools have partial support, but not for type generics
like image 55
Martin Thompson Avatar answered Oct 12 '22 12:10

Martin Thompson


Yes and no...

Generic types are a new feature of the upcoming VHDL-2008 standard : http://www.doulos.com/knowhow/vhdl_designers_guide/vhdl_2008/vhdl_200x_major/#GenericTypes

However the support of VHDL-2008 by EDA tools is still very limited. Even if your tools support it, using this feature would make your code non-portable.

Sticking to VHDL-2002, a solution would be to declare your interface types in a package and mytypesand use it everywhere needed with use work.mytypes.all.

like image 44
wap26 Avatar answered Oct 12 '22 11:10

wap26