1
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ It sounds like you are thinking of what would be called a "microprogrammed" machine, where in a simplistic view the opcode provides the most significant bits of the microcode ROM lookup address, and that ROM has a wide data width so it can assert the various control signals - the key being that an opcode doesn't point to one line, but a whole subroutine-like "microprogram". The AM2910 is the classic engine for implementing this type of processor on a board; you may find its documentation informative; many real computers and academic courses have been built around it. \$\endgroup\$ – Chris Stratton May 20 '17 at 15:25
  • \$\begingroup\$ yes that is how those work, google CISC. the 8 bits are not ripped apart into register definitions and alu mux selection, etc. in some way, shape, or form the 8 bits feed you into a table of other operations where those things are defined. it could feed you into a state machine or could go into a rom or other table that contains the real instructions that feed the real cpu. \$\endgroup\$ – old_timer May 21 '17 at 21:19
  • \$\begingroup\$ alternatively as you see a little in x86, since you would need a variable length instruction set anyway, the one byte is just the opcode and the rest of the parameters in are in the following bytes (rather than microcoded in a table or other). \$\endgroup\$ – old_timer May 22 '17 at 1:24
5
\$\begingroup\$

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

\$\endgroup\$
  • \$\begingroup\$ Excellent recommendation! I am a huge fan of his videos. He explains everything so lucidly. I believe his videos should be required for electrical/computer engineering programs. \$\endgroup\$ – Steven Sep 12 '17 at 11:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.