Remainder of a division operation in System Generator

4 次查看(过去 30 天)
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.
Thanks!

采纳的回答

Andy Bartlett
Andy Bartlett 2023-1-23
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.
  4 个评论
Andy Bartlett
Andy Bartlett 2023-1-25
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.
Regards
Andy

请先登录,再进行评论。

更多回答(1 个)

Bharath Venkataraman
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.
  4 个评论
Bharath Venkataraman
编辑:Bharath Venkataraman 2023-1-26
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Fixed-Point Designer 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by