My type in main entity

Z

zlotawy

Hi,
I'd like to create entity like this:

entity top1 is

generic (
NUMBER : Integer := 14
);

PORT(
P_IN_DAC : IN my_type(NUMBER -1 downto 0)

);
end top1;

and my_type is:

type my_type is array(natural range <>) of std_logic_vector(20 downto 0) ;

Compilation has errors. Where do I have to declare my type? Is it possible
to create input port of FPGA with own type?


Thanks,
zlotawy
 
M

Macias Wojtas

Compilation has errors. Where do I have to declare my type?

You can declare your type in your own package and use this packed in file
where you have this input.
Is it possible to create input port of FPGA with own type?

Of course it is possible, but your type has to be synthesable eg. array of
STD_LOGIC_VECTOR.

Best regards

Macias
 
A

Andy

You can declare your type in your own package and use this packed in file
where you have this input.


Of course it is possible, but your type has to be synthesable eg. array of
STD_LOGIC_VECTOR.

Best regards

Macias

There are far more composite types than arrays of SLV that are
synthesizable. Records and arrays of boolean, bit, integer, other
records and other arrays, etc., are all synthesizable.

They type declaration needs to be in a package that is referenced in
the context clause of the entity (i.e. in a use statement). Of course
what ever instantiates that entity (or its component), like a test
bench, will also have to reference the package.

Andy
 
M

Macias Wojtas

Andy said:
There are far more composite types than arrays of SLV..

I know that's why I used 'e.g.' befor 'array of STD_LOGIC_VECTOR'.

Best regards

Macias
 
Z

zlotawy

I cretated this code:

package pcg is
constant DATA_SIZE : Integer := 20;
type my_type is array(natural range <>) of std_logic_vector(DATA_SIZE-1
downto 0) ;
end pcg ;

entity top1 is

generic (
NUMBER : Integer := 14
);

PORT(
P_I_CLK : IN std_logic;
P_IN_DAC : IN my_type(NUMBER -1 downto 0)

);
end top1;



and I got error:
Undefined symbol 'std_logic'.


What is wrong?

Thanks
zlotawy
 
M

Mike Treseler

zlotawy said:
What is wrong?
missing library declarations and references

-- Mike Treseler
______________________________________________
library ieee;
use ieee.std_logic_1164.all;
package pcg is
constant DATA_SIZE : integer := 20;
type my_type is array(natural range <>)
of std_logic_vector(DATA_SIZE-1 downto 0);
end pcg;

library ieee;
use ieee.std_logic_1164.all;
use work.pcg.all;
entity top1 is
generic (
NUMBER : integer := 14
);

port(
P_I_CLK : in std_logic;
P_IN_DAC : in my_type(NUMBER -1 downto 0)
);
end top1;
 
A

Andy

Uzytkownik "Andy" <[email protected]> napisal w wiadomosci


I cretated this code:

package pcg is
constant DATA_SIZE : Integer := 20;
type my_type is array(natural range <>) of std_logic_vector(DATA_SIZE-1
downto 0) ;
end pcg ;

entity top1 is

generic (
NUMBER : Integer := 14
);

PORT(
P_I_CLK : IN std_logic;
P_IN_DAC : IN my_type(NUMBER -1 downto 0)

);
end top1;

and I got error:
Undefined symbol 'std_logic'.

What is wrong?

Thanks
zlotawy

You created a package, and it is compiled into the library when you
compile the file, but you did not tell your entity to reference that
(or any other library or) package. There is no "file" scope in vhdl.
Just because a package is declared in the same file as the entity,
does not mean that the entity has automatic visibility of that
package.

Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top