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

From: Surya Pratik Saha <spsaha_at_.....>
Date: Tue Jun 09 2009 - 07:34:22 PDT
Hi Dave,
Your example is legal. In your example, for "wire i = x", x will point to module level 'x'. This is simple because it is resolved by normal identifier searching rule. But as per LRM, function body searching rule is different than normal identifier searching rule.

I can't completely agree with your argument for "let" constructor binding. Because it will conflict with function body searching rule. And since there is no syntactical difference between a let construct call, and a function call, it is really difficult to understand to distinguish in between.
Consider the following e.g.

package p;
    let f(a, b) = a < b;
endpackage

module top;
    import p::*;
    int x;
    initial x = f(1,2);
    function int f(input a, b);
       return 1;
    endfunction
endmodule

If I go by your argument, then declaration of function 'f' is illegal, as let 'f' is already imported inside  the module. But if a function is defined inside the package, then it is not illegal, and actually the function call will be bound with the function defined in the module. I don't think this is the intention of the LRM, and also don't think any tool can support in such way.

Regards
Surya


-------- Original Message  --------
Subject: Re:[sv-bc] Let constructor searching rule vs function searching rule
From: Rich, Dave <Dave_Rich@mentor.com>
To: Surya Pratik Saha <spsaha@cal.interrasystems.com>, sv-bc@eda.org <sv-bc@eda.org>
Date: Tuesday, June 09, 2009 7:42:55 PM

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, 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:35:52 2009

This archive was generated by hypermail 2.1.8 : Tue Jun 09 2009 - 07:36:39 PDT