3-bit counter using D flipflops with some twists

Discussion in 'Homework Help' started by Chris P. Nutts, Apr 5, 2015.

  1. Chris P. Nutts

    Thread Starter New Member

    Apr 5, 2015
    3
    0
    My homework assignment is to design a 3-bit counter using D flipflops. Now here are the twists:
    • it has to be able to count from 0 through N and 0 through M, where 2 <N <= 4 and 5 < M (but otherwise I can choose N and M) in a modulus style so if N was 3 the counter would go 0-1-2-3-0-1-2-3-0-... and if M was six it would go 0-1-2-3-4-5-6-0-1-2-3-4-5-6-0-... and so forth.
    • it has to be able to count forwards and backwards for both (0-N, N-0, 0-M and M-0)
    • it has to have a state where it stops counting and just sits still at some the number 1
    So my design process was to make a state diagram and then a state table. My problems arise when I try to find formulas for the counters next state because of the sheer amount of variables. I'm using 3 D flipflops and 3 input variables; one to switch between N and M counting, one to switch between forward and backward counting and one to stop/start the system. My state table has 64 lines and I feel like I must be doing something wrong since we're suppose to use karnaugh maps to get simplified expressions from the table but have not been taught how to use k-maps for more than 4 input variables. In fact, we've never done anything with more than 4 input variables where we had to get simplified expressions.
     
  2. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,796
    831
    One step at a time. How are you going to define N in your circuit? What conditions must be met to start counting over and how do you start over?
    Adding an option to count to M (M+1 cycles) will be similar... And will be the next step.
     
  3. MrChips

    Moderator

    Oct 2, 2009
    12,421
    3,357
    You have five variables as follows, three flip-flops, one direction, one M/N.
    Start/stop can be implemented using a gated CLOCK.

    A 4-input Karnaugh map has 16 states.
    A 5-input map has 32 states. You can draw this as two separate 4-input maps or you can draw the two maps conjoined.
     
  4. Chris P. Nutts

    Thread Starter New Member

    Apr 5, 2015
    3
    0
    ok so I definitely can't get away with fewer than 5 variables right? So I'll just have learn how to do a 5-input map on my own I guess.
     
  5. MrChips

    Moderator

    Oct 2, 2009
    12,421
    3,357
  6. WBahn

    Moderator

    Mar 31, 2012
    17,716
    4,788
    Are you required to minimize the logic, or just implement a system that works? Minimized logic is not always the goal as it can lead to solutions that are difficult to understand and maintain.

    You need to be sure that you have your specs understood correctly.

    A mode-N counter has N states which are traditionally from 0 through (N-1). Your examples for N and M are counting modulus (N+1) and (M+1).

    Your third twist is poorly defined. What do you mean "at some the number 1". Does it continue counting normally until it enters state 1 and then stalls there? Or does it immediately reset to state 1?

    It is pretty straightforward to do K-maps up to six variables manually. Just imagine having four 4-variable K-maps stacked on top of each other for the additional two variables. If you use that mental image you can draw the four K-maps side by side and work with them fairly handily. Instead of looking for rectangular groupings of ones (or zeroes), you are looking for groupings that form a rectangular solid.

    But you can avoid this by approaching the problem systematically. First understand that what you are looking for is exactly how you described it in your title -- a three-bit counter with some twists. What you have at the core of this is a three-bit bidirectional binary counter. So get that implemented first. Then ask yourself what needs to be different in order to make it a programmable mod-N counter in which the modulus is determined by three signals. Think about what the N value does and how it affects the operation of the basic binary counter. Finally, ask what is supposed to happen in response to that start/stop switch and how that can be folded into the mix.
     
  7. Chris P. Nutts

    Thread Starter New Member

    Apr 5, 2015
    3
    0
    Hey, thanks for the response.

    I am required to minimize the logic. The specs are definitely to count 0-N including both 0 and N, the specs we were given specify that it's a modulus counter but show examples of how it should work which is why I'm sure about the specs. "at some the number 1" is suppose to be "at the number 1", it's a typo. The functionality is that at any time during any sort of counting you can flip that switch and the counter goes to 1 and stays there until the switch is flipped back.

    I'd love to do this the way you described it in the end, in fact I always start my designs by making a simplified version and then adding features to it. My problem is that I have to follow the set design path of 1. Design a state diagram (and here I started with a very simple diagram and added features to it) 2. make a state table 3. simplify and derive formulas for it 4. write HDL based on my derived equations 5. and lastly, implement it next week after I've turned in my report about how I did steps 1-4. Step 3 is what I'm having trouble with since it's so and the state table is huge. I was hoping I'd missed something obvious and I was making it more complicated than it has to be.
     
  8. WBahn

    Moderator

    Mar 31, 2012
    17,716
    4,788
    You might include in your report some comments about how it is actually a mod-(N+1) counter. No need to be confrontational in doing so, but make it clear that you understand what a mod-N counter really is and that you are implementing your design so as to be consistent with the examples given in the assignment.

    I'm still a bit unsure about the hold functionality. When you say, "the counter goes to 1 and stays there" does that mean that it continues counting until it reach 1 and then stays there, or does that mean that the counter goes immediately to 1 and then stays there.
     
Loading...