Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.arch.embedded > #25783

Re: Do you use FSMs or HSMs?

Path csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Don Y <blockedofcourse@foo.invalid>
Newsgroups comp.arch.embedded
Subject Re: Do you use FSMs or HSMs?
Date Mon, 6 Feb 2017 14:19:37 -0700
Organization A noiseless patient Spider
Lines 89
Message-ID <o7ap5v$kuv$1@dont-email.me> (permalink)
References <o79gce$om1$1@dont-email.me> <o7ab2k$fvs$1@gioia.aioe.org> <sT2mA.698994$vP3.351399@fx45.am4> <o7agp6$ijm$1@dont-email.me> <s55mA.728172$SV2.500573@fx39.am4>
Mime-Version 1.0
Content-Type text/plain; charset=iso-8859-15; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Mon, 6 Feb 2017 21:17:57 -0000 (UTC)
Injection-Info mx02.eternal-september.org; posting-host="5be0074feb2f54cddff6d9510ad97557"; logging-data="21471"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/7eJDBvGpiUgZNQy/D/04R"
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:45.0) Gecko/20100101 Thunderbird/45.4.0
In-Reply-To <s55mA.728172$SV2.500573@fx39.am4>
Cancel-Lock sha1:eGU21N4qPoFfctIhM9zokJgV7t8=
Xref csiph.com comp.arch.embedded:25783

Show key headers only | View raw


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.

You'd find it hard to apply it to performing multiplications,
divisions, etc. in a way that was anywhere near as efficient
as the underlying instruction set!

[An FSM effectively gives you a new "language" layered atop
the native instruction set via any intermediate languages]

> Each input character is an "event", and the states are
> things like "skipping leading whitespace, parsing
> before decimal point" etc. An "E" transitions from
> "parsing before decimal point" or parsing after
> decimal point" to "parsing exponent", and transitions
> to "error" elsewhere.
>
> E&OE, of course :)

In a similar vein, using it to parse "messages" in some
arbitrary syntax.  There, it makes it relatively easy to
add new "message options" without having to rewrite a
bunch of spaghetti code.  *Or*, buffer an entire message
before it can be parsed.

I've often used it to decode barcode labels at higher
levels.  I.e., use procedural mechanisms to process the
"raw video" into "characters"; then a FSM to decide which
sequences of characters are representative of valid messages.

In my implementations, an "action routine" (transition routine)
can perform a test on the data and then simulate a GO/NOGO
event that is the *only* "event" processed in the succeeding
state.  It can then redirect the machine to the correct
next state based on some (possibly complex) computation
performed on "embedded" data (e.g., verifying a checksum
is not something that you would encode into the normal
state transitions; instead, compute it in the CHECK state
and then act on that GO/NOGO event in the DISPATCH state
that immediately follows)

At the same time, input from keypads, mains power detectors,
UART character streams, etc. can continue, being buffered
until the machine opts to examine them, again (based on
the significant events defined for THIS particular state).

Allowing inputs to simultaneously arrive from multiple
sources WITHOUT enforcing an ordering on them external
to the FSM lets you cascade machines, have machines
talking to each other while operating concurrently,
implement co-routine machines, etc.

It's just like designing synchronous hardware.

Back to comp.arch.embedded | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Do you use FSMs or HSMs? pozz <pozzugno@gmail.com> - 2017-02-06 10:43 +0100
  Re: Do you use FSMs or HSMs? Don Y <blockedofcourse@foo.invalid> - 2017-02-06 03:20 -0700
  Re: Do you use FSMs or HSMs? Dave Nadler <drn@nadler.com> - 2017-02-06 06:38 -0800
  Re: Do you use FSMs or HSMs? "QL" <80499@EmbeddedRelated> - 2017-02-06 08:56 -0600
    Re: Do you use FSMs or HSMs? Don Y <blockedofcourse@foo.invalid> - 2017-02-06 12:13 -0700
    Re: Do you use FSMs or HSMs? jim.brakefield@ieee.org - 2017-02-06 16:52 -0800
      Re: Do you use FSMs or HSMs? Don Y <blockedofcourse@foo.invalid> - 2017-02-06 18:11 -0700
      Re: Do you use FSMs or HSMs? Les Cargill <lcargill99@comcast.com> - 2017-02-06 23:32 -0600
    Re: Do you use FSMs or HSMs? pozz <pozzugno@gmail.com> - 2017-02-07 10:39 +0100
  Re: Do you use FSMs or HSMs? John Speth <johnspeth@yahoo.com> - 2017-02-06 09:17 -0800
    Re: Do you use FSMs or HSMs? Tom Gardner <spamjunk@blueyonder.co.uk> - 2017-02-06 18:03 +0000
      Re: Do you use FSMs or HSMs? Don Y <blockedofcourse@foo.invalid> - 2017-02-06 11:56 -0700
        Re: Do you use FSMs or HSMs? Tom Gardner <spamjunk@blueyonder.co.uk> - 2017-02-06 20:34 +0000
          Re: Do you use FSMs or HSMs? Don Y <blockedofcourse@foo.invalid> - 2017-02-06 14:19 -0700
            Re: Do you use FSMs or HSMs? Tom Gardner <spamjunk@blueyonder.co.uk> - 2017-02-06 22:12 +0000
              Re: Do you use FSMs or HSMs? Don Y <blockedofcourse@foo.invalid> - 2017-02-06 15:29 -0700
              Re: Do you use FSMs or HSMs? Phil Hobbs <pcdhSpamMeSenseless@electrooptical.net> - 2017-02-08 12:15 -0500
                Re: Do you use FSMs or HSMs? Tom Gardner <spamjunk@blueyonder.co.uk> - 2017-02-08 23:52 +0000
                Re: Do you use FSMs or HSMs? Phil Hobbs <pcdhSpamMeSenseless@electrooptical.net> - 2017-02-08 19:59 -0500
              Re: Do you use FSMs or HSMs? Steve Watt <steve.removethis@Watt.COM> - 2017-02-17 00:30 +0000
                Re: Do you use FSMs or HSMs? Tom Gardner <spamjunk@blueyonder.co.uk> - 2017-02-17 00:44 +0000
            Re: Do you use FSMs or HSMs? Clifford Heath <no.spam@please.net> - 2017-02-07 10:12 +1100
              Re: Do you use FSMs or HSMs? Les Cargill <lcargill99@comcast.com> - 2017-02-06 23:36 -0600
                Re: Do you use FSMs or HSMs? George Neuner <gneuner2@comcast.net> - 2017-02-07 03:15 -0500
                Re: Do you use FSMs or HSMs? Les Cargill <lcargill99@comcast.com> - 2017-02-10 17:41 -0600
                Re: Do you use FSMs or HSMs? Clifford Heath <no.spam@please.net> - 2017-02-07 19:56 +1100
                Re: Do you use FSMs or HSMs? Paul Rubin <no.email@nospam.invalid> - 2017-02-07 01:30 -0800
                Re: Do you use FSMs or HSMs? Clifford Heath <no.spam@please.net> - 2017-02-07 20:42 +1100
                Re: Do you use FSMs or HSMs? Paul Rubin <no.email@nospam.invalid> - 2017-02-07 02:46 -0800
                Re: Do you use FSMs or HSMs? Clifford Heath <no.spam@please.net> - 2017-02-08 00:27 +1100
  Re: Do you use FSMs or HSMs? Paul Rubin <no.email@nospam.invalid> - 2017-02-06 18:35 -0800
    Re: Do you use FSMs or HSMs? Don Y <blockedofcourse@foo.invalid> - 2017-02-06 21:50 -0700
    Re: Do you use FSMs or HSMs? Les Cargill <lcargill99@comcast.com> - 2017-02-06 23:39 -0600
      Re: Do you use FSMs or HSMs? Paul Rubin <no.email@nospam.invalid> - 2017-02-06 23:20 -0800
        Re: Do you use FSMs or HSMs? Les Cargill <lcargill99@comcast.com> - 2017-02-10 17:47 -0600
          Re: Do you use FSMs or HSMs? Paul Rubin <no.email@nospam.invalid> - 2017-02-10 16:11 -0800
            Re: Do you use FSMs or HSMs? Les Cargill <lcargill99@comcast.com> - 2017-02-11 15:43 -0600
  Re: Do you use FSMs or HSMs? Les Cargill <lcargill99@comcast.com> - 2017-02-06 23:24 -0600

csiph-web