Forum Discussion
Altera_Forum
Honored Contributor
13 years agomod - remainder confiusion
Dear all, Anyone can explain what mean by this line of code: ad<=(-5) mod 8; I know the "mod" is the remainder. But, why need negative? What the different with ad<=5 mod 8? Th...
Altera_Forum
Honored Contributor
13 years ago --- Quote Start --- Do some simple maths... If you divide 13 by 8 you get 1 remander 5. If you divide 13-8 (= 5) by 8 you get 0 remainder 5. If you divide 13-8*2 (= -3) by 8 you get -1 remainder 5 (or 0 remainder -3). If you divide 13-8*3 (= -11) by 8 you get -2 remainder 5 (or -1 remainder -3). Which of the quotient and remainder is negative varies according to the definition used by the language. --- Quote End --- Hai all, Actually I try to understand this code example. I used this code as my reference to rewrite my own code later. One more thing, I try to view the state machine diagram using Quartus, but it said that "no state machine". I search from this forum, it said that I need to add reset case to create the state machine automatically. How to add the reset case? Thanks for quick reply