Computer Architecture Lab/SS2014/group 5 lab 2

< Computer Architecture Lab < SS2014

To model and implemented a CPU(Central Processing Unit) inside an FPGA, the CPU should be able to perform the task that of a normal CPU. The main processes are instruction fetch, instruction decode, memory read, execute and memory write back. Hence,CPU’s main function is to Fetch instructions, decode them and execute the given instruction set. Instruction set is based on MIPS.

Instruction set:

InstructionFunctionEncodingopfunct
add r1,r2,r3addition: r1 <- r2 + r3Register000000100000
sub r1,r2,r3subtraction: r1 <- r2 – r3Register000000100010
mult r1,r2,r3multiply: r1 <- r2 * r3Register000000100100
div r1,r2,r3division: r1 <- r2 / r3Register000000100101
and r1,r2,r3bitwise and: r1 <- r2 and r3Register000000101000
or r1,r2,r3bitwise or: r1 <- r2 or r3Register000000101001
slt r1,r2,r3set less than: r1 <- 1 if r2 < r3, r1 <- 0 otherwiseRegister000000110100
srl r1,r2,r3shift from right to left: r1 <- r2 amount of r3Register000000111000
slr r1,r2,r3shift from left to right: r1 <- r2 amount of r3Register000000111001
addi r1,r2,immadd immediate: r1 <- r2 + immImmediate100001
beq r1,r2,imm (destination)branch if equal r1 = r2: PC <- PC + imm × 4Immediate000010
jmp destinationjump: PC <- PC + destination × 4Jump000001
lb r1,r2,immload byte: r1 <- mem[r2 + imm]Immediate100000
sb r1,r2,immstore byte: mem[r2 + imm] <- r1Immediate110000

Instruction format (32 bit):

Immediate:

6 bit5 bit5 bit16 bit
opr1r2imm

Jump:

6 bit26 bit
opdestination

Register:

6 bit5 bit5 bit5 bit5 bit6 bit
opr1r2r3shift amountfunct