- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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? Thanks in advanceLink Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
While I am not sure if this is the helpful or not (as I can not see the context of your code):
5 as a byte: 0b00000101 -5 as a byte (one's complement): 0b11111010 -5 as a byte (two's complement): 0b11111011- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- 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
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page