# 4 bit up counter

Discussion in 'General Electronics Chat' started by vead, Jan 17, 2014.

Nov 24, 2011
701
11
I want to design 4 bit counter using D flip flop that will count 0 to 7number I have used 3 d flip flop to make up counter to count o to 7 number

truth table
N C B A clk present state next state
-- - ------------------------------------
0 0 0 0
1 0 0 1
2 0 1 0
3 0 1 1
4 1 0 0
5 1 0 1
6 1 1 0
7 1 1 1

1) how to determine present state
2) how clok work I mean when does clock raise or fall

help me to complete table

2. ### tshuck Well-Known Member

Oct 18, 2012
3,527
675
Shouldn't you figure out how to make a D flip-flop first? Unless this is to be implemented in behavioral modelling...

Anyway, you seem confused, assuming C, B, and A are your flip flop outputs, why not use these as your present state? Doing this, you can make the next stage equal to the present state + 1.

Nov 24, 2011
701
11
A, B, c are the inputs

I know the basic table of D flip flop with positive edge

D flip flop table
d clk q q_bar
0 ↑ 0 1
1 ↑ 1 0

when clock is raising with positive edge output will same as input d otherwise no change

but in counter there is three d flip flop so how to determine the output?

4. ### tshuck Well-Known Member

Oct 18, 2012
3,527
675
What purpose do they serve?

So why do you need 4 bits to count to 7 (111)?

5. ### ScottWang Moderator

Aug 23, 2012
5,483
864
The first output of D-FF is b0, and it will changing the status while the clock on the rising edge.

The second output of D-FF is b1, and it will changing the status while the b0 on the rising edge.

The third output of D-FF is b2, and it will changing the status while the b1 on the rising edge.

Nov 24, 2011
701
11
now i understood that A,B,C are the output of d flip flops these are the current state your post related to JK flip flop but how canI determine the next state for D flip flop Should I used to K map

7. ### tshuck Well-Known Member

Oct 18, 2012
3,527
675
You can have inputs, as in the case with a load function, but considering your grasp of the concept, it's best to say there aren't any.

Yes, the same idea is applied to D flip flops, but you only need one K-map per flip flop. Another thread I made uses both, but in designing modulus counters. The idea is the same though.

Nov 24, 2011
701
11
It means that if i want to find out the value of next state i need to k map

can we use k map for any counter to find out next state

9. ### tshuck Well-Known Member

Oct 18, 2012
3,527
675
No, the K-map just gives the implementation. You define the next state. The K-map only works when you know what it is doing...

The next state is just the next count ( e.g. 1 goes to 2, 2 goes to 3, etc.)

Nov 24, 2011
701
11
so how to find out next state

truth table
N C B A next state
-- - ------------------------------------
0 0 0 0
1 0 0 1
2 0 1 0
3 0 1 1
4 1 0 0
5 1 0 1
6 1 1 0
7 1 1 1

11. ### tshuck Well-Known Member

Oct 18, 2012
3,527
675
Count.

truth table
 N C B A(current state) next state 0 0 0 0 001 1 0 0 1 2 0 1 0 3 0 1 1 4 1 0 0 5 1 0 1 6 1 1 0 7 1 1 1

Note that CBA is backwards from most implementations, usually written ABC...

Nov 24, 2011
701
11
truth table
 N C B A(current state) next state 0 0 0 0 001 1 0 0 1 010 2 0 1 0 011 3 0 1 1 100 4 1 0 0 100 5 1 0 1 110 6 1 1 0 111 7 1 1 1 000

is it correct

13. ### tshuck Well-Known Member

Oct 18, 2012
3,527
675
Say what?

Maybe you should reformat the table - either put it in the table that I did, or space it and put it between some code tags [code ][/code]

Nevermind, you did that while I typed...

14. ### tshuck Well-Known Member

Oct 18, 2012
3,527
675
As is, it will only ever count to 4. A single bit can mess it up...

Nov 24, 2011
701
11
now

truth table
 N C B A(current state) next state 0 0 0 0 001 1 0 0 1 010 2 0 1 0 011 3 0 1 1 100 4 1 0 0 101 5 1 0 1 110 6 1 1 0 111 7 1 1 1 000

Last edited: Jan 18, 2014

Nov 24, 2011
701
11
what does it mean?

17. ### djsfantasi AAC Fanatic!

Apr 11, 2010
3,496
1,253
You corrected your table. Why? I suspect that you saw an error and corrected it. What was the effect of the error before you corrected it?

Nov 24, 2011
701
11
i did put the wrong value the the sequence of counter may be change

19. ### tshuck Well-Known Member

Oct 18, 2012
3,527
675
This looks good to me, just be aware of the input variable sequence (CBA as opposed to ABC) and you should be able to implement the K-maps...

20. ### tshuck Well-Known Member

Oct 18, 2012
3,527
675
You fixed it. Your counter would have counted up to 4 and stayed there indefinitely had it been implemented as you had shown (100 goes to 100).