Skip to content

Commit 0b01c1f

Browse files
committed
Reload waves seems to be working
1 parent 93380d8 commit 0b01c1f

File tree

6 files changed

+31
-2
lines changed

6 files changed

+31
-2
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ A list of features that have not yet been implemented.
6161
* Expose local variables in always blocks?
6262
* Time multiplier for waves (e.g. wave 1 unit is really X us/ns/ps/)
6363
* Wave + source should be able to figure out enums in waves.
64-
* Reload waves, and possibly live updates.
6564
* Search for value in wave.
6665
* Analog signals.
6766
* Detect unrolled arrays in waves, make them expandable in the waveforms

src/source_panel.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,7 @@ void SourcePanel::SetItem(const slang::ast::Symbol *item, bool save_state) {
792792

793793
SetLineAndScroll(line_idx);
794794
BuildHeader();
795+
// TODO: This is overkill, reading all wave data on every item set.
795796
UpdateWaveData();
796797
}
797798

src/ui.cc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ void UI::UpdateTooltips() {
7070
{.hotkeys = "C-p",
7171
.description =
7272
std::string(layout_.show_wave_picker ? "SHOW/hide" : "show/HIDE") + " picker"});
73+
tooltips_.push_back({.hotkeys = "C-r", .description = "Reload waves"});
7374
}
7475
if (panels_[focused_panel_idx_]->Searchable()) {
7576
tooltips_.push_back({"/nN", "search"});
@@ -152,6 +153,21 @@ UI::~UI() {
152153
endwin();
153154
}
154155

156+
void UI::ReloadWaves() {
157+
for (Panel *p : panels_) {
158+
p->PrepareForWaveDataReload();
159+
}
160+
Workspace::Get().Waves()->Reload();
161+
Workspace::Get().TryMatchDesignWithWaves();
162+
for (Panel *p : panels_) {
163+
p->HandleReloadedWaves();
164+
}
165+
// Force a refresh on the signals in the refreshed wave data tree.
166+
if (const auto scope = wave_tree_panel_->ScopeForSignals()) {
167+
wave_signals_panel_->SetScope(*scope);
168+
}
169+
}
170+
155171
void UI::EventLoop() {
156172
while (int ch = getch()) {
157173
bool quit = false;
@@ -265,6 +281,13 @@ void UI::EventLoop() {
265281
LayoutPanels();
266282
}
267283
break;
284+
case 0x12: // ctrl-R
285+
if (layout_.has_waves && (panels_[focused_panel_idx_] == waves_panel_.get() ||
286+
panels_[focused_panel_idx_] == wave_tree_panel_.get() ||
287+
panels_[focused_panel_idx_] == wave_signals_panel_.get())) {
288+
ReloadWaves();
289+
}
290+
break;
268291
case 0x9: // tab
269292
case 0x161: { // shift-tab
270293
const bool fwd = ch == 0x9;

src/ui.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class UI {
3030
void UpdateTooltips();
3131
void Draw() const;
3232
void DrawHelp(int panel_idx) const;
33+
void ReloadWaves();
3334

3435
std::unique_ptr<DesignTreePanel> design_tree_panel_;
3536
std::unique_ptr<SourcePanel> source_panel_;

src/wavedata_tree_panel.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ void WaveDataTreePanel::BuildInitialTree() {
2121
WaveDataTreePanel::WaveDataTreePanel() { BuildInitialTree(); }
2222

2323
void WaveDataTreePanel::HandleReloadedWaves() {
24+
data_.Clear();
2425
BuildInitialTree();
2526
scope_for_signals_ = dynamic_cast<WaveDataTreeItem *>(data_[line_idx_])->SignalScope();
2627
}

src/workspace.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ bool Workspace::ParseDesign(int argc, char *argv[]) {
4848
<< "\n";
4949
return 0;
5050
}
51+
bool design_ok = false;
5152
if (try_read_design && slang_driver_->processOptions()) {
5253
std::cout << "Parsing files...\n";
5354
if (!slang_driver_->parseAllSources()) return false;
@@ -65,11 +66,14 @@ bool Workspace::ParseDesign(int argc, char *argv[]) {
6566
std::cin.get();
6667
}
6768
design_root_ = &slang_compilation_->getRoot();
69+
design_ok = true;
6870
}
6971

72+
bool waves_ok = false;
7073
if (waves_file) {
7174
try {
7275
wave_data_ = WaveData::ReadWaveFile(*waves_file, *keep_glitches);
76+
waves_ok = true;
7377
} catch (std::runtime_error &e) {
7478
std::cout << "Problem reading waves: " << e.what() << "\n";
7579
return false;
@@ -78,7 +82,7 @@ bool Workspace::ParseDesign(int argc, char *argv[]) {
7882
sv::Workspace::Get().TryMatchDesignWithWaves();
7983
}
8084

81-
return true;
85+
return design_ok || waves_ok;
8286
}
8387

8488
void Workspace::TryMatchDesignWithWaves() {

0 commit comments

Comments
 (0)