Range of records

Discussion in 'VHDL' started by hssig, Apr 29, 2010.

  1. hssig

    hssig Guest

    Hi,

    I have the following declaration:


    type A is record
    first : std_logic;
    second : std_logic;
    third : std_logic;
    end record A;

    type B is record
    one : std_logic;
    two : A;
    end record B;

    signal sig : B;

    Now I want to check if all A record elements of signal sig are zero:

    process
    begin
    .....
    if sig.two = (sig.two'range => '0') then
    -- error message:Attribute "range" prefix must be appropriate for
    an array (object or type mark).
    end if;
    end process;

    Is there some possibility to check the record elements ?

    cheers,
    hssig
     
    hssig, Apr 29, 2010
    #1
    1. Advertising

  2. hssig

    Chris Higgs Guest

    On Apr 29, 5:07 pm, Rob Gaddi <> wrote:
    > On 4/29/2010 8:09 AM, hssig wrote:
    > Nothing built-in that I know of that's not a syntactic train wreck.  But
    > this is VHDL; functions are your friend.  You know what your data types
    > look like, just write one that goes through each data element doing your
    > comparison and returns a boolean.


    I define a to_vector and from_vector function for every record and pop
    it in a package called "conversions". Then you can do something like
    this:

    library mylib;
    use mylib.conversions.all;
    ....

    if or_reduce(to_vector(sig.two)) = '0' then


    Also putting records through fifos etc is nice and easy:

    wrdata <= to_vector(my_record_type);
    rdata <= from_vector(rdata_vec);

    For extra points auto-generate the conversions package :)

    Thanks,

    Chris
     
    Chris Higgs, Apr 29, 2010
    #2
    1. Advertising

  3. hssig

    hssig Guest

    Thank your for your proposals.

    Cheers,
    hssig
     
    hssig, May 1, 2010
    #3
  4. hssig wrote:

    > Hi,
    >
    > I have the following declaration:
    >
    >
    > type A is record
    > first : std_logic;
    > second : std_logic;
    > third : std_logic;
    > end record A;
    >
    > type B is record
    > one : std_logic;
    > two : A;
    > end record B;
    >
    > signal sig : B;
    >
    > Now I want to check if all A record elements of signal sig are zero:
    >
    > process
    > begin
    > ....
    > if sig.two = (sig.two'range => '0') then
    > -- error message:Attribute "range" prefix must be appropriate for
    > an array (object or type mark).
    > end if;
    > end process;
    >
    > Is there some possibility to check the record elements ?


    Instead of "sig.two'range" use "others". You can use "others" only if the
    record elements are of equal type.

    This compiles cleanly:

    ENTITY ent IS
    END ENTITY ent;

    LIBRARY ieee;
    USE ieee.std_logic_1164.ALL;

    ARCHITECTURE arch OF ent IS
    TYPE a IS
    RECORD
    first : std_logic;
    second : std_logic;
    third : std_logic;
    END RECORD a;

    TYPE b IS
    RECORD
    one : std_logic;
    two : a;
    END RECORD b;

    SIGNAL sig : b;
    BEGIN

    PROCESS (sig.two) IS
    BEGIN
    IF sig.two = (OTHERS => '0') THEN
    REPORT "Zarro";
    END IF;
    END PROCESS;

    END ARCHITECTURE arch;

    --
    Paul Uiterlinden
    www.aimvalley.nl
    e-mail addres: remove the not.
     
    Paul Uiterlinden, May 3, 2010
    #4
    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. Ahmed Moustafa

    SELECT returns a range of records?

    Ahmed Moustafa, Jul 20, 2003, in forum: Java
    Replies:
    14
    Views:
    8,758
    Steve
    Jul 25, 2003
  2. Luke Airig
    Replies:
    0
    Views:
    821
    Luke Airig
    Dec 31, 2003
  3. Replies:
    46
    Views:
    996
    Antoon Pardon
    Jul 25, 2006
  4. Dan

    Delete records or update records

    Dan, May 10, 2004, in forum: ASP General
    Replies:
    1
    Views:
    483
    Ray at
    May 10, 2004
  5. Replies:
    3
    Views:
    706
    Anthony Jones
    Nov 2, 2006
Loading...

Share This Page