Instructions have been modified from v1.0. Here is the new instruction set arcitecture:
Instructions are all 20 bits long.
First 7 bits from the left specify what operation to perform.
0000000 = nothing
0000001 = clear a specified register (register is specified via the REGISTER DESTINATION bit field)
0000010 = XOR
0000100 = ADD
0001000 = SUBTRACT
0010000 = OR
0100000 = AND
1000000 = output to 7 segment (outputs B to seven segment display)
The next 4 bits are used to specify a constant (for example 0101 will tell the processor to place 5 in the selected register). The register that the constant is sent to is defined via the REGISTER DESTINATION bit field.
0001 = send constant 1 to specified register
0010= send constant 2 to specified register
0011= send constant 3 to specified register
ect. up to 1111 (15)
The next 3 bits are used to specify the REGISTER DESTINATION, or in other words, it tells the processor what register to place the result of an operation. It is also used to specify a register to place a constant in and a register to clear.
001 = register 1
010 = register 2
011 = register 3
ect. up to 111 (7) (there are seven registers)
The next 3 bits are used to specify A. A is one of the two operands that need to be selected for ALU operations. This field specifies the register that will output to A.
001 = register 1
010 = register 2
011 = register 3
ect. up to 111 (7) (there are seven registers)
The next 3 bits are used to specify B. B is one of the two operands that need to be selected for ALU operations. This field specifies the register that will output to B. B is also used for outputting to the seven segment display. The register that you want to output the the display must first be loaded into B.
001 = register 1
010 = register 2
011 = register 3
ect. up to 111 (7) (there are seven registers)
Now I am still working on a few kinks, so you will still need to leave blank instructions between some instructions:
1. You must leave a blank instruction inbetween two (load constant to register) operations. For example. This tells the processor to load 7 to register 1 and then load 3 to register 2.
0000000 0111 001 000 000 (Loads constant (7) to register 1)
0000000 0000 000 000 000 (blank instruction)
0000000 0011 010 000 000 (Loads constant (3) to register 2)
2. When using an ALU operation such as ADD/SUB/AND/OR/XOR you cannot define the operation and the destination register for the operation in the same instruction. Therefore you must use two instructions. For example lets ADD register 1 and 2 and place the result in register 3.
0000100 0000 000 001 010 (Tells to ADD A and B)
0000100 0000 011 001 010 (Tells to ADD A and B and defines the destination)
Notice how I first defined the operation and A/B, then on the next instruction I redefined them and added the destination register (3).
3. You must leave a blank instruction between two operations. For example if you wanted to ADD reg 1 and 2 and place in 3, then SUBTRACT reg 1 and 2 and place the result in reg 4, this is what you would do.
0000100 0000 000 001 010 (Tells to ADD A and B)
0000100 0000 011 001 010 (Tells to ADD A and B and defines the destination)
0000000 0000 000 000 000 (blank instruction)0001000 0000 000 001 010 (Tells to SUB B from A)
0001000 0000 100 001 010 (Tells to SUB B from A and defines the destination)
4. When outputting the value of B to a seven segment display, you cannot define the operation and B in the same instruction. For example if we want to output register 5 to a seven segment display we would do it like this.
0000000 0000 000 000 101 (outputs register 5 to B)
1000000 0000 000 000 101 (outputs register 5 to B and specifies the function as (output to seven segment))
HERE ARE SOME EXAMPLE INSTRUCTIONS:
load constant 5 to register 7:
0000000 1010 111 000 000
clear register 7:
1000000 0000 111 000 000
load constant (7) to register 1, load constant (3) to register 2, ADD register 1 and 2 and place in register 3, SUB register 2 from register 1 and place in register 4, perform XOR on register 3 and 4 and place in register 7, output register 7 to 7 segment display:
0000000 0111 001 000 000
0000000 0000 000 000 000
0000000 0011 010 000 000
0000100 0000 000 001 010
0000100 0000 011 001 010
0000000 0000 000 000 000
0001000 0000 000 001 010
0001000 0000 100 001 010
0000000 0000 000 000 000
0000010 0000 000 011 100
0000010 0000 111 011 100
0000000 0000 000 000 111
1000000 0000 000 000 111
Here is a save showing this program:
To initiate the clock cycle you must click the metal switch at the top of the clock located bottom left of screen. You can advance the instruction stack down 1 level by pressing the down arrow button (this is for writing a program). You can also reset the 7-segment display by clicking the (c) button.
additional credits:
AlextheSax - instruction stack