Building a CPU from the Ground up Part 1 - Introduction and Fundamental Gates

I’ve been reading a bit about retro computers recently and wondered how easy it would be to design and build one from scratch. To aid me in this endeavour I thought I would try to simulate one in one of the many online logic simulation tools. My tool of choice is circuitverse It has a nice functional interface and has some fairly sophisticated features. I’m going to set myself some rules for the build:

Rule 1: everything must be built from a universal logic gate, nor or nand.
Rule 2: once I’ve built a module I will then allow myself to use the circuitverse equivalent in other modules, for example once I’ve built an AND gate I will then use the AND gate module from circuitverse.

There are some CPU designs already on circuitverse, but what I'm interested in doing here is documenting the construction from the basics to a working CPU.

I’m not going to go into loads of detail on the theory of the design. There are stacks of resources out on the interwebs which you can search for if you want to find out more.

Design Parameters

  • I’m going to start with a NOR gate. Most designs I’ve seen seem to use a NAND gate, so let’s be different. It only really matters for the first stage anyway, after that I will mainly be using circuitverse modules.

  • I’m going to construct a 4 bit CPU. 8 bits seemed a bit too many to make it practical to construct all the component parts. What can be done with a 4 bit CPU I'm not sure yet.

  • I aim to finish with a arithmetic logic unit, separate RAM and ROM, memory registers and control logic.

Notation

I will use the following conventions when labelling designs.

  • I for single bit inputs.
  • Q for outputs.
  • A and B for 4 bit inputs.
  • D for data lines.
  • E for enable lines, i.e. to turn modules on or off.
  • S for select lines.
  • CLK for the clock signal.
  • Multiples will be indicated with subscripts.
  • A prime ‘ will be used to denote NOT so Q’ is NOT(Q).

Basic fundamental gates

To start with I’m going to need the following fundamental logic gates: AND, OR, NAND, NOT, XOR, XNOR. I first created a NOT gate as it quite useful in creating the AND and OR gates, which in turn get used for the NAND and NOR and so on. You can see all the fundamental gates in the window below. The window is interactive so feel free to change the inputs and observe the output.

Multiple input fundamental gates

I am also going to need several multiple input gates, for example an AND gate with 4 inputs. Circuitverse has nice modules for these, but I need to create them from what I’ve already got. It is fairly straightforward to chain together 2 AND gates to make a 3 input AND gate for example. Below you can see the constructions for the multiple input gates I’ve used. After creating the 4 input AND I’ve then used the circuitverse version of this in the construction of the 5 input AND as per rule 2.

Comments