ToTwos

Converts a sign and magnitude into a twos complement value. The TwosComplement output is the same dataset as the Unsigned input. A List input will produce List outputs.

Object Path

CoreLib\Converters\Advanced

Inputs

Bit/List Sign

High if the input is to be converted to a negative twos complement output value. Low if the input is to be converted to a positive twos complement output value. This value is the same as the high bit of the twos complement input.

Var/List Unsigned

An MSBxxx, Lsbxxx, or BINxxx dataset to be converted to a twos complement number along with the specified Sign input. This input can also be considered the magnitude of the value.

Bit ClkG

Global clock if disconnected or a specific clock if connected

Bit AClr

Asynchronous clear. Has a value of 0 if disconnected.

Bit Go

Go

Bit Wait

Wait. Has a value of 0 if disconnected. Holds off Dones.

Outputs

Bit/List OFL

Goes high if the input had its high bit set. This value is the same as the high bit of the Unsigned (magnitude) input. If the high bit of the Unsigned input is always zero, this OFL output is unnecessary.

Var/List TwosComp

The combination of the Unsigned input (the magnitude) with the Sign input resulting in a twos complement representation of the value.

Bit ClkG

Clock input pass through

Bit AClr

Asynchronous clear input pass through

Bit Done

Done. Data valid while Done is high.

Bit Busy

Busy. Hold off Gos.

Timing Diagram

None

Program Notes

Input/Output Examples:

Sign

Unsigned

TwosComp

OFL

0

000 (0)

000 (0)

0

0

001 (1)

001 (1)

0

0

010 (2)

010 (2)

0

0

011 (3)

011 (3)

0

0

1XX

???

1

1

000 (0)

000 (0)

0

1

001 (1)

111 (-1)

0

1

010 (2)

110 (-2)

0

1

011 (3)

101 (-3)

0

1

1XX

???

1

Example

None

Revision History

None

See Also

ToTwos — Asynchronous

 

ToTwos — Asynchronous

Converts a sign and magnitude into a twos complement value. The TwosComplement output is the same dataset as the Unsigned input. A List input will produce List outputs. This object is asynchronous and may have difficulty meeting timing specifications with large datasets and/or faster frequencies.

Object Path

CoreLib\Converters\Async\Advanced

Inputs

Bit/List Sign

High if the input is to be converted to a negative twos complement output value. Low if the input is to be converted to a positive twos complement output value. This value is the same as the high bit of the twos complement input.

Var/List Unsigned

An MSBxxx, Lsbxxx, or BINxxx dataset to be converted to a twos complement number along with the specified Sign input. This input can also be considered the magnitude of the value.

Outputs

Bit/List OFL

Goes high if the input had its high bit set. This value is the same as the high bit of the Unsigned (magnitude) input. If the high bit of the Unsigned input is always zero, this OFL output is unnecessary.

Var/List TwosComplement

The combination of the Unsigned input (the magnitude) with the Sign input resulting in a twos complement representation of the value.

Timing Diagram

None

Program Notes

Input/Output Examples:

Sign

Unsigned

TwosComp

OFL

0

000 (0)

000 (0)

0

0

001 (1)

001 (1)

0

0

010 (2)

010 (2)

0

0

011 (3)

011 (3)

0

0

1XX

???

1

1

000 (0)

000 (0)

0

1

001 (1)

111 (-1)

0

1

010 (2)

110 (-2)

0

1

011 (3)

101 (-3)

0

1

1XX

???

1

Example

None

Revision History

None

See Also

ToTwos