Build System Brainstorming #410
Replies: 4 comments 8 replies
-
Awesome!! |
Beta Was this translation helpful? Give feedback.
-
Some setupThe first place that I think would benefit from some more careful coordination between XLS and Filament is data types. XLS allows you to declare something like:
which you can then define functions on, as follows:
I haven't looked into it yet, but these structs probably get flattened into a bitvector or something, since that is how most other things seem to be stored. If we want to give
Because of the current inability to express a type like
where p instead is a flattened bitvector containing the Also, we might want to compose these XLS constructs with other non-XLS constructs, like a module (implemented in Filament, Verilog, whatever) with the following Filament signature:
We can imagine this module might return some The problemObviously, the hard part here is how we should interface with the XLS-level type information in Filament. I think I see a way to do this right now. Solution 1This solution would hopefully be a formalization of the very ad-hoc XLS FFT stuff I was doing very close to the paper deadline. In short, there were some simple XLS data types (tuples, arrays) that we wanted to pass to Filament so that we could use our testing harness. My solution for this was to:
This sounds sort of bad, but I think there are a few ways we can clean it up. Mainly, we would need to come up with some sort of hardware analog to an ABI that would tell us (really the Filament compiler) how data being passed between XLS/Filament is laid out and how it can find the information it wants. Using this, it would be easier to have the compiler do the steps that I described above, which were previously done by hand. Less clear, however, is how we can import type information from XLS. If we are looking to build a coherent build system, it feels important that we should be able to reference XLS types from Filament, so that our signature can use type This seems like the hard part. I'm wondering if it would be possible to be able to import the XLS file at the top of the Filament file, and then parse it (or at least just the types). Then, the Filament compiler can see that |
Beta Was this translation helpful? Give feedback.
-
This is somewhat tangential, but I noticed a really interesting and very recent development in the FIRRTL ecosystem: they have started documenting an ABI. This document defines a contract that describes how FIRRTL-level interfaces are guaranteed to manifest in compiled Verilog code. Interestingly, the spec for data types takes the opposite approach from XLS:
That is, FIRRTL-level "bundles" (their name for structs) are lowered to Verilog-level structs that look nearly identical. XLS, in contrast, lowers all its "fancy" datatypes to plain ol' bits. In fact, it kinda sounds like (from this document) FIRRTL used to do it the XLS way, and they want to change it:
I like the XLS (and FIRRTL ABIv1) approach better, for these reasons:
The trade-off is that it is less convenient to integrate with Verilog projects that want to pass Verilog-level structs around. This is presumably a priority for FIRRTL but does not seem like an important priority for us. If we wanted this kind of interop, we would probably instead want a Verilog-specific bindgen-like tool to generate code that reconstructs Verilog aggregate types from flattened bits. |
Beta Was this translation helpful? Give feedback.
-
We've spent some time talking about these things in our weekly meetings, and I think we have nailed down enough of what we want here (at least for a first pass) that maybe some implementation can begin soon. A high-level plan is to build some richer data types into Filament, and then build language-specific bindgen-like tools. IdeasI think the first thing we want to do here is add richer data types to Filament. There are two reasons: (1) we have been wanting to do this for a while anyway (at least with structs), and (2) having these constructs in Filament makes it easier to interop with other languages that have these data types. At least to start, here are a few ideas: EnumsThe DSLX language reference describes an enum as
I think this fits nicely into Filament, where we could have something like:
Uses of enum members could look like I've been trying to think about how we handle the timing information here. One idea is to force the user to give each member an availability interval in the enum declaration, like this (the syntax is silly but it illustrates the point I guess):
Another idea I thought would be to not require an availability interval in the enum declaration and instead have the compiler figure it out after monomorphization happens. At this point, we would know the first and last uses of each enum member, so we could instantiate a constant primitive that spans that range. This would make the first typechecking pass (before monomorphizing) kind of messy, since our only option would be to assume that these will typecheck at some later point. Or, instantiate a new constant primitive for each use of the enum member, available specifically for the interval that it is being used for. This approach of not including timing information in the declaration feels a bit un-Filament-y, but I think it does make enums feel more "global". TuplesFilament has bundles, which allow you to create a group of signals available at different times, but of the same bit width. It could be nice to also have tuples, which would be a group of signals of different widths, but available at the same time. I figure a user could make a type declaration like
which would mean that the module accepts a 32-bit, 8-bit, and 16-bit input in the interval ['G, 'G+1] (which we would know from looking at the type declaration). StructsI think structs should be implemented as a group of named signals that can be different widths, and available at different times. So, basically the same as laid out in #99. Later: interfacing with XLSThis has been brought up before, but we would need to define some FFI between XLS and Filament, similar to the one that exists between Rust and C. We could have something like:
where the |
Beta Was this translation helpful? Give feedback.
-
Hello! This is where I'm going to keep a running journal of all things related to a potential build system/integration story for Filament.
Beta Was this translation helpful? Give feedback.
All reactions