dgrnbrg / piplin

Compile Clojure to FPGAs
piplin.org
93 stars 10 forks source link

Must implement distribution of casts through ast nodes (aka incremental type refinement) #31

Closed dgrnbrg closed 12 years ago

dgrnbrg commented 12 years ago

The idea is that if you cast a mux2 that returns keywords to an enum, you really should instead cast both its branches to enums, so that you can use types w/ unbound or range-restricted (or arbitrary predicate restricted) parameters (like (bits >4)). Also, you want to make sure that everything is synthesizable, and this ensures that more specific/post-cast type information gets propagated throughout the fragment.

This will be accomplished by using a new optional :distribute metadata attr. It's value is a function that takes a type (that the output is being cast to) and returns a new fragment of that type. This gives each fragment the opportunity to forward the cast down to the leaves, allowing a cast to a synthesizable type at the root to propagate to the leaves of the fragment.

The distribution functions will be simple to write, but there needs to be a standard protocol for taking the casted arguments and rebuilding the fragment. For now, we will use the sim-fn, since it takes the exact arguments that would be casted. This means that all sim-factories must be able to return a fragment as well as an immediate value.

Current sim-factories that do not work properly: bit-slice, trace, ports

dgrnbrg commented 12 years ago

It turns out that just putting it on the mux2s takes care of things for now.