K
khushalgelda
Guest
i connected 2 4-bit carry look-ahead adders. everything worked fine
but i dont see COUT2 in my simulation window..
whats the problem ??
// 1st cla
module alu1(cout,sum,x,y,cin);
output cout;
output [3:0] sum;
input [3:0] x,y;
input cin;
wire [3:0] g,p;
wire [4:0] c;
assign c[0] = cin;
assign g[3:0] = x[3:0] & y[3:0];
assign p[3:0] = x[3:0] ^ y[3:0];
assign c[1] = g[0] | (p[0]&cin);
assign c[2] = g[1] | (p[1]&g[0]) | (p[1]&p[0]&cin);
assign c[3] = g[2] | (p[2]&g[1]) | (p[2]&p[1]&g[0]) |
(p[2]&p[1]&p[0]&cin);
assign c[4] = g[3] | (p[3]&g[2]) | (p[3]&p[2]&g[1]) |
(p[3]&p[2]&p[1]&g[0]) | (p[3]&p[2]&p[1]&p[0]&cin);
assign sum[3:0] = p[3:0] ^ c[3:0];
assign cout=c[4];
endmodule
// 2nd cla
module alu2(cout2,sum,x,y,cout);
output wire cout2;
output [7:4] sum;
input [7:4] x,y;
input cout;
wire [7:4] g,p;
wire [8:4] c;
assign c[4] = cout;
assign g[7:4] = x[7:4] & y[7:4];
assign p[7:4] = x[7:4] ^ y[7:4];
assign c[5] = g[4] | (p[4]&cout);
assign c[6] = g[5] | (p[5]&g[4]) | (p[5]&p[4]&cout);
assign c[7] = g[6] | (p[6]&g[5]) | (p[6]&p[5]&g[4]) |
(p[6]&p[5]&p[4]&cout);
assign c[8] = g[7] | (p[7]&g[6]) | (p[7]&p[6]&g[5]) |
(p[7]&p[6]&p[5]&g[4]) | (p[7]&p[6]&p[5]&p[4]&cout);
assign sum[7:4] = p[7:4] ^ c[7:4];
assign cout2=c[8];
endmodule
// joining 2 4-bit carry look-ahead adders
module top(COUT2, SUM, X,Y,CIN);
output COUT2;
input [7:0] X,Y;
input CIN;
output [7:0] SUM;
wire cout;
// instantiating
alu1 alu1(cout,SUM[3:0],X[3:0],Y[3:0],CIN);
alu2 alu2(COUT2,SUM[7:4],X[7:4],Y[7:4],cout);
endmodule
but i dont see COUT2 in my simulation window..
whats the problem ??
// 1st cla
module alu1(cout,sum,x,y,cin);
output cout;
output [3:0] sum;
input [3:0] x,y;
input cin;
wire [3:0] g,p;
wire [4:0] c;
assign c[0] = cin;
assign g[3:0] = x[3:0] & y[3:0];
assign p[3:0] = x[3:0] ^ y[3:0];
assign c[1] = g[0] | (p[0]&cin);
assign c[2] = g[1] | (p[1]&g[0]) | (p[1]&p[0]&cin);
assign c[3] = g[2] | (p[2]&g[1]) | (p[2]&p[1]&g[0]) |
(p[2]&p[1]&p[0]&cin);
assign c[4] = g[3] | (p[3]&g[2]) | (p[3]&p[2]&g[1]) |
(p[3]&p[2]&p[1]&g[0]) | (p[3]&p[2]&p[1]&p[0]&cin);
assign sum[3:0] = p[3:0] ^ c[3:0];
assign cout=c[4];
endmodule
// 2nd cla
module alu2(cout2,sum,x,y,cout);
output wire cout2;
output [7:4] sum;
input [7:4] x,y;
input cout;
wire [7:4] g,p;
wire [8:4] c;
assign c[4] = cout;
assign g[7:4] = x[7:4] & y[7:4];
assign p[7:4] = x[7:4] ^ y[7:4];
assign c[5] = g[4] | (p[4]&cout);
assign c[6] = g[5] | (p[5]&g[4]) | (p[5]&p[4]&cout);
assign c[7] = g[6] | (p[6]&g[5]) | (p[6]&p[5]&g[4]) |
(p[6]&p[5]&p[4]&cout);
assign c[8] = g[7] | (p[7]&g[6]) | (p[7]&p[6]&g[5]) |
(p[7]&p[6]&p[5]&g[4]) | (p[7]&p[6]&p[5]&p[4]&cout);
assign sum[7:4] = p[7:4] ^ c[7:4];
assign cout2=c[8];
endmodule
// joining 2 4-bit carry look-ahead adders
module top(COUT2, SUM, X,Y,CIN);
output COUT2;
input [7:0] X,Y;
input CIN;
output [7:0] SUM;
wire cout;
// instantiating
alu1 alu1(cout,SUM[3:0],X[3:0],Y[3:0],CIN);
alu2 alu2(COUT2,SUM[7:4],X[7:4],Y[7:4],cout);
endmodule