-
Notifications
You must be signed in to change notification settings - Fork 8
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
Functions vs Macros #140
Comments
Great writeup! Thanks for crafting a ticket for this frequent discussion point. Here are a few quick notes:
|
Spatial inlines functions. See under "Using Functions". |
Affine functionsReal reusable functions which specify how many instances of RTL blocks implement them. For example (made up syntax):
creates
And the reasoning extends to
The type theoretic ideas might be related to graded modalities (I might be wrong about this, but the idea of affine resources consumable a finite number of things exists). Bonus implementation points: Multi ported memories will already need a similar style of reasoning to work. DSEAllowing source level reasoning for these resources will help with area-efficiency tradeoffs and maybe we can eventually infer the |
Neat! I do think time steps should indeed replenish function resources, as they do memory banks—the reason being that function calls (unless we do something drastic) are synchronous, i.e., a function call waits for the entire function to finish. If we allowed async calls, this would get more complicated—the function resource would probably need to stay consumed past the time step and only get released when synchronizing the result (like forcing a future). |
Macros
In the current semantics of Fuse, there are no true "functions". All
def
s in the semantics should be thought of simple macros that just get expanded at call locations. This notion corresponds to havingk
copies of RTL if there arek
calls to a functions. Furthermore, anunroll
context also increases the number of RTL blocks for a functions.For example, in this code:
there should be exactly
k + 2
copies offoo
in the hardware design.Functions
On the other hand, a true function in Fuse would represent exactly one RTL block regardless of the number of syntactic calls. This has a few implication for the semantics.
foo(...); foo(...)
since the same RTL block is being sent two signals in parallel.foo(...)
inside an unrolled loop is also incorrect, because the same RTL block is being invokedk
times in a single cycle.Obviously, this notion of functions is very restrictive.
Vivado's default
According to this SDAccel page, syntactic functions have the following defaults:
The notion of a hierarchy here is fuzzy to me (maybe @sa2257 can clarify). However, this seems to imply that all functions in emitted C++ code are true functions according to our definition.
Things to consider
We have to consider a few things before we add true functions to the language:
inline
pragma for all functions.All of these considerations will inform the design of fuse-to-rtl in the future. I suggest that for the first paper, we only think about
def
s as macros and not have any support for actual functions till Fuse 2.0.The text was updated successfully, but these errors were encountered: