I'm a beginner and know very little about how computers work, this is an educational project. If you find mistakes or have relevant information concerning computers feel free to comment.
The computer follows 'Harvard architecture' (I might be wrong) it has a strictly separated RAM and ROM. 4 bit is a loose indicator of bus width, the ALU is 4 bit and all the processing logic is 4 bit as is the RAM, however the ROM width ('word' length?) is 8 bits as some of the instructions contain a 4 bit value embedded.
You might have noticed the Arduino in the (inexplicably upside down) photo. the Arduino is serving as memory, originally I had wanted the Arduino to only simulate a block of D flip flops but there are nowhere near enough pins on any microcontroller (that I know how to use) to do that, as such the Arduino also simulates some of the memory access logic. The Arduino will also serve as the only source of output, it basically just streams the contents of an array to my laptop through the serial monitor in the Arduino IDE, nothing fancy, I know, but it works. And before anyone tells me not to embed an entire Arduino board, this is by no means a finished project, I just wanted a simple way to to avoid soldering 640 transistors.
The ROM is yet to be built. it will eventually consist of DIP switches and some access logic. More to come when it is built
The ALU is actually just a 4 bit ripple-carry adder/subtracter. to preform subtraction it uses 2s compliment math. The logic necessary to perform the invert consists of some multiplexers and inverters. The add one is done by using the extra bit on the first full adder in the adding circuitry.
There is also a 'comparison unit' which will eventually be responsible for actuating the JMP (jump) command, but strictly speaking this is not part of the ALU.
there are three registers. the first is the @ (address) register, it points to a location in the RAM with the current value to operate on. The second and third are the B and C registers, these registers are tied to the inputs of the ALU they contain the value for the ALU to operate on. While the registers could be considered memory I have decided to build these by hand. they consist of D flip flops built from NAND gates.
I have yet to build the program counter. the program counter will consist of a 4 bit ripple carry half adder and some additional registers. more on this when it is built.
these are the major blocks of the computer, there are a lot of areas I have glossed over, (control logic anyone?) but this should give you a rough idea of what the computer is.
instruction set :
My instruction set includes 8 commands as seen below:
LOAD RAM@ //loads RAM at indicted address
@ //indicates ram address to operate on
LOAD B //loads B register from indicated address
LOAD C //loads C register from indicated address
LOAD O //loads RAM from ALU at indicated address
ADD //toggles the ALU to perform addition
SUB //toggles the ALU to perform subtraction
JMP //loads program counter with contents of @ register
JMPEZ //loads program counter with contents of @ register if output of ALU is zero
-this is entirely my own design I am not building a computer that some one else designed.
-I have little to no knowledge of computing systems so advice, comments and criticism are welcome.
- The design is influenced by the computer outlined in the book: The Elements of Computing Systems by Noam Nisan and Shimon Schocken. However I won't pretend I understood much of it.