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

Ability to solve implicit sizes in bitvector concatenation #746

Closed
Timmmm opened this issue Oct 29, 2024 · 2 comments
Closed

Ability to solve implicit sizes in bitvector concatenation #746

Timmmm opened this issue Oct 29, 2024 · 2 comments

Comments

@Timmmm
Copy link
Contributor

Timmmm commented Oct 29, 2024

It would be neat if this worked:

let x : bits(5) = 0b1 @ zeros();

Unfortunately it doesn't currently:

14 |  let x : bits(5) = 0b1 @ zeros();
   |                    ^-----------^ checking function argument has type bitvector('m)
   | Cannot solve implicit 'n in zeros()

Obviously there will be situations where it is impossible:

let x : bits(5) = ones() @ zeros();

But as long as there is at most 1 implicit length in the concatenation it should be possible in theory I guess?

Workaround is to put it in a function and make it explicit within the function, but it's not as nice.

val leading_one : forall 'n, 'n >= 1. (implicit('n)) -> bits('n)
function leading_one(n) = 0b1 @ zeros('n - 1)

function main() -> unit = {
  let x : bits(5) = leading_one();
}
@Alasdair
Copy link
Collaborator

Would make sense to have this because it works for vector concatenation patterns, however concatenation expressions are type checked as regular functions. That has its advantages, but also means special casing things might be tricky.

@Alasdair
Copy link
Collaborator

Should be fixed by #753

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

No branches or pull requests

2 participants