"chris" <> wrote in message
news: om...
> I tried to declare an output port of my entity as an array and the
> compiler don't want it.
>
> Here comes an example :
>
> ------------
> entity test is
> generic (
> a : positive := 8;
> b : positive := 8
> );
> port (
> e : in std_logic;
> s : out array(a downto 0) of std_logic_vector(b downto 0)
> );
> end entity test;
> ------------
>
> Do I made a syntaxe error ?
> Is someone can give me a possible solution to go around this problem
?
>
Yes,
you can't create an array type "on the fly" like that - you have
to create a type first. Because it's being used on a port, you need
a package. Unfortunately that makes it tricky to use a generic for
b (the width of the std_logic_vector), though you can make "a" a
generic as follows.
library IEEE;
use IEEE.std_logic_1164.all;
package P is
subtype SLVT is std_logic_vector(8 downto 0);
-- note array element *must be constrained*
type SLVArrayT is array (natural range <>) of SLVT;
end;
library IEEE;
use IEEE.std_logic_1164.all;
use work.P.all;
entity test is
generic (a : positive :=

;
port (
e : in std_logic;
s : out SLVArrayT(a downto 0)
);
end;
architecture a of test is
-- and here's b deduced from SLVT;
constant b : positive := s'LENGTH;
begin
...
kind regards
Alan
p.s. I haven't compiled this, but it *should* work.
Sometimes analysis fails if S'LENGTH is not considered
to be locally static to initialize the constant.
--
Alan Fitch
Consultant
DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * Perl * Tcl/Tk * Verification * Project
Services
Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, Hampshire, BH24
1AW, UK
Tel: +44 (0)1425 471223 mail:
Fax: +44 (0)1425 471573 Web:
http://www.doulos.com
The contents of this message may contain personal views which are not
the
views of Doulos Ltd., unless specifically stated.