-
Notifications
You must be signed in to change notification settings - Fork 22
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
Issue with compiling AsyncReset to CoreIR #288
Comments
It turns out this issue exists for all Bit subtypes: Clock, Reset, and AsyncReset |
Yes, the issue here is that the I'll look into this, perhaps we can assert that if it passes the magma wiring logic (where type checking occurs), then we can assume that we need to do insert the wrap node when we encounter the different types. Alternatively, when traversing the connection, we may be able to find information that tells us the conversion occured. |
One workaround until this is fixed is to use the wrap module explicitly when converting between Bit and any of the named types. |
Got it. I went down the path of wrapping explicitly when trying to convert. I used the code in To be clear; this works: from magma import *
def define_wrap(type_, type_name, in_type):
def sim_wrap(self, value_store, state_store):
input_val = value_store.get_value(getattr(self, "in"))
value_store.set_value(self.out, input_val)
return DeclareCircuit(
f'coreir_wrap{type_name}',
"in", In(in_type), "out", Out(type_),
coreir_genargs = {"type": AsyncReset},
coreir_name="wrap",
coreir_lib="coreir",
simulate=sim_wrap
)
foo = DefineCircuit("foo", "r", In(AsyncReset))
EndCircuit()
top = DefineCircuit("top", "O", Out(Bit))
foo_inst = foo()
wrap = define_wrap(AsyncReset, "Bit", Bit)()
wire(bit(0), wrap.interface.ports["in"])
wire(wrap.out, foo_inst.r)
wire(bit(0), top.O)
EndCircuit()
compile("top", top, output="coreir") but this does not from magma import *
def define_wrap(type_, type_name, in_type):
def sim_wrap(self, value_store, state_store):
input_val = value_store.get_value(getattr(self, "in"))
value_store.set_value(self.out, input_val)
return DeclareCircuit(
f'coreir_wrap{type_name}',
"in", In(in_type), "out", Out(type_),
coreir_genargs = {"type": Clock},
coreir_name="wrap",
coreir_lib="coreir",
simulate=sim_wrap
)
foo = DefineCircuit("foo", "r", In(Clock))
EndCircuit()
top = DefineCircuit("top", "O", Out(Bit))
foo_inst = foo()
wrap = define_wrap(Clock, "Bit", Bit)()
wire(bit(0), wrap.interface.ports["in"])
wire(wrap.out, foo_inst.r)
wire(bit(0), top.O)
EndCircuit()
compile("top", top, output="coreir") And the error is
|
Ok, looks like with #289 it works now for clocks. I believe for |
Closing because of #289 feel free to reopen if there's still an issue. |
Reset and Enable don't have named types in coreir, so they just map to |
Right. I also added a test to make sure that |
The following snippet
results in the following error:
The text was updated successfully, but these errors were encountered: