-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathor gate
66 lines (60 loc) · 1.19 KB
/
or gate
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
// This file implements or gate in different levels of abstraction in different modules. There is testbench for each module which has a particular level of abstraction, these
//test bench modules test the functionality of the modules that implement the functionality of or gate.
module or1 (y,a,b); // Gate level modelling
input a,b;
output y;
or (y,a,b);
endmodule
module or2(y,a,b); //Dataflow modelling
input a,b;
output y;
assign y=(a|b);
endmodule
module or3(output reg y, input a,input b); //Behavioral modelling
always @ (a or b)
if((a==1'b0)&&(b==1'b0))
y=1'b0;
else if((a==1'b1)||(b==1'b1))
y=1'b1;
else
y=1'bx;
endmodule
module stimulus1;
wire y;
reg a,b;
or1 an(y,a,b);
initial
begin
$monitor($time,"Output = %b, A = %b, B = %b", y,a,b);
#5 a=1'b0; b=1'b0;
#5 a=1'b1;
#10 a=1'b0; b=1'b1;
#5 a=1'b1;
end
endmodule
module stimulus2;
wire y;
reg a,b;
or2 an(y,a,b);
initial
begin
$monitor($time,"Output = %b, A = %b, B = %b", y,a,b);
#5 a=1'b0; b=1'b0;
#5 a=1'b1;
#10 a=1'b0; b=1'b1;
#5 a=1'b1;
end
endmodule
module stimulus3;
wire y;
reg a,b;
or3 an(y,a,b);
initial
begin
$monitor($time,"Output = %b, A = %b, B = %b", y,a,b);
#5 a=1'b0; b=1'b0;
#5 a=1'b1;
#10 a=1'b0; b=1'b1;
#5 a=1'b1;
end
endmodule