[SOLVED] CS代考 CSE30: Computer Organization and Systems, Winter 2022 Instructors: and

30 $

File Name: CS代考_CSE30:_Computer_Organization_and_Systems,_Winter_2022_Instructors:___and.zip
File Size: 763.02 KB

5/5 - (1 vote)

Assignment 6: Floating Point
CSE30: Computer Organization and Systems, Winter 2022 Instructors: and
Due: Wednesday February 23, 2022 @ 11:59 PM
Please read over the entire assignment before starting to get a sense of what you will need to get done in the next week. REMEMBER: Everyone procrastinates but it is important to know that you are procrastinating and still leave yourself enough time to finish. Start early, start often. You MUST run the assignment on the pi-cluster. You HAVE to SSH: You will not be able to compile or run the assignment otherwise.

Copyright By PowCoder代写加微信 assignmentchef

ACADEMIC INTEGRITY REMINDER: you should do this assignment entirely on your own with help only from course staff. Consulting with other students (past or present) who are not in the course may result in an academic integrity violation which can have serious consequences.
Please read the FAQ and search the existing questions on Edstem before asking for help. This reduces the load on the teaching staff, and clutter/duplicate questions on Edstem. Additionally, staff support is not guaranteed to be available after 9pm on Wednesdays.
Table of Contents
1. Learning Goals
2. Assignment Overview
3. Getting Started
a. Developing Your Program
b. Running Your Program
4. How the Program Works
5. Submission and Grading
a. Submitting
b. Grading Breakdown [25 pts]
Learning Goals
● Programming in ARM assembly
● Working with floating point numbers
● Coordinating a program with both ARM assembly and C code (you aren’t writing in C)

Assignment Overview
So far, the lionesses of the Pride Lands have been using a 14-bit floating-point format to communicate important information to Mufasa. However, with the sudden death of Mufasa, Scar has taken the throne, and he demands more and more precise information about the status of the Pride Lands. The lionesses need to switch all their numbers from this 14-bit format to the standardized IEEE 754 format. Help them write and test code to convert all their old data into IEEE format.
A note about representing number literals
In the number 7’b101_0011:
● 7isthenumberofbinarybitsinthisnumber,inbase-10.
● bmeansbinary.Otherformatsaredfordecimal,oforoctal,andhforhexadecimal. ● _isaspacercharacterthatisonlytheretomakeiteasiertoread.Ithasnonumerical
meaning. A ‘_’ is usually placed every four digits.
You can read more about where this number literal representation comes from here. (Note: Anything past the first slide is irrelevant to this course, but will be useful in CSE140 & 141.)
The 14-bit FP Format
The 14-bit floating-point format is similar to, but not the same as, the one we studied in class. It has a sign bit, 6 bits of biased exponent, a bias value of 31 (base-10), and 7 bits of mantissa.

The following figure illustrates the bit assignments:
Points to note:
1. There is an implied “1.” in front of the mantissa, unless it is a denormal number.
2. Denormal numbers have “0.” in front of the mantissa, and an exponent field of
6’b000000 which represents 2−30.
3. “Infinite” numbers have an exponent field equal to 6’b111111 with any value in the
The following table shows how to interpret the exponent fields and mantissa fields.
sign (1 bit)
(6 bits, bias = 31)
mantissa (7 bits)
Exponent/mantissa
represents
111111/mmmmmmm
2^32 x 1.mmmmmmm
111110/mmmmmmm
2^31 x 1.mmmmmmm
normal number
111100/mmmmmmm
2^29 x 1.mmmmmmm
normal number
111000/mmmmmmm
2^25 x 1.mmmmmmm
normal number
110000/mmmmmmm
2^17 x 1.mmmmmmm
normal number
100000/mmmmmmm
2^1 x 1.mmmmmmm
normal number
011111/mmmmmmm
2^0 x 1.mmmmmmm
normal number
001111/mmmmmmm
2^-16 x 1.mmmmmmm
normal number
000111/mmmmmmm
2^-24 x 1.mmmmmmm
normal number
000011/mmmmmmm
2^-28 x 1.mmmmmmm
normal number
000001/mmmmmm
2^-30 x 1.mmmmmmm
normal number
000000/mmmmmmm
2^-30 x 0.mmmmmmm
denormal number (no leading 1)

Encoding in 14-bits
14’b00_0000_0000_0000 (14 bits of 0 in binary)
14’b10_0000_0000_0000
14-Bit Representation
Binary Representation
Base-10 Representation
01_1111_1xxx_xxxx
11_1111_1xxx_xxxx
Most positive #
01_1111_0111_1111
2^31 * 8’b1.1111111
4278190080
Smallest positive #
00_0000_0000_0001
2^-30 * 8’b0.0000001
2^-37 ≅ 7.275957614e−12
Most negative #
11_1111_0111_1111
-2^31 * 8’b1.1111111
-4278190080
Smallest negative #
10_0000_0000_0001
-2^-30 * 8’b0.0000001
-2^-37 ≅ -7.275957614e-12
IEEE-754 Single Precision Format
exponent (8)
mantissa (23)
The bias for the IEEE Format is 127 (base-10) and the format uses an implied 1 for normal numbers, as usual. The smallest representable exponent is -126 which is represented by 8’b0000_0001 for normal numbers, and 8’b0000_0000 for denormal numbers. The latter exponent code, which is for denormals, is not used by our program except when representing ±0.
In IEEE single precision, any exponent of all 1’s (8’b1111_1111) represents a number too large to represent. For example, 0xff80_0000 is a number with a negative sign bit, all 1’s for
the exponent and all 0’s for the mantissa. This represents negative infinity (-Inf). Similarly, 0x7f80_0000 represents positive infinity (+Inf). Note that the mantissa bits are all 0. Non-0 mantissa bits represent another kind of IEEE special number (NaN, “not a number”) which is not used in this assignment.

Summary of Select Conversions
IEEE-754 Single
00_0000_0000_0000
0x00000000
10_0000_0000_0000
0x80000000
00_0000_0000_0001
0x2d000000
10_0000_0000_0001
0xad000000
4278190080
01_1111_0111_1111
0x4f7f0000
-4278190080
11_1111_0111_1111
0xcf7f0000
01_1111_1xxx_xxxx
0x7f800000
11_1111_1xxx_xxxx
0xff800000
Getting Started
Developing Your Program
For this class, you MUST compile and run your programs on the pi-cluster. To access the server, you will need your cs30wi22xx student account, and know how to SSH into the cluster.
Need help or instructions? See the Edstem FAQ. (Do NOT wait until the end to try this. There will be limited or no ETS support on the weekends!)
We’ve provided you with the starter code at the following link:
https://github.com/cse30-wi22/A6-starter
1. Download the files in the repository. a. You can either use
git clone https://github.com/cse30-wi22/A6-starter.git directly from pi-cluster, or download the repo locally and scp the folder to pi-cluster if that doesn’t work.
2. Fill out the fields in the README before turning in.

Running Your Program
We’ve provided you with a Makefile so compiling your program should be easy!
Additionally, we’ve placed the reference solution binary at:
/home/linux/ieng6/cs30wi22/public/bin/fpconvert-a6-ref
You can directly use fpconvert-a6-ref as a command.
Makefile: The Makefile provided will create a fpconvert executable from the source files provided. Compile it by typing make into the terminal. By default, it will run with warnings turned on. To compile without warnings, run make WARN= instead. Run make clean to remove files generated by make.
How the Program Works
Your program will take a filename as an argument and read it in. This file is a raw binary file containing just bytes of data. For each 14-bit binary FP number in the file, the program will decode those 14 bits, convert it into IEEE floating point format, and print it.
Generating a binary file
To create this binary file, you will need to generate it using makebin, a separate executable that is created by running make makebin. (It would be difficult to create a binary file by hand.) Once you have makebin, you can give it an input file and an output filename to write the resulting binary to. The input file should contain the numbers you want to test, as regular text in hexadecimal format. The output file will be the binary file.
Example text input file, named somehexnums.txt:
Example of using makebin with the above text input file: ./makebin somehexnums.txt somehexnums.bin
This would generate a binary file named somehexnums.bin. If you try to edit it, you will see a bunch of gibberish, as it’s a binary file.

Running the main program
Now that you have the binary file, you can pass it into your main floating-point conversion program. For example,
./fpconvert somehexnums.bin
would read in the file somehexnums.bin, convert each 14-bit chunk to a floating point number, and print those numbers as decimal values to stdout. You can assume that a valid binary file is used and there won’t be other arguments given.
Input Guarantees
● The binary file will be valid and only contain a sequence of 14-bit-wide numbers.
● The binary file will not be empty.
● As registers are all 32-bits wide, and our 14-bit floating point format only occupies the
least significant 14 bits, the upper 18 bits of the input will be padded with 0’s.
Program Implementation Files to Edit
You should only edit the file fpconvert.s.
Functions to Implement
You will need to implement two functions within fpconvert.s:
● fpconvert(n):Thisisthefunctionthatwilldomostofthefloating-pointconversion. This function takes one argument, the value to convert.
● convert_infinity(n):Iftheargumenttofpconvertis±infinity,youshouldcall this function to do the conversion instead. This function takes one argument, the value to convert, which should only be the 14-bit format’s positive or negative infinity.
Calling a Function in ARM
To call a function in ARM, you must use the bl “branch and link” instruction. It is not sufficient or correct to use a regular branch instruction. Without branch-and-link, the return operations in the epilogue of the function will not work and return as expected.

Developing Your Code
Development Process
To make development easier, you should first implement the conversion of normal numbers. Test your code on a range of normal numbers (smallest, largest). For the smallest numbers, you should familiarize yourself with their scientific notation representations. You can also check the IEEE column of the output to see if it matches the expected IEEE version. Additionally, be sure to check the special cases of +0.0, -0.0, +Inf, and -Inf.
After thoroughly testing the functionality of your code, you should consider denormal numbers. Denormal numbers are represented when the exponent field is 6’b000000.
After implementing the conversion of denormal numbers, your code should be able to produce all of the values in the Summary of Select Conversions table.
Development Tips
Before you write assembly code, think about the algorithm.
● How are the 14-bit format and the 32-bit IEEE format similar and different?
● How do I break down the 14-bit format into the 3 individual fields?
● How does each field convert from the 14-bit format to the 32-bit IEEE format?
You should find the bitwise instructions useful for this assignment. In particular, you will want to make use of bitmasks.
While an immediate can only be 8 bits wide, you can use left and right shifts to move the mask into the right position. For example, if you need the bitmask 0xFF00, you can shift the immediate 0xFF left by 8 bits.
Debugging Tips
The public autograder will only printf test some features. DO NOT RELY ON THE AUTOGRADER. (Many CSE30 students have been burned by this.) Test your code using your own test cases!

GDB can only recognize ARM assembly labels that begin with the prefix “.L”. If you want to use GDB to debug your ARM code, you will need to prefix your labels with “.L”. Thus, ARM
code for the given C if statement would look like the code snippet on the right, rather than the snippet on the left.
if (r5 == 99) { r3 = r3 + 2;
r3 = r3 + 3;
r4 = r4 – 1;
GDB will not recognize labels:
GDB will recognize labels:
cmp r5, 99 bne else
add r3, r3, 2 b end_if
add r3, r3, 3
sub r4, r4, 1
cmp r5, 99 bne .Lelse add r3, r3, 2 b .Lend_if
add r3, r3, 3
sub r4, r4, 1
Allowed ARM Instructions
You are only allowed to use the instructions provided in the ARM ISA Green Card. Failure to comply will result in a score of 0 on the assignment.
Style Requirements
Points WILL be given for style, and teaching staff won’t be able to provide assistance or
regrades unless code is readable. Please follow these Style Guidelines for ARM assembly. Midpoint
This part of the assignment is due earlier than the full assignment, on Sunday 2/20 at 11:59 pm PST. There are no late submissions on the Midpoint.
Complete the Gradescope assignment “A6: Midpoint”, an Online Assignment that is done entirely through Gradescope. This assignment consists of a few quiz questions and a free-response question where you will document your pseudocode or the algorithm in plain

English. This is a planning document and does not need to reflect your final implementation, although you are encouraged to keep it up to date.
Discuss your implementations of the following functions: fpconvert and convert_infinity. Your fpconvert should call convert_infinity when appropriate.
Submission and Grading
Submitting
1. Submit your files to Gradescope under the assignment titled “A6: Floating Point”. You will
submit the following files:
fpconvert.s
You can upload multiple files to Gradescope by holding CTRL (⌘ on a Mac) while you are clicking the files. You can also hold SHIFT to select all files between a start point and an endpoint.
Alternatively, you can place all files in a folder and upload the folder to the assignment. Gradescope will upload all files in the folder. You can also zip all of the files and upload the .zip to the assignment. Ensure that the files you submit are not in a nested folder.
2. After submitting, the autograder will run a few tests:
a. Check that all required files were submitted.
b. Check that fpconvert.s compiles.
c. Runs some sanity tests on the resulting fpconvert executable.
Grading Breakdown [5 + 5 + 40 points]
Make sure to check the autograder output after submitting! We will be running additional tests after the deadline passes to determine your final grade. Also, throughout this course, make sure to write your own test cases. It is bad practice to rely on the minimal public autograder tests as this is an insufficient test of your program.
To encourage you to write your own tests, we are not providing any public tests that have not already been detailed in this writeup.
The assignment will be graded out of 50 points and will be allocated as follows:
● Midpoint writeup: 5 points. This part of the assignment is due earlier than the full assignment, on Sunday 2/13 at 11:59 pm PST. Complete the Gradescope assignment “A6: Midpoint”.

● Style: 5 points.
● No warnings when compiling: 1 point.
● Public tests with the provided examples.
● Private tests with hidden test cases.
NOTE: The tests expect an EXACT output match with the reference binary. There will be NO partial credit for any differences in the output. Test your code – do NOT rely on the autograder for program validation (read this sentence again).
Make sure your assignment compiles correctly through the provided Makefile on the pi-cluster without warnings. Any assignment that does not compile will receive 0 credit.
Checking For Exact Output Match
A common technique is to redirect the outputs to files and compare against the reference solution1:
./your-program args > output; our-reference args > ref
diff -s output ref
This command will output lines that differ with a < or > in front to tell which file the line came
[Optional] Bells and Whistles2 (epsilon points)
Write a new function add_fp(a, b) that takes in 2 numbers a and b that are in the 14-bit floating point format. It should add these 2 numbers together and return the value. However, what makes this complicated is that a and b may not have the same exponent! You’ll need to make the exponents the same first before you can add them.
This part of the assignment will NOT be graded – and does not need to be submitted. It is completely up to you to try writing a program which achieves the above output.
The Bells and Whistles component may be submitted to a separate Gradescope assignment: A6 Optional: Bells and Whistles.
1 You might want to check out vimdiff on the pi-cluster (https://www.tutorialspoint.com/vim/vim_diff.htm). 2 In our experience, students like extra credit. However, we find that extra credit isn’t used by students who need it the most. Thus, we have an extra credit where the number of points assigned is epsilon, where epsilon is a very small number [0, 1).

程序代写 CS代考加微信: assignmentchef QQ: 1823890830 Email: [email protected]

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CS代考 CSE30: Computer Organization and Systems, Winter 2022 Instructors: and
30 $