[sv-bc] RE: What's the difference between "let P = const_expr" and "localparam P = const_expr"?

From: Vreugdenhil, Gordon <gordon_vreugdenhil@mentor.com>
Date: Thu Oct 27 2011 - 21:45:26 PDT

There are a couple of things that are different. For the "let", the const_expr type is impacted by the type context at the point of use. For a "localparam" the type of the param is determined by the type of the local expression (and the explicit type) if any. So for non-trivial exprs, you could get different results. In addition, I don't believe a "let" introduces an "object" in the scope (a name yes, but not an object). So I don't think they can be hierarchically referenced (I don't recall if they admit class prefixed references). That's all I can think of right now but I haven't spent any time considering the LRM details.

Gord.
________________________________________
From: owner-sv-bc@eda.org [owner-sv-bc@eda.org] on behalf of Brad Pierce [Brad.Pierce@synopsys.com]
Sent: Thursday, October 27, 2011 5:16 PM
To: sv-bc@eda.org
Subject: [sv-bc] What's the difference between "let P = const_expr" and "localparam P = const_expr"?

In the proposal for Mantis 3295 there's code

   // now define lets to make the code more readable
   let LOCK = 1;
   let UNLOCK = 2;
   let ON = 3;
   let OFF = 4;
   let KILL = 5;

that looks a lot like

   typdef enum { LOCK=1, UNLOCK, ON, OFF, KILL } dummy;

or

   localparam LOCK = 1, UNLOCK = 2, ON = 3, OFF = 4, KILL = 5;

Is there any practical difference between these different ways of defining local constants? Is one way preferable to the others?

'let' can do things the others can't, such as stand for a non-constant_expression or take arguments, but for constant_expressions and no arguments what are the differences?

-- Brad

--
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 Thu Oct 27 21:45:59 2011

This archive was generated by hypermail 2.1.8 : Thu Oct 27 2011 - 21:46:06 PDT