Andrew Beckett
Senior Fellow
    
Offline

Life, don't talk to me about Life...
Posts: 1742
Bracknell, UK
|
I'd hypothesised that the problem was caused by repeatedly extending the string data_flow and this was triggering a bug in Spectre (a segmentation fault is a clear indication of a simulator bug - but of course it's triggered by something specific in the code).
From doing some debugging, I found that the issue is not with the string concatenation but the $sscanf. In fact you really don't want $sscanf here, because that would be parsing the string a, trying to find an integer within that, and putting the result in the integer variable cmp. Instead, you want to go the other way, so you should be using $swrite rather than $sscanf:
$swrite(a,"%d",cmp);
If you do that, the code runs with no problems. The crash is actually a problem if sscanf tries to parse an uninitialised string (if a is set to "" or "1" beforehand it runs without the crash, but then the code doesn't do what you want).
I filed a Cadence Change Request, 2233969, to get the crash fixed (because it makes it hard to diagnose the true problem, which is the incorrect function being used). Hopefully everything works for you with $swrite instead of $sscanf.
Regards,
Andrew.
|