1module t (/*AUTOARG*/ 2 // Inputs 3 clk 4 ); 5 input clk; 6 7 string test_string = "abcd"; 8 9 int array3d[2][3][4] = '{ 10 '{ 11 '{ 0, 1, 2, 3}, 12 '{ 4, 5, 6, 7}, 13 '{ 8, 9, 10, 11} 14 }, 15 '{ 16 '{ 12, 13, 14, 15}, 17 '{ 16, 17, 18, 19}, 18 '{ 20, 21, 22, 23} 19 } 20 }; 21 int pos; 22 int val; 23 int i; 24 byte b; 25 26 int data[4] = '{1, 2, 3, 4}; 27 28 generate 29 genvar j; 30 int gdata[4]; 31 for (j=0; j < 5; j++) begin 32 initial if (j >= 5) $stop; 33 end 34 35 for (j=0; j < 5; ++j) begin 36 initial if (j >= 5) $stop; 37 end 38 39 for (j=10; j >= 5; j--) begin 40 initial if (j < 5) $stop; 41 end 42 43 for (j=10; j >= 5; --j) begin 44 initial if (j < 5) $stop; 45 end 46 endgenerate 47 48 initial begin 49 pos = 0; 50 pos++; 51 if (pos != 1) $stop; 52 53 array3d[0][0][0]++; 54 if (array3d[0][0][0] != 1) $stop; 55 56 --array3d[0][0][0]; 57 if (array3d[0][0][0] != 0) $stop; 58 59 pos = 2; 60 b = test_string[--pos]; 61 if (b !== "b") $stop; 62 if (pos !== 1) $stop; 63 64 pos = 1; 65 b = test_string[++pos]; 66 if (b !== "c") $stop; 67 if (pos !== 2) $stop; 68 69 pos = 3; 70 b = test_string[pos--]; 71 if (b !== "d") $stop; 72 if (pos !== 2) $stop; 73 74 pos = 0; 75 b = test_string[pos++]; 76 if (b !== "a") $stop; 77 if (pos !== 1) $stop; 78 79 pos = 0; 80 val = array3d[++pos][--pos][++pos]; 81 if (pos !== 1) $stop; 82 if (val !== 13) $stop; 83 84 pos = 0; 85 val = array3d[++pos][pos--][++pos]; 86 if (pos !== 1) $stop; 87 if (val !== 17) $stop; 88 89 for (i=0; data[++i]<4;) begin 90 // loop with multiple statements 91 pos = i; 92 val = data[i]; 93 end 94 95 if (pos !== 2) $stop; 96 if (i !== 3) $stop; 97 if (val !== 3) $stop; 98 99 i = 0; 100 while (data[i++]<4) begin 101 // loop with multiple statements 102 pos = i; 103 val = data[i]; 104 end 105 106 if (pos !== 3) $stop; 107 if (i !== 4) $stop; 108 if (val !== 4) $stop; 109 110 111 pos = 0; 112 if (1 == 1) begin 113 pos++; 114 end 115 if (pos != 1) $stop; 116 117 pos = 0; 118 if (1 == 1) pos++; 119 if (pos != 1) $stop; 120 121 $write("*-* All Finished *-*\n"); 122 $finish; 123 124 end 125endmodule 126