RE: [sv-bc] Let constructor searching rule vs function searching rule

From: Rich, Dave <Dave_Rich_at_.....>
Date: Tue Jun 09 2009 - 07:12:55 PDT
It's my understanding that let has (or should have) the same visibility
rules as a type. Since the body of a let statement will be expanded into
the expression that references it, almost like a macro, you can't defer
resolution of the let reference.

 

So in your first example, x = f(y,z) should resolve to the let
statement. I don't remember if it would then be legal to define a
function with the same name as an identifier already referenced in the
same scope.

 

Ib your second example, x = f(y,z) should resolve as a function call.
Again, I don't remember if its legal to define a local symbol after it's
already been referenced in the same scope. i.e.

 

module top;
    reg x, y, z;   
    if (1) begin:b
          wire i = x;
          reg x;
    end
endmodule



 

Dave

 

 

________________________________

From: owner-sv-bc@server.eda.org [mailto:owner-sv-bc@server.eda.org] On
Behalf Of Surya Pratik Saha
Sent: Monday, June 08, 2009 11:34 PM
To: sv-bc@eda.org
Subject: [sv-bc] Let constructor searching rule vs function searching
rule

 

Hi,
As per LRM SV 2009 draft 7a, the let constructor searching is defined
as:
"In the scope of declaration, let body shall be defined before it is
used."

That means no forward reference is allowed on let construct usage.

In other context, for function and task searching rule defined as in
"23.8.1 Task and Function name resolution", the body should not be
searched until the current scope is not complete.

But there is no syntactical difference for let constructor call and a
function call. So if a let constructor call and function call are mixed
up in a design, LRM is not clear how to resolve it. If we consider the
following example:

module top;
    int x, y, z;   
    let f(a, b) = a < b;
    if (1) begin:b
        x = f (y,z); // is it let constructor call of a function call
defined later?
        function int f( int a, b);
            return 1;
       endfunction
    end
endmodule

If the above call is resolved to function call, then I don't think there
is any harm to resolve any let constructor call like function call
except the hierarchical reference which is allowed only for function.
Because, anyway, the let constructor call can't be resolved immediately
at the the place of call. We need to defer until the current scope is
completed. So the following e.g. will be legal:

module top;
    int x, y, z;   
    if (1) begin:b
          x = f (y,z); // is it let constructor call of a function call
defined later?
          let f(a, b) = a < b;
    end
endmodule

Please forgive me if there is any syntax error in the e.g. as "let"
construct is new to me.
Please let me know your thoughts.



-- 
Regards
Surya

-- 
This message has been scanned for viruses and 
dangerous content by MailScanner <http://www.mailscanner.info/> , and is

believed to be clean. 

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Tue Jun 9 07:14:20 2009

This archive was generated by hypermail 2.1.8 : Tue Jun 09 2009 - 07:14:42 PDT