[sv-bc] Revised SV-BC #67 proposal


Subject: [sv-bc] Revised SV-BC #67 proposal
From: Warmke, Doug (doug_warmke@mentorg.com)
Date: Tue Nov 11 2003 - 16:25:25 PST


Team,

Here is the revised version of the $readmem/$writemem proposal.
Textual changes are highlighted in red. The section numbers
have been corrected as per the numbering in SV3.1a draft 1.
A plain text version is attached as well in case that is more
convenient for import into FrameMaker.

Regards,
Doug

Modify Section 22.12 as follows:

For reference, the existing section reads as follows:
   $readmemb and $readmemh are extended to unpacked arrays of packed
data.
   In such cases, they treat each packed element as the vector
equivalent
   and perform the normal operation. $readmemb and $readmemh are
   not defined for packed arrays or unpacked arrays of unpacked data.

REPLACE the above with the following:
 
22.12.1 Reading packed data
   $readmemb and $readmemh are extended to unpacked arrays of packed
data,
   associative arrays of packed data, and dynamic arrays of packed data.
   In such cases, the system tasks treat each packed element
   as the vector equivalent and perform the normal operation.
   When working with associative arrays, indexes must be of integral
types.

22.12.2 Reading 2-state types
   $readmemb and $readmemh are extended to packed data of 2-state type,
   such as int or enumerated types. For 2-state integer types, reading
   proceeds the same as for conventional Verilog reg types (e.g.
integer),
   with the exception that X or Z data is converted to 0. For
enumerated
   types, the file data represents the ordinal value of the enumerated
type.
   (Cross-reference LRM section 3.10) If an enumeration ordinal is out
of
   range for a given type, then an error shall be issued and no further
   reading shall take place.

22.13 $writememb and $writememh system tasks
   SystemVerilog introduces system tasks $writememb and $writememh:

     $writememb("file_name", memory_name[, start_addr[, finish_addr]]);
     $writememh("file_name", memory_name[, start_addr[, finish_addr]]);

   $writememb and $writememh are used to dump memory contents
   to files that are readable by $readmemb and $readmemh, respectively.
   Address entries are optional when writing the file.
   If "file_name" exists at the time $writememb or $writememh is called,
   the file will be overwritten (.i.e. there is no append mode).

22.13.1 Writing packed data
   $writememb and $writememh treat packed data identically to $readmemb
   and $readmemh. See section 22.12.1.

22.13.2 Writing 2-state types
   $writememb and $writememh can write out data corresponding to
   unpacked arrays of 2-state types, such as int or enumerated types.
   For enumerated types, values in the file correspond to the
   ordinal values of the enumerated type. (X-ref LRM section 3.10).

22.13.3 Writing addresses to output file
   When $writememb and $writememh write out data corresponding to
   unpacked arrays or dynamic arrays, address specifiers (@-words)
   shall not be written to the output file.

   When $writememb and $writememh write out data corresponding to
   associative arrays, address specifiers shall be written to the
   output file.

22.14 File format considerations for multi-dimensional unpacked arrays
   In SystemVerilog, $readmemb, $readmemh, $writememb and $writememh
   can work with multi-dimensional unpacked arrays.

   The file contents are organized in row-major order, with
   each dimension's entries ranging from low to high address.
   This is backward compatible with plain Verilog memories.

   In this organization, the lowest dimension (i.e. the rightmost
   dimension in the array declaration) varies the most rapidly.
   There is a hierarchical sense to the file data.
   The higher dimensions contain words of lower-dimension data,
   sorted in row-major order. Each successive lower dimension is
   entirely enclosed as part of higher dimension words.

   As an example of file format organization, here is the layout
   of a file representing words for a memory declared

     reg [31:0] mem [0:2][0:4][5:8];

   In the example word contents, wzyx,
   z corresponds to words of the [0:2] dimension
   y corresponds to words of the [0:4] dimension
   x corresponds to words of the [5:8] dimension
        w005 w006 w007 w008
        w015 w016 w017 w018
        w025 w026 w027 w028
        w035 w036 w037 w038
        w045 w046 w047 w048
        w105 w106 w107 w108
        w115 w116 w117 w118
        w125 w126 w127 w128
        w135 w136 w137 w138
        w145 w146 w147 w148
        w205 w206 w207 w208
        w215 w216 w217 w218
        w225 w226 w227 w228
        w235 w236 w237 w238
        w245 w246 w247 w248

   Note that the diagram would be identical if one or more
   of the unpacked dimension declarations were reversed, as in
    
     reg [31:0] mem [2:0][0:4][8:5]

   Address entries in the file exclusively address the highest
   dimension's words. In the above case, address entries in
   the file could look something as follows:

     @0 w005 w006 w007 w008
        w015 w016 w017 w018
        w025 w026 w027 w028
        w035 w036 w037 w038
        w045 w046 w047 w048
     @1 w105 w106 w107 w108
        w115 w116 w117 w118
        w125 w126 w127 w128
        w135 w136 w137 w138
        w145 w146 w147 w148
     @2 w205 w206 w207 w208
        w215 w216 w217 w218
        w225 w226 w227 w228
        w235 w236 w237 w238
        w245 w246 w247 w248

   When $readmemh or $readmemb is given a file without address
   entries, all data is read assuming that each dimension has
   complete data. i.e. each word in each dimension will be
   initialized with the appropriate value from the file. If the
   file contains incomplete data, the read operation will stop
   at the last initialized word, and any remaining array words
   or subwords will be left unchanged.

   When $readmemh or $readmemb is given a file with address
   entries, initialization of the specified highest dimension
   words is done. If the file contains insufficient words
   to completely fill a highest dimension word, then the
   remaining subwords are left unchanged.

22.15 System task arguments for multi-dimensional unpacked arrays
   The $readmemb, $readmemh, $writememb, and $writememh signatures
   are shown below:

     $readmemb("file_name", memory_name[, start_addr[, finish_addr]]);
     $readmemh("file_name", memory_name[, start_addr[, finish_addr]]);
     $writememb("file_name", memory_name[, start_addr[, finish_addr]]);
     $writememh("file_name", memory_name[, start_addr[, finish_addr]]);

   memory_name can be an unpacked array, or a partially indexed multi-
   dimensional unpacked array that resolves to a lesser-dimensioned
   unpacked array.

   Higher order dimensions must be specified with an index,
   rather than a complete or partial dimension range. The lowest
   dimension (i.e. the rightmost specified dimension in the identifier)
   may be specified with slice syntax. See section 4.4 for details
   on legal array indexing in SystemVerilog.

   The start_addr and finish_addr arguments apply to the addresses
   of the unpacked array selected by memory_name. This address
   range represents the highest dimension of data in the memory_file.

   When slice syntax is used in the memory_name argument, any
   start_addr and finish_addr arguments must fall within the
   bounds of the slice's range.

   The direction of the highest dimension's file entries
   is given by the relative magnitudes of start_addr and
   finish_addr, as is the case in 1364-2001.




This archive was generated by hypermail 2b28 : Tue Nov 11 2003 - 16:27:25 PST