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

Reply

VHDL - newbie: integer to bit_vector

 
Thread Tools Search this Thread
Old 05-29-2006, 08:27 PM   #1
Default newbie: integer to bit_vector


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?=
  Reply With Quote
Old 05-29-2006, 11:01 PM   #2
KJ
 
Posts: n/a
Default Re: newbie: integer to bit_vector
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
  Reply With Quote
Old 05-29-2006, 11:03 PM   #3
KJ
 
Posts: n/a
Default Re: newbie: integer to bit_vector
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$ om...
> 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
  Reply With Quote
Old 05-29-2006, 11:06 PM   #4
KJ
 
Posts: n/a
Default Re: newbie: integer to bit_vector
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
  Reply With Quote
Old 05-30-2006, 06:57 PM   #5
Andy
 
Posts: n/a
Default Re: newbie: integer to bit_vector
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
  Reply With Quote
Old 05-30-2006, 08:42 PM   #6
=?ISO-8859-1?Q?Sch=FCle_Daniel?=
 
Posts: n/a
Default Re: newbie: integer to bit_vector
thx, it works fine


=?ISO-8859-1?Q?Sch=FCle_Daniel?=
  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
How to convert string contain Hex data into integer asifjavaid Software 0 09-09-2008 08:50 AM
Newbie; what is the best software to convert DVD (Vob) file to avi - divx ? Laura25 DVD Video 4 07-12-2006 03:03 PM
NEWBIE - DVD burn problem - need help Vic Baron DVD Video 6 09-29-2005 10:56 PM
Heeeeeeelp... Newbie with avi to dvd (or svcd) please. Mike DVD Video 11 08-14-2004 09:04 PM
Newbie Pioner 3100 help oespelan DVD Video 3 07-19-2004 04:30 AM




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