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


/************************************************************************** 
 *									  * 
 *  Module to convert 64-bit Integer into Single Precision floating point * 
 *									  * 
 **************************************************************************/ 
 
 
module ConInt64ToSP(SinglePrecOut, Int64); 
 
input [63:0] Int64; 
output [31:0] SinglePrecOut; 
 
reg [63:0] scanInRev; 
 
reg  [31:0] SinglePrecOut; 
wire [15:0] sum; 
wire [5:0]  indexOutRev; 
wire [63:0] complementIn; 
wire [63:0] complementOut; 
reg  [63:0] tempInt64; 
reg  [7:0]  index; 
 
assign complementIn = Int64[63] ? Int64 : 64'bz; 
 
bitScanRev64 Bsr1(indexOutRev, scanInRev); 
twosComp64 TC64(complementOut,complementIn); 
 
 
always @ (Int64  or complementOut or indexOutRev  ) 
 
begin 
	 
	if(Int64==64'b0) 
		SinglePrecOut=32'b0; 
	else 
	begin 
	if(Int64[63]) 
	begin 
		scanInRev=complementOut; 
		tempInt64=complementOut; 
	end 
	else 
	begin 
		scanInRev=Int64; 
		tempInt64=Int64; 
	end 
	 
	index=	 { 2'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]}) )))))); 
		 
 
	if( |(tempInt64[63:32]) == 1 ) 
	begin 
		case (indexOutRev) 
 
		6'd63: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[62:40] }; 
		6'd62: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[61:39] }; 
		6'd61: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[60:38] }; 
		6'd60: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[59:37] }; 
		6'd59: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[58:36] }; 
		6'd58: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[57:35] }; 
		6'd57: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[56:34] }; 
		6'd56: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[55:33] }; 
		6'd55: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[54:32] }; 
		6'd54: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[53:31] }; 
		6'd53: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[52:30] }; 
		6'd52: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[51:29] }; 
		6'd51: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[50:28] }; 
		6'd50: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[49:27] }; 
		6'd49: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[48:26] }; 
		6'd48: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[47:25] }; 
		6'd47: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[46:24] }; 
		6'd46: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[45:23] }; 
		6'd45: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[44:22] }; 
		6'd44: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[43:21] }; 
		6'd43: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[42:20] }; 
		6'd42: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[41:19] }; 
		6'd41: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[40:18] }; 
		6'd40: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[39:17] }; 
		6'd39: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[38:16] }; 
		6'd38: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[37:15] }; 
		6'd37: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[36:14] }; 
		6'd36: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[35:13] }; 
		6'd35: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[34:12] }; 
		6'd34: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[33:11] }; 
		6'd33: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[32:10] }; 
		6'd32: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[31:9] }; 
		endcase 
	end 
 
	else 
	begin 
 
		case (indexOutRev) 
 
		6'd31: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[30:8] }; 
		6'd30: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[29:7] }; 
		6'd29: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[28:6] }; 
		6'd28: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[27:5] }; 
		6'd27: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[26:4] }; 
		6'd26: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[25:3] }; 
		6'd25: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[24:2] }; 
		6'd24: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[23:1] }; 
		6'd23: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[22:0] }; 
		6'd22: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[21:0], 1'b0 }; 
		6'd21: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[20:0], 2'b0 }; 
		6'd20: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[19:0], 3'b0 }; 
		6'd19: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[18:0], 4'b0 }; 
		6'd18: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[17:0], 5'b0 }; 
		6'd17: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[16:0], 6'b0 }; 
		6'd16: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[15:0], 7'b0 }; 
		6'd15: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[14:0], 8'b0 }; 
		6'd14: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[13:0], 9'b0 }; 
		6'd13: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[12:0], 10'b0 }; 
		6'd12: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[11:0], 11'b0 }; 
		6'd11: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[10:0], 12'b0 }; 
		6'd10: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[9:0], 13'b0 }; 
		6'd9: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[8:0], 14'b0 }; 
		6'd8: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[7:0], 15'b0 }; 
		6'd7: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[6:0], 16'b0 }; 
		6'd6: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[5:0], 17'b0 }; 
		6'd5: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[4:0], 18'b0 }; 
		6'd4: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[3:0], 19'b0 }; 
		6'd3: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[2:0], 20'b0 }; 
		6'd2: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[1:0], 21'b0 }; 
		6'd1: 
			  SinglePrecOut  = { Int64[63], index[7:0], tempInt64[0], 22'b0 }; 
		6'd0: 
			  SinglePrecOut  = { Int64[63], index[7:0], 23'b0 }; 
		endcase 
	end 
	end	// else end 
end 
endmodule