Beruflich Dokumente
Kultur Dokumente
EXPERIMENT 1
AIM : To design and simulate a half-adder and full-adder using Verilog HDL using different
modelling.
Truth table :
Half-adder
Full-adder
Cin
Cout
Diagram :
Half Adder
Full Adder
VERILOG CODE :
Gate level Modelling
Half Adder
module ha1(a, b, s, c);
input a, b;
output c,s;
and(c,a,b);
xor(s,a,b);
3
endmodule
Full Adder
module fa11(a, b, c, s, ca);
input a,b,c;
output ca,s;
wire d,f,g;
xor(d,a,b); xor(s,d,c); and(f,d,c); and(g,a,b); or(ca,f,g);
endmodule
Data flow level Modelling
Half Adder
module ha_flow1(a, b, s, c);
input a,b;
output c,s;
assign {c,s}=a+b;
endmodule
Full Adder
module fa_flow1(a, b, ci, s, co);
input a,b,ci;
output co,s;
assign {co,s}=a+b+ci;
endmodule
Behavioural level Modelling
Half Adder
module ha_beh1(a, b, s, c);
input a,b;
output reg c,s;
initial
begin
c=0; s=0;
end
always @(a,b)
begin
case({a,b})
0: begin s=0; c=0; end
4
end
always @(a,b,ci)
begin
case({a,b,ci})
0: begin s=0; co=0; end
1: begin s=1; co=0; end
2: begin s=1; co=0; end
3: begin s=0; co=1; end
4: begin s=1; co=0; end
5: begin s=0; co=1; end
6: begin s=0; co=1; end
7: begin s=1; co=1; end
endcase
end
endmodule
Half Adder
Full Adder
Data flow level Modelling
Half Adder
Full Adder
Behavioural level Modelling
Half Adder
Full Adder
OUTPUT WAVEFORM :
Half Adder
Full Adder
RESULT : Half adder and Full adder are successfully implemented using different modelling and
their operations are verified through simulation.
8