On Friday, June 27, 2014 10:39 AM David Bishop wrote: >On 06/26/2014 10:09 PM, tgingold@free.fr wrote: >> I am slightly confused by the representation. In the ug: >> >> As a concession to C, all matrices are assumed to be in column, row format, and starting at index 0. Thus for the matrix: >> Z := ((1.0, 2.0, 3.0), >> (4.0, 5.0, 6.0), >> (7.0, 8.0, 9.0)); >> Z (0,2) = 7.0 >> >> >> I suppose we all agree that Z should be: >> [ 1 2 3 >> 4 5 6 >> 7 8 9 ] >> >> So the first dimension is the number of lines and the second dimension is the number of columns. >> This is natural both from a point of view of the VHDL language and from classical math style. >> >> But in that case and following the above excerpt, Z (0, 2) is 3.0 ! > >When I create a matrix, I do it as: > type real_matrix is array (NATURAL range <>, NATURAL range <>) of REAL; -- real matrix Which follows from: > type real_vector is array (NATURAL range <>) of REAL; Which is part of VHDL-2008. > >So what you really have is array of arrays. In order to load the >array, I have to do: > >Z := ((1.0, 2.0, 3.0), > (4.0, 5.0, 6.0), > (7.0, 8.0, 9.0)); > >which reversed rows and columns as it loads..... I strongly agree with Tristan that we want to keep the (row, column) index semantics. I can imagine the reverse making the package too confusing to be useful to me. (I would probably write an auxiliary package to somehow make the natural ordering convenient for me.) I also agree with Tristan's assessment that both mathematics and VHDL syntax match this convention. So in the array he defines, Z(0,2) is 3.0. In fact, I tried it (code at the end of the email). My simulator prints: Element (0,2) is 3.000000e+00 So, David, I'm confused by your conclusion that the aggregate "[reverses] rows and columns as it loads." >> BTW, I am not sure that starting at index "0" is the best choice. >> This is neither the matlab conversion (which is heavily used) nor the math choice. I still like the 0-based index. Since this is VHDL, you can define your objects 1-based if you like. Matlab's 1-based types make my life harder. I write my VHDL and math to used 0-based indices. - Ryan -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Mon Jun 30 11:15:33 2014
This archive was generated by hypermail 2.1.8 : Mon Jun 30 2014 - 11:16:09 PDT