on-internet
← Community

How to compare negative numbers (2's-complement)?

Stack Overflow ·

I have the following comparison statement in Verilog which works fine (positive comparison): if ((count_cc >= 13'b0000000011110) && (count_cc <= 13'b0000000111100)) // 30, 60 begin level = 4'b0010; // level 2 end However, when I use 2's-complement, it does not work: if ((count_cc >= 13'b1111111100100) && (count_cc <= 13'b1111111110110)) // -10 , -28 begin level = 4'b0101; // level 5 end Any guidance would be helpful.

Comments

Sign in or sign up to comment and upvote.

No comments yet.