Docsity

EE 3755 Homework 2: Implementing Mini Floating Point Converters and Adder, Assignments of Electrical and Electronics Engineering

Toggle sidebar
bg1
EE 3755 Homework 2 Due: March. 25.
Estimated time to solve:
Prob.1 10 Minutes.(15 pts)
Prob.2 2 Hours.(25pts)
Prob.3 2 Hours.(25pts)
Prob.4 2 Hours.(30pts)
Having Script File 5 Minutes.(5pts)
Total 6 Hours and 15 Minutes.
How to submit?
// No hard copy.
// Name your code file as hw2.v
// Name your script file as hw2.txt
// Leave your code file(hw2.v) and
// your script file(hw2.txt) on the class account.
Finish your code file(hw2.v) first, then do the followings:
Use “script hw2.txt “ command // To take a snap shot of your file. If you don’t know
// script command, look at the handout.
Use “cat hw2.v” command // To display contents of your modules.
Use “ncverilog hw2.v” //To run your code.
then stop the script.
Example)
SUN>script hw2.txt
SUN>cat hw2.v
SUN>ncverilog hw2.v
SUN> ( stop script by pressing CTRL-D)
#Do all your work on hw2.v file
After carefully read the problem description, write code on the template file(hw2.v).
pf3
pf4
pf5

Partial preview of the text

Download EE 3755 Homework 2: Implementing Mini Floating Point Converters and Adder and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

EE 3755 Homework 2 Due: March. 25.

Estimated time to solve:

Prob. 1 10 Minutes.(15 pts)

Prob. 2 2 Hours.(25pts)

Prob.3 2 Hours.(25pts)

Prob. 4 2 Hours.(30pts)

Having Script File 5 Minutes.(5pts)

Total 6 Hours and 15 Minutes.

How to submit?

// No hard copy.

// Name your code file as hw2.v

// Name your script file as hw2.txt

// Leave your code file(hw2.v) and

// your script file(hw2.txt) on the class account.

Finish your code file(hw2.v) first, then do the followings:

Use “script hw2.txt “ command // To take a snap shot of your file. If you don’t know

// script command, look at the handout.

Use “cat hw2.v” command // To display contents of your modules.

Use “ncverilog hw2.v” //To run your code.

then stop the script.

Example)

SUN>script hw2.txt

SUN>cat hw2.v

SUN>ncverilog hw2.v

SUN> ( stop script by pressing CTRL-D)

#Do all your work on hw2.v file

After carefully read the problem description, write code on the template file(hw2.v).

Problem description##

You are required to write codes for

  1. integer to floating point converter(Mini_Integer2Float_Converter)
  2. floating point to integer converter(Mini_Float2Integer_Converter)
  3. floating point adder(Mini_Float_Adder) Mini_Integer2Float_Converter This converter receives 8bit integer and produces 8bit floating point number. Assume only positive integer with 7bit magnitude(MSB is always 0) for the simplicity of the code. So 01111111 is the biggest input number. The format for the floating point number for the homework is this following: Although this is not a standard format, you are going to use this format for the simplicity of your homework code. Sign Expone nt Fractio n Bia s Mini Floating Point 1 [ 7 ] 5 [ 6 - 2 ] 2 [ 1 -0] 15 1 bit for the sign 5 bits for the exponent 2 bits for the fraction. (For reminder, IEEE 754 floating point for the single precision is this following, you are NOT going to use this IEEE 754 format for the code) Sign Exponen t Fraction Bia s Single Precision 1 [31] 8 [30-23] 23 [22-00] 127

This converter receives 8bit mini floating point number which defined above and produces 8bit integer number. Assume only positive floating point number with exponent value which is greater than or equal to 15 for the simplicity of the code. Mini_Float_Adder This adder receives two 8 bit mini floating point number which defined above and produces summation of the two 8 bit mini floating point number with the mini floating point format. //Template //Copy this template and name it "hw 2 .v". // Problem 0: // Write down your name and your account here // Your Name : ####### // Your Account: ####### // // Problem 1 : Convert the following numbers. (15pts) // 1 .1) Decimal 7 to 8-bit Binary: (2pts) // Write your answer here; // 1 .2) Decimal - 7 to 8-bit Binary (2pts) // Write your answer here: // 1 .3) Decimal 7 .875 to Binary (as many bits as needed) (3pts) // Write your answer here: // 1 .4) Decimal - 7 .875 to IEEE 754 Single Precision (8pts) // (Show in hexadecimal): // Write your answer here: //Problem 2. // 2.1 Convert integer number, 3 to the mini 8 bit floating point number(5pts).

//Answer: //(hint: think about the example above) //2.2 fill the code to complete the module Mini_Integer2Float_Converter(20pts) module Mini_Integer2Float_Converter(Out_Float,In_Int); input [7:0] In_Int; output [7:0] Out_Float; always begin //Write down your code here // There will be no penalty for a little bit longer code // as long as your code produces right answer // You may declare more variables and use them. //You should put this code: $display("print in_Int_value = %b, print_out_float_value = %b\n",In_Int,Out_Float); //You also have to think about “always @...” //Hint “ always @In_Int” or you may write your code differently. end endmodule //Problem 3. // 3.1 Convert the mini 8bit floating point number number, 01000111 to // 8 bit binary number (5pts). //Answer: //(hint: think about the example above) //3.2 fill the code to complete the module Mini_Float2Integer_Converter(20pts) module Mini_Float2Integer_Converter(Out_Int,In_Float); input [7:0] In_Float; output [7:0] Out_Int; always begin //Write down your code here // There will be no penalty for a little bit longer code

/// Do not modify test bench module test(); reg [ 7 :0] In_Int; wire[7:0] Out_Int,Out_Float,Out_Float_Add ; integer i; Mini_Integer2Float_Converter MIF(Out_Float,In_Int); Mini_Float2Integer_Converter MFI(Out_Int,Out_Float); Mini_Float_Adder MFA(Out_Float_Add,Out_Float,Out_Float); initial begin for(i=0; i<= 15 ; i=i+1) begin In_Int = i[ 7 :0]; #100; $display("####int = %b\n",In_Int); end $display("Tests completed."); $finish; end endmodule