|
|
When a binary operator has one operand of type bit and another of type logic, the result is of type logic. If one operand is of type int and the other of type integer, the result is of type integer. The operators != and == return an X if either operand contains an X or a Z, as in Verilog-2001. This is converted to a 0 if the result is converted to type bit, e.g. in an if statement. The unary reduction operators (& ~& | ~| ^ ~^) can be applied to any integer expression (including packed arrays). The operators shall return a single value of type logic if the packed type is four valued, and of type bit if the packed type is two valued. |
|
|
1 module bit_logic_operator ();
2
3 bit [7:0] a = 8'b01xz_01xz;
4 logic [7:0] b = 8'b01xz_01xz;
5 integer c = 32'b01xz_01xz_01xz_01xz;
6 int d = 32'b01xz_01xz_01xz_01xz;
7
8 initial begin
9 $display ("Value of bit a = %b", a);
10 $display ("Value of logic b = %b", b);
11 $display ("Value of integer c = %b", c);
12 $display ("Value of int d = %b", d);
13 $display (" bit + integer = %b", a + c);
14 $display (" logic + int = %b", b + d);
15 a = 10;
16 b = 20;
17 c = 30;
18 d = 40;
19 $display (" bit + logic = %b", a + b);
20 $display (" integer + int = %b", c + d);
21 end
22
23 endmodule
You could download file bit_logic_operator.sv here
|