FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > FPGA

FPGA comp.arch.fpga newsgroup (usenet)

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-10-2004, 05:23 PM
vax,3900
Guest
 
Posts: n/a
Default Monolithic state machine or structured state machine?

I am designing a state machine that will be fit into a CPLD (Xilinx XC95xx).
The state machine needs to wait certain number of clockes here and there (
for example, 80 clockes here, and 160 clockes there ). If I design
everthing with hand, I whould choose structured state machine; that is, a
state machine plus a counter. But since I am using VHDL, and the compiler
would take care of everything, I think I might be able to make a monolithic
state machine with the counter built in ( that is, to add 80 states here,
and 160 states there ). Excluding the counter, the state machine has about
100 states.

My question is, which approach is better, for a CPLD? The monolithic design
will require less FF's, maybe. Have you guys met this question in your
projects?
Reply With Quote
  #2 (permalink)  
Old 05-10-2004, 07:15 PM
Jim Lewis
Guest
 
Posts: n/a
Default Re: Monolithic state machine or structured state machine?

Hi,
> But since I am using VHDL, and the compiler
> would take care of everything, ...

The compilers are not as smart as you think.
They are good and take care of many tedious problems,
but there are things you still must manage. My
opinion is that this is one of them. I recomment that
you stay with your old approach.

Code all arithmetic resources separately from your
statemachine. Synthesis & Optimization bring many reasons
for doing this.
1) Random logic (statemachines) and structured logic
(Arithmetic) are optimized using different synthesis
algorithms. For some tools you may get better quality of
results if the arithmetic is in a separate entity (file).
2) Writing your code explicitly, the counters can be
shared explicitly. This is even more important when the
counters are potentially different sizes (7 bits vs 8 bits).
It gets much more difficult (if not impossible) for a
synthesis tool to share resources that are different sizes.

When you are counting resources, don't forget your end detect
(zero detect) logic is a resource and should be coded separately
from your statemachine.

I have mostly used ASICs and FPGAs, so I cannot address the
specifics of a CPLD, but with a big statemachine, FPGA/CPLD tools
tend to make them one hot - one register bit per state.
With counters, there is one bit per log2 states. With
ASICs and FPGAs, counters tend to be more efficient than
statemachines.

Cheers,
Jim

vax,3900 wrote:
> I am designing a state machine that will be fit into a CPLD (Xilinx XC95xx).
> The state machine needs to wait certain number of clockes here and there (
> for example, 80 clockes here, and 160 clockes there ). If I design
> everthing with hand, I whould choose structured state machine; that is, a
> state machine plus a counter. But since I am using VHDL, and the compiler
> would take care of everything, I think I might be able to make a monolithic
> state machine with the counter built in ( that is, to add 80 states here,
> and 160 states there ). Excluding the counter, the state machine has about
> 100 states.
>
> My question is, which approach is better, for a CPLD? The monolithic design
> will require less FF's, maybe. Have you guys met this question in your
> projects?



--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~
Jim Lewis
Director of Training mailto:[email protected]
SynthWorks Design Inc. http://www.SynthWorks.com
1-503-590-4787

Expert VHDL Training for Hardware Design and Verification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~
Reply With Quote
  #3 (permalink)  
Old 05-10-2004, 08:05 PM
James Morrison
Guest
 
Posts: n/a
Default Re: Monolithic state machine or structured state machine?

Actually Jim, what you wrote below is not really true. I'm most familiar with Xilinx tools but I've used Altera's in the past and I believe they work the same.

For FPGA's where there is an abundance of flip-flops state machines default to one-hot encoding. However for CPLD's where there is lots of logic resources available but not many flip-flops the synthesis defaults to minimise the number of flip-flops used and encodes the state as bit patterns (usually gray codes). It is possible to override this behaviour either by spelling out the state encoding specifically or by setting a tool option somewhere.

Personally, I separate the logic out from the state transitions normally for the following reasons:
1) I find it easier to see where logic may be reused. Synthesis takes care of this but its good to have a gut feel.
2) I find it easier to understand when I come back to the design a long time later. Having logic embedded into state transitions and definitions is confusing. It may save a few resources and make something fit but if you can afford the small inefficienty (although that is debatable) the increase in maintainability is huge.

Just my $0.02.

James.

~

>>> Jim Lewis<[email protected]> 5/10/2004 2:15:32 PM >>>

Hi,
I have mostly used ASICs and FPGAs, so I cannot address the
specifics of a CPLD, but with a big statemachine, FPGA/CPLD tools
tend to make them one hot - one register bit per state.
With counters, there is one bit per log2 states. With
ASICs and FPGAs, counters tend to be more efficient than
statemachines.


Reply With Quote
  #4 (permalink)  
Old 05-10-2004, 08:31 PM
Jim Lewis
Guest
 
Posts: n/a
Default Re: Monolithic state machine or structured state machine?

James,
> what you wrote below is not really true

Confusing way to start when you agree with the
the approach I recommended. Ok so the correction
is only FPGA tools like one-hot, CPLD tools prefer
other implementations.

The key thing is that we both agree that be it an ASIC,
FPGA, or CPLD, code arithmetic resources (counters)
separately from the statemachines.

If you don't factor out arithmetic resources, then there
are both potential quality of result issues and
readability/reusability issues.

Cheers,
Jim


James Morrison wrote:
> Actually Jim, what you wrote below is not really true. I'm most familiar with Xilinx tools but I've used Altera's in the past and I believe they work the same.
>
> For FPGA's where there is an abundance of flip-flops state machines default to one-hot encoding. However for CPLD's where there is lots of logic resources available but not many flip-flops the synthesis defaults to minimise the number of flip-flops used and encodes the state as bit patterns (usually gray codes). It is possible to override this behaviour either by spelling out the state encoding specifically or by setting a tool option somewhere.
>
> Personally, I separate the logic out from the state transitions normally for the following reasons:
> 1) I find it easier to see where logic may be reused. Synthesis takes care of this but its good to have a gut feel.
> 2) I find it easier to understand when I come back to the design a long time later. Having logic embedded into state transitions and definitions is confusing. It may save a few resources and make something fit but if you can afford the small inefficienty (although that is debatable) the increase in maintainability is huge.
>
> Just my $0.02.
>
> James.
>
> ~
>
>
>>>>Jim Lewis<[email protected]> 5/10/2004 2:15:32 PM >>>

>
> Hi,
> I have mostly used ASICs and FPGAs, so I cannot address the
> specifics of a CPLD, but with a big statemachine, FPGA/CPLD tools
> tend to make them one hot - one register bit per state.
> With counters, there is one bit per log2 states. With
> ASICs and FPGAs, counters tend to be more efficient than
> statemachines.
>
>



--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~
Jim Lewis
Director of Training mailto:[email protected]
SynthWorks Design Inc. http://www.SynthWorks.com
1-503-590-4787

Expert VHDL Training for Hardware Design and Verification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~
Reply With Quote
  #5 (permalink)  
Old 05-11-2004, 12:13 AM
Mike Treseler
Guest
 
Posts: n/a
Default Re: Monolithic state machine or structured state machine?

vax3900 wrote:

>I am designing a state machine that will be fit into a CPLD (Xilinx XC95xx).
>The state machine needs to wait certain number of clocks here and there (
>for example, 80 clocks here, and 160 clocks there ). If I design
>everything with hand, I would choose structured state machine; that is, a
>state machine plus a counter. But since I am using VHDL, and the compiler
>would take care of everything, I think I might be able to make a monolithic
>state machine with the counter built in ( that is, to add 80 states here,
>and 160 states there ).


Consider making the counter a separate
variable. Saying n:= n + 1 in a
few places is much cleaner than
describing hundreds of extra state transitions.

I said variable because I would write
this controller in a single process.
A counter signal and multiple processes would
work fine too.

> Excluding the counter, the state machine has about
> 100 states.


See if you can't pull out a few other
count, shifter, mode or boolean variables to reduce
the number of states and clarify
the logic description.

>My question is, which approach is better, for a CPLD? The monolithic design
>will require less FF's, maybe.


Maybe, maybe not.
To answer the utilization question, you would have
to try it both ways and see. I would expect
little difference.

I have found that a clean description is a likely to
fit as any other.

-- Mike Treseler
Reply With Quote
  #6 (permalink)  
Old 05-11-2004, 04:15 PM
Brian Drummond
Guest
 
Posts: n/a
Default Re: Monolithic state machine or structured state machine?

On 10 May 2004 16:13:55 -0700, [email protected] (Mike Treseler)
wrote:

>vax3900 wrote:
>
>>I am designing a state machine that will be fit into a CPLD (Xilinx XC95xx).
>>The state machine needs to wait certain number of clocks here and there (
>>for example, 80 clocks here, and 160 clocks there ). If I design
>>everything with hand, I would choose structured state machine; that is, a
>>state machine plus a counter. But since I am using VHDL, and the compiler
>>would take care of everything, I think I might be able to make a monolithic
>>state machine with the counter built in ( that is, to add 80 states here,
>>and 160 states there ).

>
>Consider making the counter a separate
>variable. Saying n:= n + 1 in a
>few places is much cleaner than
>describing hundreds of extra state transitions.


You need only say n:= n + 1 (I tend to use n - 1) in one place, as the
default action in the state machine process. On entering states where
you need a delay, this is over-ridden with n := delay_length. Then n=0
is simply one of the conditions for leaving the state.

If you use a signal for n, you can use an external "n_eq_z <= '1' when n
= 0 else '0';" or some such to help the synthesiser avoid replicating
the zero detection logic, but I would hope not nowadays!

- Brian

Reply With Quote
  #7 (permalink)  
Old 05-12-2004, 02:06 AM
Hal Murray
Guest
 
Posts: n/a
Default Re: Monolithic state machine or structured state machine?

>The key thing is that we both agree that be it an ASIC,
>FPGA, or CPLD, code arithmetic resources (counters)
>separately from the statemachines.


There is one case where that might not hold. Consider
a ROM based state machine. If you have lots of unused
states maybe you don't need a counter.

--
The suespammers.org mail server is located in California. So are all my
other mailboxes. Please do not send unsolicited bulk e-mail or unsolicited
commercial e-mail to my suespammers.org address or any of my other addresses.
These are my opinions, not necessarily my employer's. I hate spam.

Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
what is wrong with this state machine? Verictor Verilog 4 03-28-2007 06:32 PM
state machine without clock Miller2000 Verilog 15 05-26-2005 01:45 AM
please help! state machine Simone Winkler FPGA 4 01-05-2004 10:33 AM


All times are GMT +1. The time now is 03:27 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved