-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfulladd.v
71 lines (55 loc) · 1001 Bytes
/
fulladd.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Name: Utkarsha Dongarjal
// Date: 12/07/2024
// Project Name: 4-bit Full adder using Verilog HDL
`timescale 1ns / 1ps
module fulladd(a, b, cin, sum, cout);
input [3:0] a, b;
input cin;
output reg [3:0] sum;
output reg cout;
always @ (a or b or cin)
begin
{cout, sum} = a + b + cin;
end
endmodule
module tb_fulladd;
reg [3:0] a;
reg [3:0] b;
reg cin;
wire [3:0] sum;
wire cout;
fulladd uut (
.a(a),
.b(b),
.cin(cin),
.sum(sum),
.cout(cout)
);
initial begin
a = 0;
b = 0;
cin = 0;
#100;
a = 2;
b = 3;
cin = 1;
#100;
a = 6;
b = 2;
cin = 0;
#100;
a = 7;
b = 3;
cin = 1;
#100;
a = 6;
b = 6;
cin = 0;
#100;
a = 6;
b = 6;
cin = 1;
#100;
$finish;
end
endmodule