Tube Time Profile picture
29 Mar, 18 tweets, 5 min read
i've been thinking about digital counters for state machines lately. probably because of the interesting counter design that i found in the IBM CGA card (schematic below). 🧵 Image
but back to a basic digital counter. it's simple, right? you just count up in binary. 000->001->010->011->etc. but there are some disadvantages of doing it this way.
in digital logic, be it in an FPGA or discrete TTL chips, the basic idea of a design using synchronous logic is that you have flip flops that store your "current state" and then combinational logic that take the current state and generate the "next state". Image
the combinational logic needs a certain propagation time for a changing signal on the input side to change the signals on the output side. this has to happen *before* the next valid clock edge or the design won't work! Image
if it's a problem, you can fix it two ways: 1) slow down the clock or 2) use less combinational logic
back to the counter now: a binary synchronous counter has a case where you count from all 1's back to all 0's (i.e. 1111->0000). and this requires a *carry propagation signal* to traverse the entire counter. the more bits in the counter, the slower this gets.
but there are other counter designs! a common one is a one-hot counter. it's basically a shift register. there's a gate at one end that lets you load a single logic 1 at the beginning, and then it just circulates around and around. 100->010->001->100... Image
the one-hot counter (only one bit is 'hot', get it?) is really fast! it does need a whole flip flop per state, but there's also less decoding logic. oh yeah and you have to add some more gates (not shown) so that 000->001, preventing the '1' from vanishing.
if we make a simple tweak and add an inverter, we have a counter that goes like (000)->001->011->111->110->100->001. this is a Johnson counter and it is a nice compromise solution. you get more states than flip flops, it's fast, but it does require logic to decode the states. Image
here's the Johnson counter in the IBM CGA card. it's got 8 flip flops and 15 states. you can see the inverter that takes the last bit, inverts it, and feeds it back to the input. other logic decodes various states. Image
the states are mostly decoded with XOR gates. i went through and manually decoded what each state looks like. Image
there's a rather famous design that uses a one-hot counter. that is the instruction sequencer in the 6502 microprocessor! in fact, the undocumented HALT instructions stop the CPU by *failing* to load the '1' back into the least significant bit of the one-hot counter.
on the MOnSter 6502 you can see this happen! the counter bits are the vertical column of LEDs here in the box marked "timing logic." execute HALT, and they go dark. Image
it's not quite an HCF (halt and catch fire) instruction. catching on fire is possible in theory if the internal logic had an invalid state with output drivers trying to drive other output drivers. but the 6502 doesn't have anything like that.
but it does point to another fundamental issue with the one-hot scheme: invalid states! if there's a bit flip, a one-hot counter can't recover -- it will continue to recirculate both bits, becoming a two-hot counter. this is bad.
you could get around it by adding extra logic to reset all the other flip flops to '0' when you detect a '1' in the first bit position. so you'll only have invalid states for a short time.
the Johnson counter has the same problem. the CGA card design doesn't do anything to address it. presumably they assumed that bit flips would be super rare and a simple system reset would fix it, returning the counter to a known state.
it's more of an issue with stuff designed to fly at high altitudes or in space, where the FPGA (or whatever) can be exposed to more high energy particles that can flip bits. so it that case, you want that extra logic to prevent bad states.

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Tube Time

Tube Time Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @TubeTimeUS

25 Mar
did you know that just 5 miles from the shining skyscrapers, the overpriced single family homes, and the congested freeways of Silicon Valley is a real, bona-fide 19th century ghost town? 🧵 Image
it's called Drawbridge, California, and it was built around a railroad drawbridge located in wetlands out in the middle of the San Francisco bay. ImageImage
it all started when the original drawbridge was built in the 1880s. in the days before remote control, a tender had to live onsite and operate the bridge, opening it for ships and closing it for trains. Image
Read 10 tweets
5 Mar
here's the very first cross section I made, way back around 1997. can you guess what it is?
this is the button that goes at the end of a fencing foil. 🤺
it's a normally closed switch. you push down on it with >500g and the switch opens, which triggers the scoring machine.
Read 26 tweets
4 Mar
afternoon project: let's fix up this Amiga 4000. Image
it has a Video Toaster Flyer inside, but the cables are a huge mess. also they seem to require an external drive enclosure. Image
i want to replace the two (!) internal IDE drives with this SD-to-IDE adapter. but where to put it? Image
Read 18 tweets
27 Feb
a short but highly technical history of DRAM - dynamic random access memory! 🧵 Image
but first: dynamic?
static - a logic circuit that operates down to 0Hz clock.
dynamic - a logic circuit with a minimum clock frequency.
static RAM is made of two cross-connected inverters along with two pass gate transistors that connect and disconnect the memory cell to the bit lines. you need 6 transistors to make a cell that can store one bit of information. Image
Read 53 tweets
26 Feb
it's Black history month! this is Dr. Mark Dean, who worked on the design team of the original IBM PC. he worked on the design of the CGA card--his name is on two patents around generating composite video.
he was at the start of his career, in his early 20s, when he did this. later, he studied at Stanford University and received his PhD, then did more amazing work at IBM, ending up with the prestigious title of IBM Fellow!
more details on his career can be found at Wikipedia, although the article is a bit thin. en.wikipedia.org/wiki/Mark_Dean…
Read 7 tweets
12 Feb
i have a theory about the name of the iconic Roland TR-808 drum machine. the "TR" part stands for Transistor Rhythm but where does the 808 part come from? 🧵
but before we get to that, we need to talk about the Hammond Organ.
the Hammond Organ was a very unique instrument invented in the 1930s, and it was one of the first instruments you could call a synthesizer.
Read 42 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!