UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Scholar u4223374
Scholar
4,102 Views
Registered: ‎04-26-2015

Is this a bug or expected behaviour?

Jump to solution

Hello everyone,

 

Just testing a tiny bit of code in HLS and found this:

 

#include <ap_int.h>

typedef ap_uint<1> uint1;

void test_uint1() {
	uint1 y = 1;
	uint1 z = 1;
	uint1 w = y && (~z);
	printf("Y = %d\nZ = %d\nW = %d\n",(int) y, (int) z, (int) w);
}

The result:

Y = 1
Z = 1
W = 1

Unless I've misunderstood it completely, W = 0 would be correct. ~z should (according to UG902) return an ap_uint<1> value, which should be zero (since z is 1). Anything AND-ed with zero will be zero. Using a logical NOT instead of a bitwise NOT gives correct behaviour, although for a uint1 value you'd expect that they'd be equivalent. If I put an intermediate value in there (ie "uint1 x = ~z; w = y && x;") then I also get correct behaviour.

 

 

It's not a huge problem (easy to just use a logical NOT) but interesting and potentially worth the time that it'll take someone to fix it.

 

 

0 Kudos
1 Solution

Accepted Solutions
Moderator
Moderator
7,664 Views
Registered: ‎11-09-2015

Re: Is this a bug or expected behaviour?

Jump to solution

Hi @u4223374,

 

Yes it looks like a tool issue because if you cast the result of ~z into a uint1 it works:

uint1 w = y && (uint1)(~z);

So the operator ~ does not seems to return bitwise-NOT of z with the same width and signedness.

 

I will ask development to fix this.

 

Regards,

 

Florent


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos
5 Replies
Moderator
Moderator
7,665 Views
Registered: ‎11-09-2015

Re: Is this a bug or expected behaviour?

Jump to solution

Hi @u4223374,

 

Yes it looks like a tool issue because if you cast the result of ~z into a uint1 it works:

uint1 w = y && (uint1)(~z);

So the operator ~ does not seems to return bitwise-NOT of z with the same width and signedness.

 

I will ask development to fix this.

 

Regards,

 

Florent


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos
Scholar u4223374
Scholar
4,054 Views
Registered: ‎04-26-2015

Re: Is this a bug or expected behaviour?

Jump to solution

Hi @florentw,

 

Great! That's good to hear. I'll be awaiting a fix in HLS 2016.4!

 

Cheers,

Evan

 

0 Kudos
Moderator
Moderator
4,016 Views
Registered: ‎11-09-2015

Re: Is this a bug or expected behaviour?

Jump to solution

Hi @u4223374,

 

Just to clarify, I cannot guaranty in which release it will be fixed. This seems to be a small fix so it could be resolved in 2016.4 but there are no guaranty.

 

Regards,

 

Florent


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos
Scholar u4223374
Scholar
3,909 Views
Registered: ‎04-26-2015

Re: Is this a bug or expected behaviour?

Jump to solution

@florentw

 

Thanks for the clarification. Will there be a note about the bug being fixed (eg. in UG902) when that happens, or should I just test the same in each version of HLS until it works?

 

 

0 Kudos
Moderator
Moderator
3,888 Views
Registered: ‎11-09-2015

Re: Is this a bug or expected behaviour?

Jump to solution

Hi @u4223374,

 

I will try to remember to update the post when I will have verified the fix.

 

If I forgot, please just send me an PM.

 

PS: The fix should not be in 2016.4

 

Regards,

 

Florent


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos