vhdl unconstrained array port

Status
Not open for further replies.

shaiko

Advanced Member level 5
Joined
Aug 20, 2011
Messages
2,644
Helped
303
Reputation
608
Reaction score
297
Trophy points
1,363
Visit site
Activity points
18,302
I want to create a new VHDL type inside a package called "2d_array" .
This type will be used as an array entity intput port (or output port).
I want the port's diementions to be unconstrained in order be able to define the exact size during compilation with 2 entity generic :
"2d_array_port_depth" and "2d_array_port_width".

Is it possible with VHDL?
If yes, please show me an example.
 

LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;

PACKAGE 2d_array_pkg IS

TYPE 2d_array IS ARRAY(15 DOWNTO 0) OF STD_LOGIC_VECTOR(31 DOWNTO 0);

END 2d_array_pkg;
 

with VHDL 1993, you cannot leave all dimensions unconstrained, only the outer most one. eg:

type 2d_array_t is array(integer rage <>) of std_logic_vector(31 downto 0);

but with VHDL 2008, you can do this:

type 2d_array_t is array(integer rage <>) of std_logic_vector;

signal my_input : 2d_array_t(15 downto 0, 31 downto );

but you will need a compiler with 2008 support. otherwise you'll have to put the generics as constants in a package to define the type.

- - - Updated - - -

with VHDL 1993, you cannot leave all dimensions unconstrained, only the outer most one. eg:

type 2d_array_t is array(integer rage <>) of std_logic_vector(31 downto 0);

but with VHDL 2008, you can do this:

type 2d_array_t is array(integer rage <>) of std_logic_vector;

signal my_input : 2d_array_t(15 downto 0, 31 downto );

but you will need a compiler with 2008 support. otherwise you'll have to put the generics as constants in a package to define the type.
 
Thanks for replying dftrtl,
However - this doesn't help.

You define an array of known and constant diementions!
I want to define a type that can be used as an array input port with the exact diementions set only during compile time using entity generics...

- - - Updated - - -

TrickyDicky,

So with VHDL 93 we cannot create an array input port with completely generic diementions?
 

you can create a true 2d array with vhdl 93

type my_2d_array_t is array(integer range <>, integer range <>) of integer;

and declare:

signal a : my_2d_array_t(0 to N, 0 to M);

but I wouldnt recommend using std_logic, as it is a pain to map to std_logic_vectors, as you have to assign it bit by bit if you want a whole array.
 
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
I don't understand what you mean...
this is a generic array definitions:
Code:
type GENERIC_ARRAY is array ( 0 to GENERIC_DEPTH - 1 ) of unsigned ( GENRIC_WIDTH - 1 downto 0 ) ;
signal SOME_GENERIC_ARRAY : GENERIC_ARRAY ;
But that's inside an entity in the signal definitions area!
I want to be able to define an entity port in the same manor...
 

unless its VHDL 2008, you cant. You have to make the generics constants inside a package and declare the type in the package too.
 
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
In VHDL 2008, the actual width of an unconstrained component port can be set by connecting a constrained signal in the instantiation, you won't even need generics for it. I didn't check it, but it's discussed as an example in a text book VHDL 2008 - Just the New Stuff.
 
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
Please show me an example (using VHDL 2008) of what I want to do (explained in post #6)...
 
Last edited:

type GENERIC_ARRAY is array (natural range <> ) of unsigned;
signal SOME_GENERIC_ARRAY : GENERIC_ARRAY(0 to GENERIC_DEPTH - 1 , GENRIC_WIDTH - 1 downto 0) ;
 
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…