# Digital LogicTutorial

## The T Flip Flop

The D Flip flop is a great little bit, but there is a trap it can fall into. Sometimes we want the input of a flip flop to depend on the output of that same flip flop. In other words, we want it to change based on what it was before. For example, if we want something that goes off if it was on, and on if it was off, we might just take the output of a bit of memory and run it through an inverter, then connect it back to the input. Then each time we hit the clock line, the opposite of whatever the current output is, will go in and so it will switch back and forth. Brilliant, no?

Well... No. Because the instant you clock the input to the output, that output becomes the input and changes the output right back and over and over. It's called a "race" condition, and it's a real problem in logic design.

There are two ways to get 'round it:
1) Delay the input so you can remove the clock signal before the changed output has time to change the input or
2) use two flip flops: one to capture the new input when the clock goes on, then stop taking input and pass the new setting on to the second flip flop when the clock goes back.

The T-Flip Flop shown here is the second sort. It's made from two D-Flip Flops which are represented here by a box with a "D" on it. But keep in mind, inside the box are the same NAND gates we know and love.

There are a couple of interesting things to notice about this new circuit. First, the way it clocks the input though as the clocks go up and down. Just push the button and watch it happen. Neat huh?

But what is really important about this circuit is that the output cycles on and off at half the rate of the clock input. In this top part, each time you press and release the button, the output changes state. It takes two presses to return the output back to where it was. So the output frequency is divided by two. That's neat, and useful, but it has another really cool use.

Because computers work in binary, when one thing is going on and off half as often as the next thing, it turns out it's counting. If you haven't seen the binary page, check it out. Then press the "Clock Enable" button in the lower left. The clock will feed pulses to the first T Flip Flop, which drives the lowest bit of the binary to decimal display, and feeds the second T Flip Flop. That produces the next highest binary digit. And so on up the chain. It's counting... it's counting in binary.

• http://www.youtube.com/watch?v=y1w6Nskbx8E Excellent video from Jeri on different ways to make a "master-slave" flip flop and avoid the race condition. She demonstrates an analog, time based solution that uses fewer gates, but is sensitive to timing.+

 file: /Techref/logic/TFlipFlop.htm, 3KB, , updated: 2013/5/11 18:51, local time: 2019/7/19 21:07, TOP NEW HELP FIND:  34.229.24.100:LOG IN

 ©2019 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?Please DO link to this page! Digg it! / MAKE! /  Digital Logic Tutorial, T Flip Flop

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.

Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
 Did you find what you needed? "No. I'm looking for: " "No. Take me to the search page." "No. Take me to the top so I can drill down by catagory" "No. I'm willing to pay for help, please refer me to a qualified consultant" "No. But I'm interested. me at when this page is expanded."

.