1. Homepage
  2. Programming
  3. CSE 30: Computer Organization and Systems - Assignment 6: Floating Point

CSE 30: Computer Organization and Systems - Assignment 6: Floating Point

Engage in a Conversation
UCSDCSE 30CSE30Computer Organization and SystemsFloating Point

Assignment 6: Floating Point CourseNana.COM

CSE 30: Computer Organization and Systems, Fall 2023
Due: Tuesday Nov 14, 2023 CourseNana.COM

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. CourseNana.COM

ACADEMIC INTEGRITY REMINDER: you should do this assignment on your own. If you work with others, be sure to cite them in your submission. Never copy from others. CourseNana.COM

Please read the FAQ and search the existing questions on Edstem before asking for help. CourseNana.COM

This reduces the load on the teaching staff, and clutter/duplicate questions on Edstem. CourseNana.COM

Version updates: CourseNana.COM

  • ●  1.0 [Nov 8] Final Draft CourseNana.COM

  • ●  1.1 [Nov 8] Fix midpoint due date Sunday -> Friday CourseNana.COM

  • ●  1.2 [Nov 9] Fix: somehexnums.txt 0x8000 to 0x4000 since it is 15 bit representation. CourseNana.COM

  • ●  1.3 [Nov 9] Clarify: style won’t be regraded during resubmission CourseNana.COM

  • ●  1.4 [Nov 10] Prerelease: Midpoint answers are visible before due date. CourseNana.COM

  • ●  1.5 [Nov 12] Fix git clone link, fix # of bits in mantissas in page 4 table to be 8 bits CourseNana.COM

    Table of Contents CourseNana.COM

  1. Learning Goals CourseNana.COM

  2. Assignment Overview CourseNana.COM

  3. Getting Started CourseNana.COM

  4. How the Program Works CourseNana.COM

  5. Program Implementation CourseNana.COM

    1. Functions to Implement CourseNana.COM

    2. Developing Your Code CourseNana.COM

    3. Testing Your Code CourseNana.COM

  6. Submission and Grading a. Submitting CourseNana.COM

b. Grading Breakdown [50 pts] CourseNana.COM

Learning Goals CourseNana.COM

  • ●  Programming in ARM assembly CourseNana.COM

  • ●  Working with floating point numbers CourseNana.COM

  • ●  Coordinating a program with both ARM assembly and C code (you aren’t writing in C) CourseNana.COM

    Assignment Overview CourseNana.COM

    At the peak of time where pirates and bounty hunters are in the air. Porco Rosso makes his rounds in the vast ocean to capture any air pirates that disturb the peace near Adriano hotel. CourseNana.COM

    On the radio, Porco Rosso tunes in to listen to his next job, however he discovers an issue. The coordinates given out are in 15-bit floating-point format. He doesn’t know how to convert from this format and only knows the standardized IEEE 754 format. Gina only has devices that are written in ARM so Porco plans to rely on your assembly skills to create the conversion function. Help him write and test code to convert the coordinates into IEEE format! CourseNana.COM

    A note about representing number literals CourseNana.COM

    In the number 8’b1101_0011: CourseNana.COM

  • ●  8isthenumberofbinarybitsinthisnumber,inbase-10. CourseNana.COM

  • ●  bmeansbinary.Otherformatsaredfordecimal,oforoctal,andhforhexadecimal. CourseNana.COM

  • ●  To conserve space, we may also write the bits in hexadecimal, 0xd3 is equivalent to CourseNana.COM

    8’b1101_0011. CourseNana.COM

_isaspacercharacterthatisonlytheretomakeiteasiertoread.Ithasnonumerical meaning. A '_' is usually placed every four digits. CourseNana.COM

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 CSE 140 & 141.) CourseNana.COM

The 15-bit FP Format CourseNana.COM

The 15-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 8 bits of mantissa. Note that we include special cases to represent infinities and subnormal numbers. CourseNana.COM

The following figure illustrates the bit assignments: CourseNana.COM

FP Format (15-bit) CourseNana.COM

sign (1 bit) CourseNana.COM

exponent
(6 bits, bias = 31)
CourseNana.COM

mantissa (8 bits) CourseNana.COM

Points to note: CourseNana.COM

  1. There is an implied “1.” in front of the mantissa, unless it is a subnormal number. CourseNana.COM

  2. Subnormal numbers have an exponent field of 6’b000000 which represents 2−30 and implies a “0.” in front of the mantissa. CourseNana.COM

  3. “Infinite” numbers have an exponent field equal to 6’b111111 with ANY value in the mantissa. CourseNana.COM

The following table shows how to interpret the exponent fields and mantissa fields. CourseNana.COM

Exponent/mantissa CourseNana.COM

represents CourseNana.COM

111111/mmmmmmm CourseNana.COM

infinity CourseNana.COM

infinity CourseNana.COM

111110/mmmmmmm CourseNana.COM

2^31 x 1.mmmmmmm CourseNana.COM

normal number CourseNana.COM

111100/mmmmmmm CourseNana.COM

2^29 x 1.mmmmmmm CourseNana.COM

normal number CourseNana.COM

111000/mmmmmmm CourseNana.COM

2^25 x 1.mmmmmmm CourseNana.COM

normal number CourseNana.COM

100000/mmmmmmm CourseNana.COM

2^1 x 1.mmmmmmm CourseNana.COM

normal number CourseNana.COM

011111/mmmmmmm CourseNana.COM

2^0 x 1.mmmmmmm CourseNana.COM

normal number CourseNana.COM

001111/mmmmmmm CourseNana.COM

2^-16 x 1.mmmmmmm CourseNana.COM

normal number CourseNana.COM

000011/mmmmmmm CourseNana.COM

2^-28 x 1.mmmmmmm CourseNana.COM

normal number CourseNana.COM

000001/mmmmmmm CourseNana.COM

2^-30 x 1.mmmmmmm CourseNana.COM

normal number CourseNana.COM

000000/mmmmmmm CourseNana.COM

2^-30 x 0.mmmmmmm CourseNana.COM

subnormal number (no leading 1) CourseNana.COM

``````````````````````````````````````````````````````````````````````````````````````````````````````````` CourseNana.COM

Exponent bits are shown in purple below to help you distinguish it from the sign bit and mantissa. CourseNana.COM

Encoding in 15-bits CourseNana.COM

15’b000_0000_0000_0000 (15 bits of 0 in binary) CourseNana.COM

15’b100_0000_0000_0000 CourseNana.COM

`15-Bit Representation CourseNana.COM

Binary Representation CourseNana.COM

Base-10 Representation CourseNana.COM

15’b011_1111_xxxx_xxxx CourseNana.COM

15’b111_1111_xxxx_xxxx CourseNana.COM

Most positive # CourseNana.COM

15’b011_1110_1111_1111 CourseNana.COM

2^31 * 9’b1.11111111 CourseNana.COM

4286578688 CourseNana.COM

Smallest positive #
(subnormal)
CourseNana.COM

15’b000_0000_0000_0001 CourseNana.COM

2^-30 * 9’b0.00000001 CourseNana.COM

2^-38 3.637978807e-12 CourseNana.COM

Most negative # CourseNana.COM

15’b111_1110_1111_1111 CourseNana.COM

-2^31 * 9’b1.11111111 CourseNana.COM

-4286578688 CourseNana.COM

Smallest negative # (subnormal) CourseNana.COM

15’b100_0000_0000_0001 CourseNana.COM

-2^-30 * 9’b0.00000001 CourseNana.COM

-2^-38 -3.637978807e-1 2 CourseNana.COM

IEEE-754 Single Precision Format CourseNana.COM

Subnorms CourseNana.COM

The bias for the IEEE Format is 127 (base-10) and the format uses an implied “1.” for normal numbers, as usual. The smallest possible exponent is -126 represented by 8’b0000_0001 for normal numbers, whereas 8’b0000_0000 represents subnormal numbers. For subnormal numbers, we prepend the mantissa with “0.” instead of “1.” similar to how subnormal numbers are evaluated in our 15-bit FP format. CourseNana.COM

Infinities CourseNana.COM

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 CourseNana.COM

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 required in this assignment since our 15-bit floating point format does not use NaN. CourseNana.COM

Summary of Select Conversions CourseNana.COM

IEEE-754 Single Precision Format CourseNana.COM

sign (1 bit) CourseNana.COM

exponent
(8 bits, bias = 127)
CourseNana.COM

mantissa (23 bits) CourseNana.COM

Getting Started Developing Your Program CourseNana.COM

For this class, you MUST compile and run your programs on the pi-cluster.
Need help or instructions? See the Edstem FAQ. (Do NOT wait until the end to try this. There CourseNana.COM

will be limited or no ETS support on the weekends!) CourseNana.COM

We’ve provided you with the starter code at the following link: CourseNana.COM

1. Download the files in the repository. a. You can either use CourseNana.COM

2. Fill out the fields in the README before turning in. CourseNana.COM

Running Your Program
We’ve provided you with a Makefile so compiling your program should be easy! Additionally, the reference solution binary will be placed on Saturday 11/11 morning at: CourseNana.COM

/home/linux/ieng6/cs30fa23/public/bin/fpconvert-a6-ref CourseNana.COM

Makefile: The Makefile provided will create a fpconvert executable from the source files provided. Compile it by typing make into the terminal. Run make clean to remove files generated by make. CourseNana.COM

How the Program Works CourseNana.COM

Your program will take a filename as an argument and read it in. This file is a txt file storing the 15 bit FP numbers. The main function (implemented for you in main.c) will parse the input file and call the fpconvert function which you will implement in assembly on each 15-bit FP number to convert it into IEEE floating point format, and print the result to stdout. CourseNana.COM

Once you compiled the program with make, you can run it as follows: ./fpconvert somehexnums.txt CourseNana.COM

where somehexnums.txt is the name of the input txt file that holds the hex numbers you want to convert. CourseNana.COM

Input Guarantees
● fpconvert will be only given valid 15-bit wide numbers. CourseNana.COM

Program Implementation Files to Edit CourseNana.COM

You need to edit fpconvert.S and convert_inf.S CourseNana.COM

Functions to Implement
You will need to implement 1 function within fpconvert.S: CourseNana.COM

fpconvert(n):Thisisthefunctionthatwilldomostofthefloating-pointconversion. CourseNana.COM

  • ○  Argument: n the 15-bit FP number to convert CourseNana.COM

  • ○  Returns: n’s equivalent IEEE 754 single precision representation. CourseNana.COM

  • ○  If n is ±infinity, you MUST call convert_infinity(n) to do the conversion CourseNana.COM

    instead.
    You need to implement 1 function within
    convert_inf.S CourseNana.COM

    convert_infinity(n): CourseNana.COM

  • ○  Argument: n the 15-bit FP number to convert (should only be ±infinity) CourseNana.COM

  • ○  Returns: the FP number’s equivalent IEEE 754 single precision representation. CourseNana.COM

  • ●  32-bit ARM stores arguments passed into the function in registers r0-r3; n only symbolizes that the function takes in one argument. You cannot directly use n in your assembly program to refer to the first argument. CourseNana.COM

  • ●  As registers are all 32-bits wide, our 15-bit floating point format will always only occupy the least significant 15 bits, the upper 17 bits will be padded with 0’s. CourseNana.COM

  • ●  Return value should be stored in r0. Calling a Function in ARM CourseNana.COM

    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. CourseNana.COM

    Developing Your Code CourseNana.COM

    Development Process CourseNana.COM

    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. CourseNana.COM

    After thoroughly testing the functionality of your code, you should consider subnormal numbers. Subnormal numbers are represented when the exponent field is 6’b000000. CourseNana.COM

    After implementing the conversion of subnormal numbers, your code should be able to produce all of the values in the Summary of Select Conversions table. CourseNana.COM

    Development Tips CourseNana.COM

    Before you write assembly code, think about the algorithm. CourseNana.COM

  • ●  How are the 15-bit format and the 32-bit IEEE format similar and different? CourseNana.COM

  • ●  How do I break down the 15-bit format into the 3 individual fields? CourseNana.COM

  • ●  How does each field convert from the 15-bit format to the 32-bit IEEE format? CourseNana.COM

    You should find the bitwise instructions useful for this assignment. In particular, you will want to make use of bitmasks. CourseNana.COM

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. CourseNana.COM

Testing your Code CourseNana.COM

To run your code you need a txt file that holds the hex numbers that you want to convert, separated by a new line. CourseNana.COM

Example text input file, named somehexnums.txt: CourseNana.COM

0x0000
0x4000
0x3f00
0x7f00
0x3eff
0x0001
0x7eff
0x4001

NOTE: you should make sure each hexadecimal number only has four digits, otherwise you may get unexpected results. CourseNana.COM

Checking For Exact Output Match CourseNana.COM

A common technique is to redirect the outputs to files and compare against the reference solution1: CourseNana.COM

./your-program args > output; our-reference args > ref CourseNana.COM

diff -s output ref
This command will output lines that differ with a < or > in front to tell which file the line came CourseNana.COM

from. CourseNana.COM

Debugging Tips CourseNana.COM

The public autograder will only printf test some features. DO NOT RELY ON THE AUTOGRADER. (Many CSE 30 students have been burned by this.) Test your code using your own test cases! CourseNana.COM

GDB treats ARM assembly labels as functions except those 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”. CourseNana.COM

1 You might want to check out vimdiff on the pi-cluster (https://www.tutorialspoint.com/vim/vim_diff.htm). CourseNana.COM

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. CourseNana.COM

if (r5 == 99) { r3 = r3 + 2; CourseNana.COM

} else {
r3 = r3 + 3;
CourseNana.COM

}
r4 = r4 - 1;
CourseNana.COM

GDB will not recognize labels: CourseNana.COM

GDB will recognize labels: CourseNana.COM

cmp r5, 99 bne else
add r3, r3, 2 B end_if
CourseNana.COM

else:
add r3, r3, 3
CourseNana.COM

end_if:
sub r4, r4, 1
CourseNana.COM

cmp r5, 99 bne .Lelse add r3, r3, 2 b .Lend_if CourseNana.COM

.Lelse:
add r3, r3, 3
CourseNana.COM

.Lend_if:
sub r4, r4, 1
CourseNana.COM

Allowed ARM Instructions CourseNana.COM

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. CourseNana.COM

Style Requirements CourseNana.COM

Reading raw assembly is hard and debugging will be nigh impossible if you don’t put comments! To encourage you to make your life easier, style will be worth 2 points in this assignment on a holistic readable/unreadable basis. You will get full style points as long as your code is reasonably commented to be readable (so that someone who doesn’t know ARM can still roughly understand what it’s doing), so don’t worry if you can’t get all the details right. However, you will get no style points if it’s not (e.g. very inconsistent indentation, sparse or unreadable comments). In addition, staff won't be able to provide any assistance other than styling advice unless code is readable. For reference, here is the Style Guideline for ARM assembly. We strongly recommend you to use comments after each instruction to help describe what step occurs like what is done in the style guide. Note: style will not be graded for resubmission. CourseNana.COM

Midpoint (5 Points) CourseNana.COM

This part of the assignment is due earlier than the full assignment, on CourseNana.COM

Friday 11/10 at 11:59 pm PST. There are no late submissions on the Midpoint. CourseNana.COM

Complete the Gradescope assignment “HW6: Checkpoint”, 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 algorithm in plain English or C code. CourseNana.COM

Discuss your implementations of the following functions: fpconvert and convert_infinity. Your fpconvert should call convert_infinity when appropriate. CourseNana.COM

Submission and Grading CourseNana.COM

Submitting
1. Submit your files to Gradescope under the assignment titled “HW6 (Coding): Floating CourseNana.COM

Point”. You will submit ONLY the following files: fpconvert.S CourseNana.COM

convert_inf.S README.md CourseNana.COM

Submission will open by Saturday morning. You should test your code extensively on pi-cluster before submitting to gradescope. CourseNana.COM

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. CourseNana.COM

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. CourseNana.COM

2. After submitting, the autograder will run a few tests:
a. Check that all required files were submitted.
b. Check that
fpconvert.S and convert_inf.S compiles.
c. Runs some sanity tests on the resulting
fpconvert executable. CourseNana.COM

Grading Breakdown [5 + 45 points] CourseNana.COM

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. CourseNana.COM

CourseNana.COM

To encourage you to write your own tests, we are not providing any public tests that have not already been detailed in this writeup. CourseNana.COM

The assignment will be graded out of 50 points and will be allocated as follows: CourseNana.COM

  • ●  Code compiles with no warnings: 1 point CourseNana.COM

  • ●  Style: 2 points CourseNana.COM

  • ●  Public tests with the provided examples. CourseNana.COM

  • ●  Private tests with hidden test cases. CourseNana.COM

    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. CourseNana.COM

    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. CourseNana.COM

    [Optional] Bells and Whistles2 (epsilon points) CourseNana.COM

    Write a new function add_fp(a, b) that takes in 2 numbers a and b that are in the 15-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. CourseNana.COM

    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. CourseNana.COM

    The Bells and Whistles component may be submitted to a separate Gradescope assignment: Homework 6 Optional: Bells and Whistles. CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
UCSD代写,CSE 30代写,CSE30代写,Computer Organization and Systems代写,Floating Point代写,UCSD代编,CSE 30代编,CSE30代编,Computer Organization and Systems代编,Floating Point代编,UCSD代考,CSE 30代考,CSE30代考,Computer Organization and Systems代考,Floating Point代考,UCSDhelp,CSE 30help,CSE30help,Computer Organization and Systemshelp,Floating Pointhelp,UCSD作业代写,CSE 30作业代写,CSE30作业代写,Computer Organization and Systems作业代写,Floating Point作业代写,UCSD编程代写,CSE 30编程代写,CSE30编程代写,Computer Organization and Systems编程代写,Floating Point编程代写,UCSDprogramming help,CSE 30programming help,CSE30programming help,Computer Organization and Systemsprogramming help,Floating Pointprogramming help,UCSDassignment help,CSE 30assignment help,CSE30assignment help,Computer Organization and Systemsassignment help,Floating Pointassignment help,UCSDsolution,CSE 30solution,CSE30solution,Computer Organization and Systemssolution,Floating Pointsolution,