欧美在线专区-欧美在线伊人-欧美在线一区二区三区欧美-欧美在线一区二区三区-pornodoxxx中国妞-pornodoldoo欧美另类

position>home>Football

代寫CSE 30程序、代做c/c++編程設計

Assignment 6: Floating Point

代寫CSE 30程序、代做c/c++編程設計

代寫

CSE 30: Computer Organization and Systems, Fall 2023

代寫

Instructors: Paul Cao and Bryan Chin

代寫

Due: Tuesday Nov 14, 2023

代寫

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.

代寫

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.

代寫

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.

代寫

Version updates:

代寫

● 1.0 [Nov 8] Final Draft

代寫

● 1.1 [Nov 8] Fix midpoint due date Sunday -> Friday

代寫

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

代寫

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

代寫

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

代寫

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

代寫

Table of Contents

代寫

1. Learning Goals

代寫

2. Assignment Overview

代寫

3. Getting Started

代寫

4. How the Program Works

代寫

5. Program Implementation

代寫

a. Functions to Implement

代寫

b. Developing Your Code

代寫

c. Testing Your Code

代寫

6. Submission and Grading

代寫

a. Submitting

代寫

b. Grading Breakdown [50 pts]

代寫

Learning Goals

代寫

● Programming in ARM assembly

代寫

○ Bit masking

代寫

○ Function call

代寫

○ Branching

代寫

● Working with floating point numbers

代寫

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

代寫

Assignment Overview

代寫

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.

代寫

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!

代寫

A note about representing number literals

代寫

In the number 8’b1101_0011:

代寫

● 8 is the number of binary bits in this number, in base-10.

代寫

● b means binary. Other formats are d for decimal, o for octal, and h for hexadecimal.

代寫

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

代寫

8’b1101_0011.

代寫

● _ is a spacer character that is only there to make it easier to read. It has no numerical

代寫

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

代寫

The 15-bit FP Format

代寫

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.

代寫

The following figure illustrates the bit assignments:

代寫

FP Format (15-bit)

代寫

sign

代寫

(1 bit)

代寫

exponent

代寫

(6 bits, bias = 31)

代寫

mantissa

代寫

(8 bits)

代寫

Points to note:

代寫

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

代寫

2. Subnormal numbers have an exponent field of 6’b000000 which represents 2 and

代寫

−30

代寫

implies a “0.” in front of the mantissa.

代寫

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

代寫

mantissa.

代寫

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

代寫

Exponent/mantissa represents Notes

代寫

111111/mmmmmmm infinity infinity

代寫

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

代寫

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

代寫

000011/mmmmmmm 2^-28 x 1.mmmmmmm normal number

代寫

000001/mmmmmmm 2^-30 x 1.mmmmmmm normal number

代寫

000000/mmmmmmm 2^-30 x 0.mmmmmmm subnormal number

代寫

(no leading 1)

代寫

```````````````````````````````````````````````````````````````````````````````````````````````````````````

代寫

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

代寫

mantissa.

代寫

Number Encoding in 15-bits

代寫

+0.0 15’b000_0000_0000_0000 (15 bits of 0 in binary)

代寫

-0.0 15’b100_0000_0000_0000

代寫

Number `15-Bit

代寫

Representation

代寫

Binary

代寫

Representation

代寫

Base-10

代寫

Representation

代寫

+∞

代寫

15’b011_1111_xxxx_xxxx +Inf

代寫

-∞

代寫

15’b111_1111_xxxx_xxxx -Inf

代寫

Most positive # 15’b011_1110_1111_1111 2^31

代寫*

9’b1.11111111

代寫

4286578688

代寫

Smallest positive

代寫

#

代寫

(subnormal)

代寫

15’b000_0000_0000_0001 2^-30

代寫*

9’b0.00000001

代寫

2^-38 ≅

代寫

3.637978807e-12

代寫

Most negative # 15’b111_1110_1111_1111 -2^31

代寫*

9’b1.11111111

代寫

-4286578688

代寫

Smallest

代寫

negative #

代寫

(subnormal)

代寫

15’b100_0000_0000_0001 -2^-30

代寫*

9’b0.00000001

代寫

-2^-38 ≅

代寫

-3.637978807e-1

代寫

2

代寫

IEEE-754 Single Precision Format

代寫

IEEE-754 Single Precision Format

代寫

sign

代寫

(1 bit)

代寫

exponent

代寫

(8 bits, bias = 127)

代寫

mantissa

代寫

(23 bits)

代寫

Subnorms

代寫

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.

代寫

Infinities

代寫

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

代寫

required in this assignment since our 15-bit floating point format does not use NaN.

代寫

Summary of Select Conversions

代寫

FP 15-bit FP IEEE-754 Single

代寫

+0 15’b000_0000_0000_0000 0x00000000

代寫

-0 15’b100_0000_0000_0000 0x80000000

代寫

2^-38 15’b000_0000_0000_0001 0x2c800000

代寫

-2^-38 15’b100_0000_0000_0001 0xac800000

代寫

4286578688 15’b011_1110_1111_1111 0x4f7f8000

代寫

-4286578688 15’b111_1110_1111_1111 0xcf7f8000

代寫

+Inf 15’b011_1111_xxxx_xxxx 0x7f800000

代寫

-Inf 15’b111_1111_xxxx_xxxx 0xff800000

代寫

Getting Started

代寫

Developing Your Program

代寫

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

代寫

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-fa23/hw6-starter

代寫

1. Download the files in the repository.

代寫

a. You can either use

代寫

git clone https://github.com/cse30-fa23/hw6-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, the reference solution binary will be placed on Saturday 11/11 morning at:

代寫

/home/linux/ieng6/cs30fa23/public/bin/fpconvert-a6-ref

代寫

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.

代寫

How the Program Works

代寫

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.

代寫

Once you compiled the program with make, you can run it as follows:

代寫

./fpconvert somehexnums.txt

代寫

where somehexnums.txt is the name of the input txt file that holds the hex numbers you

代寫

want to convert.

代寫

Input Guarantees

代寫

● fpconvert will be only given valid 15-bit wide numbers.

代寫

Program Implementation

代寫

Files to Edit

代寫

You need to edit fpconvert.S and convert_inf.S

代寫

Functions to Implement

代寫

You will need to implement 1 function within fpconvert.S:

代寫

● fpconvert(n): This is the function that will do most of the floating-point conversion.

代寫

○ Argument: n the 15-bit FP number to convert

代寫

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

代寫

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

代寫

instead.

代寫

You need to implement 1 function within convert_inf.S

代寫

● convert_infinity(n):

代寫

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

代寫

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

代寫

NOTE:

代寫

● 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.

代寫

● 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.

代寫

● Return value should be stored in r0.

代寫

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 subnormal numbers.

代寫

Subnormal numbers are represented when the exponent field is 6’b000000.

代寫

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.

代寫

Development Tips

代寫

Before you write assembly code, think about the algorithm.

代寫

● How are the 15-bit format and the 32-bit IEEE format similar and different?

代寫

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

代寫

● How does each field convert from the 15-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.

代寫

Testing your Code

代寫

To run your code you need a txt file that holds the hex numbers that you want to convert,

代寫

separated by a new line.

代寫

Example text input file, named somehexnums.txt:

代寫

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.

代寫

Checking For Exact Output Match

代寫

A common technique is to redirect the outputs to files and compare against the reference

代寫

solution

代寫

1

代寫

:

代寫

./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

代寫

from.

代寫

Debugging Tips

代寫

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!

代寫

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”.

代寫

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

代寫

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;

代寫

} else {

代寫

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

代寫

else:

代寫

add r3, r3, 3

代寫

end_if:

代寫

sub r4, r4, 1

代寫

cmp r5, 99

代寫

bne .Lelse

代寫

add r3, r3, 2

代寫

b .Lend_if

代寫

.Lelse:

代寫

add r3, r3, 3

代寫

.Lend_if:

代寫

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

代寫

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.

代寫

Midpoint (5 Points)

代寫

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

代寫

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

代寫

Midpoint.

代寫

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.

代寫

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 “HW6 (Coding): Floating

代寫

Point”. You will submit ONLY the following files:

代寫

fpconvert.S

代寫

convert_inf.S

代寫

README.md

代寫

Submission will open by Saturday morning. You should test your code extensively on

代寫

pi-cluster before submitting to gradescope.

代寫

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 and convert_inf.S compiles.

代寫

c. Runs some sanity tests on the resulting fpconvert executable.

代寫

Grading Breakdown [5 + 45 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 Friday 11/10. Complete the Gradescope assignment “Homework 6:

代寫

Checkpoint”.

代寫

● Code compiles with no warnings: 1 point

代寫

● Style: 2 points

代寫

● 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.

代寫

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.

代寫

[Optional] Bells and Whistles

代寫

2

代寫

(epsilon points)

代寫

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.

代寫

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:

代寫

Homework 6 Optional: Bells and Whistles.

代寫

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).

代寫

 

代寫

請加QQ:99515681 或郵箱:99515681@qq.com   WX:codehelp

代寫

 

代寫

Popular articles

主站蜘蛛池模板: 波多野结衣加勒比| igao视频网站| 香港黄色碟片黄色碟片| 日本护士xxxx视频| 女偶像私下的y荡生活| 香蕉久久国产精品免| 日本不卡在线观看免费v| 樱桃黄高清完整版在线观看 | 又粗又黄又猛又爽大片免费| jux434被公每天侵犯的我| 最近的中文字幕视频完整| 日本一道本在线视频| 村上凉子丰满禁断五十路| 8888四色奇米在线观看免费看| 亚洲欧美色一区二区三区| 一个人看的www片免费| 在线观看高嫁肉柳1一4集中文| 国漫永生第二季在线观看| 深夜影院一级毛片| 亚洲欧美小视频| 中文字幕一区二区三区精彩视频| 美女的让男人桶爽网站| 在线中文字幕不卡| 在线观看三级激情视频| 欧美综合自拍亚洲综合图片区 | 国产gav成人免费播放视频| 国产嫩草在线观看| 99视频精品在线| 欧美成人在线免费观看| 福利一区二区三区视频在线观看| 黑人巨鞭大战洋妞| 真实处破疼哭视频免费看| 国产呦系列呦| 正在播放国产美人| 天天想你在线视频免费观看| 国产zzjjzzjj视频全免费| 亚洲日韩欧洲无码av夜夜摸| 大香煮伊在2020一二三久应用| 欧美黑人巨大videos极品| 好好的日视频| 俺也去第四色|