Electronic Design

  
Reprints     Printer-Friendly    Email this Article    RSS        Font Size     What's This?


[Ideas For Design]
Take Your Next Design From Statecharts To Code
They aren't just pretty pictures. These simple flow diagrams can help you convert your ideas into programs.

William Wong  |   ED Online ID #19775  |   October 2, 2008


SOME BACKGROUND
Also known as state diagrams, statecharts can be found on napkins and coding screens as designers turn ideas into application code. They’re simple to use and understand, as they’re just a bunch of “circles and arrows and a paragraph on the back of each one explainin’ what each one was, to be used as evidence against us,” to quote Arlo Guthrie and his classic song, “Alice’s Restaurant.” Events cause transitions between states, and most implementations allow actions based on transitions as well as within a state.

INTRODUCTION
State diagrams were used well before graphical tools were in place. But now, state diagrams are part of the development environment, with more advanced tools generating code directly. The diagrams from one tool look like those found in another, making it one of the more universal descriptive programming tools available. Check out the state of the latest tools.

GO WITH THE FLOW
Developed by the MathWorks, the Simulink graphical modeling environment incorporates event-driven state diagrams with its Stateflow module. It also incorporates deterministic execution semantics and can generate C code using the Stateflow Coder module. Additionally, it supports the Mealy and Moore finite-state machines. Stateflow can perform run-time checks to detect errors such as transition conflicts, cyclical problems, and state inconsistencies as well. For further details, see www.mathworks.com.

FORMAL STATES
The non-for-profit industry consortium Object Management Group (OMG) handles a range of standards, including UML (Unified Modeling Language). Within UML are state diagrams, the quintessential definition. The syntax and semantics are used throughout the industry, from basic diagramming tools to code-generating environments like IBM/Telelogic Rhapsody (see “UML And C No Longer Oil And Water,” ED Online 13985). State diagrams are just one of many modeling diagrams within the formal UML definition, but they’re almost universal when it comes to designers. Many slideshows mainly consist of state diagrams defining and application. Go to www.ibm.com and www.omg.org for more information.

ADDING STATES TO GRAPHICAL APPS
National Instruments’ LabVIEW graphical programming language and environment has been around for more than 20 years, but state diagrams are a rather recent addition (see “For Multicore Graphics Programming Support, Try LabVIEW 8.5” at ED Online 17116). The new StateChart feature is integrated with the existing graphical modeling environment, allowing states to contain LabVIEW code. State charts support the same type of graphical simulation and debugging as conventional LabVIEW virtual instrument models. Likewise, LabVIEW can generate C code or target FPGAs from applications that incorporate state diagrams. For more, see www.ni.com.

See Associated Figure

C STATES
IAR’s visualState turns state charts into C/C++ code (see “What’s New In Programming Languages,” ED Online 14688). Integrated with the company’s Embedded Workbench C/C++ development environment, the tool is based on a subset of the UML (see “Formal States”). The C/C++ code is generic enough to be used with other platforms. But the system works best when combined with Embedded Workbench tools like the C-Spy debugger, which allows real-time feedback via the source diagrams. See www.iAr.com for details.

See Associated Figure

THE FINAL STATE
Regardless of the development environment you choose, state diagrams can be incorporated into your design process.


Reprints   Printer-Friendly  Email this Article  RSS    Font Size   What's This?


  • In EDA, A Year Of Mergers, Failed And Otherwise
  • 2008 BEST Electronic Design Winners
  • Engineers Rely On Internet For Product Info
  • Rochester Electronics Establishes New Design and Technology Group
  • November 17, 2008
  • Custom Sources Light Way To 22-nm IC Lithography
  • Software Turns Scopes Into Vector RF Signal Analyzers
  • Couple’s $15 Million Gift Advances Rice Engineering Education
    1) Switch-Mode ICs Promote Efficient Power Management, Part 1: Switch-Mode Fundamentals
    (1173 views today)
    2) Ubuntu Goes Embedded
    (282 views today)
    3) Build A Smart Battery Charger Using A Single-Transistor Circuit
    (261 views today)
    4) Parts Add Up To Home Theater PC
    (241 views today)
    5) Ten Top Design Skills For Tough Times
    (181 views today)
    ALL TOP 20



    Reader Comments

    In an environment where a design needs review by other members of a design team, a statechart can be a life saver. I use them in every design I produce, since it will clearly and succinctly indicate what I intend to do, and how the system will operate. Clarity and brevity - a winning combination. (This is especially useful if not all design team members use the same first language. Here in Canada, we have two official languages, but we also have immigrants from many other countries, and a state versus event figure is easily understood by everyone. Makes it an even more useful tool!)

    Anonymous -October 06, 2008

    POST YOUR COMMENTS HERE
    Name:

    Email:
    Your Comments:

    Enter the text from the image below


    Please refresh the page if you have trouble reading this text.

    Search Electronic Design
         
      
     
    Web Seminar
    Sponsored By:
    Title: Read Pacing: A Performance Enhancing Feature of PCI Express Gen 2 Switch Devices
    Speakers: 
    Date: 07/01/08
    Register: 

    Electronic Design Europe Electronic Design China EEPN Power Electronics Auto Electronics Microwaves & RF
    Mobile Dev & Design Schematics Find Power Products Military Electronics EE Events Related Resources