Computer 16 Bit
A Scrap Mechanic Computer! YAY!
A single cycle 16 bit RISC processor
Thought I’d post some progress on the processor. Still working on branch instructions and some other stuff. If you find any errors let me know.
————————————————–
White switch – PC Clocked
White button – PC Step
Blue button – PC Reset
————————————————–
Reserved Registers:
Register 0 – Constant zero (first register)
Register 15 – JAL address (last register)
————————————————–
Instruction Formats:
Type R [5 bit opcode][4 bit Rd][4 bit Rs][4 bit Rt]
Type I [5 bit opcode][4 bit Rd][8 bit sign extended immediate]
Type J [5 bit opcode][12 bit address]
Type B [5 bit opcode][8 bit address][4 bit Rt]
————————————————–
Opcodes: (I’ll write this up better later, just pasted from the ALU for the Type-R functions)
00000 – NOP (No operation)
00001 – ADDu (Adds unsigned. A and B)
00010 – SUBu (Subtracts unsigned. B from A)
00011 – MULu (Multiplies unsigned. A by B)
00100 – SLL (Shift Left Logical. B << First 4 bits of A)
00101 – SRL (Shift Right Logical. B >> First 4 bits of A)
00110 – SRA (Shift Right Arithmetic. B >> First 4 bits of A)
00111 – RL (Rotate Left. B < First 4 bits of A)
01000 – RR (Rotate Right. B > First 4 bits of A)
01001 – SLT (Set Less Than. Sets output to 1 if A < B signed)
01010 – SLTu (Set Less Than Unsigned. Sets output to 1 if A < B ignores sign)
01011 – NOP (No Operation)
01100 – AND (bitwise)
01101 – OR (bitwise)
01110 – XOR (bitwise)
01111 – NOR (bitwise)
10000
10001
10010
10011
10100
10101
10110
10111
11000 BEZ Branch on equal zero (PC = 8 bit address if Rt == Rs0)
11001 BNZ Branch on not equal zero (PC = 8 bit address if Rt != Rs0)
11010 LI (Rd = 8-bit Sign extended immediate)
11011 LW (Rd = Mem[Rt])
11100 SW (Mem[Rd] = Rt)
11101 JAL Jump and link (register 15 = PC + 1 and PC = specified address)
11110 JMP Unconditionally jumps to the instruction at the specified address
11111 JR Jumps to the address contained in the specified register (register 15 for JAL)
————————————————–
Sample program currently loaded:
Countdown from 16 by 2 until zero (do while loop)
11010 0001 0001 0000 Load constant 16 into register 1
11010 0010 0000 0010 Load constant 2 into register 2
11100 0000 0000 0001 Save to memory 0 the value of register 1
00010 0001 0001 0010 Subtract register 2 from register 1 and save to register 1
11100 0000 0000 0001 Save to memory 0 the value of register 1
11001 0000 0011 0001 Branch (goto) instruction register 3 on register 1 not equal to zero
11110 0000 0000 0110 Jump to instruction register 6 (loop on this command indefinitely)