-
Notifications
You must be signed in to change notification settings - Fork 195
Channels should be encapsulated by procs in the IR #869
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
Comments
I like the idea. About channel declarations being nodes, I don't think it makes sense for them to be actual xls::Nodes, rather they could be a proc-scoped construct similar to registers in blocks. Making them xls::Nodes implies a level of dynamism we don't support. For example, can you pass them around? put them in arrays? select among them? Proc-scoped channels would also help reduce name collisions. Right now channels are global object so no two channels can be named the same. This is annoying and this constraint does not reflect any underlying constraint in the generated code. Theese channels often map to verilog module ports and there it's fine if two different modules have ports with the same name. |
Spit balling a possible syntax:
|
For the purpose of referring to things, it might be good to give spawn statements names:
This gives you a string path for referring to a specific instantation (spawning) of a proc. |
@tmichalak bf28838 fyi (for some reason it seems that I can't mention |
Signed-off-by: Michal Czyz <[email protected]>
Hey, I have a few points to contribute to this conversation from a designer's point of view. I am currently engaged in an effort to design new modules in DSLX and have the following experiences:
After analysis of the proc scoped channels proposal, I believe that this approach would solve my problems and help a lot. I wonder, however, if this is the best solution. I can imagine that during analysis of the DSLX code, an algorithm could traverse through the hierarchy of processes (analyze proc,spawn relationships) and build a hierarchy graph, which could be inserted as metadata in the IR. It seems to me that it would be a cheaper solution than "proc scoped channels", unless there are some limitations with IR manipulation that I am not aware of. I encountered also another problem mentioned in the "proc scoped channels" docs, which is inability to create unconnected ports (equivalent to What do you think? |
@mczyz-antmicro You're correct that proc-scoped channels will solve the issues you describe. Regarding implementing this as metadata, that could be done but I don't think it is the most robust solution. Keeping metadata on the side which must be kept in sync with the IR is a potential source of complexity and bugs (where the metadata does not match the IR) Sometimes it may be necessary, but ideally you avoid it and only have to keep one representation at a time. You're right in that changing channels to being proc-scoped is a significant amount of work and the metadata approach would likely be cheaper, but I think it is worth the investment now to get the right representation. The work is already underway, you can now see that there is a bit on procs ("new_style") which indicates whether it is the new kind of proc which can have channels declared in it. I'll keep adding more and more functionaliity to these "new style" procs until they can do everything the existing procs can do, and then switch existing frontends and designs over and remove the old proc representation. Regarding the use case of an unused port, I think the proc-scoped channel approach makes this much easier to support. With proc-scoped channels, there is an explicit declaration of the interface of the proc, for example:
Here Channels are proc-scoped in the frontend (DSLX) and also in the verilog representation where you have a hierarchy of instantations and all connectivity (ie, channels) are encapsulated as reg/wire/logic declarations within a module, so I think it makes sense for the IR to have a similar representation. |
Thanks for a great explanation @meheff , I am now convinced that it is worth to wait for the new implementation. Happy to hear that work on new style has already started! I have one more idea I would like to share: correct me if I'm wrong, but I believe that currently to combine design with an SRAM macro, one needs to expose the RAM channels all the way to the top-level, right? Have you given it thought if proc based channels could improve this situation? It would be neat if we could have something like a proc decorator so that the tool is capable of generating verilog with an exposed interface,e.g:
|
Unfortunately, I've found that the workaround I had proposed does not always work:
I modified the Attaching files from the verilog generation flow |
Hi, I recently encountered the same problems as @mczyz-antmicro. My attempts to generate verilog for RleBlockDecoder (part of #1213) as well as BlockDecoder (part of #1214) were both unsuccessful.
Performing IR optimization and codegen with this default top proc results in empty verilog module, like so:
I decided to follow this approach and I've manually set top level proc for IR opt as one of the internal procs (for
I've also tested this workaround and it didn't work for me. It resulted in generation of verilog logic that only receives and sends data through those dummy channels. I've come up with an idea for a possible workaround which involved:
This can be visualized by the following diagram: I tested the idea on antmicro@5a72b99 and this caused codegen to generate verilog code for I've also looked at the existing examples in XLS and it seems like in the whole repository there is only one example which is a proc that spawns other procs and has rules for verilog generation. This is Delay32x2048_init3 which is a specification of parameterized Delay. |
Just for the record. As stated in #1253 (comment) there is in fact a workaround which allows to generate valid verilog.
For procs which have empty
Additionally, all internal procs must have
|
The IR has supported proc-scoped channels for a while. Optimizations and codegen also generally support the feature though there may be some corner cases or missing features. The big missing component is the front end which I'll file a separate issue for. |
Right now, channels are global and procs can arbitrarily reference them. This freedom doesn't necessarily buy that much as codegen needs to plumb them up and down the hierarchy eventually anyways. It seems easier to understand what channels do if they were encapsulated by the proc that instantiates them (and would also allow procs to be invoked, and perhaps aid linking, etc.).
Also, it might make sense to make channel declarations nodes- right now channels are kind of their own weird thing in the IR and it's occasionally annoying that they aren't nodes.
The text was updated successfully, but these errors were encountered: