|
| 1 | +module submoduleA(input [2:0] some_input); |
| 2 | +endmodule |
| 3 | + |
| 4 | +module submoduleB(output [2:0] some_output); |
| 5 | + assign some_output = 1'd1+1'd1; |
| 6 | +endmodule |
| 7 | + |
| 8 | +module main; |
| 9 | + |
| 10 | + // 1800-2017 10.8 Assignment-like contexts |
| 11 | + |
| 12 | + // continuous assignment |
| 13 | + wire [1:0] v1; |
| 14 | + assign v1 = 1'd1+1'd1; |
| 15 | + assert final (v1 == 2'd2); |
| 16 | + |
| 17 | + // procedural assignment |
| 18 | + reg [1:0] v2; |
| 19 | + initial v2 = 1'd1+1'd1; |
| 20 | + assert final (v2 == 2'd2); |
| 21 | + |
| 22 | + // parameter with explicit type declaration |
| 23 | + parameter [1:0] v3 = 1'd1+1'd1; |
| 24 | + assert final (v3 == 2'd2); |
| 25 | + |
| 26 | + // A port connection to an input port of a module |
| 27 | + submoduleA subA(1'd1+1'd1); |
| 28 | + assert final (subA.some_input == 2'd2); |
| 29 | + |
| 30 | + // A port connection to an output port of a module |
| 31 | + submoduleB subB(); |
| 32 | + assert final (subB.some_output == 2'd2); |
| 33 | + |
| 34 | + // The passing of a value to a subroutine input port |
| 35 | + task my_task(input [1:0] some_input); |
| 36 | + assert final (some_input == 2'd2); |
| 37 | + endtask |
| 38 | + |
| 39 | + initial my_task(1'd1+1'd1); |
| 40 | + |
| 41 | + // A return statement in a function |
| 42 | + function [1:0] my_fun; |
| 43 | + return 1'd1+1'd1; |
| 44 | + endfunction |
| 45 | + |
| 46 | + assert final (my_fun() == 2'd2); |
| 47 | + |
| 48 | + // A tagged union expression |
| 49 | + |
| 50 | + // recursively, an expression within parentheses |
| 51 | + wire [1:0] v4; |
| 52 | + assign v4 = (1'd1+1'd1); |
| 53 | + assert final (v4 == 2'd2); |
| 54 | + |
| 55 | + // recursively, the second and third operand of ?: |
| 56 | + wire [1:0] v5; |
| 57 | + assign v5 = 0 ? 1'b0 : 1'd1+1'd1; |
| 58 | + assert final (v4 == 2'd2); |
| 59 | + |
| 60 | + // nondefault value in assignment pattern |
| 61 | + |
| 62 | +endmodule |
0 commit comments