” 辅导EEET2394程序、 写作VR Sensor程序、c/c++,Python,Java程序EEET2394 Laboratory 2 VR Sensor Signal ProcessingPage 2 of 6To get started, download the project template from the subject Canvas website. The project template(provided as a single .zip archive) contains code stubs together with example test routines for each ofthe assembly programming tasks described below. You will complete these code stubs and must thenarchive (.zip) and submit your project directory for assessment.3 Loops and conditionals (Linear search)The project template contains two files: min.asm and max.asm. Each file contains a code stubdefining a procedure to compute the minimum and maximum, respectively, of an array of signed 32-bit integers of arbitrary length. Your task is to complete each of these code stubs to return theminimum and maximum value using a linear search of the supplied array. Your implementation ofeach of these procedures must satisfy the following constraints:1. The array of integers is stored in memory in a contiguous range of addresses. When eachprocedure (min or max) is called, the starting address of the array will be stored in a0 andthe number of integers in the array will be stored in a1.2. Each procedure should return the index of its target (i.e., the minimum or maximum value) ina0.3. Each procedure should end with a ret pseudo-instruction.Note: The returned value should be the element index, not an addresses or byte offset.Do not rename the files (min.asm and max.asm) or change the name of the procedures (min andmax) defined in the supplied code stubs.To test your solution in RARS, you may use the example test routines tstmin.asm andtstmax.asm, provided in the tests directory.Discussion questions: Evaluate the computational cost of your solution, in terms of the number ofinstructions executed. How does this vary with the length of the supplied array?Hint: You can use RARS to confirm your estimate of the number of instructions executed using theInstruction Counter, located under the Tools menu or by using the ic command line argument.4 Procedure calls (Quicksort)The cost of many operations that involve linear search can be significantly reduced by first sortingthe array to be searched. Consider the case of finding the minimum and maximum: for a sorted arrayno search is required (the minimum and maximum are simply the first and last elements in the array).Searching for an arbitrary value in an array is another example which can benefit significantly fromsorting of the array before searching, especially if many searches for different values, are required.The project template contains an additional file: quicksort.asm. This file contains a code stubdefining a procedure to sort an array of signed 32-bit integers of arbitrary length into ascending order.Your task is to complete this code stub to sort the supplied array using the Quicksort algorithm [4].Your implementation of the sort procedure must satisfy the following constraints:1. The array of integers is stored in memory in a contiguous range of addresses. When the sortprocedure is called, the starting address of the array will be stored in a0 and the elementindices of the start and end of the region to be sorted will be stored in a1 and a2, respectively.2. The sort procedure should modify the array in place, and does not need to return any value.3. The sort procedure should end with a ret pseudo-instruction.EEET2394 Laboratory 2 VR Sensor Signal ProcessingPage 3 of 6algorithm sort(A, lo, hi) isif lo hi thenp := partition(A, lo, hi)sort(A, lo, p – 1)sort(A, p + 1, hi)algorithm partition(A, lo, hi) ispivot := A[hi]i := lofor j := lo to hi doif A[j] pivot thenswap A[i] with A[j]i := i + 1swap A[i] with A[hi]return iFig. 1. The Quicksort algorithm [4].Hint: your implementation of the sort procedure should be recursive (see Fig. 1) and make use ofthe partition procedure defined in the code stub.Do not rename the file (sort.asm) or change the name of the procedure (sort) defined in thesupplied code stub.To test your solution in RARS, you may use the example test routine tstsort.asm provided inthe tests directory.Discussion questions: Evaluate the computational cost or your solution, in terms of the number ofinstructions executed. How does this vary with the length of the supplied array? Can you reduce thiscost?5 Constraints of the RV32I ISA (Binary search)The file search.asm in the project template contains a code stub defining a procedure to search asorted array of unsigned 32-bit integers. Your task is to complete this code stub to search the suppliedarray using a binary search algorithm [5]. Your implementation of the search procedure mustsatisfy the following constraints:1. The array of integers is stored in memory in a contiguous range of addresses. When thesearch procedure is called, the starting address of the array will be stored in a0 and thenumber of integers in the array (constrained to be a power of 2) will be stored in a1. Thetarget of the search will be stored in a2.2. If the target is found in the array, the search procedure should return the index of the target ina0. If the target is not found in the array, a0 should be set to a value of -1.3. The search procedure should end with a ret pseudo-instruction.The binary search algorithm (Fig. 5) is also known as the half-interval search algorithm. It firstcompares the target with the middle element of the array. Based on this comparison half of the sortedarray is eliminated, and the search proceeds on the remaining half, again comparing the target withthe middle value (of the remaining half). Binary search is therefore based on division, by 2 to halvethe search interval after each step. In the RV32I ISA, this division must be achieved by use of a rightshiftinstruction (e.g., srai). To facilitate this division, and to simplify implementation of the binarysearch algorithm, here the length of the array is assumed (or rather constrained) to be a power of 2.EEET2394 Laboratory 2 VR Sensor Signal ProcessingPage 4 of 6function binary_search(A, n, T) isL := 0R := n 1while L R dom := L + ((R – L) 2)if A[m] T thenL := m + 1else if A[m] T thenR := m 1else:return mreturn unsuccessfulFig. 2. The binary search algorithm [4].Do not rename the file (search.asm) or change the name of the procedure (search) defined inthe supplied code stub.To test your solution in RARS, you may use the example test routine tstsearch.asm provided inthe tests directory.Discussion questions: As noted above, here the length of the array to be search is constrained to bea power of 2. How could this constraint be relaxed?6 Challenge taskIn the search procedure implemented above, the length of the array to be searched was constrainedto be a power of 2. In this Challenge Task, your task is to modify your implementation of the searchprocedure to accept (and search) arrays of arbitrary length.7 Assessment ProcessOnce you have Completed (and tested) the code stubs described above (min.asm, max.asm,sort.asm and search.asm) archive the entire project directory into a single .zip archive andsubmit this archive via the subject Canvas website. Failure to submit your code archive will incur a30% penalty.Your completed code stubs will be assembled and linked with a set of test routines designed to testtheir functionality using the RISC-V Assembler and Runtime Simulator (RARS) version 1.5 [3].These test routines are similar but not identical to those provided in the project template. The testroutines provided in the project template are intended to serve as examples for testing your code.They provide only minimal testing of your code. You are encouraged to consider different scenariosand challenging edge Cases, and to create any additional testing or debugging routines to test thosecases.Once you have completed the assessable tasks please prepare a short demonstration so the LaboratoryDemonstrator can Evaluate your solution. You should be able to step through any of your code inRARS, and to predict how the register or memory contents will change before executing eachinstruction.You should arrange To demonstrate your code before the end of your laboratory session in Week 3.如有需要,请加QQ:99515681 或邮箱:99515681@qq.com
“
添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导。