How to set Unconditional Transition State for Else Statement in HDL Coder with a Counter?
2 次查看(过去 30 天)
显示 更早的评论
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?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1657256/image.png)
0 个评论
采纳的回答
Tom Richter
2024-4-3
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 General Applications 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!