From 9b28b05f672a3e79055c39aaabfc88be3c2b0d17 Mon Sep 17 00:00:00 2001 From: Ryo ONODERA Date: Sat, 6 Jun 2026 01:36:46 +0900 Subject: [PATCH 1/3] Fix Wavedrom in Jupyter Notebook * Use HTML tags instead of jQuery. --- pyrtl/simulation.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/pyrtl/simulation.py b/pyrtl/simulation.py index 045aa3b8..d0b5df7e 100644 --- a/pyrtl/simulation.py +++ b/pyrtl/simulation.py @@ -1775,16 +1775,12 @@ def render_trace( html_elem = HTML(htmlstring) display(html_elem) # print(htmlstring) - js_stuff = """ - $.when( - $.getScript("https://cdnjs.cloudflare.com/ajax/libs/wavedrom/1.6.2/skins/default.js"), - $.getScript("https://cdnjs.cloudflare.com/ajax/libs/wavedrom/1.6.2/wavedrom.min.js"), - $.Deferred(function( deferred ){ - $( deferred.resolve ); - })).done(function(){ - WaveDrom.ProcessAll(); - });""" - display(Javascript(js_stuff)) + html_stuff = """ + + + + """ + display(HTML(html_stuff)) else: self.render_trace_to_text( trace_list=trace_list, From 2a89bb00b5eccf631151f4014df806c75e36c02e Mon Sep 17 00:00:00 2001 From: Ryo ONODERA Date: Sat, 6 Jun 2026 01:43:06 +0900 Subject: [PATCH 2/3] Remove unused `Javascript` from import --- pyrtl/simulation.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pyrtl/simulation.py b/pyrtl/simulation.py index d0b5df7e..0b318322 100644 --- a/pyrtl/simulation.py +++ b/pyrtl/simulation.py @@ -1763,7 +1763,6 @@ def render_trace( if _currently_in_jupyter_notebook(): from IPython.display import ( HTML, - Javascript, display, ) From 5e01e97d79b654ada83fb093a6578369f8fd786c Mon Sep 17 00:00:00 2001 From: Jeremy Lau <30300826+fdxmw@users.noreply.github.com> Date: Wed, 10 Jun 2026 15:22:31 -0700 Subject: [PATCH 3/3] Periodically check if WaveDrom is loaded before calling `WaveDrom.ProcessAll()`, rather than calling it `onload`. This fixes an issue where traces may not render when first executing a `render_trace()` cell, because it races with loading the JavaScript libraries. --- pyrtl/simulation.py | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/pyrtl/simulation.py b/pyrtl/simulation.py index 0b318322..3ecc5866 100644 --- a/pyrtl/simulation.py +++ b/pyrtl/simulation.py @@ -1763,23 +1763,31 @@ def render_trace( if _currently_in_jupyter_notebook(): from IPython.display import ( HTML, + Javascript, display, ) from pyrtl.visualization import trace_to_html - htmlstring = trace_to_html( - self, trace_list=trace_list, sortkey=_trace_sort_key + display( + HTML( + trace_to_html(self, trace_list=trace_list, sortkey=_trace_sort_key) + ), + HTML(""" + + + """), + # Wait for WaveDrom to load, polling every 100ms. + Javascript(""" + var interval = setInterval(function() { + if (typeof WaveDrom !== 'undefined' && + typeof WaveDrom.ProcessAll === 'function') { + clearInterval(interval); + WaveDrom.ProcessAll(); + } + }, 100); + """), ) - html_elem = HTML(htmlstring) - display(html_elem) - # print(htmlstring) - html_stuff = """ - - - - """ - display(HTML(html_stuff)) else: self.render_trace_to_text( trace_list=trace_list,