PIPS
fsm_generation.h
Go to the documentation of this file.
1 /*
2 
3  $Id: fsm_generation.h 23065 2016-03-02 09:05:50Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 #ifndef FSM_GENERATION_DEFS
25 #define FSM_GENERATION_DEFS
26 
27 #define STATE_VARIABLE_NAME "FSM%d_STATE"
28 #define STATE_VARIABLE_NAME_NO_REF "FSM_STATE"
29 #define FSM_BEGIN_COMMENT "! BEGIN FSM, %s\n"
30 #define FSM_TRANSITION_COMMENT "! Transition %s=%d\n"
31 
32 /**
33  * Build and return an expression (eg. state = 23), given an entity
34  * state_variable, an int value value, and an intrinsic name
35  */
37  int value,
38  string intrinsic_name);
39 
40 /**
41  * This function creates (and add declaration) state variable.
42  * The name of this variable is obtained by the concatenation of
43  * string STATE_VARIABLE_NAME and name identifier.
44  * If the variable doesn't exist with this name, then the variable
45  * is created, added to declarations, and returned. If this variable
46  * exists, then this functions search a new name by incrementing the
47  * integer name_identifier
48  */
50  int name_identifier);
51 
52 /**
53  * This function build and return a statement representing the
54  * initial assigment of the state_variable, given the UNSTRUCTURED
55  * statement stat.
56  */
58  entity state_variable,
59  int assignement_value);
60 
61 /**
62  * Return the state variable value corresponding to the entry
63  * in a unstructured statement
64  */
66 
67 /**
68  * Return the state variable value corresponding to the exit
69  * in a unstructured statement
70  * NB: always return 0
71  */
73 
74 /**
75  * This function build and return a statement representing the
76  * initial assigment of the state_variable, given the UNSTRUCTURED
77  * statement stat.
78  */
80  entity state_variable);
81 
82 /**
83  * This function build a transition statement (a TEST statement)
84  * corresponding to the current control current_node and the
85  * root_statement root_statement. This TEST statement takes a condition on
86  * the state_variable having the value matching the statement ordering
87  * value, and the control statement for the test_true value. The
88  * test_false value is set with a continue statement, before to be
89  * eventually replaced in next control node by a new statement.
90  */
92  statement root_statement,
93  entity state_variable,
94  const char* module_name);
95 
96 /**
97  * This function build and return a statement representing the
98  * transitions computation in the FSM, given the UNSTRUCTURED
99  * statement stat.
100  */
102  entity state_variable,
103  const char* module_name);
104 
105 
106 /**
107  * This function build and return a statement representing the
108  * FSM code equivalent to the given unstructured statement stat.
109  */
111  entity state_variable,
112  const char* module_name);
113 
114 /*
115  * This function is recursively called during FSMization. It takes
116  * the statement to fsmize stat as parameter, while module_name is
117  * the name of the module where FSMization is applied.
118  * If global variable is used for the whole module, state_variable
119  * contains this element. If state_variable is null, then new
120  * state_variable is created for this statement.
121  */
123  entity state_variable,
124  const char* module_name);
125 
126 #endif
127 
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
statement fsmize_statement(statement stat, entity state_variable, const char *module_name)
This function is recursively called during FSMization.
Definition: fsm_tools.c:536
statement make_fsm_transitions_statement(statement stat, entity state_variable, const char *module_name)
This function build and return a statement representing the transitions computation in the FSM,...
Definition: fsm_tools.c:400
statement make_state_variable_assignement_statement(statement stat, entity state_variable, int assignement_value)
This function build and return a statement representing the initial assigment of the state_variable,...
Definition: fsm_tools.c:129
statement make_transition_statement(control current_node, statement root_statement, entity state_variable, const char *module_name)
This function build a transition statement (a TEST statement) corresponding to the current control cu...
Definition: fsm_tools.c:212
entity create_state_variable(const char *module_name, int name_identifier)
This function creates (and add declaration) state variable.
Definition: fsm_tools.c:84
statement make_fsm_from_statement(statement stat, entity state_variable, const char *module_name)
This function build and return a statement representing the FSM code equivalent to the given unstruct...
Definition: fsm_tools.c:447
int exit_state_variable_value_for_unstructured(statement stat)
Return the state variable value corresponding to the exit in a unstructured statement NB: always retu...
Definition: fsm_tools.c:180
statement make_reset_state_variable_statement(statement stat, entity state_variable)
This function build and return a statement representing the initial assigment of the state_variable,...
Definition: fsm_tools.c:194
int entry_state_variable_value_for_unstructured(statement stat)
Return the state variable value corresponding to the entry in a unstructured statement.
Definition: fsm_tools.c:162
expression make_expression_with_state_variable(entity state_variable, int value, string intrinsic_name)
Build and return an expression (eg.
Definition: fsm_tools.c:66