OpenCores
URL https://opencores.org/ocsvn/generic_parameterized_carry_lookahead_adder/generic_parameterized_carry_lookahead_adder/trunk

Subversion Repositories generic_parameterized_carry_lookahead_adder

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 1 to Rev 2
    Reverse comparison

Rev 1 → Rev 2

/generic_parameterized_carry_lookahead_adder/trunk/trunk/bench/tb.v
0,0 → 1,33
module tb;
reg [2:0]A,B;
wire [2:0]S;
reg Cin;
wire Cout;
 
carry_lookahead_adder #(.N(3)) DUT(.A(A), .B(B), .S(S), .Cout(Cout), .Cin(Cin));
 
 
task load(input [2:0]a,b, input c); begin
A = a;
B = b;
Cin = c;
end
endtask
 
integer i , j,k;
initial begin
$dumpfile ("carry_lookahead_adder.vcd");
$dumpvars (0, tb);
for (k=0;k<2;k=k+1) begin
for (i=0; i<8 ; i=i+1) begin
for(j=0;j<8;j=j+1) begin
load(i,j,k);
#10;
end
end
end
$finish;
end
initial $monitor("A = %b, B = %b, Cin = %b, Cout = %b, Sum = %b",A,B,Cin,Cout,S);
 
endmodule
/generic_parameterized_carry_lookahead_adder/trunk/trunk/rtl/carry_generate.v
0,0 → 1,13
module carry_generate(P,G,C,Cin);
parameter N = 2;
input [N-1:0]P,G;
input Cin;
output [N:0]C;
assign C[0] =Cin;
genvar i;
generate for(i=1;i<=N;i=i+1) begin
assign C[i] = G[i-1] | (P[i-1]&C[i-1]);
end
endgenerate
 
endmodule
/generic_parameterized_carry_lookahead_adder/trunk/trunk/rtl/carry_lookahead_adder.v
0,0 → 1,17
module carry_lookahead_adder(A,B,S,Cout,Cin);
parameter N = 2;
input [N-1:0]A,B;
input Cin;
output [N-1:0]S;
output Cout;
 
wire [N-1:0]P, G ;
wire [N:0]C;
propagate_generate #(.N(N)) M1(.A(A), .B(B), .P(P), .G(G));
carry_generate #(.N(N)) M2 (.P(P), .G(G), .C(C), .Cin(Cin));
 
assign S = P ^ C;
assign Cout = C[N];
 
endmodule
/generic_parameterized_carry_lookahead_adder/trunk/trunk/rtl/propagate_generate.v
0,0 → 1,11
module propagate_generate(A,B,P,G);
parameter N = 2;
input [N-1 :0] A,B;
output [N-1 :0]P,G;
 
assign P = A^B;
assign G = A&B;
 
endmodule
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.