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

Reply

VHDL - Help! Signed Number Representation in Xilinx Testbench Waveform

 
Thread Tools Search this Thread
Old 01-18-2006, 06:54 PM   #1
Default Help! Signed Number Representation in Xilinx Testbench Waveform


Hi,

I am using Xilinx ISE Testbench Waveform to simulate my VHDL code and
there is something that confused me:

-256 is equal to '111100000000' in two's complement
notation.'111100000000' is equal to 3840 if you interpret it as having
no sign bit.

In the testbench waveform I have several options to enter the input.
Some of them:
Decimal(Signed)
Decimal(Unsigned)
Binary

You can enter a number in one of these ways and you can also convert
one to the other. Thus, if I enter -256 while in the Decimal(Signed)
option, I expect it to be '111100000000' in the binary option. However,
I get '100100000000' or in Decimal(Unsigned), 2304.

Does Xilinx ISE Testbench Waveform use a representation other than 2's
complement? If I want to enter a negative number and want to process it
as a signed number in my code, how should I enter it in Xilinx ISE
Testbench Waveform?

Thanks in advance for any help

E.



Emel
  Reply With Quote
Old 01-19-2006, 10:46 AM   #2
Colin Paul Gloster
 
Posts: n/a
Default Re: Help! Signed Number Representation in Xilinx Testbench Waveform
On Wed, 18 Jan 2006, Emel wrote:

"I am using Xilinx ISE Testbench Waveform to simulate my VHDL code and
there is something that confused me:

-256 is equal to '111100000000' in two's complement
notation.'111100000000' is equal to 3840 if you interpret it as having
no sign bit.

In the testbench waveform I have several options to enter the input.
Some of them:
Decimal(Signed)
Decimal(Unsigned)
Binary

You can enter a number in one of these ways and you can also convert
one to the other. Thus, if I enter -256 while in the Decimal(Signed)
option, I expect it to be '111100000000' in the binary option. However,
I get '100100000000' or in Decimal(Unsigned), 2304.

Does Xilinx ISE Testbench Waveform use a representation other than 2's
complement?"

You said that if you enter -256 that the binary representation is reported
as 100100000000 which is +256 (100000000) in two's complement binary but
with three extra more significant bits (100). So one obvious possibility
is that the single most significant bit is a flag, which when 1 denotes
that the number is the negative of the positive two's complement number
made up from the other bits, and when 0 is a positive number.

This notation is called one's complement. Positive numbers are represented
identically in one's complement and two's complement, only their negative
representations differ.

"If I want to enter a negative number and want to process it
as a signed number in my code, how should I enter it in Xilinx ISE
Testbench Waveform?"

It seems that you are more comfortable with decimal. If you want to think
in terms of binary, simply mask out (what in unsigned arithmetic would be)
the most significant bit to think about the magnitude and pay attention
to only the most significant bit when you want to think about the sign.

N.B. Positive zero is not represented the same as negative zero in one's
complement notation.

Regards,
Colin Paul Gloster


Colin Paul Gloster
  Reply With Quote
Old 01-23-2006, 01:22 PM   #3
Brian Drummond
 
Posts: n/a
Default Re: Help! Signed Number Representation in Xilinx Testbench Waveform
On Thu, 19 Jan 2006 11:46:24 +0100, Colin Paul Gloster
<> wrote:

>On Wed, 18 Jan 2006, Emel wrote:


>You said that if you enter -256 that the binary representation is reported
>as 100100000000 which is +256 (100000000) in two's complement binary but
>with three extra more significant bits (100). So one obvious possibility
>is that the single most significant bit is a flag, which when 1 denotes
>that the number is the negative of the positive two's complement number
>made up from the other bits, and when 0 is a positive number.
>
>This notation is called one's complement. Positive numbers are represented
>identically in one's complement and two's complement, only their negative
>representations differ.


Are you sure that's one's complement? Lools like sign&magnitude to me.

- Brian



Brian Drummond
  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
Xilinx 7.1 and testbench error boitsas Software 0 01-15-2008 04:14 PM




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