Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > newbie question about type declaration

Reply
Thread Tools

newbie question about type declaration

 
 
Max
Guest
Posts: n/a
 
      09-03-2003
I have a problem with types:

-----8<-----------
entity driver is
Port ( data : inout integer range 0 to 255;
clk : in std_logic);
end driver;

architecture Behavioral of driver is

type data_type is range 0 to 255;
signal data_reg: data_type;

begin

process (clk)
begin
if rising_edge(clk) then
--- some code here
data <= data_reg;
end if;
end process;
--------8<------------

the error is:
ERROR:HDLParsers:800 - driver.vhd Line xx. Type of data_reg is
incompatible with type of data.

How can I solve this problem?

thanks
 
Reply With Quote
 
 
 
 
Renaud Pacalet
Guest
Posts: n/a
 
      09-03-2003
Max wrote:
> I have a problem with types:
>
> -----8<-----------
> entity driver is
> Port ( data : inout integer range 0 to 255;
> clk : in std_logic);
> end driver;
>
> architecture Behavioral of driver is
>
> type data_type is range 0 to 255;


This declares a new type that as nothing to do with Integers.

subtype data_type is Integer range 0 to 255;

declares a subtype of type Integer and solves your problem.

Regards,

PS: inout mode for an integer port???
--
Renaud Pacalet, ENST, 46 rue Barrault 75634 Paris Cedex 13
###### Tel. : 01 45 81 78 08 | Fax : 01 45 80 40 36 ######
# Fight Spam! Join EuroCAUCE: http://www.euro.cauce.org/ #

 
Reply With Quote
 
 
 
 
Colin Marquardt
Guest
Posts: n/a
 
      09-03-2003
Renaud Pacalet <(E-Mail Removed) > writes:

> Max wrote:
>> I have a problem with types:
>> -----8<-----------
>> entity driver is
>> Port ( data : inout integer range 0 to 255;
>> clk : in std_logic);
>> end driver;
>> architecture Behavioral of driver is
>> type data_type is range 0 to 255;

>
> This declares a new type that as nothing to do with Integers.
>
> subtype data_type is Integer range 0 to 255;
>
> declares a subtype of type Integer and solves your problem.


And best make that subtype declaration in a package and also use it
for the data port in the entity. The magic number 255 should probably
also be derived from a constant like DATA_WIDTH. Next, consider using
natural or positive instead of integer. All this makes the code easier
to read and less error prone.

HTH,
Colin
 
Reply With Quote
 
 
 
Reply

Thread Tools

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
type declaration in declaration of a parameter or return type of a function Luca Forlizzi C Programming 4 11-14-2010 09:30 PM
maxplusII error: a deferred constant declaration without a full declaration is not supported Noah VHDL 5 04-07-2006 02:34 PM
"virtual outside class declaration" and "declaration does not declare anything" kelvSYC C++ 6 05-17-2005 08:58 AM
Function declaration in class declaration Ovidesvideo C++ 4 12-10-2004 06:36 PM
Intel C++ 8.0 : declaration hides declaration Alex Vinokur C++ 4 04-05-2004 09:49 PM



Advertisments