In Stateflow, how to keep generated HDL code derived from a single state's flow chart from being placed in multiple states?

3 views (last 30 days)
I am creating a state machine for decoding messages that I can query at any point and generating HDL form it. I have three states that don't do much - RESET/IDLE, WAIT_FOR_RESPONSE and WAIT_FOR_ACCEPT. The fourth state, ADDRESS_DECODE (A_D), does all the work. A_D has a few "enable:" commands but otherwise is a flow chart with some conditionals based on write enable, read enable and select flags that leads to a switch either reading to a register or writing to it for a given address.
The issue is in the generated HDL code. Since the other three states all lead to A_D the entire combinatoric logic within A_D is being placed not only in A_D but in the transition logic from any of the three states to A_D. Basically I have the same logic in four places - in each of the four state machine states when I only want it in A_D.
I understand that the logic is being placed there so that the logic executes on any transition into A_D as well as when the state machine is sitting in A_D waiting for something to happen. It's the equivalent of putting the logic both in A_D's "entry:" and "during:" blocks if I was putting this logic into a m-code function and calling it from the state actions. But I do not want this logic on a transition (entry:) and I can't figure out how to make it go away.
Can someone tell me how I tell Stateflow that a logic chart I define in a state I want only executed in that state - not on a transition as well? i.e., I want to tell it this logic is for "during:" and not both "entry:" and "during:."
I realize this is long but I hope this is clear.
Thank you!

Accepted Answer

Landon Wagner
Landon Wagner on 6 May 2015
I finally worked it out. After reading more I realized functions could help. Within state A_D I placed the flow chart logic being undesirably duplicated into a function and I put that function call into the "during:" action type. Now the generated HDL lives only in A_D and not duplicated in the other states on transition into A_D.

More Answers (0)

Categories

Find more on Stateflow in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!