From 520f50ac5aceeaa4db7d766ac764dc5405c91263 Mon Sep 17 00:00:00 2001 From: juehv Date: Tue, 5 Apr 2016 16:30:00 +0200 Subject: update --- src/uscxml/transform/ChartToVHDL.cpp | 74 +++++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 22 deletions(-) diff --git a/src/uscxml/transform/ChartToVHDL.cpp b/src/uscxml/transform/ChartToVHDL.cpp index 7b2bd6f..ca08f0a 100644 --- a/src/uscxml/transform/ChartToVHDL.cpp +++ b/src/uscxml/transform/ChartToVHDL.cpp @@ -128,7 +128,7 @@ namespace uscxml { // elements.insert(_nsInfo.xmlNSPrefix + "else"); // elements.insert(_nsInfo.xmlNSPrefix + "foreach"); // elements.insert(_nsInfo.xmlNSPrefix + "log"); - elements.insert(_nsInfo.xmlNSPrefix + "send"); + elements.insert(_nsInfo.xmlNSPrefix + "send"); // elements.insert(_nsInfo.xmlNSPrefix + "assign"); // elements.insert(_nsInfo.xmlNSPrefix + "script"); // elements.insert(_nsInfo.xmlNSPrefix + "cancel"); @@ -990,23 +990,23 @@ namespace uscxml { stream << " event_consumed <= '0';" << std::endl; stream << " elsif falling_edge(clk) and stall = '0' then" << std::endl; - + VContainer eventConsumed = VOR; for (size_t i = 0; i < _transitions.size(); i++) { Element transition(_transitions[i]); - + if (HAS_ATTR(transition, "event") == true) { *eventConsumed += VLINE("in_optimal_transition_set_" - + ATTR(transition, "postFixOrder") + "_sig"); + + ATTR(transition, "postFixOrder") + "_sig"); } } - + VBranch* tree = (VASSIGN, VLINE("event_consumed"), eventConsumed); tree->print(stream); stream << ";" << std::endl; - + stream << " if int_event_empty = '0' then " << std::endl; stream << " case next_event is " << std::endl; for (std::list::iterator eventIter = eventNames.begin(); eventIter != eventNames.end(); eventIter++) { @@ -1029,7 +1029,7 @@ namespace uscxml { stream << " next_event_dequeued <= '0';" << std::endl; stream << " end case;" << std::endl; stream << " elsif int_event_empty = '1' and event_consumed = '1' then" << std::endl; - + for (std::list::iterator eventIter = eventNames.begin(); eventIter != eventNames.end(); eventIter++) { stream << " event_" << eventNameEscape((*eventIter)->value) << "_sig <= '0';" << std::endl; } @@ -1052,11 +1052,18 @@ namespace uscxml { for (size_t i = 0; i < _states.size(); i++) { + // TÖDO: is there a case where complete entry set reflects not the next state ? VBranch* tree = (VASSIGN, + // VLINE("state_next_" + toStr(i) + "_sig"), + // (VAND, + // VLINE("in_complete_entry_set_" + toStr(i) + "_sig") , + // (VOR, VLINE("in_exit_set_" + toStr(i) + "_sig"), (VNOT, VLINE("state_active_" + toStr(i) + "_sig")))) + // ); VLINE("state_next_" + toStr(i) + "_sig"), - (VAND, + (VOR, VLINE("in_complete_entry_set_" + toStr(i) + "_sig"), - (VOR, VLINE("in_exit_set_" + toStr(i) + "_sig"), (VNOT, VLINE("state_active_" + toStr(i) + "_sig"))))); + (VAND, (VNOT, VLINE("in_exit_set_" + toStr(i) + "_sig")), VLINE("state_active_" + toStr(i) + "_sig"))) + ); tree->print(stream); stream << ";" << std::endl; @@ -1166,7 +1173,8 @@ namespace uscxml { VLINE("in_entry_set_" + toStr(i) + "_sig"), (VAND, VLINE("in_complete_entry_set_" + toStr(i) + "_sig"), - (VOR, VLINE("state_active_" + toStr(i) + "_sig"), (VNOT, VLINE("in_exit_set_" + toStr(i) + "_sig"))))); + (VOR, VLINE("in_exit_set_" + toStr(i) + "_sig"), + (VNOT, VLINE("state_active_" + toStr(i) + "_sig"))))); tree->print(stream); stream << ";" << std::endl; @@ -1174,17 +1182,26 @@ namespace uscxml { } void ChartToVHDL::writeDefaultCompletions(std::ostream & stream) { + // TODO direct connect the line in complete entry set (no extra line needed ...) stream << "-- default completion assignments" << std::endl; - + stream << "-- indikates if the state for which I am the def-completion is active" << std::endl; std::map, NodeSet > completions; + for (size_t i = 0; i < _states.size(); i++) { Element state(_states[i]); completions[state]; // initialize other completions to 0 - std::string completion = ATTR(state, "completionBools"); - for (size_t j = 0; j < _states.size(); j++) { - if (completion[j] == '1') { - completions[Element(_states[j])].push_back(state); + // we just need this if parent is a compound state + std::string parent = ATTR(state, "parent"); + if (!parent.empty() + && isCompound(Element(_states[strTo(parent)]))) { + + // Am I default completen ? + std::string completion = ATTR_CAST(_states[strTo(parent)], "completionBools"); + if (completion[i] == '1') { + // Yes? then give me the parent line + completions[state].push_back(Element(_states[strTo(parent)])); + } } } @@ -1198,7 +1215,11 @@ namespace uscxml { VContainer defaultCompleters = VOR; for (size_t i = 0; i < refs.size(); i++) { - *defaultCompleters += VLINE("in_complete_entry_set_" + toStr(i) + "_sig "); + // *defaultCompleters += VLINE("in_complete_entry_set_" + + // TODO: default completion just when state is entered the first time ? + // if yes then we use the following code. If not we have to revert + *defaultCompleters += VLINE("in_entry_set_" + + ATTR_CAST(refs[i], "documentOrder") + "_sig "); } VBranch* tree = (VASSIGN, @@ -1233,9 +1254,10 @@ namespace uscxml { } VContainer completeEntrysetters = VOR; - if (isCompound(state)) { // <- true for scxml? TODO + stream << "--" << state.getNodeName() << std::endl; // for debugging + if (isCompound(state) || isParallel(state)) { // <- true for scxml? TODO for (size_t j = 0; j < _states.size(); j++) { - if (children[j] != '1') // <- ? TODO Was ist hier der vergleich? + if (children[j] != '1') // if is child of state j continue; *completeEntrysetters += VLINE("in_complete_entry_set_up_" + toStr(j) + "_sig"); } @@ -1243,8 +1265,8 @@ namespace uscxml { VBranch* tree = (VASSIGN, VLINE("in_complete_entry_set_up_" + toStr(i) + "_sig"), - optimalEntrysetters, - completeEntrysetters); + (VOR, optimalEntrysetters, completeEntrysetters) + ); tree->print(stream); stream << ";" << std::endl; @@ -1277,7 +1299,6 @@ namespace uscxml { Element state(_states[i]); std::string completion = ATTR(state, "completionBools"); std::string ancestors = ATTR(state, "ancBools"); - std::string children = ATTR(state, "childBools"); std::string parent = ATTR(state, "parent"); if (parent.size() == 0) { @@ -1285,9 +1306,17 @@ namespace uscxml { } VContainer tmp1 = VAND; - if (isCompound(Element(_states[strTo(parent)]))) { + // if parent is compound + if (!parent.empty() && + isCompound(Element(_states[strTo(parent)]))) { + std::string children = ATTR_CAST(_states[strTo(parent)], + "childBools"); + // TODO: do not add default_completion line if not needed + // --> just if this state is the default completion of parent + // --> init attr. or if not present first in document order <-- = completion bool ? *tmp1 += VLINE("default_completion_" + ATTR(state, "documentOrder") + "_sig"); + //TODO check this for (size_t j = 0; j < _states.size(); j++) { if (children[j] != '1') continue; @@ -1302,6 +1331,7 @@ namespace uscxml { } + // if parent is parallel if (isParallel(Element(_states[strTo(parent)]))) { *tmp1 += VLINE("in_complete_entry_set_" + toStr(parent) + "_sig"); } -- cgit v0.12