www.pudn.com > x86.rar > ConInt32ToSP.v, change:2007-12-05,size:4073b


/****************************************************** 
 *                                                    * 
 * This module is used to convert 32 bit integer      * 
 *        into 32-bit Single precision value          * 
 * 						      * 
 ******************************************************/ 
 
 
 
module ConInt32ToSP(SinglePrecOut, Int32); 
 
input [31:0] Int32; 
output [31:0] SinglePrecOut; 
 
reg [31:0] tempInt32; 
reg [31:0] scanInRev; 
reg [31:0] SinglePrecOut; 
wire [15:0] sum; 
wire [31:0] complementIn; 
wire [31:0] complementOut; 
wire [4:0]  indexOutRev; 
reg  [7:0]  index; 
 
 
assign complementIn=Int32[31]? Int32: 32'bz; 
 
twosComp TC32(complementOut,complementIn); 
bitScanRev Bsr(indexOutRev, scanInRev); 
 
 
always @ ( Int32 or complementOut or indexOutRev ) 
 
begin 
	if(Int32==32'b0) 
		SinglePrecOut=32'b0; 
	else 
	  begin 
	 
		if(Int32[31]) 
		begin 
			tempInt32=complementOut; 
			scanInRev=complementOut; 
		end 
		else 
		begin 
		 
			tempInt32=Int32;	 
			scanInRev=Int32;		 
		end 
	 
		//finding the biased exponent for the given 32-bit integer 
 
		index=	 { 3'd0, indexOutRev }; 
		index[7]=~index[7] ; 
		index= 	(index[0] ? ( {index [7:1], ~index[0]}): 
			(index[1] ? ( {index [7:2], ~index[1:0]}): 
			(index[2] ? ( {index [7:3], ~index[2:0]}): 
			(index[3] ? ( {index [7:4], ~index[3:0]}): 
			(index[4] ? ( {index [7:5], ~index[4:0]}): 
			(index[5] ? ( {index [7:6], ~index[5:0]}): 
			({index[7], ~index[6:0]}) )))))); 
 
	 
		case (indexOutRev) 
	 
		5'd30: 
			  SinglePrecOut  = { Int32[31], index[7:0], tempInt32[29:7] }; 
		5'd29: 
			  SinglePrecOut  = { Int32[31], index[7:0], tempInt32[28:6] }; 
		5'd28: 
			  SinglePrecOut  = { Int32[31], index[7:0], tempInt32[27:5] }; 
		5'd27: 
			  SinglePrecOut  = { Int32[31], index[7:0], tempInt32[26:4] }; 
		5'd26: 
			  SinglePrecOut  = { Int32[31], index[7:0], tempInt32[25:3] }; 
		5'd25: 
			  SinglePrecOut  = { Int32[31], index[7:0], tempInt32[24:2] }; 
		5'd24: 
			  SinglePrecOut  = { Int32[31], index[7:0], tempInt32[23:1] }; 
		5'd23: 
			  SinglePrecOut  = { Int32[31], index[7:0], tempInt32[22:0] }; 
		5'd22: 
			  SinglePrecOut  = { Int32[31], index[7:0], tempInt32[21:0], 1'b0 }; 
		5'd21: 
			  SinglePrecOut  = { Int32[31], index[7:0], tempInt32[20:0], 2'b0 }; 
		5'd20: 
			  SinglePrecOut  = { Int32[31], index[7:0], tempInt32[19:0], 3'b0 }; 
		5'd19: 
			  SinglePrecOut  = { Int32[31], index[7:0], tempInt32[18:0], 4'b0 }; 
		5'd18: 
			  SinglePrecOut  = { Int32[31], index[7:0], tempInt32[17:0], 5'b0 }; 
		5'd17: 
			  SinglePrecOut  = { Int32[31], index[7:0], tempInt32[16:0], 6'b0 }; 
		5'd16: 
			  SinglePrecOut  = { Int32[31], index[7:0], tempInt32[15:0], 7'b0 }; 
		5'd15: 
			  SinglePrecOut  = { Int32[31], index[7:0], tempInt32[14:0], 8'b0 }; 
		5'd14: 
			  SinglePrecOut  = { Int32[31], index[7:0], tempInt32[13:0], 9'b0 }; 
		5'd13: 
			  SinglePrecOut  = { Int32[31], index[7:0], tempInt32[12:0], 10'b0 }; 
		5'd12: 
			  SinglePrecOut  = { Int32[31], index[7:0], tempInt32[11:0], 11'b0 }; 
		5'd11: 
			  SinglePrecOut  = { Int32[31], index[7:0], tempInt32[10:0], 12'b0 }; 
		5'd10: 
			  SinglePrecOut  = { Int32[31], index[7:0], tempInt32[9:0], 13'b0 }; 
		5'd9: 
			  SinglePrecOut  = { Int32[31], index[7:0], tempInt32[8:0], 14'b0 }; 
		5'd8: 
			  SinglePrecOut  = { Int32[31], index[7:0], tempInt32[7:0], 15'b0 }; 
		5'd7: 
			  SinglePrecOut  = { Int32[31], index[7:0], tempInt32[6:0], 16'b0 }; 
		5'd6: 
			  SinglePrecOut  = { Int32[31], index[7:0], tempInt32[5:0], 17'b0 }; 
		5'd5: 
			  SinglePrecOut  = { Int32[31], index[7:0], tempInt32[4:0], 18'b0 }; 
		5'd4: 
			  SinglePrecOut  = { Int32[31], index[7:0], tempInt32[3:0], 19'b0 }; 
		5'd3: 
			  SinglePrecOut  = { Int32[31], index[7:0], tempInt32[2:0], 20'b0 }; 
		5'd2: 
			  SinglePrecOut  = { Int32[31], index[7:0], tempInt32[1:0], 21'b0 }; 
		5'd1: 
			  SinglePrecOut  = { Int32[31], index[7:0], tempInt32[0], 22'b0 }; 
		5'd0: 
			  SinglePrecOut  = { Int32[31], index[7:0], 23'b0 }; 
	endcase 
 
	end	// end else 
end	//end always 
endmodule