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


module sse3Alu(enablealu,Operation,Result,Operand1,Operand2,Operand3); 
 
input enablealu; 
 
input [ 10:0] Operation; 
input [127:0] Operand1,Operand2; 
input [  7:0] Operand3; 
 
output[127:0] Result; 
reg   [127:0] Result; 
 
wire[63:0] ConvertOuta,ConvertOutb,ConvertOutc,ConvertOutd; 
wire[79:0] ConvertOut1,ConvertOut2,ConvertOut3,ConvertOut4; 
reg[79:0]  ConvertIna,ConvertInb,ConvertInc,ConvertInd; 
reg[63:0] ConvertIn1,ConvertIn2,ConvertIn3,ConvertIn4; 
 
wire[31:0] ConvertOut32_1,ConvertOut32_2,ConvertOut32_3,ConvertOut32_4; 
reg[31:0] ConvertIn32_1,ConvertIn32_2,ConvertIn32_3,ConvertIn32_4; 
reg[31:0] ConvertIn32_5,ConvertIn32_6,ConvertIn32_7,ConvertIn32_8; 
wire[79:0] ConvertOut80_1,ConvertOut80_2,ConvertOut80_3,ConvertOut80_4; 
wire[79:0] ConvertOut80_5,ConvertOut80_6,ConvertOut80_7,ConvertOut80_8; 
reg[79:0] ConvertIn80_1,ConvertIn80_2,ConvertIn80_3,ConvertIn80_4; 
 
reg[79:0] Input1_1,Input2_1,Input1_2,Input2_2,Input1_3,Input2_3,Input1_4,Input2_4; 
wire[79:0] Sum_1,Sum_2,Sum_3,Sum_4; 
reg AddSub_1,AddSub_2,AddSub_3,AddSub_4; 
 
add_sub addsub_1(Sum_1,Input1_1,Input2_1,AddSub_1); //AddSub=1 for Substraction, 0 for Addition 
add_sub addsub_2(Sum_2,Input1_2,Input2_2,AddSub_2); 
add_sub addsub_3(Sum_3,Input1_3,Input2_3,AddSub_3); 
add_sub addsub_4(Sum_4,Input1_4,Input2_4,AddSub_4); 
 
Convert80To64 convert80to64_1(ConvertOuta, ConvertIna); //Converts 80bit value to 64bit 
Convert80To64 convert80to64_2(ConvertOutb, ConvertInb); //Converts 80bit value to 64bit 
Convert80To64 convert80to64_3(ConvertOutc, ConvertInc); //Converts 80bit value to 64bit 
Convert80To64 convert80to64_4(ConvertOutd, ConvertInd); //Converts 80bit value to 64bit 
 
Convert64 convert64_1(ConvertOut1, ConvertIn1);  //Converts 64bit value to 80bit 
Convert64 convert64_2(ConvertOut2, ConvertIn2);  //Converts 64bit value to 80bit 
Convert64 convert64_3(ConvertOut3, ConvertIn3);  //Converts 64bit value to 80bit 
Convert64 convert64_4(ConvertOut4, ConvertIn4);  //Converts 64bit value to 80bit 
 
Convert80To32 convert80to32_1(ConvertOut32_1,ConvertIn80_1); 
Convert80To32 convert80to32_2(ConvertOut32_2,ConvertIn80_2); 
Convert80To32 convert80to32_3(ConvertOut32_3,ConvertIn80_3); 
Convert80To32 convert80to32_4(ConvertOut32_4,ConvertIn80_4); 
 
Convert32 convert32_1(ConvertOut80_1,ConvertIn32_1); 
Convert32 convert32_2(ConvertOut80_2,ConvertIn32_2); 
Convert32 convert32_3(ConvertOut80_3,ConvertIn32_3); 
Convert32 convert32_4(ConvertOut80_4,ConvertIn32_4); 
Convert32 convert32_5(ConvertOut80_5,ConvertIn32_5); 
Convert32 convert32_6(ConvertOut80_6,ConvertIn32_6); 
Convert32 convert32_7(ConvertOut80_7,ConvertIn32_7); 
Convert32 convert32_8(ConvertOut80_8,ConvertIn32_8); 
 
always @(enablealu or Operation or Operand1 or Operand2 or Operand3 or ConvertOuta or ConvertOutb 
	or ConvertOut1 or ConvertOut2 or ConvertOut3 or ConvertOut4 or ConvertOut32_1 or ConvertOut32_2  
	or ConvertOut32_3 or ConvertOut32_4 or ConvertOut80_1 or ConvertOut80_2 or ConvertOut80_3 or  
	ConvertOut80_4 or Sum_1 or Sum_2 or Sum_3 or Sum_4 ) 
 begin 
   if(enablealu) 
    begin 
      Result = 0; 
case (Operation) 
 
11'd1: //ADDSUBPD -- Packed Double-FP Add/Subtract 
        begin  
	ConvertIn1 = Operand1[63:0]; 
	ConvertIn2 = Operand2[63:0]; 
	Input1_1 = ConvertOut1; 
	Input2_1 = ConvertOut2; 
	AddSub_1 = 1'b1;    //Substraction 
	 
	ConvertIna = Sum_1; 
 
	Result[63:0] = ConvertOuta; 
 
        ConvertIn3 = Operand1[127:64]; 
	ConvertIn4 = Operand2[127:64]; 
	Input1_2 = ConvertOut3; 
	Input2_2 = ConvertOut4; 
	AddSub_2 = 1'b0; //Addition 
 
	ConvertInb = Sum_2; 
 
	Result[127:64] = ConvertOutb; 
	end 
 
11'd2: //ADDSUBPS -- Packed Single-FP Add/Subtract 
 
	begin 
	ConvertIn32_1 = Operand1[31:0]; 
	ConvertIn32_2 = Operand2[31:0]; 
	Input1_1 = ConvertOut80_1; 
	Input2_1 = ConvertOut80_2; 
	AddSub_1 = 1'b1; //Substraction 
 
	ConvertIn80_1 = Sum_1; 
	Result[31:0] = ConvertOut32_1; 
 
	ConvertIn32_3 = Operand1[63:32]; 
	ConvertIn32_4 = Operand2[63:32]; 
	Input1_2 = ConvertOut80_3; 
	Input2_2 = ConvertOut80_4; 
	AddSub_2 = 1'b0; //Addition 
 
	ConvertIn80_2 = Sum_2; 
	Result[63:32] = ConvertOut32_2; 
 
	ConvertIn32_5 = Operand1[95:64]; 
	ConvertIn32_6 = Operand2[95:64]; 
	Input1_3 = ConvertOut80_5; 
	Input2_3 = ConvertOut80_6; 
	AddSub_3 = 1'b1; //Substraction 
 
	ConvertIn80_3 = Sum_3; 
	Result[95:64] = ConvertOut32_3; 
 
	ConvertIn32_7 = Operand1[127:96]; 
	ConvertIn32_8 = Operand2[127:96]; 
	Input1_4 = ConvertOut80_7; 
	Input2_4 = ConvertOut80_8; 
	AddSub_4 = 1'b0; //Addition 
 
	ConvertIn80_4 = Sum_4; 
	Result[127:96] = ConvertOut32_4; 
	end 
 
11'd3: //HADDPD -- Packed Double-FP Horizontal Add 
 
	begin 
	ConvertIn1 = Operand1[63:0]; 
	ConvertIn2 = Operand1[127:64]; 
	Input1_1 = ConvertOut1; 
	Input2_1 = ConvertOut2; 
	AddSub_1 = 1'b0;    //Addition 
	 
	ConvertIna = Sum_1; 
 
	Result[63:0] = ConvertOuta; 
 
        ConvertIn3 = Operand2[63:0]; 
	ConvertIn4 = Operand2[127:64]; 
	Input1_2 = ConvertOut3; 
	Input2_2 = ConvertOut4; 
	AddSub_2 = 1'b0; //Addition 
 
	ConvertInb = Sum_2; 
 
	Result[127:64] = ConvertOutb; 
	end 
 
11'd4: //HADDPS -- Packed Single--FP Horizontal Add 
 
	begin 
	ConvertIn32_1 = Operand1[31:0]; 
	ConvertIn32_2 = Operand1[63:32]; 
	Input1_1 = ConvertOut80_1; 
	Input2_1 = ConvertOut80_2; 
	AddSub_1 = 1'b0; //Addition 
 
	ConvertIn80_1 = Sum_1; 
	Result[31:0] = ConvertOut32_1; 
 
	ConvertIn32_3 = Operand1[95:64]; 
	ConvertIn32_4 = Operand1[127:96]; 
	Input1_2 = ConvertOut80_3; 
	Input2_2 = ConvertOut80_4; 
	AddSub_2 = 1'b0; //Addition 
 
	ConvertIn80_2 = Sum_2; 
	Result[63:32] = ConvertOut32_2; 
 
	ConvertIn32_5 = Operand2[31:0]; 
	ConvertIn32_6 = Operand2[63:32]; 
	Input1_3 = ConvertOut80_5; 
	Input2_3 = ConvertOut80_6; 
	AddSub_3 = 1'b0; //Addition 
 
	ConvertIn80_3 = Sum_3; 
	Result[95:64] = ConvertOut32_3; 
 
	ConvertIn32_7 = Operand2[95:64]; 
	ConvertIn32_8 = Operand2[127:96]; 
	Input1_4 = ConvertOut80_7; 
	Input2_4 = ConvertOut80_8; 
	AddSub_4 = 1'b0; //Addition 
 
	ConvertIn80_4 = Sum_4; 
	Result[127:96] = ConvertOut32_4; 
	end 
 
11'd5: //HSUBPD -- Packed Double-FP Horizontal Sub 
 
	begin 
	ConvertIn1 = Operand1[63:0]; 
	ConvertIn2 = Operand1[127:64]; 
	Input1_1 = ConvertOut1; 
	Input2_1 = ConvertOut2; 
	AddSub_1 = 1'b1;    //Substraction 
	 
	ConvertIna = Sum_1; 
 
	Result[63:0] = ConvertOuta; 
 
        ConvertIn1 = Operand2[63:0]; 
	ConvertIn2 = Operand2[127:64]; 
	Input1_2 = ConvertOut1; 
	Input2_2 = ConvertOut2; 
	AddSub_2 = 1'b1; //Substraction 
 
	ConvertInb = Sum_2; 
 
	Result[127:64] = ConvertOutb;	 
	end 
 
11'd6: //HSUBPS -- Packed Single-FP Horizontal Sub 
 
	begin 
	ConvertIn32_1 = Operand1[31:0]; 
	ConvertIn32_2 = Operand1[63:32]; 
	Input1_1 = ConvertOut80_1; 
	Input2_1 = ConvertOut80_2; 
	AddSub_1 = 1'b1; //Substraction 
 
	ConvertIn80_1 = Sum_1; 
	Result[31:0] = ConvertOut32_1; 
 
	ConvertIn32_3 = Operand1[95:64]; 
	ConvertIn32_4 = Operand1[127:96]; 
	Input1_2 = ConvertOut80_3; 
	Input2_2 = ConvertOut80_4; 
	AddSub_2 = 1'b1; //Substraction 
 
	ConvertIn80_2 = Sum_2; 
	Result[63:32] = ConvertOut32_2; 
 
	ConvertIn32_5 = Operand2[31:0]; 
	ConvertIn32_6 = Operand2[63:32]; 
	Input1_3 = ConvertOut80_5; 
	Input2_3 = ConvertOut80_6; 
	AddSub_3 = 1'b1; //Substraction 
 
	ConvertIn80_3 = Sum_3; 
	Result[95:64] = ConvertOut32_3; 
 
	ConvertIn32_7 = Operand2[95:64]; 
	ConvertIn32_8 = Operand2[127:96]; 
	Input1_4 = ConvertOut80_7; 
	Input2_4 = ConvertOut80_8; 
	AddSub_4 = 1'b1; //Substraction 
 
	ConvertIn80_4 = Sum_4; 
	Result[127:96] = ConvertOut32_4; 
	end 
 
 
/****Move Instructions****/ 
 
11'd13: //MOVDDUP - Move One Double Up and Duplicate 
 
	begin 
	Result[63:0] = Operand2[63:0]; 
	Result[127:64] = Operand2[63:0]; 
	end 
 
11'd14: //MOVSHDUP - Move Packed Single-FP High and Duplicate 
 
	begin 
	Result[31:0] = Operand2[63:32]; 
	Result[63:32] = Operand2[63:32]; 
	Result[95:64] = Operand2[127:96]; 
	Result[127:96] = Operand2[127:96]; 
	end 
 
11'd15: //MOVSLDUP - Move Packed Single-FP Low and Duplicate 
 
	begin 
	Result[31:0] = Operand2[31:0]; 
	Result[63:32] = Operand2[31:0]; 
	Result[95:64] = Operand2[95:64]; 
	Result[127:96] = Operand2[95:64]; 
	end 
	 
endcase 
	end 
		end 
endmodule