Clear Filters
Clear Filters

Remainder of a division operation in System Generator

6 views (last 30 days)
I have an integrator which gives the running value of angle theta. To find the sine/cosine of this angle using the SysGen ROM block, the value of theta is always required to be within the range 0-360, which can be obtained by finding the remainder of division of theta by 360.
As there is no direct block that gives the remainder after division operation in SysGen blockset, please suggest a way to do this.

Accepted Answer

Andy Bartlett
Andy Bartlett on 23 Jan 2023
Consider restructuring your design to work in units of revolutions instead of in degrees. In that case you only need to perform modulo 1 which is nothing more that dropping the bits to the left of the binary-point.
FYI: when modeling with Simulink blocks instead of System Generator Blocks, Fixed-Point Designer's Modulo by Constant block can be used. It is design to give optimal handling of modulo by constants like 360, 2*pi, etc. But modulo of 1 revolution will still lead to the most efficient implementation.
Andy Bartlett
Andy Bartlett on 25 Jan 2023
Hi Suhanya,
As I noted in the your other posting.
Please reach out to the tech support team from AMD (Xilinix) for their System Generator product.
I'd like to be more helpful, but the details are specific to these AMD blocks and will require the AMD tech support or development team to explain.

Sign in to comment.

More Answers (1)

Bharath Venkataraman
Bharath Venkataraman on 20 Jan 2023
When you say "running value", what is the range of the update value? If the initial value can be set to the proper range of 0 to 360 and the update value is limited such that the accumulated value will be less than 720 degreees, you may be able to use an adder to add the value followed by a subtractor of added value-360. Then you can choose between those values to stay between 0 and 360 all the time.
So if you current value is 300 and you add in 75 degrees, you will end up with 375 out of the adder and 15 out of the subtractor. Seeing that 15 is a positive value (or knowing that 375 is greater than 360), you pick the subtractor output. Otherwise, you would pick the adder output. Whichever value you pick needs to be the next value used for the accumulation.
Bharath Venkataraman
Bharath Venkataraman on 25 Jan 2023
Edited: Bharath Venkataraman on 26 Jan 2023
For your case where the value range is not restricted, the above option I proposed will not help. You can try Andy's approach using the Modulo block in Fixed-Point Designer.
For Sysgen specific approaches, I suggest reaching out to Xilinx support.

Sign in to comment.




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!