Blog

Coursehelp
March 15, 2019
QUESTION : No Comments

(Solved) : Program Read Data Text File Produce Grade Report Data Text File Contain Class Id Title Num Q34497970

This program will read data from a text file to produce a gradereport. The data in the text file will contain the class ID (ortitle), the number of tests given in the class, and a list ofstudents and their test scores. The report will include most of thedata from the file, plus some calculated values such as eachstudent’s average test score after their lowest score is dropped,the number of students in the class, the class average and thehighest average score in the class. I’ve spent three times longeron this than I probably should have. I’m just a beginner looking tolearn C++. Please Help.

CS 210 Lab 4 Program Specifications Checkpoint due 11:59PM Sat Feb 2, 2019 Lab due 11:59 PM Wed Feb 6, 2019 Program Overview: This program will be a single-file project-no-h class definition file. You will write a program in a file named ClassReport.cpp that will read data from a text file to produce a grade report. The data in the text file will contain the class ID (or title), the number of tests given in the class, and a list of students and their test scores. The report will include most of the data from the file, plus some calculated values such as each students average test score after their lowest score is dropped, the number of students in the class, the class average and the highest average score in the class. This lab will give you more practice formatting output, and it will introduce you to using while-loops and for-loops. Output Report Specifications: Your ClassReport.cpp program will read data from a text file to produce the grade report partially shown below CS 210 Student Name Tl T2 3 T4 TSAvg ANTER ZACHARY L ARREOLA JUAN J BARBER ANTONIO D 91.8 68.8 73.1 87.4 51.1 80.3 50.1 65.0 61.3 59.3 90.0 68.9 72.7 78.5 89.6 91.8 91.3 87.8 YOKOTA YUSUKE YOUNG NICHOLAS T ZAVALA ROGELIO R 1.3 88.9 93.0 88.7 78.6 87.3 86.9 56.2 99.3 55.2 65.7 77.0 5.4 58.2 92.6 74.1 82.2 81.1 Number of Students: 31 Class Average: 79.1 Class High Average: 94.0 Input Text File Data Specifications: The data file posted with this assignment is named classData.dat The layout or format of the file will be as follows: Data Value Course ID Number of tests Name of student #1 Student #1s test scores Description The first line in the file holds the ID (Title) for the course The second line in the file holds number of tests given in the class. The third line in the file holds the first students name Each score is separated from the next with whitespace. E.g Score1 Score2 Score3 etc. Pattern repeats with name/scores pairs of lines in the file Score1 Score2 etc. (As many scores as were given in the class.) Name of student #2 Student #2s test scores Name of student #N Student #Ns test scores You may assume that any file named classData.dat will conform to the layout described above Last students name in the file Score1 Score2 etc. but you may not assume that the course ID will always be CS 210, or that the number of tests willalways be 5, or that there will always be 31 students listed, as is the case with the classData.dat file that was posted with this assignment. A portion of the files data is shown below: CS 210 ANTER ZACHARY L 91.78 68.78 73.09 87.36 51.08 ARREOLA JUAN J 50.15 65.04 61.32 59.27 89.99 YOUNG NICHOLAS T 86.92 56.22 99.3 55.24 65.69 ZAVALA ROGELIO R 75.43 58.19 92.56 74.14 82.25 Please note that a random number generator was used in an Excel spreadsheet to generate the simulated test scores, so dont be insulted if your name is given with lousy scores! Other Considerations and Requirements The Lab4Files folder posted with this assignment contains the classData.dat file. You may look at the file using your IDEs File Open menu option. For most IDEs, you should store the classData.dat file in the same folder as the ClassReport.cpp file. (If that doesnt work, try storing it in the same folder as your project file.) . .After opening the classData.dat file for input, be sure to test that the operation was successful using code similar to that shown on lines 37-40 in the Read Accounts2.cpp program posted in the Lab4Files folder. If your data file isnt successfully opened, then no other code you write will work! Everything depends on you being able to open the file and read the data from it correctly. Get your checkpoint code described in the next section of this document to work before attempting any other processing! The report generated by your program should reflect the contents of the classData.dat file. If the contents of the data file change, the contents of the report should change accordingly . . You may assume the following: 1 S the number of tests s 8. That is, there is guaranteed to be at least one test score per student, and there wont be more than 8 scores, so they will all fit on the 80-character wide console screen along with the average score if you follow the related formatting specs below Your program should end up with a for-loop nested inside a while-loop. . Display each score and average score right-justified in a field width of 6 characters, displaying exactly one digit to the right of the decimal point. Display each name left-justified in a field-width of 25 characters-you may assume no name in the data file will be longer than 25 characters Drop each students lowest score before computing their average score, unless there was only one test given in the class-then the average score for that student is simply their only test The course title is centered within the 80-character width of the console screen. HINT: Fig 5.8 on page 176 demonstrated the size) attribute of a string object. You can do some math on that as the parameter of the setw) VO manipulator introduced in Fig 5.6 on page 168 . Column headings appear above the names, scores and averages as shown in the report above. .. 80 characters are displayed above and below the detail lines of the report as shown in the report above The program computes and displays the number of students in the class in the summary at the bottom of the report as shown above . The program computes and displays the average average-score in the summary at the bottom of the report as shown above . The program computes and displays the highest average-score in the summary at the bottom of the report as shown above . The program must use appropriate style as itemized in the StyleSpecifications.pdf file posted in the Quick Links module on Canvas. SUGGESTION: The last thing you should worry about is nicely formatting the report. First get your program to read the data correctly. Then get it to produce correct computations. Only after that is done should you worry about making things look pretty Lab 4 Checkpoint Specifications The checkpoint version of your ClassReport.cpp program should echo the input from the data file to the screen, and display the number of students in the class. A portion of that output is shown below CS 210 number of tests:5 ANTER ZACHARYL 91.78 68.78 73.09 87.36 51.08 ARREOLA JUAN J 50.15 65.04 61.32 59.27 89.99 YOUNG NICHOLAS T 86.92 56.22 99.3 55.24 65.69 ZAVALA ROGELIO R 75.43 58.19 92.56 74.14 82.25 Number of Students: 31Text File Input Considerations Mixing Extraction Operations >) with getline): Study the Read_Accounts1.cpp and Read Accounts2.cpp programs posted with this assignment. They demonstrate how to open a file for input, and how to keep reading from the file until all its data has been read. You will see that its as easy to read from a text file as it is to read from the keyboard (cin). That is, you use the same extraction (>> and getline) operations no matter what input stream you are reading from. For the sake of discussion, suppose your program contains the following code to open a file for input: fstream classDataFile(classData.dat, ios::in) Heres whats really in the classDataFile input file stream: CS 210 5 nANTER ZACHARY Ln 91.78 68.78 73.09 87.36 51.08 nARREOLA JUAN J That is, it is a stream of characters, some of which are whitespace such asorn REMEMBER Warning 2 from Lab 2: The >> extraction operator ignores whitespace as it tries to extract numeric or character or string data from the input stream. If you dont want whitespace to be ignored as in the case of the space between CS and 210, or the space between first name and last name, and last name and middle initial, then you must use getline). Remember that this combination of input operations may require you to do two getline ) operations (or some of you have used ignore)). The first getline) will consume the ln following the last score on each line, and the second getline) will actually input the name Text file End-of-data Weirdness: Sometimes the last line of data in a text file does not contain an end-of-line (n) marker. This can happen when users type the data on the last line of the file and dont hit the enter key before they close the file. Alternatively, the user may hit the enter key several times at the end of a file so that there are multiple blank lines at the end of the file. This would result in an input data stream that looks like the following: cs 2101n5 ANTER ZACHARY LinZAVALA ROGELIO RIn75.43 58.19 92.56 74.14 82.25 nnnin In either case, the last line of a text file can cause challenges, especially when the program uses a mix of extraction (>> and getline() operations. This is why the while-loop in the Read Accounts2.cpp file posted with this assignment contains the following condition: while( getline (inClientFile, name) &&name) In English, this translates into While it is possible to input a line of characters from the inClientFile input stream for the name variable, and that name isnt the empty string In other words, a getline() operation may report success even though all it successfully input was an empty string! For this lab, that is not success, so the loop should terminate Note to Mac and Unix/Linux Users: The Mac and Unix OS use different end-of-line markers in their text files. Be sure to use a native text editor to open the data files I post and save them so that they will contain the native end-of-line markers used on your systems

CS 210 Lab 4 Program Specifications Checkpoint due 11:59PM Sat Feb 2, 2019 Lab due 11:59 PM Wed Feb 6, 2019 Program Overview: This program will be a single-file project-no-h class definition file. You will write a program in a file named ClassReport.cpp that will read data from a text file to produce a grade report. The data in the text file will contain the class ID (or title), the number of tests given in the class, and a list of students and their test scores. The report will include most of the data from the file, plus some calculated values such as each student’s average test score after their lowest score is dropped, the number of students in the class, the class average and the highest average score in the class. This lab will give you more practice formatting output, and it will introduce you to using while-loops and for-loops. Output Report Specifications: Your ClassReport.cpp program will read data from a text file to produce the grade report partially shown below CS 210 Student Name Tl T2 3 T4 TSAvg ANTER ZACHARY L ARREOLA JUAN J BARBER ANTONIO D 91.8 68.8 73.1 87.4 51.1 80.3 50.1 65.0 61.3 59.3 90.0 68.9 72.7 78.5 89.6 91.8 91.3 87.8 YOKOTA YUSUKE YOUNG NICHOLAS T ZAVALA ROGELIO R 1.3 88.9 93.0 88.7 78.6 87.3 86.9 56.2 99.3 55.2 65.7 77.0 5.4 58.2 92.6 74.1 82.2 81.1 Number of Students: 31 Class Average: 79.1 Class High Average: 94.0 Input Text File Data Specifications: The data file posted with this assignment is named classData.dat The layout or format of the file will be as follows: Data Value Course ID Number of tests Name of student #1 Student #1’s test scores Description The first line in the file holds the ID (Title) for the course The second line in the file holds number of tests given in the class. The third line in the file holds the first student’s name Each score is separated from the next with whitespace. E.g Score1 Score2 Score3 etc. Pattern repeats with name/scores pairs of lines in the file Score1 Score2 etc. (As many scores as were given in the class.) Name of student #2 Student #2’s test scores Name of student #N Student #N’s test scores You may assume that any file named classData.dat will conform to the layout described above Last student’s name in the file Score1 Score2 etc. but you may not assume that the course ID will always be CS 210, or that the number of tests will always be 5, or that there will always be 31 students listed, as is the case with the classData.dat file that was posted with this assignment. A portion of the file’s data is shown below: CS 210 ANTER ZACHARY L 91.78 68.78 73.09 87.36 51.08 ARREOLA JUAN J 50.15 65.04 61.32 59.27 89.99 YOUNG NICHOLAS T 86.92 56.22 99.3 55.24 65.69 ZAVALA ROGELIO R 75.43 58.19 92.56 74.14 82.25 Please note that a random number generator was used in an Excel spreadsheet to generate the simulated test scores, so don’t be insulted if your name is given with lousy scores! Other Considerations and Requirements The Lab4Files folder posted with this assignment contains the classData.dat file. You may look at the file using your IDE’s File Open menu option. For most IDEs, you should store the classData.dat file in the same folder as the ClassReport.cpp file. (If that doesn’t work, try storing it in the same folder as your project file.) . .After opening the classData.dat file for input, be sure to test that the operation was successful using code similar to that shown on lines 37-40 in the Read Accounts2.cpp program posted in the Lab4Files folder. If your data file isn’t successfully opened, then no other code you write will work! Everything depends on you being able to open the file and read the data from it correctly. Get your checkpoint code described in the next section of this document to work before attempting any other processing! The report generated by your program should reflect the contents of the classData.dat file. If the contents of the data file change, the contents of the report should change accordingly . . You may assume the following: 1 S the number of tests s 8. That is, there is guaranteed to be at least one test score per student, and there won’t be more than 8 scores, so they will all fit on the 80-character wide console screen along with the average score if you follow the related formatting specs below Your program should end up with a for-loop nested inside a while-loop. . Display each score and average score right-justified in a field width of 6 characters, displaying exactly one digit to the right of the decimal point. Display each name left-justified in a field-width of 25 characters-you may assume no name in the data file will be longer than 25 characters Drop each student’s lowest score before computing their average score, unless there was only one test given in the class-then the average score for that student is simply their only test The course title is centered within the 80-character width of the console screen. HINT: Fig 5.8 on page 176 demonstrated the size) attribute of a string object. You can do some math on that as the parameter of the setw) VO manipulator introduced in Fig 5.6 on page 168 . Column headings appear above the names, scores and averages as shown in the report above. . . 80 characters are displayed above and below the detail lines of the report as shown in the report above The program computes and displays the number of students in the class in the summary at the bottom of the report as shown above . The program computes and displays the average average-score in the summary at the bottom of the report as shown above . The program computes and displays the highest average-score in the summary at the bottom of the report as shown above . The program must use appropriate style as itemized in the StyleSpecifications.pdf file posted in the Quick Links module on Canvas. SUGGESTION: The last thing you should worry about is nicely formatting the report. First get your program to read the data correctly. Then get it to produce correct computations. Only after that is done should you worry about making things look pretty Lab 4 Checkpoint Specifications The checkpoint version of your ClassReport.cpp program should echo the input from the data file to the screen, and display the number of students in the class. A portion of that output is shown below CS 210 number of tests:5 ANTER ZACHARYL 91.78 68.78 73.09 87.36 51.08 ARREOLA JUAN J 50.15 65.04 61.32 59.27 89.99 YOUNG NICHOLAS T 86.92 56.22 99.3 55.24 65.69 ZAVALA ROGELIO R 75.43 58.19 92.56 74.14 82.25 Number of Students: 31 Text File Input Considerations Mixing Extraction Operations >) with getline): Study the Read_Accounts1.cpp and Read Accounts2.cpp programs posted with this assignment. They demonstrate how to open a file for input, and how to keep reading from the file until all its data has been read. You will see that it’s as easy to read from a text file as it is to read from the keyboard (cin). That is, you use the same extraction (>> and getline) operations no matter what input stream you are reading from. For the sake of discussion, suppose your program contains the following code to open a file for input: fstream classDataFile(“classData.dat”, ios::in) Here’s what’s really in the classDataFile input file stream: CS 210n5 nANTER ZACHARY Ln 91.78 68.78 73.09 87.36 51.08 nARREOLA JUAN J That is, it is a stream of characters, some of which are whitespace such asor’n REMEMBER Warning 2 from Lab 2: The >> extraction operator ignores whitespace as it tries to extract numeric or character or string data from the input stream. If you don’t want whitespace to be ignored as in the case of the space between CS and 210, or the space between first name and last name, and last name and middle initial, then you must use getline). Remember that this combination of input operations may require you to do two getline ) operations (or some of you have used ignore)). The first getline) will consume the ln following the last score on each line, and the second getline) will actually input the name Text file End-of-data Weirdness: Sometimes the last line of data in a text file does not contain an end-of-line (n) marker. This can happen when users type the data on the last line of the file and don’t hit the enter key before they close the file. Alternatively, the user may hit the enter key several times at the end of a file so that there are multiple blank lines at the end of the file. This would result in an input data stream that looks like the following: cs 2101n5nANTER ZACHARY LinZAVALA ROGELIO RIn75.43 58.19 92.56 74.14 82.25 nnnin In either case, the last line of a text file can cause challenges, especially when the program uses a mix of extraction (>> and getline() operations. This is why the while-loop in the Read Accounts2.cpp file posted with this assignment contains the following condition: while( getline (inClientFile, name) &&name”) In English, this translates into “While it is possible to input a line of characters from the inClientFile input stream for the name variable, and that name isn’t the empty string In other words, a getline() operation may report success even though all it successfully input was an empty string! For this lab, that is not success, so the loop should terminate Note to Mac and Unix/Linux Users: The Mac and Unix OS use different end-of-line markers in their text files. Be sure to use a native text editor to open the data files I post and save them so that they will contain the native end-of-line markers used on your systems Show transcribed image text

Expert Answer


Attached . . .

OR
OR

Have a Comment on this Question?

Questions viewed by other students


  • QUESTION : (Solved) : 12 Product Les 10 B 780 C460 1150 50 2000 350 120 Small 4 10 Given Screenshot Suppose Smal Q35532817

    12 Product les 10 B 780 C460 1150 50 2000 350 120 SMALL(,4 10 Given the above screenshot, suppose -SMALL(C2:C6,4) is entered13 Review Later Suppose -IFERROR(5000/2,1000) 100 is entered into a cell. What is the resulting output of this formula? #NUM!14 According to the information mentioned in the course, which of the following color schemes is best practice forfinancial m15 Which of the following formulas correctly anchors ONLY the row in cell A1? F1$1 SA$1 SA1 A117 What is the correct syntax for the-YEARFRAC function? -YEARFRAC(basis,start_date,end_date) -YEARFRAC(start_date,end_date.[18 The result of # ROUND(513.2413,2) is19 B C 1 Time Periods 5142017 u Dats DATE YEAR SCS1)+G1,12,31) aiven the sovw scershnt 12/31/2021 12/31/2019 12/31/2020 9/30/20 1 Assets 2 Cash 3 Accounts Receivable 5 Current Assets 6 Property& Equipment 7 Goodwill 8 Total Assets 67,971 5,100 7.805

    We were unable to transcribe this image12 Product les 10 B 780 C460 1150 50 2000 350 120 SMALL(,4 10 Given the above screenshot, suppose -SMALL(C2:C6,4) is entered into cell C9. What output will result from this formula? 2000 780 50 #NUMI 13 Review Later Suppose -IFERROR(5000/2,1000) 100 is entered into a cell. What is the resulting output of this formula? #NUM! 1100 #VALUE! 2600 14 According to the information mentioned in the course, which of the following color schemes is best practice forfinancial modeling? Hard Codes in Blue, Formulas in Black Hard Codes in Black, Formulas in Blue Hard Codes in Black, Hard Codes in Red Hard Codes in Red, Formulas in Black 15 Which of the following formulas correctly anchors ONLY the row in cell A1? F1$1 SA$1 SA1 A1 We were unable to transcribe this image17 What is the correct syntax for the-YEARFRAC function? -YEARFRAC(basis,start_date,end_date) -YEARFRAC(start_date,end_date.[basis]) YEARFRAC(start date) YEARFRAC(end date,start date) 18 The result of # ROUND(513.2413,2) is 19 B C 1 Time Periods 5142017 u Dats DATE YEAR SCS1)+G1,12,31) aiven the sovw scershnt 12/31/2021 12/31/2019 12/31/2020 9/30/2017 20 1 Assets 2 Cash 3 Accounts Receivable 5 Current Assets 6 Property& Equipment 7 Goodwill 8 Total Assets 67,971 5,100 7.805 80,876 45,500 20,000 146,376 10 Liabilities 1 Short Term Debt 12 Accounts Payable 13 Current Liabilities 14 Long Term Debt 5 Total Liabilities 6 Shareholder’s Equity 7 Equity Capital 18 Retained Earnings 19 Shareholder’sE 20 Total Liabilities & Shareholders E 21 3,902 3,902 50,000 53,902 70,000 2,474 72,474 126,376 -IF 08-D20 OK) 23 24 Given the above screenshot, what is the resulting value in cell D22? TRUE OK FALSE ERROR Show transcribed image text
    12 Product les 10 B 780 C460 1150 50 2000 350 120 SMALL(,4 10 Given the above screenshot, suppose -SMALL(C2:C6,4) is entered into cell C9. What output will result from this formula? 2000 780 50 #NUMI
    13 Review Later Suppose -IFERROR(5000/2,1000) 100 is entered into a cell. What is the resulting output of this formula? #NUM! 1100 #VALUE! 2600
    14 According to the information mentioned in the course, which of the following color schemes is best practice forfinancial modeling? Hard Codes in Blue, Formulas in Black Hard Codes in Black, Formulas in Blue Hard Codes in Black, Hard Codes in Red Hard Codes in Red, Formulas in Black
    15 Which of the following formulas correctly anchors ONLY the row in cell A1? F1$1 SA$1 SA1 A1

    17 What is the correct syntax for the-YEARFRAC function? -YEARFRAC(basis,start_date,end_date) -YEARFRAC(start_date,end_date.[basis]) YEARFRAC(start date) YEARFRAC(end date,start date)
    18 The result of # ROUND(513.2413,2) is
    19 B C 1 Time Periods 5142017 u Dats DATE YEAR SCS1)+G1,12,31) aiven the sovw scershnt 12/31/2021 12/31/2019 12/31/2020 9/30/2017
    20 1 Assets 2 Cash 3 Accounts Receivable 5 Current Assets 6 Property& Equipment 7 Goodwill 8 Total Assets 67,971 5,100 7.805 80,876 45,500 20,000 146,376 10 Liabilities 1 Short Term Debt 12 Accounts Payable 13 Current Liabilities 14 Long Term Debt 5 Total Liabilities 6 Shareholder’s Equity 7 Equity Capital 18 Retained Earnings 19 Shareholder’sE 20 Total Liabilities & Shareholders E 21 3,902 3,902 50,000 53,902 70,000 2,474 72,474 126,376 -IF 08-D20 OK) 23 24 Given the above screenshot, what is the resulting value in cell D22? TRUE OK FALSE ERROR

    Expert Answer


    Attached . . .


    view full answer
  • QUESTION : (Solved) : 12 Provide Parent Map Returned Dfs Following Graph 13 Following Table Result Dfs Max Graph Q26122487

    12)Provide the parent-map returned by a DFS of the following graph 13) The following table is the result of DFS(Max) on the graph given below using a random ordering to insert the items on the stack. Draw the resulting DFS tree. Max Max Ben Jen Jen en Amy Tim Jen 14)What is the resulting table for DFSJen) on the graph from question 13. Use any ordering to insert the items on the stack. Provide: . The resulting table . The resulting DFS tree

    12)Provide the parent-map returned by a DFS of the following graph 13) The following table is the result of DFS(Max) on the graph given below using a random ordering to insert the items on the stack. Draw the resulting DFS tree. Max Max Ben Jen Jen en Amy Tim Jen 14)What is the resulting table for DFSJen) on the graph from question 13. Use any ordering to insert the items on the stack. Provide: . The resulting table . The resulting DFS tree Show transcribed image text 12)Provide the parent-map returned by a DFS of the following graph 13) The following table is the result of DFS(Max) on the graph given below using a random ordering to insert the items on the stack. Draw the resulting DFS tree. Max Max Ben Jen Jen en Amy Tim Jen 14)What is the resulting table for DFSJen) on the graph from question 13. Use any ordering to insert the items on the stack. Provide: . The resulting table . The resulting DFS tree

    Expert Answer


    Attached . . .


    view full answer
  • QUESTION : (Solved) : 12 Pts J Isp Granted Block Ip Addresses Containing Addresses 241263 13 Isp Grant Customers Q25077153

    Ipv4 addressing and subnetting
    12. IS pts-J An ISP is granted the block of IP addresses containing the addresses: 24.12.6.3/13. The ISP does not grant its customers more than 2 valid host addresses a. Find the subnet mask that needs to be uscd in both binary and dotted decimal notation. h. Find the first valid address in the 23rd customer network. c. Find the first valid address in the 83rd customer network d. Find the last valid address in the 90th customer network e- Find the last valid address in the last customer network.12. IS pts-J An ISP is granted the block of IP addresses containing the addresses: 24.12.6.3/13. The ISP does not grant its customers more than 2 valid host addresses a. Find the subnet mask that needs to be uscd in both binary and dotted decimal notation. h. Find the first valid address in the 23rd customer network. c. Find the first valid address in the 83rd customer network d. Find the last valid address in the 90th customer network e- Find the last valid address in the last customer network. Show transcribed image text 12. IS pts-J An ISP is granted the block of IP addresses containing the addresses: 24.12.6.3/13. The ISP does not grant its customers more than 2 valid host addresses a. Find the subnet mask that needs to be uscd in both binary and dotted decimal notation. h. Find the first valid address in the 23rd customer network. c. Find the first valid address in the 83rd customer network d. Find the last valid address in the 90th customer network e- Find the last valid address in the last customer network.

    Expert Answer


    Attached . . .


    view full answer
  • QUESTION : (Solved) : 12 Pts Show Pipeline Timing Diagram One Iteration Loop Using Classic Five Stage Mips Archi Q25111378

    (12 pts) Show the pipeline timing diagram for one iteration of the loop using the classic five-stage MIPS Architecture. For all parts, assume that register read and register write can be done in the same clock cycle and branches are resolved in EX stage(i.e, the branch target address will be known at the end of EX stage and the target instruction can be fetched in the next clock cycle). There is no branch prediction mechanism employed 8. loop: lw s1, 0 (s2) addi sl, s1 SW addi s2, s2 sub bne 1, 0(s2) s4, s3, s s4, zero, loop (6 pts) Show the pipeline timing diagram of this instruction sequence assuming forwarding is not supported by the architecture a. Clock Cycle→ | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10| 11 | 12:13 | 14| 15| 16 | 17/ 18 addi sl, sl, 1 sl, 0 (s2) addi s2, s2, 4 SW sub s4, s3, s2 bne s4, zero,loop s1, 0 (s2) b. (6 pts) Do the same work in part (a) assuming forwarding is fully supported by the architecture lw addi SW addi sub bne s4, zero,loop lw sl, sl,1 s1, 0 (s2) s2, s2, 4 s4, s3, s2 s1, 0(s2)

    (12 pts) Show the pipeline timing diagram for one iteration of the loop using the classic five-stage MIPS Architecture. For all parts, assume that register read and register write can be done in the same clock cycle and branches are resolved in EX stage(i.e, the branch target address will be known at the end of EX stage and the target instruction can be fetched in the next clock cycle). There is no branch prediction mechanism employed 8. loop: lw s1, 0 (s2) addi sl, s1 SW addi s2, s2 sub bne 1, 0(s2) s4, s3, s s4, zero, loop (6 pts) Show the pipeline timing diagram of this instruction sequence assuming forwarding is not supported by the architecture a. Clock Cycle→ | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10| 11 | 12:13 | 14| 15| 16 | 17/ 18 addi sl, sl, 1 sl, 0 (s2) addi s2, s2, 4 SW sub s4, s3, s2 bne s4, zero,loop s1, 0 (s2) b. (6 pts) Do the same work in part (a) assuming forwarding is fully supported by the architecture lw addi SW addi sub bne s4, zero,loop lw sl, sl,1 s1, 0 (s2) s2, s2, 4 s4, s3, s2 s1, 0(s2) Show transcribed image text

    Expert Answer


    Attached . . .


    view full answer