Author Topic: Basic counter in verilog  (Read 1277 times)

0 Members and 1 Guest are viewing this topic.

Offline DmeadsTopic starter

  • Regular Contributor
  • *
  • Posts: 171
  • Country: us
  • who needs deep learning when you have 555 timers
Basic counter in verilog
« on: June 07, 2019, 02:40:59 am »
Hi all!

In my simulation picture below, there is a,b,c,d,e ect after the 9 in my counter.

Why is this and can anybody help me fix this please?

I am doing some research and i think it might be related to roll over?

Thanks!

You can view my code and testbench on EDA playground:
https://www.edaplayground.com/x/5Wjr

picture of simulation below
 

Online Buriedcode

  • Super Contributor
  • ***
  • Posts: 1718
  • Country: gb
Re: Basic counter in verilog
« Reply #1 on: June 07, 2019, 02:43:24 am »
That would be because it is showing hexadecimal representation of numbers rather than decimal.  You have a 4-bit counter, so in decimal it counts 0 to 15 then rolls over to 0 again.  10 in Hex is 'A', 15 is 'F'. Hex is very common and quite handy because a single hex digit represents all possible states of 4 bits (a nibble).
« Last Edit: June 07, 2019, 02:44:56 am by Buriedcode »
 
The following users thanked this post: Dmeads

Offline DmeadsTopic starter

  • Regular Contributor
  • *
  • Posts: 171
  • Country: us
  • who needs deep learning when you have 555 timers
Re: Basic counter in verilog
« Reply #2 on: June 07, 2019, 02:45:02 am »
Ah, thank you!

So if I implemented some PWM using this counter, it would work okay on the FPGA?

It seems to work okay in the simulation
 

Offline DmeadsTopic starter

  • Regular Contributor
  • *
  • Posts: 171
  • Country: us
  • who needs deep learning when you have 555 timers
Re: Basic counter in verilog
« Reply #3 on: June 07, 2019, 02:53:59 am »
Never mind I answered my own question lol it totally works!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf