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

Type annotations for magma functions #1217

Open
rkshthrmsh opened this issue Dec 23, 2022 · 1 comment
Open

Type annotations for magma functions #1217

rkshthrmsh opened this issue Dec 23, 2022 · 1 comment

Comments

@rkshthrmsh
Copy link
Contributor

For magma functions, like the one in #1213, how would one provide type annotation?

# inside a circuit definition
out = m.Register(m.UInt[32])()
count = m.Register(m.UInt[8])()

config(out.I, count.O)
# end circuit definition

def config(reg: ???, count: ???):
    with m.when(count == 0):
        reg @= m.uint(1, 32)
    with m.elsewhen(count == 1):
        reg @= m.uint(5, 32)
@leonardt
Copy link
Collaborator

leonardt commented Jan 5, 2023

In general, magma values are instances of m.Type, so like this:

def config(reg: m.Type, count: m.Type):

In this case, we could be more precise and say

def config(reg: m.UInt[32], count:m.UInt[8]):

Since m.UInt (and it's parameterized versions) are subclass of m.Type

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