Each VerySimpleCPU instruction word has a fixed length of 32-bit.
Instruction Word | ||||
---|---|---|---|---|
bit position | [31:29] | [28] | [27:14] | [13:0] |
field name | opcode | im | A | B |
bit width | 3-bit | 1-bit | 14-bit | 14-bit |
==================================================================
==================================================================
ADD
R1 <- mem[IW[27:14]]
R2 <- mem[IW[13:0]]
mem[IW[27:14]] <- (R1 + R2)
PC <- PC + 1
ADDi
R1 <- mem[IW[27:14]]
R2 <- IW[13:0]
mem[IW[27:14]] <- (R1 + R2)
PC <- PC + 1
NAND
R1 <- mem[IW[27:14]]
R2 <- mem[IW[13:0]]
mem[IW[27:14]] <- ~(R1 & R2)
PC <- PC + 1
NANDi
R1 <- mem[IW[27:14]]
R2 <- IW[13:0]
mem[IW[27:14]] <- ~(R1 & R2)
PC <- PC + 1
SRL
R1 <- mem[IW[27:14]]
R2 <- mem[IW[13:0]]
mem[IW[27:14]] <- (R2 < 32) ? (R1 >> R2) : (R1 << (R2-32))
PC <- PC + 1
SRLi
R1 <- mem[IW[27:14]]
R2 <- IW[13:0]
mem[IW[27:14]] <- (R2 < 32) ? (R1 >> R2) : (R1 << (R2-32))
PC <- PC + 1
LT
R1 <- mem[IW[27:14]]
R2 <- mem[IW[13:0]]
mem[IW[27:14]] <- (R1 < R2) ? 1 : 0
PC <- PC + 1
LTi
R1 <- mem[IW[27:14]]
R2 <- IW[13:0]
mem[IW[27:14]] <- (R1 < R2) ? 1 : 0
PC <- PC + 1
MUL
R1 <- mem[IW[27:14]]
R2 <- mem[IW[13:0]]
mem[IW[27:14]] <- (R1 * R2)
PC <- PC + 1
MULi
R1 <- mem[IW[27:14]]
R2 <- IW[13:0]
mem[IW[27:14]] <- (R1 * R2)
PC <- PC + 1
CP
R2 <- mem[IW[13:0]]
mem[IW[27:14]] <- R2
PC <- PC + 1
CPi
R2 <- IW[13:0]
mem[IW[27:14]] <- R2
PC <- PC + 1
CPI
R1 <- mem[IW[13:0]]
R2 <- mem[R1]
mem[IW[27:14]] <- R2
PC <- PC + 1
CPIi
R1 <- mem[IW[27:14]]
R2 <- mem[IW[13:0]]
mem[R1] <- R2
PC <- PC + 1
BZJ
R1 <- mem[IW[27:14]]
R2 <- mem[IW[13:0]]
PC <- (R2 == 0) ? R1 : (PC + 1)
BZJi
R1 <- mem[IW[27:14]]
R2 <- IW[13:0]
PC <- (R1 + R2)