[Scilab-Dev] code generation for microcontroller target

Clément David clement.david at scilab-enterprises.com
Thu Jun 26 14:32:32 CEST 2014


Hello Matias,

Answered in-line.

Le mercredi 25 juin 2014 à 22:29 -0300, Matías Silva Bustos a écrit :
> Hello,
> 
> I am about to begin the developement of a coder that takes a xcos
> diagram and generates C code  suitable to be ran on a ARM Cortex M3
> uC, a STM32FXXX in particular. 

Great ! Do you plan to generate an application using a POSIX-like OS ?
if not, what's the minimal set of feature of your platform (eg.
bare-metal, contiki / Osek like, RTEMS, Embedded Linux, Full Linux) ?

> Here my questions:
> 
> 
> a) Is the code generated by the xcos CodeGenerator suitable for this
> purpose without much code rewritting? 

It is, as it generates the scheduler code (with restriction), generate
I/o wrappers functions and calls to the Scilab block.

Note that even if huge double buffers are generated, small to medium
diagrams might not have any issue to run on your target.

> a_1) i.e. has the generated code too many library dependencies? I
> tryed to compile the XXX_standalone.c  but it seems to require many
> scilab libraries, Am I right?. 

Yes you are, we do *NOT* generate code for each block but re-use the
Scilab's one. The code generator is mainly a scheduler code generator.
Not that it may depend on your schema, some block functions requires
blas/lapack, others scilab graphics and others nothing but libm/stdlib.
You have to take care, some blocks are coded in fortran so your embedded
platform might have a fortran compiler.

> b) Should I begin from scratch? I think I can reuse the xcos parser
> and some other code involving the diagram description. 

In my view, to generate code that perform the same way as the simulator
you have to re-use the cpr structure (help scicos_cpr). The better way
to kick things off is to start from the current generator and start
refactor it (it's a nightmare) / implement some code generator templates
per simulation function.

Using well design code generator templates will allow you to both reduce
the actual generated code size and runtime requirements.

> b_1) But from there, Is there other classes or functions I can use?

scinotes
"SCI/modules/scicos/macros/scicos_scicos/do_compile_superblock42.sci"
will let you edit the whole code generator.

Do not hesitate to ask if you need more information ; that's a big piece
of old Scilab code !

> c) Scilab is the preferred programming language? I have seen many
> languages such as C, C++, Java, Modelica (i'm not sure what this is),
> FORTRAN.

As all Xcos informations are stored as Scilab variables, it might be
easier to code using the Scilab language. To use another language you
have "convert" the cpr structure to a language-native one.

> d) What is the format of the zcos files? Which issues has the xcos
> (XML)? :(

The Zcos file format is a zip file containing a "content.xml" file. All
Scilab data is encoded through javasci in Java encoded arrays in the
"dictionary/dictionary.ser" file.

Regards,

> I'm electronic engineer student from Argentina. I was asked to do this
> project by a professor and I accepted the challenge.
> 
> 
> Many thanks for considering my request.
> 
> Sincerely,
> 
> Matías Silva Bustos.
> 

-- 
Clément DAVID
Development Engineer / Account Manager
-----------------------------------------------------------
Scilab Enterprises
143bis rue Yves Le Coz - 78000 Versailles, France
Mobile: +33.6.26.26.51.90
Phone: +33.2.90.22.78.96
http://www.scilab-enterprises.com




More information about the dev mailing list