
This is a 4 bit CPU with very basic opcodes for running programs. The input on ui_in is of the form 4 bits opcode - 4 bits operand. The output uo_out is of the form 4 bits program counter - 4 bits value. All instructions are performed on the 4-bit accumulator, which can then be sent to the output (OUT) or stored into memory (STORE). The CPU also has 16 words of RAM on the chip. It is intended to use an Arduino or some other microcontroller as the program storage, to be able to run different programs on the chip. A list of all opcodes:
Opcode 0001: LDA (Load operand into Accumulator)
Opcode 0010: ADD (Add value at operand memory address to Accumulator)
Opcode 0011: SUB (Subtract value at operand memory address from Accumulator)
Opcode 0100: JZ (Jump to program counter value of operator if accumulator is Zero)
Opcode 1100: JMP (Jump to program counter value of operator)
Opcode 0110: SHL (Shift Left - Multiply value in accumulator by 2)
Opcode 0111: XOR (Exclusive OR, compared bitwise against value in the operand memory address)
Opcode 1011: AND (And, compared bitwise against value in the operand memory address)
Opcode 1101: OR (Or, compared bitwise against value in the operand memory address)
Opcode 1000: OUT (Write accumulator to output register)
Opcode 0101: STORE (Write accumulaor to memory at operand memory address)
Opcode 1010: LOAD (Load value at operand memory address into accumulator)
Since I'm not entirely sure how the testing will actually work, and what has to be done to ensure sucess, I can currently only give rough instructions. Once I'm able to test the design myself though, I will of course update this section. The Idea is to write a little Program using the opcodes provided and the RAM on the chip to write a little program. One could even code up a small assembler to write programs for the CPU. This program can then be fed to the CPU by a microcontroller, which also has access to the process counter, in order to send the correct instructions through ui_in. To ensure correct timing, it may be necessary to have the clock signal generated by the Arduino. I will put my arduino program(s) on my GitHub as well.
| # | Input | Output | Bidirectional |
|---|---|---|---|
| 0 | operand[0] | out_reg[0] | |
| 1 | operand[1] | out_reg[1] | |
| 2 | operand[2] | out_reg[2] | |
| 3 | operand[3] | out_reg[3] | |
| 4 | opcode[0] | pc[0] | |
| 5 | opcode[1] | pc[1] | |
| 6 | opcode[2] | pc[2] | |
| 7 | opcode[3] | pc[3] |