www.pudn.com > SHA1.zip > add_32_5_csa.v, change:2001-02-09,size:7690b


`include "csa32.v" 
 
module add_32_5_csa (a,b,c,d,e,	s); 
 
	input [31:0] a, b, c, d, e; 
	output [31:0] s; 
	 
	 
	wire [31:0] c_wire, s_wire, c_wire_1, s_wire_1, c_wire_2, s_wire_2, c_wire_3; 
	 
	fulladd u0 (a[0], b[0], c[0],		s_wire[0], c_wire[0]); 
	fulladd u1 (a[1], b[1], c[1],		s_wire[1], c_wire[1]); 
	fulladd u2 (a[2], b[2], c[2],		s_wire[2], c_wire[2]); 
	fulladd u3 (a[3], b[3], c[3],		s_wire[3], c_wire[3]); 
	fulladd u4 (a[4], b[4], c[4],		s_wire[4], c_wire[4]); 
	fulladd u5 (a[5], b[5], c[5],		s_wire[5], c_wire[5]); 
	fulladd u6 (a[6], b[6], c[6],		s_wire[6], c_wire[6]); 
	fulladd u7 (a[7], b[7], c[7],		s_wire[7], c_wire[7]); 
	fulladd u8 (a[8], b[8], c[8],		s_wire[8], c_wire[8]); 
	fulladd u9 (a[9], b[9], c[9], 		s_wire[9], c_wire[9]); 
	fulladd u10 (a[10], b[10], c[10],	s_wire[10], c_wire[10]); 
	fulladd u11 (a[11], b[11], c[11],	s_wire[11], c_wire[11]); 
	fulladd u12 (a[12], b[12], c[12],	s_wire[12], c_wire[12]); 
	fulladd u13 (a[13], b[13], c[13],	s_wire[13], c_wire[13]); 
	fulladd u14 (a[14], b[14], c[14],	s_wire[14], c_wire[14]); 
	fulladd u15 (a[15], b[15], c[15],	s_wire[15], c_wire[15]); 
	fulladd u16 (a[16], b[16], c[16],	s_wire[16], c_wire[16]); 
	fulladd u17 (a[17], b[17], c[17],	s_wire[17], c_wire[17]); 
	fulladd u18 (a[18], b[18], c[18],	s_wire[18], c_wire[18]); 
	fulladd u19 (a[19], b[19], c[19],	s_wire[19], c_wire[19]); 
	fulladd u20 (a[20], b[20], c[20],	s_wire[20], c_wire[20]); 
	fulladd u21 (a[21], b[21], c[21],	s_wire[21], c_wire[21]); 
	fulladd u22 (a[22], b[22], c[22],	s_wire[22], c_wire[22]); 
	fulladd u23 (a[23], b[23], c[23],	s_wire[23], c_wire[23]); 
	fulladd u24 (a[24], b[24], c[24],	s_wire[24], c_wire[24]); 
	fulladd u25 (a[25], b[25], c[25],	s_wire[25], c_wire[25]); 
	fulladd u26 (a[26], b[26], c[26],	s_wire[26], c_wire[26]); 
	fulladd u27 (a[27], b[27], c[27],	s_wire[27], c_wire[27]); 
	fulladd u28 (a[28], b[28], c[28],	s_wire[28], c_wire[28]); 
	fulladd u29 (a[29], b[29], c[29],	s_wire[29], c_wire[29]); 
	fulladd u30 (a[30], b[30], c[30],	s_wire[30], c_wire[30]); 
	fulladd u31 (a[31], b[31], c[31],	s_wire[31], c_wire[31]); 
		 
		 
	fulladd v0 (s_wire[0], d[0],     1'b 0,	   	s_wire_1[0], c_wire_1[0]); 
	fulladd v1 (s_wire[1], d[1], c_wire[0], 	s_wire_1[1], c_wire_1[1]); 
	fulladd v2 (s_wire[2], d[2], c_wire[1],    	s_wire_1[2], c_wire_1[2]); 
	fulladd v3 (s_wire[3], d[3], c_wire[2], 	s_wire_1[3], c_wire_1[3]); 
	fulladd v4 (s_wire[4], d[4], c_wire[3], 	s_wire_1[4], c_wire_1[4]); 
	fulladd v5 (s_wire[5], d[5], c_wire[4], 	s_wire_1[5], c_wire_1[5]); 
	fulladd v6 (s_wire[6], d[6], c_wire[5], 	s_wire_1[6], c_wire_1[6]); 
	fulladd v7 (s_wire[7], d[7], c_wire[6], 	s_wire_1[7], c_wire_1[7]); 
	fulladd v8 (s_wire[8], d[8], c_wire[7], 	s_wire_1[8], c_wire_1[8]); 
	fulladd v9 (s_wire[9], d[9], c_wire[8], 	s_wire_1[9], c_wire_1[9]); 
	fulladd v10 (s_wire[10], d[10], c_wire[9],      s_wire_1[10], c_wire_1[10]); 
	fulladd v11 (s_wire[11], d[11], c_wire[10],     s_wire_1[11], c_wire_1[11]); 
	fulladd v12 (s_wire[12], d[12], c_wire[11],     s_wire_1[12], c_wire_1[12]); 
	fulladd v13 (s_wire[13], d[13], c_wire[12],     s_wire_1[13], c_wire_1[13]); 
	fulladd v14 (s_wire[14], d[14], c_wire[13],     s_wire_1[14], c_wire_1[14]); 
	fulladd v15 (s_wire[15], d[15], c_wire[14],     s_wire_1[15], c_wire_1[15]); 
	fulladd v16 (s_wire[16], d[16], c_wire[15],     s_wire_1[16], c_wire_1[16]); 
	fulladd v17 (s_wire[17], d[17], c_wire[16],     s_wire_1[17], c_wire_1[17]); 
	fulladd v18 (s_wire[18], d[18], c_wire[17],     s_wire_1[18], c_wire_1[18]); 
	fulladd v19 (s_wire[19], d[19], c_wire[18],     s_wire_1[19], c_wire_1[19]); 
	fulladd v20 (s_wire[20], d[20], c_wire[19],     s_wire_1[20], c_wire_1[20]); 
	fulladd v21 (s_wire[21], d[21], c_wire[20],     s_wire_1[21], c_wire_1[21]); 
	fulladd v22 (s_wire[22], d[22], c_wire[21],     s_wire_1[22], c_wire_1[22]); 
	fulladd v23 (s_wire[23], d[23], c_wire[22],     s_wire_1[23], c_wire_1[23]); 
	fulladd v24 (s_wire[24], d[24], c_wire[23],     s_wire_1[24], c_wire_1[24]); 
	fulladd v25 (s_wire[25], d[25], c_wire[24],     s_wire_1[25], c_wire_1[25]); 
	fulladd v26 (s_wire[26], d[26], c_wire[25],     s_wire_1[26], c_wire_1[26]); 
	fulladd v27 (s_wire[27], d[27], c_wire[26],     s_wire_1[27], c_wire_1[27]); 
	fulladd v28 (s_wire[28], d[28], c_wire[27],     s_wire_1[28], c_wire_1[28]); 
	fulladd v29 (s_wire[29], d[29], c_wire[28],     s_wire_1[29], c_wire_1[29]); 
	fulladd v30 (s_wire[30], d[30], c_wire[29],     s_wire_1[30], c_wire_1[30]); 
	fulladd v31 (s_wire[31], d[31], c_wire[30],     s_wire_1[31], c_wire_1[31]); 
	 
	 
	fulladd x0 (s_wire_1[0], e[0], 1'b 0, 			   	s_wire_2[0], c_wire_2[0]); 
	fulladd x1 (s_wire_1[1], e[1] ,c_wire_1[0], 		s_wire_2[1], c_wire_2[1]); 
	fulladd x2 (s_wire_1[2], e[2] ,c_wire_1[1], 	   	s_wire_2[2], c_wire_2[2]); 
	fulladd x3 (s_wire_1[3], e[3] ,c_wire_1[2], 		s_wire_2[3], c_wire_2[3]); 
	fulladd x4 (s_wire_1[4], e[4] ,c_wire_1[3], 		s_wire_2[4], c_wire_2[4]); 
	fulladd x5 (s_wire_1[5], e[5] ,c_wire_1[4], 		s_wire_2[5], c_wire_2[5]); 
	fulladd x6 (s_wire_1[6], e[6] ,c_wire_1[5], 		s_wire_2[6], c_wire_2[6]); 
	fulladd x7 (s_wire_1[7], e[7] ,c_wire_1[6], 		s_wire_2[7], c_wire_2[7]); 
	fulladd x8 (s_wire_1[8], e[8] ,c_wire_1[7], 		s_wire_2[8], c_wire_2[8]); 
	fulladd x9 (s_wire_1[9], e[9] ,c_wire_1[8], 		s_wire_2[9], c_wire_2[9]); 
	fulladd x10 (s_wire_1[10], e[10] ,c_wire_1[9], 	    s_wire_2[10], c_wire_2[10]); 
	fulladd x11 (s_wire_1[11], e[11] ,c_wire_1[10],     s_wire_2[11], c_wire_2[11]); 
	fulladd x12 (s_wire_1[12], e[12] ,c_wire_1[11],     s_wire_2[12], c_wire_2[12]); 
	fulladd x13 (s_wire_1[13], e[13] ,c_wire_1[12],     s_wire_2[13], c_wire_2[13]); 
	fulladd x14 (s_wire_1[14], e[14] ,c_wire_1[13],     s_wire_2[14], c_wire_2[14]); 
	fulladd x15 (s_wire_1[15], e[15] ,c_wire_1[14],     s_wire_2[15], c_wire_2[15]); 
	fulladd x16 (s_wire_1[16], e[16] ,c_wire_1[15],     s_wire_2[16], c_wire_2[16]); 
	fulladd x17 (s_wire_1[17], e[17] ,c_wire_1[16],     s_wire_2[17], c_wire_2[17]); 
	fulladd x18 (s_wire_1[18], e[18] ,c_wire_1[17],     s_wire_2[18], c_wire_2[18]); 
	fulladd x19 (s_wire_1[19], e[19] ,c_wire_1[18],     s_wire_2[19], c_wire_2[19]); 
	fulladd x20 (s_wire_1[20], e[20] ,c_wire_1[19],     s_wire_2[20], c_wire_2[20]); 
	fulladd x21 (s_wire_1[21], e[21] ,c_wire_1[20],     s_wire_2[21], c_wire_2[21]); 
	fulladd x22 (s_wire_1[22], e[22] ,c_wire_1[21],     s_wire_2[22], c_wire_2[22]); 
	fulladd x23 (s_wire_1[23], e[23] ,c_wire_1[22],     s_wire_2[23], c_wire_2[23]); 
	fulladd x24 (s_wire_1[24], e[24] ,c_wire_1[23],     s_wire_2[24], c_wire_2[24]); 
	fulladd x25 (s_wire_1[25], e[25] ,c_wire_1[24],     s_wire_2[25], c_wire_2[25]); 
	fulladd x26 (s_wire_1[26], e[26] ,c_wire_1[25],     s_wire_2[26], c_wire_2[26]); 
	fulladd x27 (s_wire_1[27], e[27] ,c_wire_1[26],     s_wire_2[27], c_wire_2[27]); 
	fulladd x28 (s_wire_1[28], e[28] ,c_wire_1[27],     s_wire_2[28], c_wire_2[28]); 
	fulladd x29 (s_wire_1[29], e[29] ,c_wire_1[28],     s_wire_2[29], c_wire_2[29]); 
	fulladd x30 (s_wire_1[30], e[30] ,c_wire_1[29],     s_wire_2[30], c_wire_2[30]); 
	fulladd x31 (s_wire_1[31], e[31] ,c_wire_1[30],     s_wire_2[31], c_wire_2[31]); 
	 
 
	assign c_wire_3[31:1] = c_wire_2[30:0]; 
	assign c_wire_3[0]= 0; 
	 
	csa32 csa32_0 (c_wire_3, s_wire_2, s);	 
	 
 
endmodule 
 
 
module fulladd (a, b, c_in,    s, c_out); 
	input a, b, c_in; 
	output	s, c_out; 
	wire	s1, c1, c2, c_out_bar; 
	 
	halfadd H1(a, b, s1, c1); 
	halfadd H2(s1, c_in, s,c2); 
	nor nor1(c_out_bar, c1,c2); 
	not not1(c_out, c_out_bar); 
endmodule 
 
 
 
module halfadd(a,b, s,c); 
	input a, b; 
	output s, c; 
	wire	c_bar; 
	 
	xor xor1(s, a,b); 
	nand nand1(c_bar,a,b); 
	not not2(c, c_bar); 
endmodule