[sv-ac] Hierarchical ref of local variable in action blocks

From: ben cohen <hdlcohen@gmail.com>
Date: Tue Jul 19 2011 - 12:02:25 PDT

Ran the following 3 models:
From the current simulator that I have:
1) Action block local variable must be declared as "static" or "automatic"
2) If "static", then local var maintains its old value as expected.
3) assertion_label.var_name (e.g., *a1.x) does not work *
*Ben *
*-----------------------------------------*
module asn;
    static int result, count=0;
    logic a=1, b=1, clk=1;
    initial forever #10 clk=!clk;
   * a1: assert property (@(posedge clk)a |-> ##3 b) begin *
* static int x=0; x +=1; result = x; *
    end
    always @(posedge clk) begin
        count+=1;
        if(count>=6) begin
        b<=0;
        $display("count=%d, result=%d", count, result);
        end
    end
endmodule

# count= 6, result= 2
# count= 7, result= 3
# ** Error: Assertion error.
# Time: 140 ns Started: 80 ns Scope: asn.a1 File: asn.sv Line: 18 Expr:
b
# count= 8, result= 3
# ** Error: Assertion error.
# Time: 160 ns Started: 100 ns Scope: asn.a1 File: asn.sv Line: 18 Expr:
b
# count= 9, result= 3
# ** Error: Assertion error.
# Time: 180 ns Started: 120 ns Scope: asn.a1 File: asn.sv Line: 18 Expr:
b
# count= 10, result= 3
# ** Error: Assertion error.
# Time: 200 ns Started: 140 ns Scope: asn.a1 File: asn.sv Line: 18 Expr:
b
============================================================
module asn_auto;
    static int result, count=0;
    logic a=1, b=1, clk=1;
    initial forever #10 clk=!clk;
    *a1: assert property (@(posedge clk)a |-> ##3 b) begin *
* automatic int x=0; x +=1; result = x; *
    end
    always @(posedge clk) begin
        count+=1;
        if(count>=6) begin
        b<=0;
        $display("count=%d, result=%d", count, result);
        end
    end
endmodule : asn_auto
# count= 6, result= 1
# count= 7, result= 1
# ** Error: Assertion error.
# Time: 140 ns Started: 80 ns Scope: asn_auto.a1 File: asn_auto.sv Line:
18 Expr: b
# count= 8, result= 1
# ** Error: Assertion error.
# Time: 160 ns Started: 100 ns Scope: asn_auto.a1 File:
asn_auto.svLine: 18 Expr: b
# count= 9, result= 1
# ** Error: Assertion error.
# Time: 180 ns Started: 120 ns Scope: asn_auto.a1 File:
asn_auto.svLine: 18 Expr: b
# count= 10, result= 1
# ** Error: Assertion error.
# Time: 200 ns Started: 140 ns Scope: asn_auto.a1 File:
asn_auto.svLine: 18 Expr: b

 ==================================
module asn_2;
    static int result, count=0, path_result;
    logic a=1, b=1, clk=1;
    initial forever #10 clk=!clk;
    a1: assert property (@(posedge clk)a |-> ##3 b) begin
        static int x=0; x +=1; result = x;
    end
    always @(posedge clk) begin
        count+=1;
        *path_result <= a1.x +1; // line 23*
        if(count>=6) begin
            b<=0;
            $display("count=%d, result=%d", count, result);
            $display("path_result=%d", path_result);
        end
    end
endmodule
*** Error: asn_2.sv(23): Unresolved reference to 'x'.*

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Tue, 19 Jul 2011 12:02:25 -0700

This archive was generated by hypermail 2.1.8 : Tue Jul 19 2011 - 12:03:52 PDT