-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadder_explicit.v
More file actions
72 lines (63 loc) · 1.08 KB
/
adder_explicit.v
File metadata and controls
72 lines (63 loc) · 1.08 KB
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
72
//---------------------------------------
// THis is simple adder Program
// Design Name : adder_explicit
// File Name : adder_explicit.v
// Function : This program shows how implicit
// port connection are done
// Coder : Mayank Parasar
//---------------------------------------
`include "comment.v"
module adder_explicit (
result, // Output of the adder
carry, // Carry output of adder
r1, // first input
r2, // second input
ci // carry input
);
// Input Port Declarations
input [3:0] r1;
input [3:0] r2;
input ci;
// Output Port Declarations
output [3:0] result;
output carry;
// Port Wires
wire [3:0] r1;
wire [3:0] r2;
wire ci;
wire [3:0] result;
wire carry;
// Internal variables
wire c1;
wire c2;
wire c3;
// Code starts here
addbit u0 (
.a (r1[0]),
.b (r2[0]),
.ci (ci),
.sum (result[0]),
.co (c1)
);
addbit u1 (
.a (r1[1]),
.b (r2[1]),
.ci (c1),
.sum (result[1]),
.co (c2)
);
addbit u2 (
.a (r1[2]),
.b (r2[2]),
.ci (c2),
.sum (result[2]),
.co (c3)
);
addbit u3 (
.a (r1[3]),
.b (r2[3]),
.ci (c3),
.sum (result[3]),
.co (carry)
);
endmodule