Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Decimal numbers

Reply
Thread Tools

Decimal numbers

 
 
Tim Hubberstey
Guest
Posts: n/a
 
      04-21-2004
Ed wrote:
> When using std_logic_vectors(xx downto yy) I can use either binary numbers
> in the form "11010101" or hex numbers in the form x"00". How can I use
> decimal numbers?


Use type conversion functions:

library ieee;
use ieee.numeric_std.all;
....
signal some_vector : std_logic_vector(x-1 downto 0);
....
some_vector <= std_logic_vector(to_unsigned(DECIMAL_VAL, x);
or
some_vector <= std_logic_vector(to_signed(DECIMAL_VAL, x);

Limitations: Maximum value for 'x' is 31 for unsigned, 32 for signed.
--
Tim Hubberstey, P.Eng. . . . . . Hardware/Software Consulting Engineer
Marmot Engineering . . . . . . . VHDL, ASICs, FPGAs, embedded systems
Vancouver, BC, Canada . . . . . . . . . . . http://www.marmot-eng.com

 
Reply With Quote
 
 
 
 
Ed
Guest
Posts: n/a
 
      04-22-2004
Hello,

When using std_logic_vectors(xx downto yy) I can use either binary numbers
in the form "11010101" or hex numbers in the form x"00". How can I use
decimal numbers? I've done a google search but can't find any answers.

Thanks,


 
Reply With Quote
 
 
 
 
Thomas Reinemann
Guest
Posts: n/a
 
      04-22-2004
Tim Hubberstey wrote:
> some_vector <= std_logic_vector(to_unsigned(DECIMAL_VAL, x);
> or
> some_vector <= std_logic_vector(to_signed(DECIMAL_VAL, x);

some_vector <= std_logic_vector(to_signed(DECIMAL_VAL,some_vector 'length);

will automatically pass the right value to "to_signed". Of course you
can use it in "to_unsigned".

Regards,

Tom
 
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
decimal.Decimal formatting python@lists.fastmail.net Python 0 07-19-2010 12:32 PM
how to convert from Decimal('1.23456789') to Decimal('1.234') valpa Python 11 03-24-2009 07:11 AM
Error: Cannot convert Decimal("0.0000") to Decimal Vitaliy Python 1 05-29-2008 10:36 AM
TypeError: unsupported operand type(s) for -: 'Decimal' and 'Decimal'. Why? Gilbert Fine Python 8 08-01-2007 01:58 AM
Decimal to Packed Decimal Conversion in C++ Ven C++ 3 08-01-2006 03:56 PM



Advertisments