Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
DETECTARRAY error on packed structures #610
The following triggers the DETECTARRAY error (ID_MSB is a localparam with value 1):
This is a classic loop within a vector, so triggers UNOPTFLAT. However if UNOPTFLAT is turned off (-Wno-UNOPTFLAT), we get:
DETECTARRAY is not actually in the manual (I've fixed that). The problem is in @genChangeDet()@ in @V3Changed.cpp@, which can only deal with change on basic types and unpacked arrays of modest size.
I think this should not be too difficult to change for packed structures, since the standard allows them always to be treated as vectors (i.e. 1-D packed arrays). I'm working on a patch for this, but tripping over the type system a bit, so any hints on this are much appreciated.
While working on this I found a second bug. If in the above example, I don't use a localparam, but just an explict constant, 1, I trigger an internal error due to a broken link:
I haven't started looking at why this happens, but I suspect it is completely unrelated.
In the meantime, please pull a patch from branch detectarray at firstname.lastname@example.org:jeremybennett/verilator.git. This contains an update to the user guide, a test (t_detectarray_1) to demonstrate DETECTARRAY error with a packed structure and a test (t_detectarray_2) to trigger the broken link problem.
Original Redmine Comment
Applied the doc change to git.
The git version deals with packed arrays as normal bit vectors so I suspect the test that prints the warning can be improved to just allow any AstPackArray or AstNodeClass (with isPacked).
It might be that the ChangeDet node later on then has another test that assumes a basic data type, if so that can be fixed similarly.
Please give it a try.
Original Redmine Comment
Took far longer than I intended. I made heavy weather of trying to break down the structure, before I realized it should just be treated as simple vector, so in the end it's a tiny patch.
I ran regression, which failed in two places. One is an apparent minor discrepancy between Verilator and SystemPerl headers which I have fixed (in Verilator). The other is t_vpi_var, which gets a mismatch (@rfr[39:0]=0x60064B1CDB@ versus @sig[39:0]=0x00064B1CDB@ in @arr@). I don't know enough about VPI to see where that is going wrong. It also fails on the master branch, so I think it's not this patch. I'll raise this as a separate Issue.
Please pull a patch from branch detectarray at email@example.com:jeremybennett/verilator.git.