Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
image text in transcribed
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. Your class should be named Branching Unit. It should have two methods and be able to be created with the default constructor. Methods: public int getInstruction Pointer () 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. public 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 OurSA.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 o Output: none Notes: 1. Be sure that you start with the instructior pointer at 0 2. Be sure to always update the instruction pointer during every call to determineNextinstruction Pointer 3. Calls to getInstruction Pointer should not change the instruction pointer 0010 multiply srl $r2 $r3 0011 division $rl $r2 $r3 0100 increment $ri $r2 ($r1=$r2+1, $r3 unused) 0101 decrement $rl $r2 0110 lshift $rl $r2 $r3 0111 rshift $ri $r2 $r3 1000 and $rl $r2 $r3 1001 or $rl $r2 $r3 1010 not $rl $r2 1011 xor $r1 r2 $r3 1100 left rotate $rl $r2 $r3 1101 right rotate $r1 $r2 $r3 Jumping/branching (10) 0000 branch less than $r2(value) $r3(location) ($rl 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 $r1 $i(7 bits) ($r1 = $i) 0001 Load $rl $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 Back OurCPU-Branching Unit.png 0000 0000 0001 0000 A 0002 0000 0003L 0000 sel Id cir 0000 0000 0001 0000 A0002 0000 0003 0000 strsel dicit DOQC Clock 0 MUX

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_2

Step: 3

blur-text-image_3

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

Database Design Application Development And Administration

Authors: Mannino Michael

5th Edition

0983332401, 978-0983332404

More Books

Students also viewed these Databases questions