12/15/2020 : Quiz Submissions - Midterm - ECED3204 - Microprocessors (Sec 1) - 2020 Fall - Dalhousie University https://dal.brightspace.com/d2l/lms/quizzing/user/quiz_submissions_attempt.d2l?isprv=&qi=73467&ai=2206011&isInPopup=0&cfql=0&fromQB=0&ou… 1/11 Quiz Submissions - Midterm Derrick Yin (username: yc907275) Attempt 1 Written: Oct 30, 2020 3:10 PM - Oct 30, 2020 4:48 PM Submission View Microcontroller program debugging Question 1 0 / 1 point Your friend has just been hired to design a traffic light controller for the city of Halifax using an ATmega328P microcontroller. Unfortunately, your friend is not an electrical engineer and is having trouble programming the traffic light controller. The first thing your friend has to do is get the lights to turn on independently. Your friend complains that they can not get the lights to properly turn on, and shows you their code: Your quiz has been submitted successfully. Answer all the 3 questions 12/15/2020 : Quiz Submissions - Midterm - ECED3204 - Microprocessors (Sec 1) - 2020 Fall - Dalhousie University https://dal.brightspace.com/d2l/lms/quizzing/user/quiz_submissions_attempt.d2l?isprv=&qi=73467&ai=2206011&isInPopup=0&cfql=0&fromQB=0&ou… 2/11 When one light turns on, the other lights must turn off. How would you edit your friend’s code to make each light work properly? void set_red_on() { PORTD = (1<
PORTD = (0< PORTD = (0<} void set_green_on() { 12/15/2020 : Quiz Submissions - Midterm - ECED3204 - Microprocessors (Sec 1) - 2020 Fall - Dalhousie University https://dal.brightspace.com/d2l/lms/quizzing/user/quiz_submissions_attempt.d2l?isprv=&qi=73467&ai=2206011&isInPopup=0&cfql=0&fromQB=0&ou… 3/11 The correct answer is not displayed for Written Response type questions. View Feedback Question 2 0.5 / 2 points a. Your friend tells you that the red light needs to be on for 15 seconds, then the green light has to be on for 10 seconds, and the yellow light has to be on for 5 seconds. They tried to use timers to do this but they think they made a mistake: the lights blink on and off too fast! They show you some of their main function and their interrupt service routine: PORTD = (0< PORTD = (1< PORTD = (0<} void set_yellow_on() { PORTD = (0< PORTD = (0< PORTD = (1<} 12/15/2020 : Quiz Submissions - Midterm - ECED3204 - Microprocessors (Sec 1) - 2020 Fall - Dalhousie University https://dal.brightspace.com/d2l/lms/quizzing/user/quiz_submissions_attempt.d2l?isprv=&qi=73467&ai=2206011&isInPopup=0&cfql=0&fromQB=0&ou… 4/11 Your friend says they are using a pre-scale of 64, and they have to use the output compare register because the overflow register is already being used by something else. How would you change their code so that their microcontroller properly counts to 30 and resets back to 0 when it reaches 30? b. Your friend is having trouble with the lights again: they all turn on but the timing isn’t correct. They show you a function they wrote to make the lights turn on one after the other using the function you helped them with earlier: How would you change this function so that the lights all turn on properly based on the time they are supposed to be on? a) Change OCR0A = 1, to OCR0A = 30 b) void manage_three_way_light(){ set_red_on(); _delay_ms(15000); set_green_on(); _delay_ms(10000); 12/15/2020 : Quiz Submissions - Midterm - ECED3204 - Microprocessors (Sec 1) - 2020 Fall - Dalhousie University https://dal.brightspace.com/d2l/lms/quizzing/user/quiz_submissions_attempt.d2l?isprv=&qi=73467&ai=2206011&isInPopup=0&cfql=0&fromQB=0&ou… 5/11 The correct answer is not displayed for Written Response type questions. View Feedback Question 3 1 / 1 point Your friend comes to you with another problem: they have connected their traffic light controller via USB to a computer so that the traffic monitor can gather some data. Once they did that, the pedestrian button stopped working! Why is this? The walk button is connected to PORT D1. The correct answer is not displayed for Written Response type questions. Question 4 4 / 4 points The following is a part of a C function that calculates the difference between two events on an input of an Atmega328P microcontroller. The start time is presented by 3 variables start_seconds, start_minutes and start_hours and the stop time is presented using also 3 variables: stop_seconds, stop_minutes and stop_hours. The difference between the two events is presented by 3 variable as well: hours, minutes and seconds. if (stop_seconds > start_seconds) { --start_minutes; //this is equivalent to start_minutes = statrt_minutes -1 start_seconds += 60; //this is equivalent to start_minutes = start_minutes + 60 seconds = start_seconds - stop_seconds; if (stop_minutes> start_minutes) { --start_hours; start_minutes += 60; minutes = start_minutes - stop_minutes; hours = start_hours - stop_hours; Supposing that you are required to create a "CVM" similar to the IJVM (shown below). set_yellow_on(); _delay_ms(5000); } (CPU frequency needs to define as 16000000UL) (that is : #define F_CPU 16000000UL) PORT D1 and USB data output port share the same data I/O stream. Therefore, USB connected traffic monitor used the data transfer source by default, and blocked any action on the pedestrain button that connected to PORT D1. 12/15/2020 : Quiz Submissions - Midterm - ECED3204 - Microprocessors (Sec 1) - 2020 Fall - Dalhousie University https://dal.brightspace.com/d2l/lms/quizzing/user/quiz_submissions_attempt.d2l?isprv=&qi=73467&ai=2206011&isInPopup=0&cfql=0&fromQB=0&ou… 6/11 What should the CVM Instruction Set include to exactly be able to interpret the above mentioned program? By "exactly" we mean that you should not include any instructions that are not necessary to execute this particular program. Consider all the variables local (Hint, some of your instructions would be a subset of IJVM, but you can also add some instructions that are not in the IJVM). The correct answer is not displayed for Written Response type questions. Question 5 3 / 4 points Using the IJVM instruction set given in the following table, write the corresponding Java assembly language of the following program: BIPUSH, ISTORE, ILOAD, IFLT, IADD, ISUB, 12/15/2020 : Quiz Submissions - Midterm - ECED3204 - Microprocessors (Sec 1) - 2020 Fall - Dalhousie University https://dal.brightspace.com/d2l/lms/quizzing/user/quiz_submissions_attempt.d2l?isprv=&qi=73467&ai=2206011&isInPopup=0&cfql=0&fromQB=0&ou… 7/11 While (B[i] != C[i]) //!= means not equal to A[i]= B[i] - C[i]; ISTORE A[i] ISTORE B[i] ISTORE C[i] ILOAD B[i] ILOAD C[i] IF_ICMPEQ L1 ILOAD B[i] ILOAD C[i] ISUB ISTORE A[i] 12/15/2020 : Quiz Submissions - Midterm - ECED3204 - Microprocessors (Sec 1) - 2020 Fall - Dalhousie University https://dal.brightspace.com/d2l/lms/quizzing/user/quiz_submissions_attempt.d2l?isprv=&qi=73467&ai=2206011&isInPopup=0&cfql=0&fromQB=0&ou… 8/11 The correct answer is not displayed for Written Response type questions. View Feedback Question 6 3 / 4 points Given a memory system of 1MByte main memory and 1KByte direct-mapped cache memory, with block and line size of 16 Bytes, answer the following questions: a. How many blocks are there in the main memory and in the cache memory? b. Show the format of the Memory Physical Address. c. If the CPU needs to access the memory at the address 0A123, which cache memory address will this be mapped to? The correct answer is not displayed for Written Response type questions. View Feedback Multiple choice questions Question 7 1 / 1 point a) MemoryBlock = MemorySize/BlockSize = 1048576/16 = 65536 blocks CacheBlock = CacheSize/BlockSize = 1024/16 = 64 blocks b) MS = 1048576 bytes = 2^20 bytes; PA=20 CS = 1024 bytes = 2^10 bytes; CA=10 BS = 16 bytes = 2^4 bytes; BO=4 Therefore, the format of the Memory Physical Address is: PhysicalAddress=20 = BO+CI+TB BlockOffset=4; CacheIndex=10-4=6; TagBits=20-10=10 c) This will be mapped to cache memory address: 100011 12/15/2020 : Quiz Submissions - Midterm - ECED3204 - Microprocessors (Sec 1) - 2020 Fall - Dalhousie University https://dal.brightspace.com/d2l/lms/quizzing/user/quiz_submissions_attempt.d2l?isprv=&qi=73467&ai=2206011&isInPopup=0&cfql=0&fromQB=0&ou… 9/11 Translation means Question 8 1 / 1 point Consider the operation of a machine with the data path of the following figure. Suppose that loading the ALU input registers takes 5 nsec, running the ALU takes 10 nsec, and storing the result back in the register scratchpad takes 5 nsec. What is the maximum number of Convert a document written in French to English Covert a document written in English to machine language replacing the instructions of an L1 program by L0 instructions and then executing the L0 program executing the instructions of L1 program one-by-one after replacing each one by its L0 equivalents 12/15/2020 : Quiz Submissions - Midterm - ECED3204 - Microprocessors (Sec 1) - 2020 Fall - Dalhousie University https://dal.brightspace.com/d2l/lms/quizzing/user/quiz_submissions_attempt.d2l?isprv=&qi=73467&ai=2206011&isInPopup=0&cfql=0&fromQB=0&o… 10/11 MIPS (Mega Instruction Per Second) this machine is capable of? Question 9 1 / 1 point Multicore chips, with multiple CPUs on the same die, are becoming popular. What advantages do they have over a system consisting of multiple PCs connected by Ethernet? Question 10 1 / 1 point What are the four steps (in order) CPUs use to execute an instruction? Attempt Score:77.5 % Overall Grade (highest attempt):77.5 % 60 50 20 40 In a multicore system, the cores can share caches and primary memory easily. There will be no cache misses in a multicore system. Communication among cores on the same chip is much faster than communication among PCs connected by Ethernet. The cores on the chip are using optic fibers to communicate among each other. Fetch instruction, execute, read data, write Fetch instruction, read data, execute, write Write, fetch instruction, read data, execute Read data, fetch instruction, execute, write 12/15/2020 : Quiz Submissions - Midterm - ECED3204 - Microprocessors (Sec 1) - 2020 Fall - Dalhousie University https://dal.brightspace.com/d2l/lms/quizzing/user/quiz_submissions_attempt.d2l?isprv=&qi=73467&ai=2206011&isInPopup=0&cfql=0&fromQB=0&o… 11/11 Done 欢迎咨询51作业君