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: 
Observer pjayav
Observer
4,971 Views
Registered: ‎11-11-2009

Ceil function using System generator 9.2 ??

Jump to solution

hi experts

 

Is there any block or logic to implement Ceil function using system generator blocks.

 

I am trying using Scale block. Shall i proceed exploring it or there are any easy logic is there to implement Ceil function using Xilinx system generator 9.2i.

 

 

regards

selvam

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Adventurer
Adventurer
5,402 Views
Registered: ‎08-20-2007

Re: Ceil function using System generator 9.2 ??

Jump to solution
Yeah, sorry, forgot about this.

View solution in original post

0 Kudos
5 Replies
Adventurer
Adventurer
4,966 Views
Registered: ‎08-20-2007

Re: Ceil function using System generator 9.2 ??

Jump to solution

If I understand right your logic, then ceiling is the same as flooring + 1. So far I remember flooring of two’s complement numbers is done by truncating the fraction part, both for positive and negative. At least it works for me.

So basically for flooring you don't need any logic, if you use "Convert" block with options Truncate and Wrap and binary point 0. 

Then add 1 to result for ceiling.

0 Kudos
Xilinx Employee
Xilinx Employee
4,958 Views
Registered: ‎11-28-2007

Re: Ceil function using System generator 9.2 ??

Jump to solution

 To make it complete, you will need to test if the input is already an integer as floor and ceil of an integer have the same result.

 

 


syoma wrote:

If I understand right your logic, then ceiling is the same as flooring + 1. So far I remember flooring of two’s complement numbers is done by truncating the fraction part, both for positive and negative. At least it works for me.

So basically for flooring you don't need any logic, if you use "Convert" block with options Truncate and Wrap and binary point 0. 

Then add 1 to result for ceiling.


 

Cheers,
Jim
0 Kudos
Highlighted
Adventurer
Adventurer
5,403 Views
Registered: ‎08-20-2007

Re: Ceil function using System generator 9.2 ??

Jump to solution
Yeah, sorry, forgot about this.

View solution in original post

0 Kudos
Observer pjayav
Observer
4,929 Views
Registered: ‎11-11-2009

Re: Ceil function using System generator 9.2 ??

Jump to solution
Thank you jim and syoma.  Your answers solved my problem
0 Kudos
Explorer
Explorer
2,359 Views
Registered: ‎11-03-2013

Re: Ceil function using System generator 9.2 ??

Jump to solution

You can use this function for ceil, if your calculation is CEIL(Y/2) :

 

function integer ceil_of_half (integer x);
begin
   if (x & 1)
       ceil_of_half = x/2 + 1;
   else
       ceil_of_half = x/2;
end
endfunction

x = ceil_of_half(Z);
0 Kudos