Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3.0 Project Functionality 3.1 Overview We wish to perform Square Root calculation in MIPS, however there is no hardware support for square root. Most Square

3.0 Project Functionality 3.1 Overview We wish to perform Square Root calculation in MIPS, however there is no hardware support for square root. Most Square Root algorithms are iterative, meaning they converge to a value close to the desired output using multiple iterations of numeric refinement. Thus, complete the parts A, B, C of this design project in the order listed below to realize an IEEE754 Single-Precision Format Floating-Point Square Root function. Note: all float values are IEEE754 Single-Precision format in this project.

3.2 Part A: Write a callable/returning MIPS subroutine called HDE(x,y) You are tasked to write a callable/returning MIPS subroutine called HDE(x)which accepts a positive float x as the input parameter. It returns a float value equal to the Half Debiased Estimate for the square root of x.

Namely, HDE(x)=(De-biased Exponent of the floating point representation of x)/2 Here recall the IEEE754 stores values with Excess-127 bias format. So the above refers to the

value stored in the Exponent field with the bias removed, and then divided by two.

For example, HDE(125348ten) = 8ten since: 125348ten = 0100 0111 1111 0100 1101 0010 0000 0000 spfpbf

where spfpbf denotes single-precision floating-point binary format. Thus, the biased exponent is 10001111two = 143ten thus 143-127=16 (since spfpbf uses Excess-127 format for the Exponent field) thus 16/2=8ten.

However, the value returned by HDE must be a float, thus to complete part A of the project, it is necessary for you to write MIPS code to convert the value above, in this case 8ten, into single- precision floating-point binary format. You can achieve this readily by noting that intermally in MIPS the values are represented in fixed-point binary rather than decimal, unless specified to be float. Thus, you will need to develop a routine to convert:

0000 0000 0000 0000 0000 0000 0000 1000 two 

into

0100 0001 0000 0000 0000 0000 0000 0000 spfpbf which is the value returned for HDE(125348). A hint on this is to use a shift followed by mask to normalize the mantissa, then create the exponent using the cumulative shift amount without the hidden 1. All values used here will be positive.

Finally, since HDE(x)must be implemented as a subroutine function using jal/jr then all non- temporary registers used must be saved on to the stack upon entry to the HDE subroutine and restored prior to exit of the HDE subroutine.

For reference of the above steps to compute HDE(x,n), the below provides a concise mathematical description found conveniently at Wikipedia for estimating the square root of S) using an identical procedure:

image text in transcribed

Note during testing, it may be convenient to output your result to the console using print_float service code of syscall --- however please remove this debugging-aid output before beginning Part B.

3.3 Part B: Compute sqrt(x,n) You are tasked to write a callable/returning MIPS subroutine called sqrt(x,n)which accepts a positive float x as the input parameters x and n. It returns a float value for the square root of x using n iterations of the algorithm listed below, where initially S=n.

image text in transcribed

3.4 Part C: Make a calling loop in order to create Accuracy Error Plot

Make a plots depicting the error of function sqrt(x,n) above versus n for the following values: x = 5628765 with n={0, 1, 2, 3, 4 , 5, 6, 7} where MaxIter=7

Achieve Part C as follows for the submitted version: 1) Input x from the keyboard using read_float service code to syscall 2) Input MaxIter from the keyboard using read_float service code of syscall 3) For each value of n from 0 to MaxIter inclusive, output the value returned by your function

sqrt(x,n) on a separate line on the console.

Finally, after Part C completes execution, then manually paste yourself using mouse to highlight/copy/paste the values into Microsoft Excel and then subtract a highly accurate value for the square root of 5628765 which is 2372.501844045648, in order to create a plot of Error(sqrt(x,n)) on the y-axis versus the values of n on the x-axis.

3.5 Single Program Submission

For full credit, implement each of the three Parts A, B, C in a single MIPS program that can execute in MARS. To obtain credit the function sqrt(x,n) must use the method stated above, and accept arbitrary values of x and n, in other words it can compute square root not using hardcoded output values.

When working in the binary numeral system (as computers do internally), by expressing S as a 22n where 0.12

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro SQL Server Wait Statistics

Authors: Enrico Van De Laar

1st Edition

1484211391, 9781484211397

More Books

Students also viewed these Databases questions

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago