Objective: Build an event-based simulator in Julia.
I have coded one in Matlab, now looking for speed.
Instead of simple translating, I looked how others do it.
Reactive.jl looks like a good candidate to start with.
The Reactive.jl package is operational, used in several other registered packages. Others got along with it…
From experience I stay away from using complete packages (or Matlab toolboxes) because there is always something which needs to be modified (with Julia a package might be easier to mod though).
So on to study the Reactive.jl code to progress learning the julian way.
Does this package use a priority queue? A heap?
How to search code on github? I ended up with google site: search, but nothing conclusive.
Then ran into the WeakRef function (type?). But where is it defined? Site search again zero.
Must be something built-in, lets try on JuliaLang:
WeakRef objects and finalizers are not currently handled properly by the serializer (this will be fixed in an upcoming release).
And that’s it. A general google search: julia WeakRef gives a buch of hits on issues, discussions, but hey…
Just one example, but IMHO typical for the Julia ecosystem.
How do you find your way?
Still looks like overkill, probably I can do faster without features not needed for a Verilog-like hardware description.
A basic HDL reactivity feature set should include:
create/combine observers for signals: @(change x), @(posedge clk && data == 1), attach callback functions to them
delay a signal change or delay a callback with actual parameters, complete it with parameters when event is due
The delayed functions are typically implemented as a priority queue which accepts (time, action) pairs,
– time is used as key, PQ can have multiple identical key entries (causal ordering)
– action is [callback, parameters].
Did not find Julia equivalents for Python MyHdl, PyVHDL, PyMTL, PyPI.
The electronics EDA folks have yet to discover Julia!
Day time jungle is better than night time jungle I suppose?
do you copy snippets of source code instead? If you write everything from scratch, then it doesn’t matter if other EDA folks have discovered Julia or not?
For various reasons, using Google to search for anything is not guaranteed to give good results. Searching with “julia” as a keyword doesn’t always turn out well either. Most people have probably learned the hard way to use “julialang” as a keyword.
On github you can use “language:julia”. StackExchange has a tag, but JuliaHub is pretty good for searching registered packages.
Some more thoughts on navigating through the code of packages, particularly if the definitions come from somewhere else:
Building on what @mkitti said, once you have identified that WeakRef comes from Julia Core with @which, you could then directly go to https://github.com/JuliaLang/julia and use the Github search feature, which allows to search “In this repository” and will display where the search term comes up in either the source code itself, commits or issues.
However, my favorite way to navigate through Julia code is using the VSCode Julia extension, specifically the features described in Code Navigation · Julia in VS Code.
In the example given, once you have opened the file containing the definition you are wondering about in VSCode (e.g. by locating it in the ~/.julia/Packages/Reactive folder), you can then Ctrl+Click on WeakRef and an excerpt of the definition will appear directly below. You can then also click on the file title, and it will open the file where the definition comes from in a new tab.
I am actually not sure how useful this is for this particular example, but in general I find it quite convenient to be able to quickly jump between definitions this way, even across different packages.