`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 20:19:06 07/21/2018 // Design Name: // Module Name: Walace_tree // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // Revision: // Revision 0.01 - File Created // Additional Comments: // ////////////////////////////////////////////////////////////////////////////////// module Walace_tree(x1,x2,x3,x4,x5,x6,x7,s,cout ); input [7:0] x1,x2,x3,x4,x5,x6,x7; output [9:0] s; output cout; wire [7:0] c1,c2,c3,c4,c5; wire [7:0] s1,s2,s3,s4,s5,s33,s55,c44; csa_8bit m1(x1,x2,x3,s1,c1); csa_8bit m2(x4,x5,x6,s2,c2); csa_8bit m3(x7,s1,s2,s3,c3); csa_8bit m4(c1,c2,c3,s4,c4); assign s33 = {1'b0,s3[7:1]}; assign c44 = {c4[6:0],1'b0}; csa_8bit m5(s4,c44,s33,s5,c5); assign s55 = {c4[7],s5[7:1]}; cpa_8bit m6(s55,c5,s[9:2],cout); assign s[0] = s3[0]; assign s[1] = s5[0]; endmodule module csa_8bit(a,b,d,s,c ); input [7:0] a,b,d; output [7:0] s,c; fa m1(a[0],b[0],d[0],s[0],c[0],); fa m2(a[1],b[1],d[1],s[1],c[1],); fa m3(a[2],b[2],d[2],s[2],c[2],); fa m4(a[3],b[3],d[3],s[3],c[3],); fa m5(a[4],b[4],d[4],s[4],c[4],); fa m6(a[5],b[5],d[5],s[5],c[5],); fa m7(a[6],b[6],d[6],s[6],c[6],); fa m8(a[7],b[7],d[7],s[7],c[7],); endmodule module cpa_8bit(s,c,s1,cout ); input [7:0] s,c; output [7:0] s1; output cout; wire c1,c2,c3,c4,c5,c6,c7; ha m1(s[0],c[0],s1[0],c1); fa m2(s[1],c[1],c1,s1[1],c2,); fa m3(s[2],c[2],c2,s1[2],c3,); fa m4(s[3],c[3],c3,s1[3],c4,); fa m5(s[4],c[4],c4,s1[4],c5,); fa m6(s[5],c[5],c5,s1[5],c6,); fa m7(s[6],c[6],c6,s1[6],c7,); fa m8(s[7],c[7],c7,s1[7],cout,); endmodule