필터 지우기
필터 지우기

How to set Unconditional Transition State for Else Statement in HDL Coder with a Counter?

조회 수: 3 (최근 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?

채택된 답변

Tom Richter
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
  댓글 수: 1
Michael Felger
Michael Felger 2024년 4월 4일
편집: Michael Felger 2024년 4월 4일
Hello Tom,
thanks for your answer!
I did not have any propblems with latches yet, so for the moment I'm fine for my designs.
I just wanted to follow the guideline, but then found that for the after(n,E) events the default transition is breaking the stateflow logic...... and wanted to know if I'm missing something.
Thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 General Applications에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by