Ejemplo n.º 1
0
void V3Error::abortIfWarnings() {
    bool exwarn = warnFatal() && warnCount();
    if (errorCount() && exwarn) {
	v3fatal ("Exiting due to "<<dec<<errorCount()<<" error(s), "<<warnCount()<<" warning(s)\n");
    } else if (errorCount()) {
	v3fatal ("Exiting due to "<<dec<<errorCount()<<" error(s)\n");
    } else if (exwarn) {
	v3fatal ("Exiting due to "<<dec<<warnCount()<<" warning(s)\n");
    }
}
Ejemplo n.º 2
0
 void dumpGraphFilePrefixed(const string& nameComment) const {
     if (v3Global.opt.dumpTree()) {
         string filename = v3Global.debugFilename(nameComment)+".txt";
         const vl_unique_ptr<std::ofstream> logp(V3File::new_ofstream(filename));
         if (logp->fail()) v3fatal("Can't write "<<filename);
         dumpGraph(*logp, nameComment);
     }
 }
Ejemplo n.º 3
0
void V3ParseImp::lexFile(const string& modname) {
    // Prepare for lexing
    UINFO(3,"Lexing "<<modname<<endl);
    s_parsep = this;
    fileline()->warnResetDefault();	// Reenable warnings on each file
    lexDestroy();	// Restart from clean slate.
    lexNew(debugFlex()>=9);

    // Lex it
    if (bisonParse()) v3fatal("Cannot continue\n");
}
Ejemplo n.º 4
0
void V3Stats::statsReport() {
    UINFO(2,__FUNCTION__<<": "<<endl);

    // Open stats file
    string filename = v3Global.opt.makeDir()+"/"+v3Global.opt.prefix()+"__stats.txt";
    std::ofstream* ofp (V3File::new_ofstream(filename));
    if (ofp->fail()) v3fatal("Can't write "<<filename);

    StatsReport reporter (ofp);

    // Cleanup
    ofp->close(); delete ofp; VL_DANGLING(ofp);
}
Ejemplo n.º 5
0
int main(int argc, char** argv, char** env) {
    // General initialization
    ios::sync_with_stdio();

    time_t randseed;
    time(&randseed);
    srand( (int) randseed);

    // Post-constructor initialization of netlists
    v3Global.boot();

    // Preprocessor
    // Before command parsing so we can handle -Ds on command line.
    V3PreShell::boot(env);

    // Command option parsing
    v3Global.opt.bin(argv[0]);
    string argString = V3Options::argString(argc-1, argv+1);
    v3Global.opt.parseOpts(new FileLine("COMMAND_LINE",0), argc-1, argv+1);
    if (!v3Global.opt.outFormatOk()
	&& !v3Global.opt.preprocOnly()
	&& !v3Global.opt.lintOnly()
	&& !v3Global.opt.xmlOnly()
	&& !v3Global.opt.cdc()) {
	v3fatal("verilator: Need --cc, --sc, --sp, --cdc, --lint-only, --xml_only or --E option");
    }
    // Check environment
    V3Options::getenvSYSTEMC();
    V3Options::getenvSYSTEMC_ARCH();
    V3Options::getenvSYSTEMC_INCLUDE();
    V3Options::getenvSYSTEMC_LIBDIR();
    V3Options::getenvSYSTEMPERL();
    V3Options::getenvSYSTEMPERL_INCLUDE();

    V3Error::abortIfErrors();

    // Can we skip doing everything if times are ok?
    V3File::addSrcDepend(v3Global.opt.bin());
    if (v3Global.opt.skipIdentical()
	&& !v3Global.opt.preprocOnly()
	&& !v3Global.opt.lintOnly()
	&& !v3Global.opt.cdc()
	&& V3File::checkTimes(v3Global.opt.makeDir()+"/"+v3Global.opt.prefix()+"__verFiles.dat", argString)) {
	UINFO(1,"--skip-identical: No change to any source files, exiting\n");
	exit(0);
    }

    // Internal tests (after option parsing as need debug() setting)
    AstBasicDTypeKwd::test();
    V3Graph::test();

    //--FRONTEND------------------

    // Cleanup
    V3Options::unlinkRegexp(v3Global.opt.makeDir(), v3Global.opt.prefix()+"_*.tree");
    V3Options::unlinkRegexp(v3Global.opt.makeDir(), v3Global.opt.prefix()+"_*.dot");
    V3Options::unlinkRegexp(v3Global.opt.makeDir(), v3Global.opt.prefix()+"_*.txt");

    // Read first filename
    v3Global.readFiles();

    // Link, etc, if needed
    if (!v3Global.opt.preprocOnly()) {
	process();
    }

    // Final steps
    V3Global::dumpGlobalTree("final.tree",990);
    V3Error::abortIfWarnings();

    if (!v3Global.opt.lintOnly() && !v3Global.opt.cdc()
	&& v3Global.opt.makeDepend()) {
	V3File::writeDepend(v3Global.opt.makeDir()+"/"+v3Global.opt.prefix()+"__ver.d");
    }
    if (!v3Global.opt.lintOnly() && !v3Global.opt.cdc()
	&& (v3Global.opt.skipIdentical() || v3Global.opt.makeDepend())) {
	V3File::writeTimes(v3Global.opt.makeDir()+"/"+v3Global.opt.prefix()+"__verFiles.dat", argString);
    }

    // Final writing shouldn't throw warnings, but...
    V3Error::abortIfWarnings();
#ifdef VL_LEAK_CHECKS
    // Cleanup memory for valgrind leak analysis
    v3Global.clear();
#endif
    FileLine::deleteAllRemaining();

    UINFO(1,"Done, Exiting...\n");
}
Ejemplo n.º 6
0
void V3Error::incErrors() {
    s_errCount++;
    if (errorCount() == errorLimit()) {  // Not >= as would otherwise recurse
	v3fatal ("Exiting due to too many errors encountered; --error-limit="<<errorCount()<<endl);
    }
}