-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simulation only instructions? #121
Comments
You raise an excellent point. At some point we want input/output from the simulation, as you say, to back Verilog's Regarding possible ways to implement this, I'm inclined to keep things as minimal as possible. For example:
The mechanism to call into native code is not implemented at the moment, but would work in roughly the same fashion: you declare an "external" function in LLHD, that you can then call. The simulator would try to dynamically link that symbol on startup, e.g. to a sys/libc call. Then you could gain access to native code via DPI, or call into OS functions:
Any thoughts on this? |
I think this approach makes a lot of sense.
Was Rambling a bit now:
I would want to back |
Yes exactly. There must be a clear separation about what is described inside an LLHD model, and what is an opaque/black-box call into some piece of code that the linker of the operating system gives you access to.
Exactly.
Indeed, a first step to prepare synthesis would be to remove everything from the LLHD description which does not strictly contribute to an input-to-output relationship.
External code can only be functions, by the nature of how regular code executing on the processor works. So if you want to have a module that is either implemented in LLHD, or derives its behaviour from some external software model, you would have to create a wrapper module for the latter, which calls the software model as a function. A features where certain parts of an LLHD description are only enabled for simulation, and some only for synthesis, is pretty neat. However I'm not yet sure how useful this is going to be in practice, because realistically your testing code is vastly different from your synthesis code, and swapping out a synthesizable module for a simulation model is something you would probably do in a language frontend such as Moore, rather than very far down the IR pipeline. |
Thanks for the clarifications. You mentioned that
Does
I think an explicit wrapper around native calls providing an entity interface that matches that of the synthesizable one would work fine. I am not sure how obvious of a feature that would be, but I suppose what I am after here is for the option to trivially do something similar to passing a different
I suppose one flow I like to follow to quickly push ahead on the dev of my RTL looks something like this: For what it's worth, another flow I was contemplating for ages was something like having RTL code only for a DUT and have its interface stimulated from external native code in lieu of a testbench, hence literally having NO testing code in the same source language. I quite liked this approach, but maybe it is very naive? What do you think about those potential use cases? |
@gameboo Being able to drive a DUT from a Python testbench — or orchestrating multiple DUTs & native modules in Python would be killer. |
Not at the moment. It's easy to add to the IR, but I'm currently pushing Moore ahead to a point where it would be able to emit e.g. DPI calls in SV (function calls currently missing). At that point I will go in and add the
Yeah I think this flow should be easily possible with this approach!
Yeah this makes a lot of sense. I think that would be well-covered by extern calls.
This could work a bit like CocoTB testbenches, where you push everything testing-related out into Python via DPI calls. Pretty exciting stuff! |
Hello,
I am enjoying gently diving into llhd as hobby during lockdown, and in that sense, my reading of the paper and the information out there might not be as thorough as it could be, so please ignore/close this if I missed something obvious :).
I was wondering to what extend it would be desirable / a big no no to have "simulation only" instructions in llhd.
Basically, I am after mapping terminal input / output in a simulation. I tried llhd-sim and realized it produced a vcd file which is nice, but rapidly hard to use as a debugging method for more complex designs. "printf" style debugging could use a
simOut
instruction to output strings mingled with values from the simulation (backing verilog's$display
or$write
). AsimIn
could also map values from outside a simulation to signals. These could help in simulating a UART for example. And they get ignored in all cases that are not simulation.The paper (section 2.5.8 about memory instructions) mentions "a mechanism to call into native code". Is what I suggest already covered by such things in some way?
Thanks!
The text was updated successfully, but these errors were encountered: