Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Programming language For this assignment, you should build a Java class which represents the Branching Unit in the CPU. Submit the Java code to

Java Programming language image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
For this assignment, you should build a Java class which represents the Branching Unit in the CPU. Submit the Java code to the appropriate assignment on codepost.io The branching unit keeps track of which instruction we are working on and then updates for which one will be loaded next. It stores a value called the "instruction pointer" which stores the location of the current instruction. From which location the next instruction will be loaded depends on the current instruction. The desired behavior of the Branching Unit in response to instructions should be like this: if an instruction is an ALU or Memory instruction (not branch or jump), it should simply move to the next instruction by adding one if an instruction is a branch less than, it should check if r2 is less than 0. If it is, it should jump to the location in r3. If not, it should simply move to the next instruction by adding one . if an instruction is a branch greater than, it should check if r2 is greater than 0. If it is, it should jump to the location in r3. If not, it should simply move to the next instruction by adding one if an instruction is a branch equal to, it should check if r2 is equal to 0. If it is, it should jump to the location in r3. If not, it should simply move to the next instruction by adding one if an instruction is a branch not equal to, it should check if r2 is not equal to 0. If it is, it should jump to the location in r3. If not, it should simply move to the next instruction by adding one if an instruction is a jump, it should jump to the location in r3. In Logisim, we built a subcircuit for the branching unit, but this was then connected to a register (the instruction pointer) which was attached to the memory and also fed back into the branching unit subcircuit. This class should incorporate both the logic of the branching unit from the circuit and the instruction pointer register. (See this image if you want to see the area which is being included.) Your class should be named Branching Unit. It should have two methods and be able to be created with the default constructor. Methods: . int getInstructionPointer() o Inputs: none o Output: returns the current instruction pointer. When the class has just been created, this should be 0. After that, it will change when the other method is called. void determineNextinstruction Pointer (boolean is Jump, int op, int r2, int r3) Inputs: boolean isJump - will be true for a branch or jump instruction, will be false for all other types of instructions. . int op - the number of the operation being used. See OurISA.txt for details about the operation codes for jumping and branching int r2- the value from the second int getinstructionPointer() Inputs: none o Output: returns the current instruction pointer. When the class has just been created, this should be 0. After that, it will change when the other method is called. void determineNextInstruction Pointer (boolean is Jump, int op, int r2, int r3) o Inputs: boolean isJump - will be true for a branch or jump instruction, will be false for all other types of instructions. int op - the number of the operation being used. See Our SA.txt for details about the operation codes for jumping and branching int r2- the value from the second register used in the instruction - int r3 - the value from the third register used in the instruction Output: none Notes: 1. Be sure that you start with the instruction pointer at 0 2. Be sure to always update the instruction pointer during every call to determineNextinstructionPointer 3. Calls to getInstruction Pointer should not change the instruction pointer 8 registers (3 bits) (Register 0 doesn't store anything, just always has O as its value) Categories: Math/bit fiddling (ALU) (00) 0000 subtract Sri Sr2 $r3 ($rl=$r2-$r3) 0001 add $rl $r2 $r3 0010 multiply $ri $r2 $r3 0011 division $rl $r2 $r3 0100 increment $ri $r2 ($rl=$r2+1, $r3 unused) 0101 decrement $rl $r2 0110 lshift $rl $r2 $r3 0111 rshift $rl $r2 $r3 1000 and $rl $r2 $r3 1001 or $rl $r2 $r3 1010 not $rl $r2 1011 xor $rl $r2 $r3 1100 left rotate $rl $r2 $r3 1101 right rotate $ri $r2 $r3 Jumping/branching (10) 0000 branch less than $r2 (value) $r3(location) ($ri unused) 0001 branch greater than $r2(value) $r3(location) 0010 branch equal to $r2(value) $r3 (location) 0011 branch not equal to $r2 (value) $r3(location) 0100 jump $r3 (location) ($rl and $r2 unused) Memory (11) 0000 Load immediate $ri i(7 bits) ($rl = i) 0001 Load $r1 $r2 ($rl = mem[$r2]) 0010 Store $r2 $r3 (mem[ $r2]=$r3) Example: add r4 r5 r7 r4 = r5 + r7 00 0001 100 101 111 0 0000011001011110 0000 0110 0101 1110 0 6 5 e 065e load immediate r2 17 r2 = 17 11 0000 010 0010001

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

More Books

Students also viewed these Databases questions

Question

How does the Proposition I equation differ between the two models?

Answered: 1 week ago

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago