Question: Fetch ( ) Review pages 1 3 to 1 5 of lecture slide CSE 1 4 0 _ Lecture - 4 _ Processor - 1
Fetch
Review pages to of lecture slide CSELectureProcessor
Create a function named Fetch that reads one instruction from the input program text file
per cycle.
PC: As learned in the lecture, the CPU needs to fetch an instruction that is pointed by the PC
value and the PC value needs to be incremented by Declare a global variable named pc
and initialize it as Whenever you read one instruction from the input program text file,
increment the pc value by and read the ith instruction that is pointed by PC value, i For
example, if pc is you will read st instruction, which is the second instruction when we
count from
Next PC: After fetching an instruction, fetch step will increment the PC value by as can be
seen in the lecture slide. Declare one variable named nextpc and store pc Later, we
will need to choose the next cycle pc value among this nextpc value and the branch target
address. We will discuss later but the branch target address will be updated by another
function that produces branchtarget So add a logic in this Fetch function that copies
one of the three possible pc values nextpc and branchtarget to pc variable. This updated
pc value will be used for the next instruction fetch.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
