Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - How to pass a global data type to an entity?

 
Thread Tools Search this Thread
Old 09-20-2005, 04:35 PM   #1
Default How to pass a global data type to an entity?


Hi,
I would like a help:
How to pass a global data type to an entity?

This is the statements I wrote and it has errors.

LIBRARY ieee;
USE ieee.std_logic_1164.all;
use ieee.numeric_std.all; -- for "unsigned"
LIBRARY unisim;
USE UNISIM.VCOMPONENTS.ALL;

package NewType is
type ByteType is array(7 downto 0) of std_logic_vector(7 downto 0);
end NewType;

entity AModule is port (
DataIn : ByteType;
...
);
end AModule;

architecture A of AModule is
....
end A;

What is wrong?

Thank you.

Weng



Weng Tianxiang
  Reply With Quote
Old 09-20-2005, 06:00 PM   #2
Jonathan Bromley
 
Posts: n/a
Default Re: How to pass a global data type to an entity?
On 20 Sep 2005 08:35:13 -0700, "Weng Tianxiang" <> wrote:

>This is the statements I wrote and it has errors.
>
>LIBRARY ieee;
>USE ieee.std_logic_1164.all;
>use ieee.numeric_std.all; -- for "unsigned"
>LIBRARY unisim;
>USE UNISIM.VCOMPONENTS.ALL;
>
>package NewType is
>type ByteType is array(7 downto 0) of std_logic_vector(7 downto 0);
>end NewType;
>
>entity AModule is port (
> DataIn : ByteType;

[...]

Two related problems:

(1)
LIBRARY and USE clauses do NOT apply to the whole source
file. They apply only to the next design unit.
Design unit = package, package body, entity, architecture,
configuration.
So, your LIBRARY and USE clauses apply only to the package.
You need to repeat them just before the entity.

(2)
Creating a package in a source file does NOT make the
package available to other design units in the source file.
So, you need to "USE" the package just before the entity
that needs it.

The solution....

LIBRARY ieee;
USE ieee.std_logic_1164.all; -- Only this is needed for NewType

package NewType is
type ByteType is array(7 downto 0) of std_logic_vector(7 downto 0);
end NewType;
--------------------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.all;
use ieee.numeric_std.all;
LIBRARY unisim;
USE UNISIM.VCOMPONENTS.ALL;

USE work.NewType.all; -- needed to make "ByteType" visible

entity AModule is port (
DataIn : ByteType;

Note that it is now OK to put the two design units in two
separate source files. This is probably a good idea anyway.

HTH
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL, Verilog, SystemC, Perl, Tcl/Tk, Verification, Project Services

Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, 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.



Jonathan Bromley
  Reply With Quote
Old 09-20-2005, 06:01 PM   #3
Mike Treseler
 
Posts: n/a
Default Re: How to pass a global data type to an entity?
Weng Tianxiang wrote:

> How to pass a global data type to an entity?


Put your global package in a separate file.
Otherwise I have to compile AModule and
its parents just to use your byte type in myModule.

Use subtypes of standard vectors not new types.

Add:
use work.global_package.all;
at the top of AModule.


-- Mike Treseler
-----------------------------------------------------------------
-- File global_package.vhd
library ieee;
use ieee.std_logic_1164.all; -- for std_logic_vector

package global_package is
subtype byte_t is std_logic_vector(7 downto 0);
end package global_package;

-----------------------------------------------------------------
-- File AModule
library ieee;
use ieee.std_logic_1164.all; -- for std_logic_vector
use ieee.numeric_std.all; -- for unsigned
use work.global_package.all;

entity AModule is port (
DataIn : in byte_t;
DataOut : out unsigned(byte_t'range) -- make use of package
);
end entity AModule;

architecture synth of AModule is
begin
DataOut <= unsigned(DataIn); -- make use of unsigned
end architecture synth;
-----------------------------------------------------------------


Mike Treseler
  Reply With Quote
Old 09-20-2005, 08:05 PM   #4
Weng Tianxiang
 
Posts: n/a
Default Re: How to pass a global data type to an entity?
Hi Mike, Jonathan,
I learn from your answers several times.

Thank you very much.

Weng



Weng Tianxiang
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Error: Physical sythesis tool PALAC is not supported by Formal Verification tool Conf bbiandov Software 0 12-22-2008 05:25 AM
Eclipse - Axis2 - Java Webservices Error amanjsingh Software 1 10-09-2007 09:03 AM
Need help on Modelsim VHDL syntax? ASAP:) kaji General Help Related Topics 0 03-14-2007 10:43 PM
Need help on a Modelsim VHDL Syntax? ASAP:) kaji Software 0 03-14-2007 10:43 PM
Need Help on a Modelsim VHDL Syntax....ASAP:) kaji Hardware 0 03-14-2007 10:41 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46