Skip to content
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

Arrays #9

Open
aprocter opened this issue Oct 13, 2014 · 2 comments
Open

Arrays #9

aprocter opened this issue Oct 13, 2014 · 2 comments

Comments

@aprocter
Copy link
Contributor

Some kind of support for arrays (including bit vectors) would be extremely handy going forward. There are two main challenges here that I see:

  1. The type system: we will need support for type-level nats in some form. For example, the array append operator has type a[n] -> a[m] -> a[n+m].
  2. It may be difficult to ensure that the synthesis tools infer block/distributed RAMs for arrays when intended.
@aprocter
Copy link
Contributor Author

Will need to think about what operators we want, as these will probably have to be implemented as primitives (though I suppose we could have array pattern matching). At a minimum I see:

 elem :: a[n] -> (m:Nat | 0 <= m < n) -> a
 append :: a[n] -> a[m] -> a[n+m]
 slice :: a[n] -> (x:Nat | 0 <= x < n) -> (y:Nat | x <= y < n) -> a[(n - (y - x)) + 1]

So a surprising amount of expressivity is needed where the type-level nats are concerned.

@aprocter
Copy link
Contributor Author

A lightweight alternative that's still useful for many (maybe all!) purposes would be to implement finite map types. Then a register file or a memory could have types like:

 rf :: Reg=>Word
 mem :: Addr=>Word

Where Reg and Addr are "y'know, whatever." Semantically these are just functions, but maintaining a distinction between functions and maps in the type system would allow us to restrict the signature of => to simple update and read operations, and provides a critical optimization hint to the compiler. (Also it dances around the "Eq" issue.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant