On SR latches, D latches, and why most sites get edge-triggered circuits wrong.

So my latest two boards arrived, implementing four demonstration circuits using NPN transistors: a bistable circuit using two transistors (well, four–I need two more to drive the two LEDs), an SR gate using NOR gates, an SR gate using NAND gates, and a D latch: a latch which can be used to store a single bit of data, and most often used as a building block to build a register in a CPU.

I’ve just posted the pages.

And I’m building to something here.

Now I don’t mean to pick on the authors of this web site; I think they did a fantastic job with the artwork and with the explanations of how different types of digital electronic circuits work.

It’s just that the article is dead wrong when it describes J-K flip-flops. A mistake that is made on multiple web sites across the Internet. (Example 1) (Example 2) (Example 3)

Screenshot 2023 01 08 at 9 33 14 PM

Notice the article itself even admits there is a problem with their design:

The JK flip flop is an improved clocked SR flip flop. But it still suffers from the “race” problem. This problem occurs when the state of the output Q is changed before the clock input’s timing pulse has time to go “Off”. We have to keep short timing plus period (T) for avoiding this period.

“We have to keep short timing plus period…”

What? What?

This is utter nonsense. And it was encountering articles like this that motivated me to start up the Hacking Den, and to actually build these circuits, in transistors, and to properly prototype them to make sure they work before posting what is, in essence, nonsense.

It’s why I’m holding off writing articles on NMOS, PMOS and CMOS circuits; I only just got the P-MOSFET transistors, and need to spend a little time breadboarding to verify the circuit works (without letting the magic smoke that allow these things to work escape). And it’s why I’m holding off articles on PNP transistor circuits; for some reason or another the bag of PNP transistors I ordered have yet to arrive in the mail.

Runqsbwxjn561


Getting your circuit to work with edge-triggered logic, by the way, is not just a couple of extra NAND gates and a whole bunch of wishful thinking. You can see how getting a circuit to respond to an edge-triggered signal by looking at the logic diagram associated with the 74LS74 TTL D-flip flop work (on page 3), or the 4013 CMOS D-flip flop.

Just a quick glance at the logic for these circuits in their documentation, and it’s clear there is far more to an edge-triggered flip flop than just some additional NAND gates.


It’s also important to remember that a lot of these circuits did not just fall fully formed from the forehead of Zeus, to grace us as fundamental facts of the universe, like the speed of light, the rising of the sun, or how buttered toast always lands butter-side down.

These circuits were designed and engineered to function according to certain required functionality. JK latches did not just fall from the sky; somewhere someone needed a latch which functioned like a JK latch–and someone designed and built it.

And designed it they did: you really have to appreciate the complexity of a 4027 series CMOS J-K flip flip.

Screenshot 2023 01 08 at 9 41 01 PM

This is hardly the 4 NAND gates in the “clocked SR flip flop” example those various informative–but incorrect–web sites.


Bottom line is you have to prototype your circuits before teaching people the wrong stuff.

Otherwise, what are you but a pretty face spewing garbate?

Announcing a new Quick Video: Building an ALU.

So this one is a little different; in this video I show the steps to go from the design of an arithmetic logic unit to actually demonstrating a working 8-bit ALU, made entirely out of 2N3904 transistors.

The show notes include links to circuit diagrams and files in case you may want to build your own.

Here’s the video, and thanks for watching.

A note about the next Introduction To Digital Computers video.

I originally planned to try to get this video out by the end of October.

But I just returned from a two week trip to Spain and the south of France–and before I release a video which starts to tie together the registers developed in the third video with the arithmetic logic in the second video, I want to put together these circuits to test to make sure they in fact work.

And this will take some time.

So the next video may be delayed a week or two.

Sorry for any inconvenience.

Announcing a new Quick Video: A Full Adder

When we used NPN transistors to build our logic gates, it implies they can be used for building bigger things. In this video I’ve built a full 1 bit adder from our second Introduction video, entirely from discrete transistors.

Build 8 of these–and you have an 8-bit adder.

The show notes include the complete circuit diagram.

So here’s the video.

And thanks for watching.

What I’ve been doing with my time.

Okay, I confess I’ve left the gear cutting stuff on the back burner while I recover from a bug I picked up while in Mexico. During my spare time I’ve been working towards a series of videos which I hope to post on this site that discuss various topics in computer science.

The goal of this first series of videos is twofold. First, I want to describe how computers work–and I mean down to the level of transistors all the way up. I want you to feel like if you had enough transistors, resistors, some discrete components and a whole bunch of wire and a lot of time and patience, you could build a computer completely from scratch.

Second, I’m trying to find my “voice.”

See, my entire point in starting this blog is to share what I know and to hopefully get others excited about computers, computer science, electronics, calculators (and that includes mechanical calculators; thus, the gear cutting stuff). And one avenue of teaching is the instructional video.

So by starting with a relatively complex topic, I hope to learn how to put together videos like this.

Practice makes perfect, right?

So here’s the video, any constructive comments are welcome.

Administrative: the velocity of my posts.

I love computers.

I’ve always been fascinated by computers, by the things you can do with computers, and by making things in general: hardware, software, networks, servers, user interfaces. I also have a love of mechanical things: watches, clocks, orreries, mechanical adding machines: all the things we use and have used in the past to do math, visualize planets, watch the passing of time, or explore the world around us.

And I started The Hacking Den with the intent to share my fascination through creating videos and articles which help walk someone through step-by-step in making things.

It’ll be a while for me to find my voice.

When I started The Hacking Den I had a series of three articles I wanted to write immediately, and I’ve just finished two of them: a series of articles on 3D graphics, and a series on user interface design. The third–a simple game for the Arduboy, I plan to start working on in the next few weeks. And as always, everything will be on Github so you can play with the code yourself.

But beyond those articles I have a number of projects I want to work on for this web site. Unlike these three other articles, however, I don’t have this stuff quite on tap: I can’t just sit down, crank the code out and document the steps I followed to do what I did.

The Earth-Moon Orrery is one of those projects. I’m still learning how to cut gears, and I’m starting small. My eventual goal–one that may take a year or two–is to build a rather accurate Orrery representing the planets of the solar system.

Another project I’m working on for The Hacking Den is a series of videos which describe how a microprocessor works, from transistors to assembly language and all the steps in between.

I eventually want to do a series of videos teaching C, a series of videos covering building more complex projects, perhaps a few videos covering basic computer science topics (such as state machines or LR1 languages) and perhaps a series of articles or videos sharing some of the other things I’ve learned in my 30 years as a software developer.

But all of this will take time.


What I’m saying here is that up until now, my posting “velocity” has been pretty high, as I write the three series of posts I had “on-tap.”

But moving forward, that velocity will start to slow–as I work on educational videos, as I work on physical hardware, as I work through new projects for this site.


Good educational materials takes time to produce–and so far I’ve cranked out a bunch of stuff on a daily, which may be a bit telling as to the quality of the work I’ve provided. But I wanted a firm foundation of materials for which to define my new site, rather than to create an empty vanity site.

I also wanted to commit myself to this project moving forward: to promise myself to build those videos, to make the orrery (and document how I did it), to work through ways to explain many of the things I’ve learned over the years.

So hopefully when I’m done, you’ll love computers too.

And so it begins.

It’s been my desire for a while now to somehow give back to the community, to teach people how to write code and how to create things, and how to take joy in designing new things and bringing them into existence.

And so it begins.

The intent of this blog and web site is for me to share with you different development techniques and algorithms, different designs and different things to make. Think of this as an extension to the various “makers movements” out there, the Thingiverse, Make Magazine and DIY tech stuff, but with a focus on things I find interesting, from algorithm design to 3D printing to computer graphics and the like.

This may not be the most focused blog in the world, as I tend to like to play with a wide variety of algorithms, software and hardware designs, and just random stuff in general. But hopefully you’ll learn something along the way.

Thanks for being here, and I hope you hang around for a while!