[sv-bc] Partial proposal for issue #091- take #3

From: Jacobi, Dan <dan.jacobi@intel.com>
Date: Tue Sep 14 2004 - 23:38:56 PDT

This proposal intends to solve the first part of the problem described
in
    http://www.eda.org/svdb/bug_view_page.php?bug_id=0000091
<http://www.eda.org/svdb/bug_view_page.php?bug_id=0000091>
"$typeof function as used in 23.2 is not fully supported in the BNF"

"array query functions of 23.7 take a simple_type as well as a type
identifier?"

 

Motivation
========

Problem #1

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

 

The example in section 23.2 in the (original) SV 3.1a LRM uses the
$typeof system function to set the default type of a type parameter:
    Example 1:

    bit [12:0] A_bus, B_bus;
    parameter type bus_t = $typeof(A_bus);

 

Also we would like to enable the override of type parameters using the
$typeof system function such as:

    Example 2:

    son #( .son_type_param($typeof(A_bus) ) myson (...);

 

Section 23.2 also reads:

"The $typeof system function returns a type derived from its argument.
The data type returned by the

$typeof system function may be used to assign or override a type
parameter, or in a comparison with another

$typeof, evaluated during elaboration."

 

However the BNF does not enable the usage of the $typeof system function
to assign a type parameter value as shown in example 1 (Note that it
does permit the overriding of the type parameters as shown in example 2)

 

The type parameter type declaration BNF reads :

 

A.2.2.1
    parameter_declaration ::=
        parameter data_type_or_implicit list_of_param_assignments
        | parameter type list_of_type_assignments
A.2.3
    list_of_type_assignments ::= type_assignment { , type_assignment }
A.2.4
    type_assignment ::= type_identifier = data_type

 

Note that the parameter override as shown in example 2 is enabled using
the following rules from the BNF

 

A.4.1.1

    ordered_parameter_assignment ::= param_expression

    named_parameter_assignment ::= . parameter_identifier ( [
param_expression ] )

A.8.3

    param_expression ::= mintypmax_expression | data_type

the mintypmax_expression token eventually reduces the system function
call rule

 

 

Problem #2

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

The $typeof and $typename system functions may receive a data type as
their argument

 

Section 23.2 and 23.3 read :

typeof_function ::=

$typeof ( expression )

| $typeof ( data_type )

// not in Annex A

 

typename_function ::=

$typename ( expression )

| $typename ( data_type )

// not in Annex A

 

Enabling RTLs such as

generate

case ($typeof(bus_t))

$typeof(logic[10:0]): do some

Default : do some thing else

endcase

endgenerate

 

However the BNF does not allow non expression arguments for system
functions

 

Annex A Reads:

A.8.2 Subroutine calls

system_tf_call ::= system_tf_identifier [ ( list_of_arguments ) ]

 

list_of_arguments ::=

[ expression ] { , [ expression ] } { , . identifier ( [ expression ] )
}

| . identifier ( [ expression ] ) { , . identifier ( [ expression ] ) }

 

 

Problem #3

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

System Verilog introduces the following new system functions (among
others)

$bits, $dimensions, $left , $right, $low, $high, $increment and $size

We want to enable these system tasks to receive integer types as
arguments

Enabling such system function calls

            $dimensions (integer)

            $size(bit)

 

Still the following will be considered illegal

            $dimensions(reg[10:0])

            $size(struct {reg a; byte b;})

            $size(real)

 

Note that currently the following is legal

            typedef reg mytype;

            ...

            $dimensions(mytype)

 

 

Problem #4

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

This problem might have already been addressed, if so please ignore it

 

There is a typo in the example of section 23.2

bit [12:0] A_bus, B_bus;

parameter type bus_t = $typeof(A_bus);

generate

case ($typeof(but_t))

$typeof(bit[12:0]): addfixed_int #(bus_t) (A_bus,B_bus);

$typeof(real): add_float #($typeof(A_bus)) (A_bus,B_bus);

endcase

endgenerate

 

line 4 should read

            case ($typeof(bus_t))

 

 

Proposals

========

 

Proposal #1 (addresses problem #1)

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

 

Under section A.2.4

 

REPLACE

    type_assignment ::= type_identifier = data_type

WITH

    type_assignment ::= type_identifier = data_type

        | type_identifier = $typeof ( expression 28 )

        | type_identifier = $typeof ( data_type )

 

* Equal signs = parentheses () and the sequences $typeof or all in bold

** the number 28 is in supper script indicating a reference to a
footnote

 

Under Annex A Footnote sections

ADD

28) The expression that was is used as the argument to the $typeof
system function shall contain no hierarchical references.

 

Notes

=====

this proposal will also enable V2K style module declarations with type
parameters such as

    module m1 #( $typeof(A_bus) ) (input ....)

 

and the usage of the $typeof system function to declare type parameters
in class, program and interface declarations as well.

 

 

Proposal #2 (addresses problem #2 and #3)

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

Under section A.8.2

 

A.8.2 Subroutine calls

REPLACE

system_tf_call ::= system_tf_identifier [ ( list_of_arguments ) ]

WITH

system_tf_call ::= system_tf_identifier [ ( list_of_arguments ) ]

                        | system_tf_identifier (data_type [ , expression
] )

 

* commas ',' and parentheses '()' are in bold

 

 

Proposal #3 (addresses problem #3)

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

Under section 23.4 Expression size system function

 

REPLACE the text box

size_function ::=

$bits ( expression )

| $bits ( type_identifier )

// not in Annex A

WITH

size_function ::=

$bits ( expression )

| $bits ( type_identifier )

| | $bits ( integer_type )

// not in Annex A

 

* $bits and parentheses '()' are in bold

 

Under section 23.7 Array querying system functions

 

REPLACE the text box

array_query_function ::=

array_dimension_function ( array_identifier , dimension_expression )

| array_dimension_function ( type_identifier [ , dimension_expression ]
)

| $dimensions ( array_identifier )

| $dimensions ( type_identifier )

array_dimension_function ::=

$left

| $right

| $low

| $high

| $increment

| $size

dimension_expression ::= expression

// not in Annex A

WITH

array_dimension_function ( array_identifier , dimension_expression )

| array_dimension_function ( type_identifier [ , dimension_expression ]
)

| array_dimension_function (integer_type [ , dimension_expression ] )

| $dimensions ( array_identifier )

| $dimensions ( type_identifier )

| $dimensions ( integer_type )

array_dimension_function ::=

$left

| $right

| $low

| $high

| $increment

| $size

// not in Annex A

 

* $dimensions, $left, $right, $low, $high, $incrament, $size, commas
','and parentheses '()' are in bold

 

Proposal #4 (addresses problem #4)

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

In section 23.2 Elaboration-time typeof function

 

REPLACE the example

bit [12:0] A_bus, B_bus;

parameter type bus_t = $typeof(A_bus);

generate

case ($typeof(but_t))

$typeof(bit[12:0]): addfixed_int #(bus_t) (A_bus,B_bus);

$typeof(real): add_float #($typeof(A_bus)) (A_bus,B_bus);

endcase

endgenerate

WITH

bit [12:0] A_bus, B_bus;

parameter type bus_t = $typeof(A_bus);

generate

case ($typeof(bus_t))

$typeof(bit[12:0]): addfixed_int #(bus_t) (A_bus,B_bus);

$typeof(real): add_float #($typeof(A_bus)) (A_bus,B_bus);

endcase

endgenerate

 

Note that line 4 now reads 'case ($typeof(bus_t))' and not 'case
($typeof(but_t))'

 

 

 

 

Dan Jacobi, Intel Corporation

972-4-8655855

 

 

 

 

 
Received on Tue Sep 14 23:40:11 2004

This archive was generated by hypermail 2.1.8 : Tue Sep 14 2004 - 23:40:44 PDT