@@ -25,10 +25,25 @@ const slang::SourceManager *Workspace::SourceManager() const {
2525 return slang_compilation_->getSourceManager ();
2626}
2727
28+ bool Workspace::ReParse () {
29+ slang_compilation_ = nullptr ;
30+ design_root_ = nullptr ;
31+ const bool parse_ok = ParseDesign (/* initial*/ false );
32+ const bool success = slang_driver_->diagEngine .getNumErrors () == 0 ;
33+ return parse_ok && success;
34+ }
35+
2836bool Workspace::ParseDesign (int argc, char *argv[]) {
37+ command_line_.argc = argc;
38+ command_line_.argv = argv;
39+ return ParseDesign (/* initial*/ true );
40+ }
41+
42+ bool Workspace::ParseDesign (bool initial) {
2943 // Avoid invoking the slang compiler if only wave-reading options are specified.
3044 const bool try_read_design =
31- !(argc == 3 && (std::strcmp (argv[1 ], " -w" ) == 0 || std::strcmp (argv[1 ], " --waves" ) == 0 ));
45+ !(command_line_.argc == 3 && (std::strcmp (command_line_.argv [1 ], " -w" ) == 0 ||
46+ std::strcmp (command_line_.argv [1 ], " --waves" ) == 0 ));
3247 slang_driver_ = std::make_unique<slang::driver::Driver>();
3348 // Additional options from simview:
3449 std::optional<bool > show_help;
@@ -41,36 +56,36 @@ bool Workspace::ParseDesign(int argc, char *argv[]) {
4156 " Retain 0-time transitions in the wave data. Normally pruned." );
4257
4358 slang_driver_->addStandardArgs ();
44- if (!slang_driver_->parseCommandLine (argc, argv)) return false ;
45- if (show_help == true ) {
59+ if (!slang_driver_->parseCommandLine (command_line_. argc , command_line_. argv )) return false ;
60+ if (show_help == true && initial ) {
4661 std::cout << slang_driver_->cmdLine .getHelpText (
4762 " simview: a terminal-based verilog design browser and waves viewer." )
4863 << " \n " ;
4964 return 0 ;
5065 }
5166 bool design_ok = false ;
5267 if (try_read_design && slang_driver_->processOptions ()) {
53- std::cout << " Parsing files...\n " ;
68+ if (initial) std::cout << " Parsing files...\n " ;
5469 if (!slang_driver_->parseAllSources ()) return false ;
55- std::cout << " Elaborating...\n " ;
70+ if (initial) std::cout << " Elaborating...\n " ;
5671 slang_compilation_ = slang_driver_->createCompilation ();
57- // TODO: This freezes the design and somehow makes traversal throw exceptions.
58- // std::cout << "Analyzing...\n";
59- // slang_analysis_ = slang_driver_->runAnalysis(*slang_compilation_);
6072 // This print all tops, and collects diagnostics.
61- slang_driver_->reportCompilation (*slang_compilation_, /* quiet */ false );
62- const bool success = slang_driver_->reportDiagnostics (/* quiet */ false );
63- // Give the user a chance to see any errors before proceeding.
64- if (!success) {
65- std::cout << " Errors encountered, press Enter to continue anyway...\n " ;
66- std::cin.get ();
73+ slang_driver_->reportCompilation (*slang_compilation_, /* quiet */ !initial);
74+ if (initial) {
75+ const bool success = slang_driver_->reportDiagnostics (/* quiet */ !initial);
76+ // Give the user a chance to see any errors before proceeding.
77+ if (!success) {
78+ std::cout << " Errors encountered, press Enter to continue anyway...\n " ;
79+ std::cin.get ();
80+ }
6781 }
6882 design_root_ = &slang_compilation_->getRoot ();
6983 design_ok = true ;
7084 }
7185
7286 bool waves_ok = false ;
73- if (waves_file) {
87+ // Waves are only read on initial load. There's a separate mechanism that triggers wave reload.
88+ if (initial && waves_file) {
7489 try {
7590 wave_data_ = WaveData::ReadWaveFile (*waves_file, *keep_glitches);
7691 waves_ok = true ;
0 commit comments