Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Verilog-counter-values counted from 0 to 127 and then it starts from -128 to 0

Status
Not open for further replies.

kpraneethin007

Newbie level 6
Joined
Jan 2, 2011
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,350
Hi I have designed a 8-bit counter using verilog.
I simulated it using modelsim. counter is performing it's function correctly till the total event at the output reaches 127 (i.e after counting 127 clock cycles)
but after 127 I am getting a value of -128, then -127,126,-125 and so on for each additional clock cycle.
why it is going to -128, why not 129 ?
when I convert decimal to binary value I am getting values correctly in an incremental order, eg: 1111111(127) then for the next clock cycle I am getting 10000000 and so on. Why the same is not happening in case of decimal values?

I have attached the waveform below

Thanks for the reply
 

Attachments

  • counterdoubt.jpg
    counterdoubt.jpg
    42.9 KB · Views: 82

This is purely due to the way you tell modelsim to display the variable. As you noticed after 01111111 (127) you get 10000000 (128). But it so happens that 10000000 is -128 in signed decimal notation for 8 bits. You know, 2s complement notation and all that. So your counter is working fine.

Hope that helps.
 

This is purely due to the way you tell modelsim to display the variable. As you noticed after 01111111 (127) you get 10000000 (128). But it so happens that 10000000 is -128 in signed decimal notation for 8 bits. You know, 2s complement notation and all that. So your counter is working fine.

Hope that helps.

Thanks a lot!!
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top