Commit d6754b2b authored by Elwin Pater's avatar Elwin Pater Committed by Michael Weber

Added simple guard necessary enabling set matrix

parent b3202051
...@@ -2232,6 +2232,63 @@ void dve_compiler::gen_transition_info() ...@@ -2232,6 +2232,63 @@ void dve_compiler::gen_transition_info()
line(buf); line(buf);
block_end(); block_end();
line(); line();
///////////////////////////////////////////////
// EXPORT NECESSARY ENABLING SETS FOR GUARDS //
///////////////////////////////////////////////
// guard nes matrix (#guards x #transitions)
sprintf(buf, "int guard_nes[%zu][%zu] = ", guard.size(), transitions.size());
line(buf);
block_begin();
for(size_int_t i=0; i < guard.size(); i++) {
append("{");
for(size_int_t j=0; j < transitions.size(); j++) {
if (j != 0) append(", ");
append(is_guard_nes(guard[i], transitions[j])?"1":"0");
}
if (i == guard.size() - 1)
line("}");
else
line("},");
}
block_end();
line(";");
line();
// guard nes function
line ("extern \"C\" const int* get_guard_nes_matrix(int g) " );
block_begin();
sprintf(buf, "if (g>=0 && g < %zu) return guard_nes[g];", guard.size());
line(buf);
sprintf(buf, "return NULL;");
line(buf);
block_end();
line();
}
bool dve_compiler::is_guard_nes( guard& g, ext_transition_t& t ) {
switch (g.type) {
case GUARD_PC:
if (g.pc.gid == t.first->get_process_gid())
return (g.pc.lid == t.first->get_state2_lid());
if (t.synchronized && g.pc.gid == t.second->get_process_gid())
return (g.pc.lid == t.second->get_state2_lid());
return false;
case GUARD_CHAN:
if (!t.synchronized && g.chan.chan == t.first->get_channel_gid()) {
if (t.first->get_sync_mode() == SYNC_EXCLAIM_BUFFER ||
t.first->get_sync_mode() == SYNC_ASK_BUFFER) {
return g.chan.sync_mode != t.first->get_sync_mode();
}
}
return false;
case GUARD_COMMITED_FIRST:
return ( dynamic_cast<dve_process_t*>(get_process(t.first->get_process_gid()))->get_commited(t.first->get_state1_lid()) &&
!dynamic_cast<dve_process_t*>(get_process(t.first->get_process_gid()))->get_commited(t.first->get_state2_lid()));
}
return true;
} }
bool dve_compiler::may_be_coenabled( guard& ga, guard& gb) { bool dve_compiler::may_be_coenabled( guard& ga, guard& gb) {
......
...@@ -231,6 +231,7 @@ struct dve_compiler: public dve_explicit_system_t ...@@ -231,6 +231,7 @@ struct dve_compiler: public dve_explicit_system_t
void merge_dependent_expression(std::vector<guard>& guard, int sv_count); void merge_dependent_expression(std::vector<guard>& guard, int sv_count);
void gen_transition_info(); void gen_transition_info();
bool get_const_expression( dve_expression_t & expr, int & value); bool get_const_expression( dve_expression_t & expr, int & value);
bool is_guard_nes( guard& g, ext_transition_t& t );
bool may_be_coenabled( guard& ga, guard& gb); bool may_be_coenabled( guard& ga, guard& gb);
void extract_predicates( std::vector<simple_predicate>& p, dve_expression_t& e); void extract_predicates( std::vector<simple_predicate>& p, dve_expression_t& e);
bool is_conflict_predicate(simple_predicate& p1, simple_predicate p2); bool is_conflict_predicate(simple_predicate& p1, simple_predicate p2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment