How to set Unconditional Transition State for Else Statement in HDL Coder with a Counter?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Michael Felger
el 2 de Abr. de 2024
Editada: Michael Felger
el 4 de Abr. de 2024
Hi,
in the HDL Coder Guideline, it is recommended to insert an unconditional Else transition: "Insert Unconditional Transition State for Else Statement in HDL Code"
How to do this, if the after(..., tick) transition is used?
Consider the following modification to the example: the transition between the 2 states shall happen every 2 clock cycles.
With the unconditional "else" transition, the transition will never happen, because the timer (which evaluates the "after(2,tick)" event) is always reset to 0 by the unconditional "else" transition → counter value of 2 is never reached. So the unconditional transition breaks the whole functionality.
I do not see any solution how to follow the guideline with after(n,E) events used: https://de.mathworks.com/help/stateflow/ref/after.html.
The only workaround would be to re-invent the wheel and implement a custom counter in the stateflow, and use "if(counter == 2)" instead of the after(n,E) event - which is obviously a bad workaround.
In my opinion, an transition type that does not reset the counters for the after(n,E) events is missing for stateflow.
What do you think about this, or am I missing something?
0 comentarios
Respuesta aceptada
Tom Richter
el 3 de Abr. de 2024
Hello Michael,
This is a good catch. Have you tried to use the “after” temporal logic operator on a smaller design? Did the Synthesis tool do some strange things or added latches? The guideline says you should have an unconditional transition to prevent having latches later. If this is not the case, I would just say the after operator is fine and can be justified. If you see latches then yes, the workaround you mentioned is a possible solution. Instead of a conditional transition you would switch to an “about to switch” state where you count up to N-1 (in your case it would just be an empty state).
If you think MathWorks should offer a better solution I suggest contacting Technical Support to help you with this issue/question. If you go to
, you can submit a support request and add example or reproduction files. The page also displays phone contact information based on your location.
Best regards,
Tom
1 comentario
Más respuestas (0)
Ver también
Categorías
Más información sobre Model Compatibility Checks en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!