Forum Discussion

MHamz1's avatar
MHamz1
Icon for New Contributor rankNew Contributor
7 years ago

Efficient way of making counter

What is the efficient way of making counters in VHDL when the source clock is in range of 400MHZ

4 Replies

  • ak6dn's avatar
    ak6dn
    Icon for Regular Contributor rankRegular Contributor

    Google LFSR-based counter. In just about any FPGA 400MHz is too fast for a binary counter of any reasonable size (ie, 8-16 bits or more).

    • RRomano001's avatar
      RRomano001
      Icon for Contributor rankContributor

      Hi ak6dn, also ring counter, Johnson counter, Möbius counter.

      They are cases of LFSR but not for sure are mentioned by LFSR theory.

      Regards.

  • ak6dn's avatar
    ak6dn
    Icon for Regular Contributor rankRegular Contributor

    Good point RRomano001. Those are also options. A lot will depend on the number of states desired in the count sequence, if reloading the counter to allow for varying count lengths, or a specific count sequence is required. So the longer answer is, it depends.

    An LFSR of N-registers will allow a count length of 2^N-1 for a maximal length LFSR. The count sequence however 'appears' somewhat random, so is not always useful. Feedback logic is basically a set of XOR gates that depends on the LFSR. Usually it is pretty simple. A 16-bit LFSR can have up to 65,535 distinct states.

    A Johnson counter of N-registers will allow a count length of 2*N with a more predictable sequence. No feedback logic (other than possibly an inverter) is required, so it can be very fast. However to get a large number of states requires a large number of registers. A 16 bit Johnson counter will only have 32 states.

    So depends on what the requirement is in number of states vs frequency vs resources.

    • RRomano001's avatar
      RRomano001
      Icon for Contributor rankContributor

      Hi ak6dn, happy to share ideas and knowledge, I never used so much LFSR counter than for poyinomial CRC.

      First I encountered on my career was the old cd4017 Johnson counter based IC.

      After that a lot of thing changed my mind about counting when frequency rise till leaving digital to analog on microwave counter. (Nowaday can read extreme microwave with commercial chip over .2THz)

      It is forever right your sentence: depend on what. Too often who ask is focused in his problem and forget detail can help fine printing solution.

      Regards

      Roberto