-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfulladder.sv
More file actions
47 lines (38 loc) · 999 Bytes
/
Copy pathfulladder.sv
File metadata and controls
47 lines (38 loc) · 999 Bytes
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
// full adder design
interface fulladder();
logic a , b , c ;
logic s , carry ;
modport dut(input a,b,c,output s,carry);
modport tb(input s ,carry , output a,b,c);
endinterface
module f_add(fulladder.dut inf);
initial begin
assign inf.s = inf.a ^ inf.b ^ inf.c;
assign inf.carry = (inf.a&inf.b) | (inf.a^ inf.b)&inf.c ;
end
endmodule
// code for the full adder
// code for testbench
// Code your testbench here
module ftb(fulladder.tb intf);
initial begin
#5 intf.a=1'b0;intf.b=1'b0;intf.c=1'b0;
#5 intf.a=1'b0;intf.b=1'b0;intf.c=1'b1;
#5 intf.a=1'b0;intf.b=1'b1;intf.c=1'b0;
#5 intf.a=1'b0;intf.b=1'b1;intf.c=1'b1;
#5 intf.a=1'b1;intf.b=1'b0;intf.c=1'b1;
#5 intf.a=1'b1;intf.b=1'b1;intf.c=1'b0;
#5 intf.a=1'b1;intf.b=1'b1;intf.c=1'b1;
#200 $finish;
end
initial
begin
$dumpfile("dump.vcd");
$dumpvars;
end
endmodule
module Ftop();
fulladder infc();
f_add dut(infc) ;
ftb tb(infc);
endmodule