# D flip flop : How does it work in depth

I'm coming to you today because I have some trouble to understand how works D flip flop in depth. Two weeks ago we started at school learning sequential logic and so register and everything that come with. We saw how to build a D flip flop using RS Asynchronous flip flop like this one :

Then we made a synchronous version of this one using two AND logic gate (one per input) and a clock input. The D flip flop we made is only a RS Asynchronous using only one input linked to S, and the NOT linked to R. Just like this :

And as I wrote it works on HIGH LEVEL. So to make any shift register based on this it is impossible. So I decided to go my own way and I ended with something like this :

I was conviced that it's the good way. It works on falling edge so it's perfect for shift register. And then my teacher told me that we couldn't use any gate on clock (in my case I use a NOT gate). But he can't tell me clearly how to do a D flip flop working on rising or falling edge. Even if Logisim (the software I use to simulate circuits) there is a D flip flop where you can make it working on Rising, falling edge or even at high or low level. So my main question is : What is the good way to make a D flip flop working or RISING or FALLING edge if we can't use a single gate on clock ? And why can't we use gate on clock ?

• This question is off-topic here, but might be on-topic on Electrical Engineering. – Yuval Filmus Feb 15 '19 at 5:26
• @YuvalFilmus Oh okay I will move my post, thank's for the info. – Sakeiru Feb 15 '19 at 5:29

Here's a big hint, and then I'll let you work out the rest for yourself. Because we want cs.SE to be a collection of questions and answers, please post your solution as an answer.

Edge-triggered D flip flops are generally done using the "two RS flip flop" design that you have. You got that right. Reading from left to right, I'm going to call these RS flip flops "stage 1" and "stage 2".

Before the transition "happens", stage 1 should load the data. The effect of the transition is to make stage 1 hold its data and make stage 2 load its data from the output of stage 1.

So to create a D flip flop that is triggered on the rising edge:

• When the clock is low, stage 1 should load its data and stage 2 should hold its data.
• When the the clock is high, and stage 2 should load its data and stage 1 should hold its data.

The effect of this is that the transition from low to high shifts the result from stage 1 to stage 2.

Conversely, to create a D flip flop that is triggered on the falling edge, stage 1 should load when the clock is high, and stage 2 should load when the clock is low.

Now can you implement that?

Incidentally, I don't understand your teacher's requirement "we couldn't use any gate on clock". When you realise digital circuits in CMOS or NMOS, clock fanout is a large practical issue. Besides, you only get inverting gates, so putting gates on clock lines is normal and expected.

Nonetheless, perhaps they meant you to use de Morgan's laws to reduce the gate count?

• "Nonetheless, perhaps they meant you to use de Morgan's laws to reduce the gate count?". He said me that it wasn't allowed to use gates on clock because it could cause dysfunction in practical use. So is my third schema is correct (I mean, would it work in practial use ?) ? If yes I think to make it working on rising edge I should just change position of the NOT gate on the first RS flip flop. – Sakeiru Feb 15 '19 at 2:10
• I definitely agree with your instructor. The problem with gates is that you cannot master their traversal time (that depends on tech, temperature, etc) and relative traversal time on several gates can create unwanted spikes. On normal signals in a synchronous system, this is not a problem. On a clock, this can lead to real problems. To reduce consumption, designers tends to use clock gating, but this is definitely advanced design methods with specific techniques and one must first master standard synchronous systems. – Alain Merigot Feb 17 '19 at 0:10

With the answer I got, and after I searched in Electrical engineering. I think I was both wrong and right. In fact it looks like we "can" use gate on clock signal theoretically, but in practice as Alain Merigot said (don't know how to mention) it can cause some trouble.

The problem with gates is that you cannot master their traversal time (that depends on tech, temperature, etc) and relative traversal time on several gates can create unwanted spikes.

On a clock, this can lead to real problems.

I still don't know how to create a D flip flop without using gate on clock signal and I think it requires way more knowledge I have to manage it. I now have my answer thank to people who helped me !

P.S : I don't know if there's a way to "close" a question.

Edit : "I still don't know how to create a D flip flop without using gate" -> D flip flop working on rising/falling edge.

• There is no "closing" a question. There is only accepting an answer. And if I were you, I'd accept your answer rather than mine. – Pseudonym Feb 20 '19 at 23:20