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). 🧵
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".
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!
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...
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.
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.
the states are mostly decoded with XOR gates. i went through and manually decoded what each state looks like.
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.
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
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? 🧵
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.
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.
a short but highly technical history of DRAM - dynamic random access memory! 🧵
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.
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!
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.