Jump to content

In systemc: FSDB dump fails when simulation is ended with assert statement.


Recommended Posts

I have an issue with fsdb dump when simulation in systemc fails using an   assert   statement such as  (assert(a==b) .. etc. 

The signals in the waveform show as  nf  (not found). Any way to fix this issue? 

Link to comment
Share on other sites

The only option is to close your database properly. BTW, this only applies to VCD or transaction recording (e.g. https://github.com/Minres/LWTR4SC). One way to achieve this under Linux would be to use the setjmp/longjmp mechanism:

#include <systemc>
...
#include <csetjmp>
#include <csignal>
  
using namespace sc_core;

jmp_buf abrt;
void ABRThandler(int sig) { longjmp(abrt, 1); }

int sc_main(int argc, char* argv[]) {
    signal(SIGABRT, ABRThandler);
    ///////////////////////////////////////////////////////////////////////////
    // create toplevel, trace, etc
    ///////////////////////////////////////////////////////////////////////////
	...
    ///////////////////////////////////////////////////////////////////////////
    // run the simulation
    ///////////////////////////////////////////////////////////////////////////
    int ret = -1;
    if(setjmp(abrt) == 0) {
        try {
			sc_start();            }
        } catch(sc_report& rep) {
            sc_report_handler::get_handler()(rep, SC_DISPLAY | SC_STOP);
        }
		// make sure end_of_simulation gets invoked
        if(!sc_end_of_simulation_invoked()) {
			sc_stop();
		}
        ret = sc_report_handler::get_count(SC_ERROR) + sc_report_handler::get_count(SC_WARNING);
    } else {
        ret = -1;
    }
    ///////////////////////////////////////////////////////////////////////////
    // close databases, cleanuo
    ///////////////////////////////////////////////////////////////////////////
	...
    ///////////////////////////////////////////////////////////////////////////
    // finish execution returning the number of errors/warnings as exit status
    ///////////////////////////////////////////////////////////////////////////
	return ret;
}

It also reports the number of warnings and errors so that it can be used in CI scenarios or regression testing.

Link to comment
Share on other sites

  • 2 weeks later...

This is not entirely true, VCD has the same problems only at a different scale. Writing a text file using fwrite usually employs buffering for performance reasons. Stopping a program using abort (called by a failing assert) will not write this buffer to disc. So the content is lost. Depending of the amount a signals being traced and their activiy you might loose the most interesting part of the trace....

On 8/1/2024 at 1:21 AM, shaddad said:

We still need a fix for the fsdb (verdi) issue. 

This cannot be fixed in fsdb, you need to modify your sc_main to allow proper closing of trace database(s).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...