Electronic – Can you make a CPU out of logic gates

computer-architecturecpu

If i solder together enough binary adders, binary subtractors is it possible for it to work like a modern (very very slow) CPU (Such as one found in a graphics calculator).

Best Answer

Yes! One can build such a real slow processor with discreet logic put together. Or implement it in an FPGA.

(Assuming this may not have an immediate application and just for thought! Apologies if it is too lengthy. Just ideation!) Here are some basic steps one can consider-

  1. Develop an instruction-set first. List each instruction and required number of operands. Assign each instruction a unique binary number. Your instruction decoder is going to recognize these unique instructions by the number you assign.

If it's for a calculator application, focus on math operations. Basic arithmetic is easy. Scientific computing needs more sophisticated instruction set and architecture.

  1. Your instructions and architecture, implicitly define the bus-width (Instruction, Data - 8,16,32,64 or even 128 bits!)

  2. Build the instruction decoder. It will be a combinational logic circuit. And also supporting sequential logic for timing, sequencing and synchronization. At a very high level you can think of the instruction decoder as a decoder/demultiplexer. The signals of this block are going enable/disable and setup subsequent oprations.

  3. Build all the necessary registers, special function registers SFRs, I/O buffers, pins, enable/disable signals.

  4. Build the timers, counters, synch circuits

  5. Build special peripheral driving hardware circuits. With the example of calculator, it could be the screen, keypad, battery monitoring and speaker/buzzer etc.

  6. Build the ALU (Arithmetic Logic Unit). Actually build an advanced ALU!

  7. Build a nice math hardware. Also implement floating-point arithmetic hardware! (Special functions, Logs, Trigonometric functions are implemented as Taylor's series or other custom series math on some hardware)

  8. Actually we live in the age of data-science and AI. So implement array / vector processing units. Build a vector processor!

  9. Implement scratchpad, cache and other internal book-keeping memory areas.

  10. Build bus peripherals such as I2C, SPI and memory interfaces and any other useful peripheral one can think!

  11. Build program counter, fetch circuits before you feed the instructions to the decoder.. Or build an instruction pipeline and some instruction parallelism

  12. Look into C programming language specification. Try to fit your own CPU instructions to be compiled from that language. May be develop your own implementation specifics and develop your own compiler!

  13. Most importantly have a RESET implemented inside the circuit and also make it available on an external pin!