Electronic – CPU – Basic control unit design

cpudigital-logic

I've been trying to implement a simple 8-bit CPU in Logisim, and have put together an ALU, register file and so on, such that manipulating a few control lines for each part allows you to determine its operation. Unfortunately I'm struggling to implement the control unit in order to coordinate the control of these signals.

A lot of the basic CPUs I can find for reference use 16-bit instructions where all of the control logic is part of the opcode itself, such as the Hack architecture specified in The Elements of Computing Systems (which I've previously completed). This makes controlling the CPU a lot easier, but I'm interested in using an 8-bit instruction format, such as that on classic 8-bit micros.

I gather that you could, for example, use a simple look-up table to make sure you output the correct control signals for each instruction (which I understand the principles of), and also that you might use a state machine for something more complex, but none of the information I can find really touches on implementation.

What is generally the simplest way to design a CU for a CPU that may have variable-cycle instructions and an instruction length that cannot directly encode all the control signals? I'm not concerned about using pipelining or any other features that would complicate the CPU's design.

Also, when designing an FSM, I understand you normally construct Karnaugh maps from a truth table in order to design the necessary combinational logic for it, but even with just 16 instructions (4 input bits) and 16 states, surely you'd have too many variables to even create a k-map from? How do you even begin constructing an FSM that complex? Again, all of the examples you can find focus on the simplest case imaginable, which is usually not a particularly useful, "real-world" one. Also, I gather that FSMs are generally not used a great deal in processor design, but for a simple CPU are they necessarily a bad idea?

Basically, I have no clue where to start designing a CU, despite having had minimal difficulty constructing the other basic elements of a CPU.

Best Answer

Search for Ben Eater, "Building an 8 bit breadboard computer" on YouTube. He has an entire tutorial on building an 8 bit computer, using 74LS series ICs, on a breadboard. He is currently working on the Control Logic including the instructions and micro-code. This is an awesome tutorial that takes you through every module of a working computer capable of running simple programs. He starts with the basics of each module and develops a working unit that is clear and easy to understand. Can't recommend it enough!!! Hopes this helps