Edit code - EDA Playground
Warning! This exercise has been opened in another tab; autosave has been disabled. Close this tab or refresh to reactivate.

 Languages & Libraries

 Tools & Simulators

 Examples

208


41
 
1
module m; 
2
    // from 
3
    // import sva_delay_repeat_range_pkg::*;
4
     bit busy, er, ok, ok2, er2, clk; 
5
     bit[1:0] max=2'b11; 
6
     initial forever #10 clk = !clk;
7
   
8
     sequence dynamic_delay(count);
9
       int v;
10
     (count<=0) or ((1, v=count) ##0 (v>0, v=v-1) [*0:$] ##1 v<=0);
11
     endsequence // dynamic_delay
12
   
13
     sequence dynamic_delay_lohi_sq(d1, d2, sq);
14
       int v1, vdiff;
15
         ( (1, v1=d1, vdiff=d2-d1) ##0 dynamic_delay(v1)   ##0     
16
             (vdiff>=0, vdiff=vdiff - 1)[*1:$] ##0 sq); 
17
     endsequence
18
   
19
    ap_tobusy:  assert property (@(posedge clk) $rose(busy) |-> 
20
           dynamic_delay_lohi_sq(1, max, $fell (busy)))  ok=1; else er=1;   //##[1:max] $fell (busy))
21
22
    property p_2busy; 
23
        int count = 0;
24
        @(posedge clk) $rose(busy) |-> 
25
      first_match((busy, count = count+1, $display("c=%d", count))[*1:$] ##1 $fell(busy)) ##0 (count <= max); 
26
    endproperty
27
    ap_2busy:  assert property(p_2busy) ok2=1; else er2=1;
28
   
29
     initial begin
30
       $dumpfile("dump.vcd"); $dumpvars;
31
       @(posedge clk) busy<= 1'b1; 
32
       repeat(4) @(posedge clk);
33
            busy<=1'b0; 
34
            repeat(3) @(posedge clk);
35
            $finish;
36
      end
37
   endmodule
38
         
39
40
41
      
2
 
1
// Code your design here
2
78 views and 0 likes     
A short description will be helpful for you to remember your playground's details
 
100:0