[sv-ec] disable class method

From: danielm <danielm_at_.....>
Date: Wed Jul 18 2007 - 00:51:29 PDT
I cannot found  in LRM  statements describing if "disable" is allowed on
class method (task) and how it should work.
 
I assume that if LRM doesn't forbid such usage so this is allowed, but I
still have doubts how it should work.
 
1)
Generally there are 2 possibilities. Disable can work per object(*) or per
class(**). Take a look on code sample:
 
module top;
        class C;
                reg [10*8-1:0] str;
                task  t(input int i);
                                $display("start %0d %s", $time, str);
                                #i;
                                $display("stop %0d %s", $time, str);
                endtask
        endclass

        C a,b;
        initial begin
                #20 disable a.t;
        end
        initial begin
                    a=new;a.str="object a"; 
                    b=new;b.str="object b";
                fork
                    #1 a.t(50);
                    #2 b.t(50);    
                    #100 $finish;
                join
        end
endmodule
 
(*)results if disable should work per object - only task triggered in object
a is disabled
start 1   object a
start 2   object b
stop 52   object b

(**) results if dsiable work per class - both task are disabled although
disable is called on object a
start 1   object a
start 2   object b

2)
Another question is what should happen if we try to disable method of an
non-existing object (below sample) - should it be runtime error(imho in case
we aprove disabling per object the it shoudl be runtime) or task called in
fork should be disabled in time 20 (this how it may work if we aprove
disabling per class)?
 
module top;
        class C;
                reg [15*8-1:0] str="unknown object";
                task  t(input int i);
                                $display("start %0d %s", $time, str);
                                #i;
                                $display("stop %0d %s", $time, str);
                endtask
        endclass

        C a,b;
        initial begin
                #20 disable a.t;
        end
        initial begin
                b=new; b.str="object b";
                fork
                    #1 b.t(50);
                    #100 $finish;
                join
        end
endmodule
 
 
3) 
The simplest possibility is to try disable static task - because it can be
done with :: operator. There is no problem with null references, and this
obviously works per class. So maybe disabling should be allowed only for
static methods? and should disable all task being  currently in progress
  
module top;
        class C;
                static reg [15*8-1:0] str="unknown object";
                static task  t(input int i);
                                $display("start %0d %s", $time, str);
                                #i;
                                $display("stop %0d %s", $time, str);
                endtask
        endclass

        C a,b;
        initial begin
                #20 disable C::t;
        end
        initial begin
                b=new; 
                fork
                    #1 b.t(50);
                    #2 C::t(50);
                    #100 $finish;
                join
        end
endmodule
 
proper result ?: 
start 1  unknown object
start 2  unknown object

 
 
Maybe rules for above problems should be added to LRM?
 
DANiel

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Wed Jul 18 00:52:17 2007

This archive was generated by hypermail 2.1.8 : Wed Jul 18 2007 - 00:52:55 PDT