Notice: The Ansys Innovation Space websites will be temporarily unavailable on Monday November 6 from 8:30 EDT to 1:00pm EDT for scheduled maintenance.
We apologize for any inconvenience this may cause and appreciate your understanding.
Embedded Software

Embedded Software

Scade One – Bridging the Gap between Model-Based Design and Traditional Programming

    • SolutionSolution
      Guest

      Introducing the Scade One launch blog series

      This article is part of the Scade One launch blog series. Scade One is a model-based solution for the development of embedded software applications. As we approach the launch of the first product version of Scade One, we are publishing this blog series on the main highlights of Scade One 2024 R1, starting with:

      • A Visual Coding Experience: We’ll introduce the new modern user interface and user experience of Scade One, designed to make the tool intuitive and engaging.
      • Bridging the Gap between Model-Based Design and Traditional Programming (this blog): We’ll show how Scade One combines the ease of use of model-based tools and the power and expressivity of programming languages. New modeling constructs allow Scade One to be used both in traditional control software and more complex mission and autonomy software.
      • An Open Model-Based Ecosystem, Ready for MBSE: Scade One is designed to be integrated into a Model-Based Systems Engineering (MBSE) process, and is bundled with the Ansys System Architecture Modeler, a web-based SysML v2 modeler. We’ll also describe the import of software component interfaces from SysML v2 into Scade One.
      • Democratizing Model-Based Development: We’ll introduce the new entry-level offering of Scade One, making the model-based approach, used successfully for safety-critical applications for more than 20 years, accessible to any company developing safe and reliable embedded software.

      We are eager to share with you what is coming in this new chapter for SCADE.


      Overview

      We claim that Scade One bridges the gap between model-based design and traditional programming, but you might be wondering what it means. Here’s what we will show you in the rest of this blog. In a nutshell:

      • If you are a control or systems engineer, Scade One will allow you to build software visually, using a familiar block diagram notation. No need to be a programmer and know about the intricacies and pitfalls of a low-level language like C to build safe and reliable software.
      • If you are a software engineer, you will be pleased to learn that Scade One is based on a formal, domain-specific programming language. You can use textual notation (or a mix of diagrams and text), with all the services expected of a textual editor. The language offers advanced features, inspired from general-purpose programming languages, to allow development of not only traditional control software but also mission and autonomy software.

      Swan, a domain-specific language for embedded software

      Modeling in Scade One is based on a domain-specific programming language called Swan, designed for real-time safe and reliable embedded software. This language builds on decades of research in the field of synchronous languages (including the academic language Lustre) and the legacy of successive Scade language versions (up to Scade 6, used in SCADE Suite).

      What are the benefits of this approach?

      • Swan is a declarative dataflow language. It means that you describe what to do, not how to do it. It is then up to the code generator to create efficient C code that implements the model’s behavior. Experience has proven this approach is less error-prone than manual C coding.
      • Swan is a high-level/domain-specific language. It includes built-in concepts such as logical time and concurrency and constructs such as state machines allowing the designer to easily describe complex reactive behaviors.
      • Swan is a formally defined language. The behavior of models is well-defined, independent of tool version or code generation options. Formal verification of model properties, such as value overflow or division by zero, is possible. Static checks, such as type checking, may also be performed to ensure the correctness of models.
      • Swan is designed for safe embedded software. Many properties are guaranteed by construction, like bounded memory and reaction time, or the absence of out-of-bounds accesses for arrays. There is no need for a safe subset or coding rules like with other approaches. This makes Swan easy to use for non-experts in programming, avoiding the pitfalls of a general-purpose language like C/C++.

      One language, two notations

      There are two ways to describe models using Swan:

      Using diagrams: the model is made of block diagrams that can be mixed with state machines. Block diagrams are a standard notation, very often used by control engineers for control law design.

      let y = x + 1;

      Using text: an operator can be defined completely as text, like a function in a textual programming language.

      Text and diagrams can be mixed: textual expressions or textual blocks can be put anywhere in a block diagram. You can decide to use either textual notation or block diagram notation (or both!), based on your preferences. For instance, diagrams are great to view the states and transitions of a state machine, while text can be more readable for complex arithmetic expressions.
      Note that there is just one language. Any model can be described using diagrams or text. The serialization format is the same for textual and diagrammatic models.


      Using diagrams, text or both in Scade One

      All activities, from design to debugging to verification activities, can be performed for graphical and textual models. The modeler provides dedicated features for each approach:

      • Diagrams offer auto-layout and smart guides to create nice-looking views.
      • Textual parts can be edited with syntax highlighting and auto-completion.

      Whether you are a control or systems engineer, familiar with model-based simulation tools, or a software engineer, used to Integrated Development Environments (IDEs), you will immediately feel at home with Scade One. Take a look at the first blog in this series to learn more about Scade One’s new UI/UX.

      Swan’s key features

      Swan is an evolution of Scade 6, the language used in SCADE Suite. Swan improves on Scade 6, but also extends it with new features to answer the challenges and objectives of a modern modeling and programming tool.

      A very common drawback of visual programming languages is that diagrams can become messy visual spaghetti.

       

      Me trying to explain my spaghetti “prototype” #UE4 blueprint code to literally anyone. pic.twitter.com/GCeE6D5Yic

      — Holomento (@HolomentoGame) May 20, 2020

      Swan introduces the notion of groups, to simplify and declutter block diagrams. Groups allow one wire or variable to represent multiple flows:


      The same model without groups (left, in SCADE Suite) and with groups (right, in Scade One)

      Like Scade 6, Swan takes inspiration from programming language best practices and combines them with the model-based approach. For instance, Scade 6 allows the creation of reusable, generic libraries. Swan goes further by introducing the concept of interfaces, inspired from Ada, that allow separation of the interface of a module from its implementation. This is particularly useful during early architectural design phases. Interfaces can also be used to control the visibility of declarations in a module. This can look very standard for a software engineer, but it is not usually found in other model-based tools.


      Using interfaces for a modular design

      Swan allows you to manipulate rich data types and data structures. On top of the arrays and structures already available in Scade 6, Swan supports the definition of variants (a.k.a. tagged unions). A variant can be used to store values of different types in the same flow or data structure.

      type cartesian =
      {x: float32, y: float32}
      type polar =
      {rho: float32, theta: float32}

      type coord =
      Cartesian {cart}
      | Polar     {polar}


      Declaring (top) and using (bottom) variants

      Swan also introduces a new for-loop-like construct to design iterative models, more intuitive than the iterators in Scade 6. This new construct can be used for arrays or matrix computations, like the matrix multiplication shown below, or for traversing data structures.


      Matrix multiplication using the new loop-like construct, using diagram notation

      C = forward <‍<‍P‍>‍> with <‍<‍i‍>‍>
      <‍<‍M‍>‍> with <‍<‍j‍>‍>
      let Cij = forward <‍<‍N‍>‍> with <‍<‍k‍>‍>
      let sum = last 'sum + A[i][k] * B [k][j];
      returns (sum: last = 0);
      returns ([[ Cij ]]);

      Matrix multiplication using the new loop-like construct, using textual notation

      Put together, these new constructs allow creating and manipulating complex data structures. This sets Swan aside from other model-based tools, and closer to the power and expressiveness of a general-purpose programming language. This means that you will be using Scade One, with all the associated benefits of reduced development time, for more applications than just traditional control applications.

      Stay tuned!

      In this blog, we’ve demonstrated how Scade One provides the best of both model-based and programming, resulting in a tool and language usable by both control/systems and software engineers. We could only scratch the surface of Swan, so stay tuned for more deep dives into the new constructs of Swan and concrete examples.

      In the next blog, we’ll discuss how Scade One integrates in a Model-Based Systems Engineering (MBSE) process.