-
Notifications
You must be signed in to change notification settings - Fork 4
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
[RFC] Better support for magma in hwtypes #102
Comments
I think qualifiers could be made using However raw modifiers are probably not sufficient as magma does not allow operators on input types (those for which e.g.: class Foo(hwtype):
_in_methods_ = 'bar',
_out_methods_ = 'baz',
def bar(self):
print("I'm an input or undirected")
def baz(self):
print("I'm an output or undirected")
foo = Foo()
foo.bar() # works
foo.baz() # works
in_foo = In(Foo)()
in_foo.bar() # works
in_foo.baz() # error
out_foo = Out(Foo)()
out_foo.bar() # error
out_foo.baz() # works We could also build first class support for qualifiers which would make some sense. This would allow us to block certain undesirable statements like class BitVector:
_out_methods_ = 'make_constant',
def __init__(self, value):
...
self.make_constant(value)
# raises an error if BitVector is an input type Perhaps the biggest reason for using a modifier as opposed to having a qualify method is that modifiers automatically build a bunch of type relationships, although this logic could be extracted so that it would be easy to use. For example, in magma it is currently illegal to say * The relationship between |
As for wiring I think it would be pretty easy to bring in. Its a well defined operation (unification). My only concern is the use of @rewrite
def bar(x, y):
if x <= 0: #If(Compare(...), ...)
y <= 0 #Expr(Compare(...)) Expr "casts" expr to stmt
else:
y <= 1 Secondly it forces types to reason about wiring rules / qualification which I would prefer to keep as isolated as possible. I suppose if we go the modifier approach we could insert I would propose we use |
As I have been working on trying to get Sum types to work in magma I have realized that I have developed things in a way that is fairly incompatible with magma. There are two major issues, qualification of types (
In
,Out
, etc...) and wiring.The text was updated successfully, but these errors were encountered: