newbie: integer to bit_vector

Discussion in 'VHDL' started by =?ISO-8859-1?Q?Sch=FCle_Daniel?=, May 29, 2006.

  1. Hello,

    I want to write a simple test benchmark
    I want to generate all possible bit combinations
    for bit_vector(7 downto 0) through an integer variable

    eg

    for i in 0 to 255 loop
    bv <= convert(8, i); -- 8 width, and i value
    end loop;

    is there some convert function for this purpose?

    I couldn't find it using google
    too much information but not what I am looking for

    Regards, Daniel
     
    =?ISO-8859-1?Q?Sch=FCle_Daniel?=, May 29, 2006
    #1
    1. Advertising

  2. =?ISO-8859-1?Q?Sch=FCle_Daniel?=

    KJ Guest

    Assuming 'bv' is std_logic_vector(7 downto 0)...

    And you include the IEEE numeric_std library...
    library IEEE;
    use IEEE.numeric_std.all;

    then....
    for i in 0 to 255 loop
    bv <= std_logic_vector(to_unsigned(i, bv'length)); -- 8 width, and i
    value
    end loop;

    KJ
     
    KJ, May 29, 2006
    #2
    1. Advertising

  3. =?ISO-8859-1?Q?Sch=FCle_Daniel?=

    KJ Guest

    Oops...just noticed that you wanted 'bv' to be a bit_vector....well, you can
    work out that last conversion I'm sure.
    KJ

    "KJ" <> wrote in message
    news:OaKeg.35999$...
    > Assuming 'bv' is std_logic_vector(7 downto 0)...
    >
    > And you include the IEEE numeric_std library...
    > library IEEE;
    > use IEEE.numeric_std.all;
    >
    > then....
    > for i in 0 to 255 loop
    > bv <= std_logic_vector(to_unsigned(i, bv'length)); -- 8 width, and i
    > value
    > end loop;
    >
    > KJ
    >
     
    KJ, May 29, 2006
    #3
  4. =?ISO-8859-1?Q?Sch=FCle_Daniel?=

    KJ Guest

    First nclude the IEEE numeric_std library...
    library IEEE;
    use IEEE.numeric_std.all;

    then....

    for i in 0 to 255 loop
    bv <= bit_vector(to_unsigned(i, bv'length)); -- 8 width, and i value
    end loop;

    KJ
     
    KJ, May 29, 2006
    #4
  5. =?ISO-8859-1?Q?Sch=FCle_Daniel?=

    Andy Guest

    Use numeric_bit instead of numeric_std package.

    It defines signed and unsigned vectors of bit instead of std_logic.

    So type conversions from numeric_bit.unsigned to bit are allowed:

    bit_vector(unsigned(int_val)) works as long as numeric_bit is used.

    Andy
    KJ wrote:
    > First nclude the IEEE numeric_std library...
    > library IEEE;
    > use IEEE.numeric_std.all;
    >
    > then....
    >
    > for i in 0 to 255 loop
    > bv <= bit_vector(to_unsigned(i, bv'length)); -- 8 width, and i value
    > end loop;
    >
    > KJ
     
    Andy, May 30, 2006
    #5
  6. thx, it works fine
     
    =?ISO-8859-1?Q?Sch=FCle_Daniel?=, May 30, 2006
    #6
    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. Scott Brady Drummonds

    vector<bool>, bit_vector, or something else?

    Scott Brady Drummonds, Jul 3, 2003, in forum: C++
    Replies:
    3
    Views:
    585
  2. Dimitar Georgiev

    bit_vector and list_wl in VC++ 7.0

    Dimitar Georgiev, Sep 11, 2003, in forum: C++
    Replies:
    1
    Views:
    403
    Kevin Goodsell
    Sep 11, 2003
  3. Amal

    bit_vector comparison

    Amal, Mar 20, 2007, in forum: VHDL
    Replies:
    7
    Views:
    1,526
    Duane Clark
    Mar 20, 2007
  4. Markus Dehmann
    Replies:
    8
    Views:
    602
    James Kanze
    Oct 27, 2007
  5. Xin Xiao

    std_logic_vector or bit_vector?

    Xin Xiao, Dec 5, 2007, in forum: VHDL
    Replies:
    1
    Views:
    1,118
    Mike Treseler
    Dec 6, 2007
Loading...

Share This Page