//Template //Copy this template and name it "hw2.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 // as long as your code produces right answer // You may declare more variables and use them. //You should put this code: $display("print in float_value = %b, print_out int_value = %b\n",In_Float,Out_Int); //You also have to think about “always @...” end endmodule //Problem . // 4.1 Add these two mini 8bit floating point numbers , 01100111 and 01000000, // and represent the result into mini 8bit floating point number. (5pts). //Answer( What will be the result?) //(hint: think about the example above) //4.2 fill the code to complete the module Mini_Float_Adder(25pts) module Mini_Float_Adder(Out_Float,In1_Float,In2_Float); input [7:0] In1_Float,In2_Float; output [7:0] Out_Float; always begin //Write down your code here //Assume always In1_Float is bigger or equal to In2_Float for the simplicity of your code // 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(" out_float = %b, in1_float = %b,in2_float= %b\n",Out_Float,In1_Float,In2_Float); //You also have to think about “always @...” end endmodule ////////////////////////////Do not modify this test_all module//////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// Test Bench /// 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