Here's an attempt to summarize what the ballot draft LRM says about whether strings are aggregate or singular. Clause 7.1 clearly includes strings in its list of aggregate types, but it's out on a limb - everywhere else, aggregates are specified to be unpacked structs, arrays and unions; everything else is singular. Although strings look somewhat like unpacked arrays of bytes, there is nothing that requires them to be so. So let's see if it would be OK to make strings singular. There are several places where a singular type is mandatory. Taking each of these in turn... 1) The target of a $cast must be of a singular type. ~~~~ I can't see why one would ever need to $cast(str, something); on the other hand, it's not inherently unreasonable. This doesn't sway the choice one way or the other. 2) Event expressions must evaluate to a singular value. ~~~~ Two out of three simulators accept @(str) and deal with it in the obvious way; a third rejects it as non-singular. I'm guessing that users would like to be able to do this. 3) The target of a force or a procedural assign must be singular. ~~~~ Although this isn't nice, I can easily imagine why users might wish to force a string - perhaps to modify the flow of a testbench. But I can see that there are implementation difficulties with forcing a dynamic-size variable, and no tool I tried supports it. If we eventually decide that strings are singular, there will need to be a special restriction prohibiting force/assign for strings. 4) The left operand of "inside" must be singular. ~~~~ The LRM has examples of (str inside {"str1", "str2"}) but tool support for it is patchy. It's clearly something that one would like to be able to do. 5) Subprogram arguments, and module ports, must be singular if they are to have a default value. ~~~~ Even in the tool that treats strings as aggregates, string arguments can be defaulted. It's unimaginable to forbid it. 6) %p descends through an aggregate until it finds a singular. ~~~~ The LRM clearly states in 21.2.1.7 that a string is singular in this respect. The only tool I could find that supports %p exactly follows the LRM here, even though in most respects it treats strings as being aggregates. In summary, then: on balance it is clear to me that strings should be singular, and should be removed from clause 7; it would be easy to put the text of 7.8 into 6.16, and to add a restriction outlawing force and procedural assign to string targets. Comments? -- Jonathan Bromley Consultant Doulos - Developing Design Know-how VHDL * Verilog * SystemVerilog * SystemC * PSL * Perl * Tcl/Tk * Project Services Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, Hampshire, BH24 1AW, UK Tel: + 44 (0)1425 471223 Email: jonathan.bromley@doulos.com Fax: +44 (0)1425 471573 http://www.doulos.com -------------------------------------------------------------------------------- Doulos Ltd is registered in England and Wales with company no. 3723454 Its registered office is 4 Brackley Close, Bournemouth International Airport, Christchurch, BH23 6SE, UK. This message may contain personal views which are not the views of Doulos, unless specifically stated. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Mon Jun 1 06:59:50 2009
This archive was generated by hypermail 2.1.8 : Mon Jun 01 2009 - 07:00:39 PDT