newbie question about type declaration

Discussion in 'VHDL' started by Max, Sep 3, 2003.

  1. Max

    Max Guest

    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
    Max, Sep 3, 2003
    #1
    1. Advertising

  2. 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/ #
    Renaud Pacalet, Sep 3, 2003
    #2
    1. Advertising

  3. Renaud Pacalet <> 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
    Colin Marquardt, Sep 3, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Noah
    Replies:
    5
    Views:
    955
  2. Alex Vinokur
    Replies:
    4
    Views:
    582
    Jonathan Turkanis
    Apr 5, 2004
  3. Ovidesvideo
    Replies:
    4
    Views:
    504
    Andrey Tarasevich
    Dec 10, 2004
  4. kelvSYC
    Replies:
    6
    Views:
    7,226
    Richard Herring
    May 17, 2005
  5. Luca Forlizzi
    Replies:
    4
    Views:
    461
    Luca Forlizzi
    Nov 14, 2010
Loading...

Share This Page