scLego ocLego sscLego - Lego C code generator
scLego [scoc options] file.sc
ocLego [sscoc options] file.oc
sscLego [sscc options] file.ssc
Interpreted C code
esterel -ILego foo.strlAutomaton C code
esterel -ALego foo.strlEquation C code
esterel -LLego foo.strlCode for simulation is also possible using the -simul option.
scLego expects one or several predefined objects to be used. The next section API describes the Esterel specific API that must be used.
scLego parses the Esterel intermediate code given as input and defined the value of the constants if not defined in the Esterel code. Then it calls the actual C code generator. Finally, it modifies the generated C code to add output function definitions and a main function.
% time control
%-------------
% Tells how many times
the controller is called within one second.
% User can change the
default value of 100, which may be omitted.
% Automaton is run each
1000 / TICKS_PER_SECOND ms.
constant TICKS_PER_SECOND
= 100 : integer;
% Engine control
%---------------
constant MOTOR_OFF
: integer,
MOTOR_FWD : integer,
MOTOR_REV : integer,
MOTOR_BRAKE : integer;
% If argument is MOTOR_FWD,
return MOTOR_REV and vice versa
function CHANGE_MOTOR_DIR
(integer) : integer;
constant MAX_SPEED = 255 : integer;
output MOTOR_A_DIR
:= MOTOR_OFF : integer,
MOTOR_A_SPEED :=
0
: integer;
output MOTOR_B_DIR
:= MOTOR_OFF : integer,
MOTOR_B_SPEED :=
0
: integer;
output MOTOR_C_DIR
:= MOTOR_OFF : integer,
MOTOR_C_SPEED :=
0
: integer;
% Contact sensors
%----------------
input TOUCH_1;
input TOUCH_2;
input TOUCH_3;
% Light sensors
%--------------
constant DEFAULT_LIGHT_THRESHHOLD
= 50 : integer;
sensor LIGHT_1_VALUE
: integer; % current light measure
% set light sensor threshhold
output SET_LIGHT_1_THRESHHOLD
:= DEFAULT_LIGHT_THRESHHOLD : integer;
input
LIGHT_LOW_1;
% pure signal if below threshhold
input
LIGHT_HIGH_1;
% pure signal if above threshhold
sensor LIGHT_2_VALUE
: integer;
output SET_LIGHT_2_THRESHHOLD
:= DEFAULT_LIGHT_THRESHHOLD : integer;
input LIGHT_LOW_2;
input LIGHT_HIGH_2;
sensor LIGHT_3_VALUE
: integer;
output SET_LIGHT_3_THRESHHOLD
: integer;
input LIGHT_LOW_3;
input LIGHT_HIGH_3;
% If argument is MOTOR_FWD,
returns MOTOR_REV and vice versa.
% Else returns argument.
Automatically defined in C generated
% code.
function CHANGE_MOTOR_DIR(integer)
: integer;
% Screen display
%---------------
output CPUTS : string;