-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathex-basics-logic-sbit.v
49 lines (33 loc) · 1.11 KB
/
ex-basics-logic-sbit.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
module top;
// Declare single-bit logic variables.
logic a;
logic b;
logic c;
initial begin
// Single-bit literals
a = 1'b0; $display( "1'b0 = %x ", a );
a = 1'b1; $display( "1'b1 = %x ", a );
a = 1'bx; $display( "1'bx = %x ", a );
a = 1'bz; $display( "1'bz = %x ", a );
// Bitwise logical operators for doing AND, OR, XOR, and NOT
a = 1'b0;
b = 1'b1;
c = a & b; $display( "0 & 1 = %x ", c );
c = a | b; $display( "0 | 1 = %x ", c );
c = a ^ b; $display( "0 ^ 1 = %x ", c );
c = ~b; $display( "~1 = %x ", c );
// Bitwise logical operators for doing AND, OR, XOR, and NOT with X
a = 1'b0;
b = 1'bx;
c = a & b; $display( "0 & x = %x ", c );
c = a | b; $display( "0 | x = %x ", c );
c = a ^ b; $display( "0 ^ x = %x ", c );
c = ~b; $display( "~x = %x ", c );
// Boolean logical operators
a = 1'b0;
b = 1'b1;
c = a && b; $display( "0 && 1 = %x ", c );
c = a || b; $display( "0 || 1 = %x ", c );
c = !b; $display( "!1 = %x ", c );
end
endmodule