cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
simozz
Scholar
Scholar
279 Views
Registered: ‎05-14-2017

More than one FSM in a same module

Hello,

I have a design for which I need 2 FSM.

Despite te correctness of each FSM implementation (each one with its status register en default case), is it a good or a bad idea having more than one FSM in the same module ?

Thanks.

s.

0 Kudos
6 Replies
xilinxacct
Instructor
Instructor
254 Views
Registered: ‎10-23-2018

@simozz 

I have a couple questions…

1) Are the FSMs independent? e.g. would the does something meaningful as an independent module?

2) Do you have any reason you want/need them to be in one module?

I don’t know details, but I would say in general, If there is no need, it would seem that keeping them independent would reduce the complexity, and increase the potential for reuse.

Hope that Helps
If so, Please mark as solution accepted. Kudos also welcomed.

0 Kudos
simozz
Scholar
Scholar
234 Views
Registered: ‎05-14-2017

Hello @xilinxacct 

1) Yes, they are independent. For each one I have a case statement for its state register, and other case statements for others registers update depending on the FSM state register value.

2) It is mainly for simplicity and to keep the code as compact as possible without having multiple modules. 

Of course it is not a bad idea to keep them in separate modules

However my doubt is more related to possible HW implementation issues rather than good or poor coding technique.

s.

0 Kudos
xilinxacct
Instructor
Instructor
225 Views
Registered: ‎10-23-2018

@simozz  

I can't think of any potential hardware related issues that would be complicated by keeping them separate, so I see it all as an upside with what you have described.

Hope that Helps
If so, Please mark as solution accepted. Kudos also welcomed.

richardhead
Scholar
Scholar
217 Views
Registered: ‎08-01-2012

As long as it is fully synchronous, that's all the hardware considerations you need.  Readable and understandable code should be the first consideration before considering minor implementation details in the first instance.  Synthesisors are very good at turning almost any code into functional logic,  but it can't do anything if your code makes no sense to a new engineer 3 years after you've left.

0 Kudos
bruce_karaffa
Scholar
Scholar
189 Views
Registered: ‎06-21-2017

I have a whole family of designs that include a UART-like interface.  This code has a read state machine and a transmit state machine in the same module.  So far, neither my boss nor my office mate has complained about the coding style.  I guess it's OK.

maps-mpls
Mentor
Mentor
184 Views
Registered: ‎06-20-2017

It's a question of style and best practices, where best is in the eye of the beholder.

For me, these are the questions I'd answer while considering:

Do the FSMs interact with each other?  If yes, is the pair atomic (e.g., will they make any sense if you separate them).  If no, will either one ever have the chance of being useful on its own?

Is the file getting long (say above 200 -400 lines long)?  Will creating extra hierarchy make the design more understandable to the next person who has to maintain or enhance the design?

Can the FSMs be tested individually?  Should they be tested individually?

 

 

*** Destination: Rapid design and development cycles *** Unappreciated answers get deleted, unappreciative OPs get put on ignored list ***
0 Kudos