Starting from:

$30

ECS154A-Homework 4 Solved

Problem 1: CPU.circ
Build a 4-bit single cycle CPU that can implement the given instructions.

 

Instruction Format
Our CPU will be using fixed length instructions. Our CPU will also have two types of instruction formats: R-type and I-type. In R-type instructions both operands come from registers. In I-type instructions, the first operand comes from a register and the second will be contained within the instruction.

R-Type
 

Name
Bits
Description
OpCode
15 - 12
Determines what operation should be performed
C
11 - 8
The destination register. The C in RegC = RegA OP RegB
A
7 - 4
The first source register. The A in RegC = RegA OP RegB
B
3 - 0
The second source register. The B in RegC = RegA OP RegB
 

 
I-Type
 

Name
Bits
Description
OpCode
15 - 12
Determines what operation should be performed
C
11 - 8
The destination register. The C in RegC = RegA OP Imm
A
7 - 4
The first source register. The A in RegC = RegA OP Imm
Immediate
3 - 0
The second source register. The Imm in RegC = RegA OP Imm
 

 
Instructions
 

Operation
Encoding (The value in the OpCodeField)
Description
STOP
0000
The CPU ceases execution
NOP
0001
Do nothing
LOAD
0010
RegC = Immediate
MOVE
0011
RegC = RegA
ANDR
0100
RegC = RegA AND RegB
ANDI
0101
RegC = RegA AND Immediate
ORR
0110
RegC = RegA OR RegB
ORI
0111
RegC = RegA OR Immediate
XORR
1000
RegC = RegA XOR RegB
XORI
1001
RegC = RegA XOR Immediate
NOT
1010
RegC = NOT RegA
NEGATE
1011
RegC = -RegA
ADDR
1100
RegC = RegA + RegB
ADDI
1101
RegC = RegA +Immediate
SUBR
1110
RegC = RegA - RegB
SUBI
1111
RegC = RegA - Immediate
 

 

 
Inputs
Pin
Size (in bits)
Explanation
Instruction
16
The instruction located at Instruction_Address
ClkIn
1
The Clock. Connect this to the clock ports of your registers/flip-flops. Do nothing else with this.
Outputs
Pin
Size (in bits)
Explanation
Instruction_Address_Out
5
The address of the instruction you want to execute
Reg0-15
4
The values in the register file. This has already been connected for you
CPU Components
Your CPU should have

A Program Counter (PC)This stores and keeps track of what instruction you are on
Instruction DecoderThis is a bunch of combinational logic that sets the control signals inside of your CPU
Register FileA bunch of registers as well as ways to specify which ones you want. This has already been created for you.
The only outputs of the register file that you are allowed to use are A_Out and B_Out. The rest are for testing purposes and should not be used. Using them will result in a 50% penalty in your grade.

More products