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: 
Visitor ssingh1
Visitor
5,403 Views
Registered: ‎09-25-2012

Vivado HLS: problem with precision data types

Problem 1: I am trying to implement a simple 3 bit counter with vivado HLS using precision data types.

 

void counter()
{
uintx3 count; // typedef ap_uint<3> uintx3;

int i;

count = 0;

for (i=0;i<11;i++)
{
printf ("\n Count = %d", count);
count = count + 1;
}
}

 

I get a blank screen on the console wiht no errors. If I change tha data type of variable 'count' to short, I get the results. But then it would not be a counter. :)

 

Problem 2: I read in ug902 that if 2 variables with different precision data types are added, the result should have a bit width one more than the highest bit width among the operands. But if I do:

 

typedef ap_uint<10> uintx10;

typedef ap_int<3> intx3;

 

uinttx10 a;

intx3 i;

 

a = a + i;

 

This would mean that 'a' on the left hand side should be 1-bit more than a on the right which is not possible.

0 Kudos
1 Reply
Mentor xilinxacct
Mentor
121 Views
Registered: ‎10-23-2018

Re: Vivado HLS: problem with precision data types

@ssingh1

The note is highlighting the fact that an overflow can happen. (which can happen even with fixed precision numbers). 

You can decide whether or not you need to know or want to handle the overflow condition. For a simple 3 bit counter, I suspect you just want to rollover, which should be the default condition (eg. the carry just disappears)

Hope that helps

Please mark as solution accepted to close the issue. Kudos also welcomed. :-)

0 Kudos