Ansys Assistant will be unavailable on the Learning Forum starting January 30. An upgraded version is coming soon. We apologize for any inconvenience and appreciate your patience. Stay tuned for updates.
Embedded Software

Embedded Software

Topics related to SCADE Suite, SCADE Display, SCADE One and more.

Header stdint.h

    • raphael.courousse.1
      Subscriber

      How do I use the types defined in stdint.h in my models ? Do i have to import them ? If so how do I procede.

    • Benjamin Descorps
      Ansys Employee

      Hello,

      To use external definitions (whatever it concerns types, constants or functions), you should use imported code.

      As example, you can define a new type and declare it as imported. In the Properties, you can select the Definition file that provides its C definition. Finally, you could define some constraints on this type, expecially if it is a numeric type (useful to allow use of mathematical Scade functions for example):

      Use of imported types introduces some constraints. You must also provide:

      • an init function for KCG
      • copy and comp functions

      You can refer to the chapter Design and Model Editing > 3 / Designing Models > Defining Data Types > Setting Imported Types of the USer Manual for further information.

      Benjamin

    • raphael.courousse.1
      Subscriber

      How do I make those 3 functions for my imported type ?  Why does KCG tries to re-define the type (this is kcg_imported_types.dh) when it's already defined here  in my user_macros.h ?

      Also will my operators be able to process my imported types ?

      Raphaël

    • Benjamin Descorps
      Ansys Employee

      Hello,

      The init function is required to define behavior for initialization. Example:

      void int32_t_init(int32_t *kcg_c1)
      {
          *kcg_c1= 0;
      }

      This is the minimum required to generate code with KCG.

      For Simulation purpose, you will need to provide some additional functions:

      • conversion functions are necessary for displaying observable variables of immorted types
      • Comparison functions are necessary for evaluating breakpoints and for checking expected values against simulation values

      You should refer to the Technical Manual for additional information and for an example.

      I will point out that use of imported types shall be reserved to complex cases.

      For numeric types, I will rather recommend you to use the native types of the Scade language (integr/float types of the Scade language). For mapping with the C types, you have possibility to map implementation of these numeric types with definition of your stdint.h library. As example, KCG generates the following default definition:

      You can the provide your own definition of the macro kcg_int32 and map it to definition of stdint.h.

      It could be a way to avoid use of imported types in your Scade model.

      Hope this helps,

      Benjamin

    • raphael.courousse.1
      Subscriber

      The bypass worked just fine. Thanks a lot !

Viewing 4 reply threads
  • You must be logged in to reply to this topic.
[bingo_chatbox]