From: Steven Sharp (sharp@cadence.com)
Date: Tue Jul 20 1999 - 14:39:04 PDT
Under the current definition, an integer constant can be treated as a single
lexical element whose value is known at parse time. The parser can treat
it as a terminal in the grammar. I would be surprised if any tools do not
treat them this way. If a parameter is allowed to specify the width, then
sized constants are not literal constants. They are expressions, and very
strange ones at that. They cannot be treated as terminals in the grammar,
and their values may not be known until after elaboration. This would
require major changes to every tool that parses Verilog. It would
complicate the parsing and elaboration process. Given how common integer
constants are in designs, it could have an impact on the speed and memory
usage of the tools.
This would also introduce an extreme irregularity into the language. There
is no other situation where a parameter reference is allowed and a constant
expression is not. Maintaining orthogonality in a language is an important
factor in its simplicity and usability. Extending the change to allow
expressions for the width would avoid the irregularity. However, it would
increase the complexity of the sized constants in the users' eyes. These
constants are supposed to be the most basic lexical elements of the language,
and keeping them simple is important.
I also ran some simple benchmarks to test the performance impact of using
multiple concatenation instead of a sized constant. I simply evaluated each
version repeatedly inside a loop. There was no performance difference in
NC-Verilog, which is a compiled code simulator. The multiple concatenation
was evaluated at compile time, of course, so no difference was expected.
In Verilog-XL with twin_turbo, there was a 3% slowdown with the multiple
concatenation. In a realistic testcase, the slowdown would not be visible.
Also, since a sized constant with a parameterized size would have to be
treated as an expression, an interpreted simulator might not pre-evaluate
it any better than the multiple concatenation. They are both constant
expressions whose value becomes known after parameter values are set. In
fact, making this change might slow down an interpreted simulator on sized
constants without parameterized sizes. It is all a matter of implementation.
Steven Sharp
sharp@cadence.com
This archive was generated by hypermail 2.1.4
: Mon Jul 08 2002 - 12:53:29 PDT
and
sponsored by Boyd Technology, Inc.