cancel
Showing results for
Did you mean:
Highlighted
Participant
6,770 Views
Registered: ‎10-16-2010

## Strange result at the output of Negate block

Hello! I am doing a design with LUTs and I have dudes about a result I get from a negate block I have to use.

The design works properly, but I would like to know why happens this. If you see the picture, the input of the negate block is -999 but the output is -25, why it is not 999?

Thank you so much for your help.

Tags (3)
5 Replies
Highlighted
Professor
6,767 Views
Registered: ‎08-14-2007

## Re: Strange result at the output of Negate block

If you have a calculator that does hex numbers, you can see that 999 and -25 have

the same value in the lower 10 bits:

- 25 = 0xFFFFFFE7

999 = 0x000003E7

If the display you added is only 10 bits and signed, then it will report -25 rather

than 999.  You would need 11 bits to display the signed number properly.

-- Gabor

-- Gabor
Highlighted
Xilinx Employee
6,761 Views
Registered: ‎11-28-2007

## Re: Strange result at the output of Negate block

As Gabor pointed out, it's probably a data type problem. If you can turn on the data type display (Simulink menu Format->Port/Signal Displays->Port Data Types), that will help determine if that is the case. I did a quick test and I got the expected result (see snapshot below):

Cheers,
Jim
Highlighted
Professor
6,758 Views
Registered: ‎08-14-2007

## Re: Strange result at the output of Negate block

You might also notice in Jim's diagram that the output of the negate block has one more bit

than its input.  In the originally posted diagram, you can't see the data widths, but there may

be some truncation when the negate block output goes into the multiplexer, whose other

inputs would have the same width as the input side of the negate block.  Since the display

is tapped off the bus connection between the negate block and the multiplexer, it's not clear

whether it gets the full output of the negate block or only those bits connected to the multiplexer.

-- Gabor

-- Gabor
Highlighted
Participant
6,756 Views
Registered: ‎10-16-2010

## Re: Strange result at the output of Negate block

So Is only a problem about the display format? So the functionality of my design is proper? I think so, because I get the number expectec at the output point of the cash block.

Highlighted
Xilinx Employee
6,751 Views
Registered: ‎11-28-2007

## Re: Strange result at the output of Negate block

It's hard to say without knowing the data types at various points. If you can attach the model or a snopshot with all data type displayed on the model, we can take a look if it's just a display problem.

@2010stone wrote:

So Is only a problem about the display format? So the functionality of my design is proper? I think so, because I get the number expectec at the output point of the cash block.

Cheers,
Jim