TOPIC: Multicycle Instruction Datapath SUBJECT: Computer Architecture PROBLEM: W
ID: 3592046 • Letter: T
Question
TOPIC: Multicycle Instruction Datapath
SUBJECT: Computer Architecture
PROBLEM: What is the Multicycle Instruction Datapath for the instruction type addi $15, $20, 5?
The explanation should address the 4 cycles and subquestions below:
(1) Instruction Fetch
(a) Instruction is fetched FROM memory. Where is it placed?
(b) What control signals cause all this to happen?
(c) What else happens during this step?
(2) Instruction Decode and Register Fetch
(a) What values are read which the registers, and what happens to those values?
(b) What else occurs durring this step (i.e. what does the ALU do)? You have the wrong value listed for operand 1, and you have two different values being listed as operand 2 -- which is used?
(c) What control signals cause all this to happen?
(3) Execution (perform math/logic operation in ALU with register and immediate value operands)
(a) Where to the ALU operands come from?
(b) What control signals cause all this to happen?
(4) Instruction Completion (Write resulting value to register).
(a) Where does the result come from?
(b) How does the CPU know where to store it?
(c) What control signals cause all this to happen?
Explanation / Answer
def main():
#getting name, age and ensuring customer is in the right age group
new_quote = 'y'
while new_quote =='y' or new_quote == 'Y':
name = input("Please enter your name:")
age = int(input("Please enter your age:"))
if age<16 or age>106:
print("Invalid age")
new_quote =='y'
#getting number of traffic violations
if age >=16 and age<106:
traffic_violations = int(input("Enter your number of violations:"))
if traffic_violations<0:
print("Invalid Entry")
else:
risk_code,risk_type = calc_risk(traffic_violations)
insurance_price = calcInsurance(age, traffic_violations, risk_code)
display_quote(name,risk_type,insurance_price)
new_quote = input("Would you like another quote? Y or N: ")
if new_quote=='N' or new_quote=='n':
print("Have a good day")
break
#calculate the risk code and risk type
def calc_risk(traffic_violations):
if traffic_violations >=4:
risk_code = 1
risk_type = 'high'
elif traffic_violations == 3:
risk_code = 2
risk_type = 'moderate'
elif traffic_violations == 2:
risk_code = 3
risk_type = 'moderate'
elif traffic_violations == 1:
risk_code = 3
risk_type = 'low'
elif traffic_violations == 0:
risk_code = 4
risk_type = 'no'
return risk_code, risk_type
# gets the insurance price
def calcInsurance(age, number_tickets, risk_code) :
if age <= 24 and number_tickets >= 4 and risk_code == 1:
insurance_price = 480
elif age >= 25 and number_tickets >= 4 and risk_code == 1:
insurance_price = 410
elif age <= 24 and number_tickets == 3 and risk_code == 2:
insurance_price4 = 450
elif age >= 25 and number_tickets == 3 and risk_code == 2:
insurance_price = 390
elif age <= 24 and number_tickets == 2 and risk_code == 2:
insurance_price = 405
elif age >= 25 and number_tickets == 2 and risk_code == 2:
insuransce_price = 365
elif age <= 24 and number_tickets == 1 and risk_code == 3:
insurance_price = 380
elif age >= 25 and number_tickets == 1 and risk_code == 3:
insurance_price = 315
elif age <= 24 and number_tickets == 0 and risk_code == 4:
insurance_price = 325
elif age >= 25 and number_tickets == 0 and risk_code == 4:
insurance_price = 275
#display output
def display_quote(name, risk_type, insurance_price):
print()
print(name,",as a",risk_type,"risk driver, your insurance will be $[.2f]".format(insurance_price))
#call the main function
main()
It is telling me the break is outside the loop, so I am not sure it is actually running. Can anyone help?
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.