Actions from BNF review on March 14
Subject: Actions from BNF review on March 14
From: Peter Flake (flake@co-design.com)
Date: Sun Mar 17 2002 - 12:04:27 PST
1. Port declarations with port expressions
It is sometimes useful to have a part select or concatenation connected
to a port. The old style ports allow this but the new style port
declarations do not. So SystemVerilog allows a combination of port
declarations and port expressions. This feature can also be used to
connect two ports together (jumpered ports).
2. Define const
Constants are named data items which never
change. There are three kinds of constants, declared with the
keywords localparam, specparam and const
respectively. All three can be initialized with a literal:
localparam
char colon1 = ":" ;
specparam
int delay = 10 ; // specparams are used for specify
blocks
const
logic flag = 1 ;
A local parameter is a constant which is calculated at elaboration time,
and can depend upon parameters or other local parameters at the top level
or in the same module or interface.
A specify parameter is also calculated at elaboration time, but it may be
modified by the PLI and so cannot be used to set parameters or local
parameters.
A constant declared with the 'const’ keyword is calculated after
elaboration. This means that it can contain an expression with any
hierarchical path name. This constant is like a variable which
cannot be written
const
logic option = a.b.c ;
3. Clarify bit 0 of int
in 4.2 it says:
The packed dimension of these integer types shall be numbered down to 0,
such that the right-most index is 0.
In 4.4 there is the following:
An expression can select part of a packed array, or indeed any integer
type, which is assumed to be numbered down to 0:
int
j = 0;
shortint msh = j[31:16]; // most significant half
4. Clarify packing of structures
Since May, when the donation document was prepared, Co-Design has found the need to have both packed and unpacked structures and unions, like packed and unpacked arrays. So it is proposed to amend BNF lines 331 and 332 as follows:
| struct [packed][ signing ] { { struct_union_member } }
| union [packed][ signing ] { { struct_union_member } }
A packed structure consists of bit fields, which are packed together in memory without gaps. This means that they are easily converted to and from bit vectors. An unpacked structure has an implementation-dependent packing, normally matching the C compiler.
Like a packed array, a packed structure can be used as a whole with arithmetic and logical operators. The first member specified is the most significant. The structures are declared using the packed keyword, which can be followed by the signed or unsigned keywords, according to the desired arithmetic behavior, which defaults to unsigned:
struct packed signed { int a; shortint b; byte c; bit [7:0] d;} pack1; // signed, unmasked
struct packed unsigned {time a; integer b; logic [31:0] c;} pack2; // unsigned, masked
If any data type within a packed structure is masked, the whole structure is treated as masked. Any unmasked members are converted as if cast, i.e. an X will be read as 0 if it is in a member of type bit. One or more elements of the packed array may be selected assuming an [n-1:0] numbering:
pack1 [15:8] // c
Non-integer data types, such as real and shortreal, are not allowed in packed structures or unions. Nor are unpacked arrays.
A packed structure can be used with a typedef.
- typedef struct packed
{ // default unsigned
- bit [3:0] GFC;
- bit [7:0] VPI;
- bit [11:0] VCI;
- bit CLP;
- bit [3:0] PT ;
- bit [7:0] HEC;
- bit [47:0] [7:0] Payload;
- bit [2:0] filler;
- } s_atmcell;
A packed union contains members that are packed structures or arrays of the same size. This ensures that you can read back a union member that was written as another member. If any member is masked, the whole union is masked. A packed union can also be used as a whole with arithmetic and logical operators, and its behavior is determined by the signed or unsigned keyword, the latter being the default.
For example, a union can be accessible with different access widths:
- typedef union packed
{ // default unsigned
- s_atmcell acell;
- bit [423:0] bit_slice;
- bit [52:0][7:0] byte_slice;
- } u_atmcell;
u_atmcell u1;
byte b; bit [3:0] nib;
b = u1.bit_slice[415:408]; // same as b = u1.byte_slice[51];
nib = u1.bit_slice [423:420]; // same as nib = u1.acell.GFC;
Note that writing one member and reading another is independent of the byte ordering of the machine, unlike a normal union of normal structures, which are C-compatible and have members in ascending address order.
5. Define function and task prototypes and correct BNF for modport
A function prototype specifies the types and directions of the arguments and the return value of a function which is defined elsewhere. Similarly a task prototype specifies the types and directions of the arguments of a task which is defined elsewhere. In a modport the import and export constructs can either use task or function prototypes or use just the identifiers.
<modport_port> ::= <attribute_instance> <modport_port>
- | [<direction>] [<port_type>] <identifier>
| <identifier> '.' <identifier>
| <import_export> 'task' <named_task_proto>
| <import_export> 'function' <named_fn_proto>
- | <import_export> <identifier> {',' <identifier>}
<import_export> ::= 'import' | 'export'
[ note that port should be removed from the task_proto_formal productions 518-520, and line 521 should be deleted. ]
6. Define semantics of multi-dimensional array of instances
If the size and type of the port connection match the size and type of a single instance port, the connection shall be made to each instance in the array.
If the port connection is an unpacked array, the unpacked array dimensions of each port connection shall be compared with the dimensions of the instance array. If they match exactly in size, each element of the port connection will be matched to the port left index to left index, right index to right index. If they do not match it shall be considered an error.
If the port connection is a packed array, each instance shall get a part-select of the port connection, starting with all right-hand indices to match the rightmost part-select, and iterating through the rightmost dimension first. Too many or too few bits to connect all the instances shall be considered an error.
7. Specify restrictions on jump statements
The continue and break statements can only be used in a loop. The continue statement jumps to the end of the loop and executes the loop control if present. The break statement jumps out of the loop.
The return statement can only be used in a task or function. In a function returning a value, the return must have an expression of the correct type.
This archive was generated by hypermail 2b28
: Mon Mar 18 2002 - 08:04:45 PST