-
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
sequential bug when state is not given a new value #432
Comments
Similarly, sub-sequential-circuits require a new value (call), both these would be resolved by implicitly generating "enable/valid" logic. |
This issue has been noted in the documentation: https://github.com/phanrahan/magma/blob/master/docs/circuit_definitions.md#sequential-circuit-definition For optional updates of state elements, the algorithm seems straightforward (generate an enable signal that is set high when a write occurs (can default to be 0, with the input being the output value, rewrite the tree such that any write to a state element is followed by setting the enable signal high, optimize out the enable signal in the case that it is always high in every branch). Optional invocations of sub-circuits is trickier. We can model is as an "implicit valid" on the input values, so a valid low would set all the sub-circuit's state elements to be low. This slightly changes the semantics that |
|
Sequential semantics dictate that anything declared inside the
I think the use case was that someone was iteratively developing their code and they just wanted to return the register value in the beginning, but this broke the compiler, sure this isn't something that someone would want to do, but it shouldn't break (it has well defined semantics). w.r.t. generating the verilog directly versus going through coreir, I think that's a separate discussion/issue unrelated to this. The semantics should be the same, however it may be the case that the synthesis tool will interpret it differently depending on how the verilog is generated. If you'd like to open an issue about getting better synthesis results from the magma generated code, please go ahead, code examples would be helpful for us to improve it. This issue is just about fixing a bug in the compiler that prevents code from being compiled that should be able to be compiled (not about writing/generating optimal code). |
Re: compiling to verilog directly, there is an open PR related to this #441 you're welcome to contribute comments/code there |
Sorry, I misread number 2, I think this is in response to one of my follow up comments re: the enable logic for sub circuit invocations. Again, there should be some well defined semantics, but it seems like you're saying how we generate code may not play nicely with the synthesis tool. What is the best way to have enable logic with registers to play nicely with a synthesis tool? |
I think the most reliable way to do this would be to generate verilog similar to what I've written above except with You may also get away with having a "register with enable" primitive that exposes D, Q, clk, w_en (or however you want to name them) and making sure that primitive is correctly inferred. Then you could probably compute the enable signal and wire it up. I haven't looked into which of the two would give better synthesis results. |
gives the error
it should set the default value of register input to be its output.
The text was updated successfully, but these errors were encountered: