-
Notifications
You must be signed in to change notification settings - Fork 647
Customization option: emit module->blackbox #4351
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
Conversation
e84bc1e to
acd997f
Compare
1c87bd3 to
8dd5bd4
Compare
|
I think it's important to not mix Chisel language features with command line features. How I would suggest doing this is to instead make Riffing off the example you show, something like this: package Example
class NoIO extends Bundle {}
class Leaf extends RawModule
class Branch extends FixedIORawModule[NoIO](new NoIO) {
val l0 = Module(new Leaf)
val l1 = Module(new Leaf)
}
class BranchBlackBox extends FixedIOExtModule[NoIO](new NoIO) {}
class Root(branchIsExtModule: Boolean) extends RawModule {
val b0, b1 = branchIsExtModule match {
case false => Module(new Branch)
case true => Module(new BranchBlackBox)
}
}This can then be invoked with You can already almost do this with Orthogonally, module vs. blackbox or module swapping can be preserved through to Verilog via instance choice. There's great utility in delaying this choice to Verilog elaboration time when possible. I completely realize that this is just an example of the types of things you could do with a hypothetical |
|
FWIW. I think we may need these features for separate linking features, which is intended to be provided by this PR:
After these three are implemented in chisel. Maybe we can provide a multiple phase new elaboration flow:
This flow is non backward compatible but should essentially solve the nightmare of DFS module instantiation. And also enable the separate linking flow at phase 2. |
Whether I agree with the principle stated, but not the reasoning of applying it to this situation because the evidence is that this feature should be a commandline feature, not a Chisel language feature, to encourage encapsulation and keeping orthogonal concerns separate. |
I somewhat agree with this, though from a different direction. I don't think there is an actual desire for a user to have a design which has That said, a user is entirely free to do whatever they want! If they want to make this configurable, more power to them. What my example shows is that Chisel is already powerful enough to describe this kind of generator. What I'm pushing back on is making this a command line argument to Chisel when Chisel can already do this. This is what my example is showing. The only piece missing is the ability to run this generator from the command line. |
Yes, and my point is that this is a mis-application of the utility of a generator's power because it breaks encapsulation. The better way to do it is to not have |
|
I would like this PR to be placed in a larger context of all the things we might want to do when asked to |
Right -- if we generally want to be able to swap out implementations sometimes, do we really want to have to route that around to every single module instantiation site? If we really do want to route it through chisel, then maybe the missing feature is letting a Module (not its parent) decide if it wants to be emitted as a black box or not.
I really like this point. It's yet another "what I might want to do" on a per-module-instance basis which we could certainly route through top-down, but i think this PR is really about -- is there a pattern better than passed-from-the-parent to make these decisions? |
|
@azidar wrote:
@mwachs5 wrote:
I'm actually advocating against writing generators where there is a choice of what is a blackbox or not. I'm generally against both:
However, since we already have (1), and a user is entirely free to write generators like this if they want, I don't see a reason to stop them. (2) doesn't provide value over (1) other than it provides a dangerous (IMO) way of having a shadow parameter that is not captured by the Chisel design. While I don't think (1) is a good way to write a generator, it at least encodes what a design is as opposed to making this a side-band mechanism through the command line. What I would love to see is the ability to run generators with arguments on the command line with something like: sbt run chisel3.stage.ChiselMain --module 'foo.bar.Baz(42, "hello")' -o build/Maybe we can agree to start with support for extensions to I do think that this notion of |
Can you explain in more detail your reasoning and provide supporting evidence for holding this opinion? |
|
@azidar wrote:
Sure. My reasoning is guided by two principles:
If we have a design where we want to encode that an instance may be a module or a blackbox, then make that plain in Chisel. Chisel has two mechanisms for this already: parameter passing and instance choice [1]. Both of these, by the first principle, are advantageous over the CLI approach because the optionality is in Chisel and not captured in side-band information of what command line invocation was used to do Chisel elaboration. There are then three ways that an instance could be instantiated: statically using the same module always (no instance optionality), with a Verilog elaboration-time choice (using the instance choice feature), or at Chisel elaboration time (parameter passing or the proposed CLI). These are ordered from least powerful to most powerful. By the second principle, a static module choice should be used unless the designer has a reason to use more power. The proposed CLI enables the most powerful feature for every module in a design at all times. [1]: The instance choice docs have a good example of module vs. blackbox: https://www.chisel-lang.org/docs/explanations/instchoice |
Most programming languages have a separate build configuration, which would put together multiple separately compiled units. So for Scala, as an example, the build config contains critical information to determine the behavior of one's Scala project. I believe there is more nuance to the first premise. Can you expand this premise to consider more details for when information should be in the build config, versus a language? |
A thought-experiment-in-code for how to customize the FIRRTL emission from Chisel.
We could add lots of different options, say in more of a table based approach where for each module/Instantiate call, given a match of some sort you do one of a few things, e.g. emit as a black box, or replace with some other firrtl implementation, etc. The match could be more descriptive than just module name, like including regexy-ness of: class (exact or inherited), desiredName, actual ChiselName, class but only with certain parameters.
This strategic line of thinking is more aligned with viewing Chisel as a CLI tool, rather than a framework.
Contributor Checklist
docs/src?Type of Improvement
Desired Merge Strategy
Release Notes
Reviewer Checklist (only modified by reviewer)
3.6.x,5.x, or6.xdepending on impact, API modification or big change:7.0)?Enable auto-merge (squash), clean up the commit message, and label withPlease Merge.Create a merge commit.