Operating System Design :: Lessons :: Sequential Logic
This lesson is a synopsis of Chapter 3 from the book Building a Modern Computer From First Principles. After reading this synopsis you should read that chapter as well as any of the Hardware Simulator tutorial you have not read yet.
All of the chips you built for the first two projects were combinatorial chips, or chips that can be built solely from combinations of their input values. The drawback of these chips is they have no way to maintain state and remember information. Sequential chips, on the other hand, can be used to maintain state to build the memory chips in a computer.
Most computers represent the passage of time using a master clock that delivers a continuous stream of alternating signals typically labeled "0" and "1" or "tick" and "tock." The elapsed time between the beginning of a tick and the end of a tock is known as a clock cycle.
A flip-flop is the most basic sequential chip. A data flip-flip, or DFF, contains a single-bit input, a single-bit output, and a clock input that comes from the master clock. This can be used to help maintain state in more complicated chips.
A register is a storage device that can remember a value over time. A register can be built using a multiplexor to handle the original input and the output from the DFF. This register can remember a single bit and larger registers can easily be made to remember more bits.
A counter is a sequential chip that simply increments an integer every time unit. A common use of a counter is a program counter in a CPU to determine the address of the next instruction to execute.
A number of registers can be stacked together to form a random access memory unit. Anything stored in RAM, regardless of its physical location in the memory, should be directly accessible at the same speed as anything else in memory. Each word in the n-bit RAM can has a unique address, which is an integer between 0 and n-1. Each RAM device has a width (the width of a single word) and a size (the number of words in RAM). Modern computers typically have 32- or 64-bit RAM with sizes up to the hundreds of millions.