Help! Signed Number Representation in Xilinx Testbench Waveform

E

Emel

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.
 
C

Colin Paul Gloster

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
 
B

Brian Drummond

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top