File: t_assert_disable_count.v

package info (click to toggle)
verilator 5.038-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 162,552 kB
  • sloc: cpp: 139,204; python: 20,931; ansic: 10,222; yacc: 6,000; lex: 1,925; makefile: 1,260; sh: 494; perl: 282; fortran: 22
file content (69 lines) | stat: -rw-r--r-- 1,865 bytes parent folder | download | duplicates (2)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2024 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0

`define stop $stop
`define checkd(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got=%0d exp=%0d (%s !== %s)\n", `__FILE__,`__LINE__, (gotv), (expv), `"gotv`", `"expv`"); `stop; end while(0);

module t (/*AUTOARG*/
   // Inputs
   clk
   );

   input clk;

   int cyc;

   Sub sub ();

   default disable iff (cyc[0]);

   int a_false;
   always @(posedge clk iff !cyc[0]) begin
      if (cyc < 4 || cyc > 9) ;
      else a_false = a_false + 1;
   end

   int a0_false;
   a0: assert property (@(posedge clk) disable iff (cyc[0]) (cyc < 4 || cyc > 9))
     else a0_false = a0_false + 1;

   int a1_false;
   // Note that Verilator supports $inferred_disable in general expression locations
   // This is a superset of what IEEE specifies
   a1: assert property (@(posedge clk) disable iff ($inferred_disable) (cyc < 4 || cyc > 9))
     else a1_false = a1_false + 1;

   int a2_false;
   // Implicitly uses $inferred_disable
   a2: assert property (@(posedge clk) (cyc < 4 || cyc > 9))
     else a2_false = a2_false + 1;

   int a3_false;
   // A different disable iff expression
   a3: assert property (@(posedge clk) disable iff (cyc == 5) (cyc < 4 || cyc > 9))
     else a3_false = a3_false + 1;

   always @(posedge clk) begin
      cyc <= cyc + 1;
      if (cyc == 20) begin
         `checkd(a_false, 3);
         `checkd(a0_false, a_false);
         `checkd(a1_false, a_false);
         `checkd(a2_false, a_false);
         `checkd(a3_false, 5);
         $write("*-* All Finished *-*\n");
         $finish;
      end
   end
endmodule

module Sub;

   initial begin
      if ($inferred_disable !== 0) $stop;
   end

endmodule