EDA.org Mantis
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] Wiki ] View Advanced ] Issue History ] Print ]
ID Category Severity Date Submitted Last Update
0001273 [SystemVerilog P1800] SV-BC feature 2006-01-04 22:27 2010-02-08 21:14
Reporter shalom View Status public  
Assigned To
Priority normal Resolution open  
Status new   Product Version
Summary 0001273: Allowing parameters to define the length of a constant
Description This comes from B31 of the old enhancement request list for 1364-2001, by Adam Krolnik.

The original request was as follows:

Currently the only acceptable way to define the size of a constant is with a constant number, or a preprocessor substitution. Allowing parameters would at least bring numbers to the abilities of ports and other sized data types.

Please consider allowing parameters (at the least) to define the length of a constant. Should there be other ways to specify the size of a value? Should there be a restriction that the size be constant?

An Example

module tst;

`define length 4
`define width 6
parameter size = `len * `wid;

reg[`width:1] a, out;
reg[`length*`width:1] b;

initial begin
$display("Size is %0d.", size);
b = size 'b0; // Using parameter to specify size.
end

always @(clk) begin
{out, b} = {b, a};
end
endmodule

Proposed text:

To section 2.5.1 "Integer constants" third paragraph, second sentence, which reads:
"It [size constant] shall be specified as an unsigned decimal number."

Replace it with:

"It [size constant] shall be specified as an unsigned decimal number or a parameter."

BNF:

size ::=
unsigned_number
| parameter_identifier

-----------------------------------------------------

SV has casting operation, but apparently does not have ability to cast to a parametric length.

Discussion:

Shalom: This would be useful.
Steven: There could be order dependencies, since parameter values are only determined at elaboration time. Need restrictions.
If we did this as a conversion function instead of as part of the syntax for specifying a constant, it would be better.
Shalom: OK
MEDIUM-HIGH priority.
Additional Information Was BTF 594.
I think there is an indirect way to do this in SV, by defining a type of the required length, and then casting to that type. But it would be nice if it were possible to cast directly to the required length.
Tags No tags attached.
Type Clarification
Attached Files

- Relationships
child of 0002351new Master issue for SV-BC Parameter issues 

-  Notes
User avatar (0002554)
Brad Pierce (developer)
2006-04-20 22:47

You can usually get that effect in SV with a width cast, for example,
size'(0), but I agree that proposed enhancement sounds sensible.
User avatar (0002555)
shalom (manager)
2006-04-22 11:38
edited on: 2006-04-22 12:00

Brad pointed out that according to Syntax 4-6, you CAN write P'(expr), where P is a parameter name. I mistakenly thought it is not allowed.

So I would settle for a clarification in the text about what the <size> can be and a couple of examples, one showing a parameter.

But now I don't understand what Brad wrote that the "proposed enhancement sounds sensible".

edited on: 04-22-06 12:00
User avatar (0002557)
Brad Pierce (developer)
2006-04-22 21:29

It would be OK with me to close this request.
User avatar (0002558)
shalom (manager)
2006-04-22 23:17

Now I remember what the request was. It was to allow writing a literal with a parametric size directly, instead of going through a cast. i.e., to write

P'b110 instead of what you can do in SV: P'(3'b110).
I had originally thought that in SV you can not even write the latter,
but I seem to be wrong.

This SV capability is good enough for me, so I am willing to withdraw the enhancement request, but I still think a clarification in the text is very desirable.
User avatar (0002846)
shalom (manager)
2006-08-13 05:42

Changed issue type from Enhancement to Clarification.

- Issue History
Date Modified Username Field Change
2006-01-04 22:27 shalom New Issue
2006-01-04 22:27 shalom Type => Enhancement
2006-04-20 22:47 Brad Pierce Note Added: 0002554
2006-04-22 11:38 shalom Note Added: 0002555
2006-04-22 12:00 shalom Note Edited: 0002555
2006-04-22 21:29 Brad Pierce Note Added: 0002557
2006-04-22 23:17 shalom Note Added: 0002558
2006-06-18 02:29 shalom Status new => assigned
2006-06-18 02:29 shalom Assigned To => shalom
2006-08-13 05:42 shalom Type Enhancement => Clarification
2006-08-13 05:42 shalom Note Added: 0002846
2006-08-13 05:42 shalom Summary Allowing parameters to define the length of a constant => Allowing parameters to define the length of a constant
2008-04-07 04:32 shalom Relationship added child of 0002351
2008-04-29 11:36 shalom Status assigned => new
2008-05-09 05:14 shalom Assigned To shalom =>
2010-02-08 21:14 shalom Category V-1364 => SV-BC
2010-02-09 00:16 shalom Issue Monitored: shalom


Mantis 1.1.7[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker