A computer made completely out of logic gates. Version 2. V1 can be found here: https://circuitverse.org/users/13948/projects/49969
Because of the limitations of the circuitverse.org simulator, and for easier use, some inbuilt components are used (like the 256-byte RAM module), but most of it is made up of OR, AND, NOT, XOR, NOR and NAND.
This project was originally made for my profile project. This is (or will be) version 2 of the 8-bit computer.
Working CPU with eight 8-bit registers and eleven commands. Instructions in the project, command list below.
LDA r - loads value from register r into accumulator
STA r - stores accumulator value in register r
CLR r - clears register r
INC r - increments the value of register r and replaces into r
DEC r - decrements the value of register r and replaces into r
COM r - stores the complement of the value in register r in the accumulator
ADD r - adds value in register r to the accumulator
SUB r - subtracts accumulator value from value in register r, replaces into accumulator
AND r - stores value of (accumulator AND r) in accumulator
IOR r - stores value of (accumulator OR r) in accumulator [inclusive or]
XOR r - stores value of (accumulator XOR r) in accumulator [exclusive or]
*Eight 8-bit registers: r must be a value between 0 and 7 and refers to the address of the register, not its contents*
WELCOME TO MY PROGRAMMABLE COMPUTER!
You can code your own program or play a precoded game named "Play Roulette!"
It is a working CPU using fifteen 16-bit instructions that can by coded to develop a reasonable program containing up to 256 rows of machine code. I have also made some input/output features to make using of the computer as comfortable as possible.
There are two 16Byte Registers named "General Register A", "General Register B" and two 16bit registers named "Status Register A" and "Status Register B". Thanks to given instructions you can manipulate DATA in the registers (write, read, copy, delete etc.), You can make some calculations (adding, subtraction, multiplication, comparation etc.) You can also do some logic operations (and, or, not etc..)
You can make a list of this instructions (program rows) and thanks to implemented Program Counter you can run them as programs. For this reason there are also instructions to jump in your program rows (You can make any combination of absolute jump, relative jump forwards or backwards, unconditional jump, conditional jump etc..)
Last but not least: There are instructions that will PRINT given data to TTY display component in numeric or ASCII format. And there is also a numeric keyboard designed for easiest possible user input while the program is running.
HOW TO PLAY ROULETTE:
"Play Roulette" is an easy program "simulating" the roulette. The source code could be found in the "Play Roulette" Sub-circuit.
You are a hazard player. At the begining you have cash 100 dollars . Then you can bet to a number or to a color. If you hit the right number, you triple the amount of money, you have bet. If you dont hit, you lose all the money, you have bet. If you hit the right color (red or black) you double the amount of money you have bet and so on..
Before you play:
Make sure the "POWER" value is set to "1"
Make sure the "STOP CLOCK" is set to "0"
Make sure the "CHOOSE SOURCE" value is set to "1".
In case of unexpected behaviour press the RESET button
When you play:
If the program runs properly, it should first load some data, then it will give you some instructions like: Choose a number to bet or choose how much money are you going to bet and so on.. All this tasks could be done via the numeric keyboard below.
The game ends when your cash is under 0 or over 255. If you want to play again, just press RESET button.
The speed of game depends on the clock time. Unfortunately even if the best frequency is set (50 ms), the game is very slow. So be patient please.
The game have some bugs for sure. Sorry for them! It is not designed to entertain somebody :D It is designed to test abilities of my Computer.
HOW TO CODE YOUR OWN PROGRAM:
On the left side in the project you can see 256 16bit inputs connected to the CPU. There you can code your own program using 16 bit instructions.
0000: WRITE (writes given 8bit DATA to a given ADRESS of General Register A)
0001: READ (reads 8bit DATA from given ADRESS of given REGISTER)
0010: DEL (deletes DATA from given ADRESS of given REGISTER)
0011: COPY (copies DATA from given ADRESS of given REGISTER to an other given ADRESS of given RESTER
0100: IS EQUAL (compares DATA from given ADRESS of given REGISTER with an other DATA from given ADRESS of given REGISTER. If both are equal, then it writes "1" to ADRESS 1000 of Status Register B. Otherwise it writes "0". - This specific adress is reserved for RESULT of "IS EQUAL" instruction.
0101: IS BIGGER (compares DATA from given ADRESS of given REGISTER with an other DATA from given ADRESS of given REGISTER. If DATA from the first one are bigger than from the second one, then it writes "1" to ADRESS 1001 of Status Register B. Otherwise if writes "0". This specific adress is reserved for RESULT of "IS BIGGER" instruction
0110: AND (makes logic AND with DATA from given ADRESS of given REGISTER and an other DATA from given ADRESS of given REGISTER. If the logic AND is true, then it writes "1" to ADRESS 1010 of Status Register B. Otherwise it writes "0". This specific adress is reserved for RESULT of "AND" instruction.
0111: OR (makes logic OR with DATA from given ADRESS of given REGISTER and an other DATA from given ADRESS of given REGISTER. If the logic OR is true, then it writes "1" to ADRESS 1011 of Status Register B. Otherwise it writes "0". This specific adress is reserved for RESULT of "OR" instruction.
1000: ADD (adds DATA from given ADRESS of given REGISTER to DATA from an other given ADRESS of given REGISTER. The RESULT is then stored to ADRESS of the first one of this two. (The DATA from the first one given ADRESS of given REGISTER are overwrited by the RESULT of adding). If the result is bigger than 255 (11111111), then "1" is written to ADRESS 1100 of Status Register B and the RESULT of adding is not provided and the Program Counter is not incremented so the program STOPS!!! Also the red diode "ERR OVF" should be enlightened. This ADRESS (1100 od Status Register B) named ERROR OVERFLOW is reserved for all error overflow situations.
1001: SUB (substracts DATA from given ADRESS of given REGISTER from DATA from given ADRESS of given REGISTER. (The second one is substracted from the first one). The RESULT is then stored to ADRESS of the first one of this two. (The DATA from the first one given ADRESS of given REGISTER are overwrited by the RESULT of substraction). If the result is lower than 0 (00000000) , then "1" is written to ADRESS 1100 of Status Register B and the RESULT of substraction is not provided. The Program Counter is not incremented so the program STOPS!!! Also the red diode"ERR OVF" should be enlighted. This specific ADRESS (1100 od Status Register B) named ERROR OVERFLOW is reserved for all error overflow situations.
1010: MULTIPLY (multiplies DATA from given ADRESS of given REGISTER with data from an other given ADRESS of given REGISTER. The RESULT is then stored to adress of the first one of this two. (The DATA from the first one given ADRESS of given REGISTER are overwrited by the RESULT of multiplication) If the result is bigger than 256 (11111111) , then "1" is written to ADRESS 1100 of Status Register B and the RESULT of multiplication is not provided. The Program Counter is not incremented so the program STOPS!!! Also the red diode"ERR OVF" should be enlighted. This specific ADRESS (1100 od Status Register B) named ERROR OVERFLOW is reserved for all error overflow situations.
1011: JUMP (canges the value of Program Counter variable that defines what row of program should be performed.
There are 4 possible MODES of jumping depending on given parameter and format of code: It is:
There are also 4 possible CONDITIONS that coud be combinated with each MODE
1100: RANDOM (writes a random number of given maximal value to given ADRESS of given REGISTER
1101 NOT USED
1110: LOAD EXT (provides HALT function - the Program Counter is not incremented until user inputs some DATA using the numeric keyboard. This user DATA are then written to given ADRESS of given REGISTER
1111: PRINT EXT (prints DATA from given ADRESS of given REGISTER to the TTY display. This 8bit DATA could be represented as number (0-255) or as ASCII sign. It depends on given parameter
Detailed formats how to compose the 16bit instruction for each of this 15 cases is described inside the project. In the Play Roulette Sub-circuit you coud find inspiration.
EXAMPLE OF MACHINE CODE:
0000 0001 01010101
This will write DATA "01010101" to ADRESS 0001 in General Register A.
0011 0001 00 0001 01
This will copy DATA from ADRESS 0001 of General Register A (00) to ADRESS 0001 of General Register B (01)
1000 0001 00 0001 01
Then this will ADD DATA from ADRESS 0001 of General Register A (00) to ADRESS 0001 of General Register B (01) and the RESULT is then stored to ADRESS 0001 of General Register A (The original DATA in first given REGISTER are overwriten by the RESULT)
FEEL FREE to ask questions and give me feedback. You can contact me via [email protected]
THANKS AND NOTES:
I would like to THANK to the team of developers of Circuit Verse. It is a fntastic product and I learned a lot!
Two months ago my knowledge of logic gates was ZERO.. Literally ZERO. I have no other education in this area. Everything what is done in this project I have Iearned during two months of recent Coronavirus quarantine... :)) Thanks to Circuit Verse, Youtube and Wikipedia!
I am not an IT professional at all. Actually I am a journalist. I did not study any IT school, I did not systematicaly study existing CPUs or computer architectures. Everything in this project is more or less my own invention. It means there are many mistakes and bad solutions. Therefore I will be extremly glad to get any feedback from anyone who really understands this area.
Thank you and sorry for my weak english!
This is a CPU witch is capable of executing a lot of stuff in one clock cycle, and this CPU can shift left up to 7 times and shift right up to 7 times witch means that it is possible to multiply and divide in one clock cycle if you program a table in the program memory. it has a 32 bit instruction width and a 8 bit address. it also has
The ALU has the following operations:
If you have any questions about this or other designs, feel free to shoot me an email at [email protected] I don't check it very often (since it's a secondary account), and you may not receive a reply for around a week.
A simple computer with an added RAM module. A work in progress, with much more I want to add, such as bitwise operators, a larger bus size, data type support including unsigned and signed integers, floating point numbers, conditional instructions, and more. There are two programmed versions, one that calculates the fibonacci sequence, and the other uses conditional instructions to determine whether it should increment a number, or halt the program. And there is also the first design I've made, which has a lot of unneeded parts in it.
UPDATE 1: added a jump instruction to allow loops and other useful applications.
UPDATE 2: Made a second version of the design, and made a better instruction set for it, removed the Memory register, since it's totally unnecessary with a RAM module. The second version also calculates the Fib sequence.
UPDATE 3: Added signed integer addition and subtraction support to version 2. Of course, this limits the positive range of integers to 127, rather than 255, but c'est la vie, I'm going to expand the size of the bus anyway.
UPDATE 4: Version 2 is temporarily down, since I'm finally adding bitwise operator functions to the ALU.
UPDATE 5: Version 2 is now back in action, with some added functions such as increment and decrement by 1, as well as left bit shifting. The ALU still needs some more work, since I'm having trouble implementing a right bit shift function. Once I have bit shifting working, I might make a program that can multiply using the shift/add method.
UPDATE 6: Version 2 now has magnitude comparison and bit-shifting functions. Conditional jumps still in the works.
UPDATE 7: Version 2 finally has a conditional jump register. It can be loaded with a Boolean from either RAM or the ALU, or directly set to either 1 or 0 by way of a set instruction. I still need to add a flag register to the design, so it can detect overflows (and maybe in the future, interrupts).
BONUS UPDATE: After a few months of studying processor and computer design, I discovered that I've unwittingly designed a Von-Neumann architecture computer (as opposed to the Harvard architecture. Reference Wikipedia if these terms are unfamiliar). Frankly, I went into this project relatively blind, and just a week ago discovered that this kind of design had a name. Well, the more you know.
UPDATE 8: I've created a new CPU design, some of which I will implement into this main circuit later this summer. Here's the link to that design: https://circuitverse.org/users/3464/projects/19687. Also, I plan to overhaul the entire design to minimize cycle inefficiencies.