You can create a 3-input, 3-output circuit that maps one state in the count sequence to the next. Then feed the 3 Q outputs of the FF's into this combinatorial circuit, and connect the output of the combinatorial circuit to the 3 D inputs of the FF's. Connect all 3 of the FF's clock lines together, and then whenever an active edge comes along the flip flops act like a 3 bit register, and just load up the next value.
The answer is 3.
You are actually counting a sequence of 8 states. So you need 3 bits... = 3 flip-flops.
The values 0,1,2 and 3 are taken from the 2nd and 3rd bit of the counter. You ignore the first "bit".
Or if you prefer, you can refer to the first stage as a clock divider "/2" for your two bit counter.
State machines can be simple or can get to be extremely complicated looping, input dependant beasts what give engineers nightmares.
In your simple examples you are actually asking for two different things.
First, to sequence through a pattern of N numbers then repeat. For that you need to count where you are in the sequence using your counter up to N. When N is reached you need logic to reset the counter.
Second you need logic to OUTPUT the appropriate value at each count.
If the latter is extremely complex or likely to change upon development and experimentation, it is usually done by feeding the count as an address into an E-Prom which is programmed to give out the right value on its data pins according to the counter value.
One of said data pins can be used to reset the counter so you can have a different N value, some can be used to feed back on itself as more address pins to switch pages.
As I say, it can get intricately complicated.
Best Answer
It doesn't matter
Assume you are designing a 1-Bit up counter
Count_Pos
Such that each positive clock cycle it will add 1 to whatever stored in its count register.And another identical counter
Count_Neg
that will add 1 to whatever stored in its count register each negative clock cycleBoth of these counters do have a combinatorial circuit part and a sequential circuit part; Such that at positive or negative edge the sequential part captures the combinatorial part output and stores it. When you are doing a Boolean minimization using K-map you are talking about minimizing the combinatorial part of the circuit that is doing the addition operation not the part that is storing the output of this operation.
For an example these are two synthesized 1-bit up counter i`ve used Yosys to synthesize them
The circuit after synthesis
And the other module is
You can see that the synthesis tool replaces the positive edge triggered D-Flip flop [_DFF_P_] with a negative edge triggered one [_DFF_N_] while keeping the same combinatorial circuit part [Which is a simple NOR gate]
So whenever designing a counter or any other state machine. You are using K-map to minimize the combinational part of the circuit.