hi Daniel I'll try to answer your questions based on my reading of the existing LRM. > 1. imo there is a typo in chapter 7.11 queues: > There is {} described as array literal - while {} is a > concatenation. not literal > The empty array literal {} is used to denote an empty queue > Question is what should be there - "empty array concatenation {}", > or "empty array literal '{}" ? I think it should probably say "empty unpacked array concatenation {}", but I don't believe there is any difficulty in interpretation. > My question is are literal allowed to directly drive queues and > dynamic arrays? LRM has special chapter about literal behaviour for > associative arrays but is silent about literal and dynamic array and > associative array. What would be behaviour of default if this is > legal and so on? Some of this question is answered, I think, by clause 10.10 (Unpacked array concatenation) and 7.6 (Array assignments). Although 7.6 does not show any examples of assigning array literals to arrays, it seems clear enough that all the following are legal: int da[]; int q[$]; int a[5]; da = {1,2,3}; q = {1,2,3}; a = '{1,2,3,4,5}; // assignment pattern a = {1,2,3,4,5}; // unpacked array concatenation a = {q, 4, 5}; // unpacked array concatenation > int da[]; > int q[$]; > initial begin > da = new [3]('{1,2,3}); //this is legal. Yes, I agree. There are some other interesting cases: da = new[3]('{1,2}); // gives da[0]=1, da[1]=2, // da[2] unwritten (initialized to 0) da = new[3]('{1,2,3,4,5}); // initializer truncated to '{1,2,3} > da = new [5]('{1,2,3, default:123}); //is this legal? I don't think so. The size (index range) of the initializer argument to new[]() is presumably self-determined - its size is not in any way controlled by the size of the created array - so we don't know the index range of the assignment pattern. Consequently, default: makes no sense. > da = '{1,2,3, default:123}; // is this legal da[3] and da[4] > // would be assigned with 123?? Again I would say not, for the same reason; a dynamic array resizes to match whatever is assigned to it, so the width of the right-hand side is not known. In general, I don't think it is *ever* legal to use default: in an assignment pattern that is being assigned to a variable-sized array. > da = '{4:2};// is this legal? It's not legal because the assignment pattern cannot possibly match any dynamic array, whose indices are always [0:N]. > da size is bigger than literal size should it be > raported as error or da should be silently resized? Clauses 7.5 and 7.6 clearly say that a dynamic array resizes to fit whatever you assign to it. Consequently I would expect both of these to be legal: da = '{1,2}; // now we have da[0:1] da = '{100{1}}; // now we have da[0:99] > da = '{1:0, 4:2};// is this legal? indexes are not consecutive Although I can't find explicit mention of it, I would say that an assignment pattern with missing elements should be illegal. The contents of the pattern don't correctly match its data type. It would, of course, be OK to assign that pattern to an associative array such as "int AA[int]". > //same question raising for queues Same answers, since anything that could be assigned to a dynamic array could similarly be assigned to a queue (see 7.6). -- 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 Fri May 8 03:36:28 2009
This archive was generated by hypermail 2.1.8 : Fri May 08 2009 - 03:37:12 PDT