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


//  Module to Convert Single Precision Value into 32-bit Integer 
 
 
 
module ConvertSPTo32Int(Int32Out, SPIn); 
 
output [31:0] Int32Out; 
reg    [31:0] Int32; 
input  [31:0] SPIn; 
 
wire [31:0] compInt32Out; 
wire [31:0] compInt32In; 
wire [31:0] SPIn; 
reg [7:0] index; 
 
assign Int32Out = SPIn[31] ? compInt32Out : Int32;  
assign compInt32In = SPIn[31] ? Int32 : 32'bz; 
 
twosComp TC32(compInt32Out, compInt32In); 
 
always @ ( SPIn or compInt32Out) 
 
begin 
 
	index=	 SPIn[30:23]; 
	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 (index) 
 
		5'd30: 
			  Int32  = { 1'b0, 1'b1 , SPIn[22:0], {7{1'b0}} }; 
		5'd29: 
			  Int32  = { 1'b0, 1'b0, 1'b1 ,  SPIn[22:0], {6{1'b0}} }; 
		5'd28: 
			  Int32  = { 1'b0, {2{1'b0}}, 1'b1 , SPIn[22:0], {5{1'b0}} }; 
		5'd27: 
			  Int32  = { 1'b0, {3{1'b0}}, 1'b1 , SPIn[22:0], {4{1'b0}} }; 
		5'd26: 
			  Int32  = { 1'b0, {4{1'b0}}, 1'b1 , SPIn[22:0], {3{1'b0}} }; 
		5'd25: 
			  Int32  = { 1'b0, {5{1'b0}}, 1'b1 , SPIn[22:0], {2{1'b0}} }; 
		5'd24: 
			  Int32  = { 1'b0, {6{1'b0}}, 1'b1 , SPIn[22:0], 1'b0 }; 
		5'd23: 
			  Int32  = { 1'b0, {7{1'b0}}, 1'b1 , SPIn[22:0] }; 
		5'd22: 
			  Int32  = { 1'b0, {8{1'b0}}, 1'b1 , SPIn[22:1] }; 
		5'd21: 
			  Int32  = { 1'b0, {9{1'b0}}, 1'b1 , SPIn[22:2] }; 
		5'd20: 
			  Int32  = { 1'b0, {10{1'b0}}, 1'b1 , SPIn[22:3] }; 
		5'd19: 
			  Int32  = { 1'b0, {11{1'b0}}, 1'b1 , SPIn[22:4] }; 
		5'd18: 
			  Int32  = { 1'b0, {12{1'b0}}, 1'b1 , SPIn[22:5] }; 
		5'd17: 
			  Int32  = { 1'b0, {13{1'b0}}, 1'b1 , SPIn[22:6] }; 
		5'd16: 
			  Int32  = { 1'b0, {14{1'b0}}, 1'b1 , SPIn[22:7] }; 
		5'd15: 
			  Int32  = { 1'b0, {15{1'b0}}, 1'b1 , SPIn[22:8] }; 
		5'd14: 
			  Int32  = { 1'b0, {16{1'b0}}, 1'b1 , SPIn[22:9] }; 
		5'd13: 
			  Int32  = { 1'b0, {17{1'b0}}, 1'b1 , SPIn[22:10] }; 
		5'd12: 
			  Int32  = { 1'b0, {18{1'b0}}, 1'b1 , SPIn[22:11] }; 
		5'd11: 
			  Int32  = { 1'b0, {19{1'b0}}, 1'b1 , SPIn[22:12] }; 
		5'd10: 
			  Int32  = { 1'b0, {20{1'b0}}, 1'b1 , SPIn[22:13] }; 
		5'd9: 
			  Int32  = { 1'b0, {21{1'b0}}, 1'b1 , SPIn[22:14] }; 
		5'd8: 
			  Int32  = { 1'b0, {22{1'b0}}, 1'b1 , SPIn[22:15] }; 
		5'd7: 
			  Int32  = { 1'b0, {23{1'b0}}, 1'b1 , SPIn[22:16] }; 
		5'd6: 
			  Int32  = { 1'b0, {24{1'b0}}, 1'b1 , SPIn[22:17] }; 
		5'd5: 
			  Int32  = { 1'b0, {25{1'b0}}, 1'b1 , SPIn[22:18] }; 
		5'd4: 
			  Int32  = { 1'b0, {26{1'b0}}, 1'b1 , SPIn[22:19] }; 
		5'd3: 
			  Int32  = { 1'b0, {27{1'b0}}, 1'b1 , SPIn[22:20] }; 
		5'd2: 
			  Int32  = { 1'b0, {28{1'b0}}, 1'b1 , SPIn[22:21] }; 
		5'd1: 
			  Int32  = { 1'b0, {29{1'b0}}, 1'b1 , SPIn[22] }; 
		5'd0: 
			  Int32  = { 1'b0, {30{1'b0}}, 1'b1 }; 
		 
		default: 
			  Int32  = 32'b0; 
		endcase 
 
 
end	// end always 
 
endmodule