You must login before you can post a comment.
Author: noulmao
Forked from: Martianno/Play Roulette / Programmable Computer
Project access type: Public
Description:
WELCOME TO MY PROGRAMMABLE COMPUTER!
DESCRIPTION:
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.
Story:
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.
INSTRUCTION SET:
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!
Martin
Created: May 10, 2021
Updated: Aug 26, 2023
Comments