Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

CSCE611: Advanced Digital Design

Fixed-Point RISCV Square Root

Due: Sunday, Sept. 10 2023

Instructions

Objective

ln this lab you will write a Rlscv assembly language program that reads a 32-bit signed integer input value from the console, interprets this as an unsigned 32-bit value with 14 fractional bits, computes its square root, and prints the output value to the console as a signed 32-bit value with 14 fractional bits.

Value conversions

lf the value entered by the user is named input-raw, then the actual input value, named input-actual is computed as:

(1) if 131072 < input-actual <= 0, then:

1 input- raw = floor(input-actual *  2Λ14)

(2) if 262144 < input-actual <= 131072, then:

1 input- raw = floor(-(2Λ32  - (input-actual *  2Λ14)))

For example:

.  if input-actual = 3.75 then input-raw = floor(3.75 * 16384)= 61440

.  if input-actual = 150000, then input-raw = -1837367296

lnternally your code must treat the input value as an unsigned fixed-point value with 14 fractional bits and 18 non-fractional bits.

Thus, if the value printed is named output-raw, then the actual output value, named output-actual is computed as:

(1)2147483648 < output-raw <= 0, then:

1 output-actual = output- raw / 14

(2) -2147483648 < output-raw <= -1, then:

1 output-actual =   (2Λ32  + output- raw /  2Λ14

Note that if your code is working properly, it should always produce an actual output value that is less than sqrt(262144)= 512, which corresponds to an raw output value of 8388608 (i.e. the raw output should never be negative).

Your code should produce the following outputs for the example inputs shown in the table below.

Your code should run in the RARs simulator.

Additional considerations

.  please do not print prompts or other messages from your program; only the raw result value.

.  we recommend you use an initial guess of 0 and an initial step of 256 (as an actual value). Also,  note that comparing the x2 value (square of the guess)as a (32,14)value as opposed to a (64,28) value will cause a loss in accuracy, but you will not be penalized for this.

Deliverables

.  submit your Rlscv program as a single Ascll text file with name“sqrt.asm”.

.  Each group only needs to submit once via either partner.

Rubric

.    (A) 10 points - reads input value.

.    (B) 10 points - squares and shiis guess.

.    (c) 20 points - compares guess with input value with outcomes to <, >, and ==.

.    (D) 20 points - adds or subtracts guess.

.    (E) 10 points -shiis step.

.    (F) 20 points - loops until step becomes 0.

.    (G) 10 points - prints final guess.

Maximum score: 100 points.