Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Les Cargill Newsgroups: comp.arch.embedded Subject: Re: Do you use FSMs or HSMs? Date: Mon, 6 Feb 2017 23:36:01 -0600 Organization: A noiseless patient Spider Lines: 67 Message-ID: References: <589902df$0$17334$c3e8da3$dd9697d2@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 7 Feb 2017 05:31:40 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="0c3f843cc7080b873602f174ef60d8b0"; logging-data="1003"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18WYbOIUaonsUqlqcUsd5a/SNqSlE1DRug=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0 SeaMonkey/2.46 In-Reply-To: <589902df$0$17334$c3e8da3$dd9697d2@news.astraweb.com> Cancel-Lock: sha1:y4oRu0mfbycZZppwVNIzXfs6+Bw= Xref: csiph.com comp.arch.embedded:25794 Clifford Heath wrote: > On 07/02/17 08:19, Don Y wrote: >> On 2/6/2017 1:34 PM, Tom Gardner wrote: >>> On 06/02/17 18:56, Don Y wrote: >>>> On 2/6/2017 11:03 AM, Tom Gardner wrote: >>>>>> I find that sometimes I'll sketch a FSM and then find out >>>>>> it's just too simple or too linear. ON the flip side, I've had >>>>>> project for >>>>>> which >>>>>> I'd have an extremely simple FSM documented and later it's starts >>>>>> to get >>>>>> elaborate and useful as new requirements emerge. >>>>> >>>>> Precisely. >>>>> >>>>> A large part of engineering is being able to >>>>> demonstrate which part of an design implements >>>>> each part of the specification. >>>>> >>>>> A good implementation of an FSM enables you >>>>> to easily see exactly what will happen when >>>>> any event occurs in any state. That can be very >>>>> difficult with if-then-else clauses. >>>> >>>> Exactly. IME, they are excellent for representing UI actions >>>> along with other formal "protocols". They allow you to verify >>>> by inspection that all possibilities are addressed and >>>> addressed in the manner intended -- without having to >>>> count nesting levels of conditionals, etc. >>>> "Will this 'if' cover this condition in ALL states? Or, >>>> does it only apply to some subset of the states, based on >>>> where it is syntactically anchored?" >>>> >>>> I'd *not* use one to implement a floating point package... >>> >>> Yes, but... >>> >>> They are very neat way of implementing parsing an ascii >>> string and turning it into a floating point number. >> >> Different problem -- and one that could be "automated" with a >> simple grammar/lex/yacc. > > Lex is a language for describing a regular expression, > which it implements by turning it *into* an FSA. > > You don't need yacc to parse FP numbers. Such parsers > are for handling languages that require unbounded state, > not finite state. > Just to be pedantic :), it's deterministic vs. non deterministic FA. Deterministic FA are equivalent to regular expressions. NFA are not, and very often, NFA are what we use for program control flow. > I'm also enthusiastic in using FSAs where appropriate, > but a lot of problems I face require unbounded state. This is where NFA shine - they're less formal than DFA. > In either case, I tend not to do them long-hand - there > are good domain-specific languages to generate the code. > > Clifford Heath. -- Les Cargill