-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoperators.v
39 lines (35 loc) · 840 Bytes
/
operators.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
module logical_operator_summary();
reg[2:0] a, b, c;
reg a1, b2, c3;
initial
begin
a = 12;
b = 3'b101;
c = 2'h4;
a1 = a && b; // AND op
b2 = b || c; // OR op
c3 = !(b||c); // NOT of b and c
$display("Results are: %a1, %b2, %c3", a1, b2, c3);
end
endmodule
module reduction_operators();
reg[2:0] a, b, c;
reg a1, b2, c3;
initial
begin
a = 3'b110;
b = 4'b0011;
a1 = ~& a; // NAND of a - bit by bit
b2 = ^b; // XOR of b
end
endmodule
module shift_op();
// from the above values of a,b,c
wire a, b, c, a1, b2, c3;
initial
begin
a1 = a << 2; // left shift_op
b2 = b >>3; // right shift by 3
c3 = c >>> 1; // arithmeticlay shift c by 3
end
endmodule