A basic ALU design for my personal projects.
[ Under Development ]
This is a 16-bit processor with 18 instructions of length 16 bit, 16 registers of size 16 bit and only the primary cache in its architecture.
[ Instruction Set ]
from 0 to f
0 is also known as ra as its used for jump and link and jump register
instructions
0000 0XXX XXXX XXXX - no-op X can be anything- no operation
0000 1XXX XXXX XXXX - jmp X is the address offset from pc - jump
0001 XXXX YYYY YYYY - lli X is the register to write data to and Y is the data to load in lower 8 bits- load lower imediate
0010 XXXX YYYY YYYY - orui X is the register to write data to and Y is the data to or with the upper 8 bits in X - or upper imediate
0011 0XXX XXXX XXXX - jal X is the address offset to pc and pc+1 is stored in ra - jump and link
0011 1XXX XXXX XXXX - jr X can be anything, pc is restored by value in ra- jump register( only from ra register )
0100 XXXX YYYY ZZZZ - shw X is the register containing the data to write, Y is the offset, Z is the register containing the address in memory - store 16bits in memory ( Addresses in memory can be read or written 16 bits at a time only)
0101 XXXX YYYY ZZZZ - lhw X is the register to store data in, Y is the offset, Z is the register containing the memory address - load 16bits from memory ( That is 0 represents first 16 bits and 1 represents next 16 bits)
0110 XXXX YYYY ZZZZ - beq X is the PC offset, Y and Z are registers to compare - break equal
0111 XXXX YYYY ZZZZ - bne X is the PC offset, Y and Z are registers to compare - break not equal
In the following, assume $ is the operation
X, Y and Z are registers, X=Y$Z
1000 XXXX YYYY ZZZZ - and - and gate
1001 XXXX YYYY ZZZZ - or - or gate
1010 XXXX YYYY ZZZZ - add - addition
1100 XXXX YYYY ZZZZ - and~ - A and ~B
1101 XXXX YYYY ZZZZ - or~ - A or ~B
1110 XXXX YYYY ZZZZ - sub - subtraction
if(Y<Z) X=1 else X=0
1111 XXXX YYYY ZZZZ - stl - set less than
To do list:
Forwarding unit - on going
Hazard detection unit - yet to start
8-bit CPU
Working on a NEW CPU: Femboy-16!
ASSEMBLER:
https://output.jsbin.com/wutikij
GPU:
https://circuitverse.org/users/214464/projects/cb-ppu
INSTRUCTION SET:
00: NOP - Nothing
01: HLT - Halt program
02: OUT [id] - Output the accumulator out of an output
03: LDI A, [d8] - Loads immediate 8 bit word into the accumulator
04: MOV [r], A - Move register to accumulator
05: MOV A, [r] - Move accumulator to register
06: INC [r] - Increment a register
07: DEC [r] - Decrememt a register
08: ADD [r], A - Add the accumulator from a register
09: SUB [r], A - Subtract the accumulator from a register
0A: AND [r], A - And the register and accumulator
0B: IOR [r], A - OR the register and accumulator
0C: XOR [r], A - XOR the register and accumulator
0D: NOT [r] - NOT a register
0E: SRR [r] - Barrel shift accumulator right
0F: SRL [r] - Barrel shift accumulator left
10: JUP [d8] - Jump to a location
11: JPP [r] - Jump to a register value
12: JPL A, [d8] - Jump if accumulator is less than 0
13: JZO A, [d8] - Jump if accumulator is 0
14: JPG A, [d8] - Jump if accumulator is greater than 0
15: JLE A, [d8] - Jump if accumulator is less than or equal to 0
16: JGE A, [d8] Jump if accumulator is greater than or equal to 0
17: JNZ A, [d8] Jump if accumulator is not 0
18: CLR [r] - Clear a register
19: INP [id] - Store INPUT id in accumulator
1A: MOV pA, [r] - Move the value at address A register r
1B: MOV [r], pA - Move register r into address A
1C: MOV [p], A - Move a value in a pointer to the accumulator
1D: MOV A, [p] - Move the accumulator to a location
1E: MLT [r], A - Multiply register r by the accumulator
1F: DIV [r], A - Divide register r by accumulator
REGISTERS:
00: REGISTER 1
01: REGISTER 2
02: REGISTER 3
04: REGISTER 4
05: ZERO FLAG (R)
06: PC (R)
07: ALU Result (R)
Update Notes:
V4:
So this is the 4th iteration of my CPU lol... I added a few programs for you all to try out and you can even use an assembler now!
V5:
Long time since I updated this... But I've added a GPU! It's called "Color burst" and you can go try out some premade programs I have added on it! There's an assembler guide with GPU dev guide and I encourage you all to go try and make some graphical programs! Also more docs can be found on it's project page.
To-Do:
Increase amount of registers to 8
Make a simple command line
Make a simple operating system for the CPU
Functional Electronic Machine Binary Operator Yes - 8-bit cpu
This is a work in progress right now.
INSTRUCTION SET:
00: NOP - Nothing
01: HLT - Halt program
02: OUT [r] - Output a register
03: LDA [d8] - Loads 8 bit data into the accumulator
04: MOV [r], A - Move register to accumulator
05: MOV A, [r] - Move accumulator to register
06: INC [r] - Increment a register
07: DEC [r] - Decrememt a register
08: ADD [r], A - Add the accumulator from a register
09: SUB [r], A - Subtract the accumulator from a register
0A: AND [r], A - And the register and accumulator
0B: IOR [r], A - OR the register and accumulator
0C: XOR [r], A - XOR the register and accumulator
0D: NOT [r] - NOT a register
0E: SRR [r] - Shift register right
0F: SRL [r] - Shift register Left
REGISTERS:
00: REGISTER 1
01: REGISTER 2
02: REGISTER 3
04: REGISTER 4
Update Notes:
The instruction set now has 16 instructions with logic operations, loading, shift, and nop.
To-Do:
Add WIP instructions
Add the accumulator to a register address
Increase amount of registers to 8
Add Ram manipulation instructions
Add Input to CPU
Add more operations to the ALU
Add ASCII i/o
Make a simple command line
Make an assember
Make a simple operating system for the cpu
Add rgb output
Functional Electronic Machine Binary Operator Yes - 8-bit cpu
This is a work in progress right now.
INSTRUCTION SET:
00: NOP - Nothing
01: HLT - Halt program
02: OUT [id] - Output the accumulator out of an output
03: LDI A, [d8] - Loads immediate 8 bit word into the accumulator
04: MOV [r], A - Move register to accumulator
05: MOV A, [r] - Move accumulator to register
06: INC [r] - Increment a register
07: DEC [r] - Decrememt a register
08: ADD [r], A - Add the accumulator from a register
09: SUB [r], A - Subtract the accumulator from a register
0A: AND [r], A - And the register and accumulator
0B: IOR [r], A - OR the register and accumulator
0C: XOR [r], A - XOR the register and accumulator
0D: NOT [r] - NOT a register
0E: SRR [r] - Shift register right
0F: SRL [r] - Shift register Left
10: JUP [d8] - Jump to a location
11: JPP [r] - Jump to a register value
12: JPL A, [d8] - Jump if accumulator is less than 0
13: JZO A, [d8] - Jump if accumulator is 0
14: JPG A, [d8] - Jump if accumulator is greater than 0
15: JLE A, [d8] - Jump if accumulator is less than or equal to 0
16: JGE A, [d8] Jump if accumulator is greater than or equal to 0
17: JNZ A, [d8] Jump if accumulator is not 0
18: CLR [r] - Clear a register
19: INP [id] - Store INPUT id in accumulator
1A: MOV pA, [r] - Move the value at address A register r
1B: MOV [r], pA - Move register r into address A
1C: MOV [p], A - Move a value in a pointer to the accumulator
1D: MOV A, [p] - Move the accumulator to a location
1E: MLT [r], A - Multiply register r by the accumulator
1F: DIV [r], A - Divide register r by accumulator
REGISTERS:
00: REGISTER 1
01: REGISTER 2
02: REGISTER 3
04: REGISTER 4
05: ZERO FLAG (R)
06: PC (R)
07: ALU Result (R)
Update Notes:
Welcome to the 3rd iteration of my Femboy-8 CPU! This might be the last version with 32 instructions.
To-Do:
Increase amount of registers to 8
Make a simple command line
Make an assember
Make a simple operating system for the CPU
Add rgb output
Functional Electronic Machine Binary Operator Yes - 8-bit cpu
Working on a new CPU: Femboy-16
ASSEMBLER:
https://output.jsbin.com/wutikij
INSTRUCTION SET:
00: NOP - Nothing
01: HLT - Halt program
02: OUT [id] - Output the accumulator out of an output
03: LDI A, [d8] - Loads immediate 8 bit word into the accumulator
04: MOV [r], A - Move register to accumulator
05: MOV A, [r] - Move accumulator to register
06: INC [r] - Increment a register
07: DEC [r] - Decrememt a register
08: ADD [r], A - Add the accumulator from a register
09: SUB [r], A - Subtract the accumulator from a register
0A: AND [r], A - And the register and accumulator
0B: IOR [r], A - OR the register and accumulator
0C: XOR [r], A - XOR the register and accumulator
0D: NOT [r] - NOT a register
0E: SAR [d8] - Barrel shift accumulator right
0F: SAL [d8] - Barrel shift accumulator left
10: JUP [d8] - Jump to a location
11: JPP [r] - Jump to a register value
12: JPL A, [d8] - Jump if accumulator is less than 0
13: JZO A, [d8] - Jump if accumulator is 0
14: JPG A, [d8] - Jump if accumulator is greater than 0
15: JLE A, [d8] - Jump if accumulator is less than or equal to 0
16: JGE A, [d8] Jump if accumulator is greater than or equal to 0
17: JNZ A, [d8] Jump if accumulator is not 0
18: CLR [r] - Clear a register
19: INP [id] - Store INPUT id in accumulator
1A: MOV pA, [r] - Move the value at address A register r
1B: MOV [r], pA - Move register r into address A
1C: MOV [p], A - Move a value in a pointer to the accumulator
1D: MOV A, [p] - Move the accumulator to a location
1E: MLT [r], A - Multiply register r by the accumulator
1F: DIV [r], A - Divide register r by accumulator
REGISTERS:
00: REGISTER 1
01: REGISTER 2
02: REGISTER 3
04: REGISTER 4
05: ZERO FLAG (R)
06: PC (R)
07: ALU Result (R)
Update Notes:
So this is the 4th iteration of my CPU lol... I added a few programs for you all to try out and you can even use an assembler now!
To-Do:
Increase amount of registers to 8
Make a simple command line
Make an assember
Make a simple operating system for the CPU
Add rgb output
A programable CPU/Proccessor/computer/whatever this qualifies as! 256 bytes of RAM/Memory, a working ALU and processor, and programable. Takes commands as 32 bit inputs, explained at the top of the "CURRENT PROGRAM" subcircuit, currently setting the first variable to 3 and then incrementing it. to edit the program, change the constants at the top of the CURRENT PROGRAM subcircuit to the commands you want(commands are listed in the processor subcircuit). note: variables, if not set to a value somewhere previous in a program, will not be 0, but undefined(red). also, all numbers are stored as 8 bit, and will roll over. there is no difference between adding 255 and subtracting 1. if you want to use a different ALU, make sure to either adjust commands in the programs you make or use the same ones as mine.