The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Mar 29th, 2020, 12:06pm
Pages: 1
Send Topic Print
how to deal with segmentation fault in veriloga simulation (Read 86 times)
Bisharp
New Member
*
Offline

newbie

Posts: 6
China
how to deal with segmentation fault in veriloga simulation
Mar 04th, 2020, 6:54pm
 
Does anyone ever meet the (SPECTRE-18) segmentation fault ?
I try to write a detector as follow to help me print the output data. and when i run the simulation in spretre, a fatal error:
"Encountered a critical error during simulation. Please run  `mmsipack" to pack the test case... FATAL(SPECTRE-18):Segmentation fault."
I found some explanation that the segmentation fault is due to the wrong usage of memory. but i am still confused in my case...
Back to top
 

20200305.jpg
View Profile   IP Logged
Andrew Beckett
Senior Fellow
******
Offline

Life, don't talk to
me about Life...

Posts: 1723
Bracknell, UK
Re: how to deal with segmentation fault in veriloga simulation
Reply #1 - Mar 5th, 2020, 6:54am
 
Well, the message asks you to use mmsimpack to package up the test case and contact customer support. So that's the best thing. A segmentation fault shouldn't happen - it indicates the program is accessing memory it shoudn't.

Does it print progressively longer strings and then fails when the string gets very large? I'd try it out, but I don't want to spend time re-typing in your code (screenshots are not very useful for this... better to paste the code into the post and use the "Insert Code" icon around it (the # symbol in the icons when creating your post).

Anyway, contacting http://support.cadence.com would make most sense.

Andrew
Back to top
 
 
View Profile WWW   IP Logged
Bisharp
New Member
*
Offline

newbie

Posts: 6
China
Re: how to deal with segmentation fault in veriloga simulation
Reply #2 - Mar 5th, 2020, 7:20am
 
Andrew Beckett wrote on Mar 5th, 2020, 6:54am:
Well, the message asks you to use mmsimpack to package up the test case and contact customer support. So that's the best thing. A segmentation fault shouldn't happen - it indicates the program is accessing memory it shoudn't.

Does it print progressively longer strings and then fails when the string gets very large? I'd try it out, but I don't want to spend time re-typing in your code (screenshots are not very useful for this... better to paste the code into the post and use the "Insert Code" icon around it (the # symbol in the icons when creating your post).

Anyway, contacting http://support.cadence.com would make most sense.

Andrew



Thank you Andrew, your advice is realy nice to me (as a newbie). and I will remember that.
in my testbench, i set the trans. simulation time to 800p, and set the parameter "peiod" to 10p; The input "data" is a square wave with a period of 10p;  
Code:
module datadet(data);
input data;
electrical data;
parameter real vh =1 from [0:inf);
parameter real vl = 0 from [0:inf);
parameter real vth = (vh+vl)/2;
parameter real start_time = 0 from [0:inf);
parameter real period = 10p from (0:inf);
integer cmp;
string data_flow,a;
analog begin
    @(initial_step)
	  data_flow="";
    @(timer(start_time, period)) begin
	  cmp = (V(data)>vth);
	  $sscanf(a,"%d",cmp);
	  data_flow = {data_flow,a};
	  $strobe("the data in %M is %s", data_flow);
    end
end
endmodule
 

Back to top
 
 
View Profile   IP Logged
Bisharp
New Member
*
Offline

newbie

Posts: 6
China
Re: how to deal with segmentation fault in veriloga simulation
Reply #3 - Mar 5th, 2020, 7:41am
 
As above mentioned, in my understanding, the timer command only repeat nearly 80 times, the string “data_flow” is only a combination of 80 bits number,how could it accessing forbidden memory. I am confused...
Back to top
 
 
View Profile   IP Logged
Andrew Beckett
Senior Fellow
******
Offline

Life, don't talk to
me about Life...

Posts: 1723
Bracknell, UK
Re: how to deal with segmentation fault in veriloga simulation
Reply #4 - Mar 8th, 2020, 3:16am
 
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.
Back to top
 
 
View Profile WWW   IP Logged
Bisharp
New Member
*
Offline

newbie

Posts: 6
China
Re: how to deal with segmentation fault in veriloga simulation
Reply #5 - Mar 8th, 2020, 4:03am
 
Andrew Beckett wrote on Mar 8th, 2020, 3:16am:
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.


Thank you very much for your detailed and patient answers. It really helps me better understand this error!

-Ying
Back to top
 
 
View Profile   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2020 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.