30 FD_DCG(
"CodePrimitives(" <<
this <<
")::CodePrimitives()");
35 FD_DCG(
"CodePrimitives(" <<
this <<
")::~CodePrimitives()");
41 FD_DCG(
"CodePrimitives(" <<
this <<
")::Clear()");
72 FD_DCG(
"CodePrimitives::DoReadTargetConfiguration()");
77 if(rTr.ExistsBegin(
"Prefix")) {
78 rTr.ReadBegin(
"Prefix",token);
79 mPrefix=token.AttributeStringValue(
"val");
83 rTr.ReadEnd(
"Prefix");
86 if(rTr.ExistsBegin(
"WordType")) {
87 rTr.ReadBegin(
"WordType",token);
88 mWordType=token.AttributeStringValue(
"val");
89 rTr.ReadEnd(
"WordType");
92 if(rTr.ExistsBegin(
"WordSize")) {
93 rTr.ReadBegin(
"WordSize",token);
94 mWordSize=token.AttributeIntegerValue(
"val");
95 rTr.ReadEnd(
"WordSize");
98 if(rTr.ExistsBegin(
"IntegerType")) {
99 rTr.ReadBegin(
"IntegerType",token);
101 rTr.ReadEnd(
"IntegerType");
104 if(rTr.ExistsBegin(
"IntegerSize")) {
105 rTr.ReadBegin(
"IntegerSize",token);
107 rTr.ReadEnd(
"IntegerSize");
110 if(rTr.ExistsBegin(
"ArrayForTransitions")) {
111 rTr.ReadBegin(
"ArrayForTransitions",token);
113 rTr.ReadEnd(
"ArrayForTransitions");
116 if(rTr.ExistsBegin(
"MaintainStateIndices")) {
117 rTr.ReadBegin(
"MaintainStateIndices",token);
119 rTr.ReadEnd(
"MaintainStateindices");
122 if(rTr.ExistsBegin(
"ArrayForBitmasks")) {
123 rTr.ReadBegin(
"ArrayForBitmasks",token);
125 rTr.ReadEnd(
"ArrayForBitmasks");
128 if(rTr.ExistsBegin(
"ArrayForBitarray")) {
129 rTr.ReadBegin(
"ArrayForBitarray",token);
131 rTr.ReadEnd(
"ArrayForBitarray");
134 if(rTr.ExistsBegin(
"BitAddressArithmetic")) {
135 rTr.ReadBegin(
"BitAddressArithmetic",token);
137 rTr.ReadEnd(
"BitAddressArithmetic");
140 if(rTr.ExistsBegin(
"BisectionForBitfind")) {
141 rTr.ReadBegin(
"BisectionForBitfind",token);
143 rTr.ReadEnd(
"BisectionForBitfind");
146 if(rTr.ExistsBegin(
"ArrayForState")) {
147 rTr.ReadBegin(
"ArrayForState",token);
149 rTr.ReadEnd(
"ArrayForState");
152 if(rTr.ExistsBegin(
"EventsetsForPerformance")) {
153 rTr.ReadBegin(
"EventsetsForPerformance",token);
155 rTr.ReadEnd(
"EventsetsForPerformance");
158 if(rTr.ExistsBegin(
"LoopPendingInputs")) {
159 rTr.ReadBegin(
"LoopPendingInputs",token);
161 rTr.ReadEnd(
"LoopPendingInputs");
164 if(rTr.ExistsBegin(
"LoopEnabledOutputs")) {
165 rTr.ReadBegin(
"LoopEnabledOutputs",token);
167 rTr.ReadEnd(
"LoopEnabledOutputs");
170 if(rTr.ExistsBegin(
"StrictEventSynchronisation")) {
171 rTr.ReadBegin(
"StrictEventSynchronisation",token);
173 rTr.ReadEnd(
"StrictEventSynchronisation");
176 if(rTr.ExistsBegin(
"EventNameLookup")) {
177 rTr.ReadBegin(
"EventNameLookup",token);
179 rTr.ReadEnd(
"EventNameLookup");
182 if(rTr.ExistsBegin(
"StateNameLookup")) {
183 rTr.ReadBegin(
"StateNameLookup",token);
185 rTr.ReadEnd(
"StateNameLookup");
188 if(rTr.ExistsBegin(
"EventExecutionHook")) {
189 rTr.ReadBegin(
"EventExecutionHook",token);
191 rTr.ReadEnd(
"EventExecutionHook");
194 if(rTr.ExistsBegin(
"StateUpdateHook")) {
195 rTr.ReadBegin(
"StateUpdateHook",token);
197 rTr.ReadEnd(
"StateUpdateHook");
200 if(rTr.ExistsBegin(
"IncludeBefore"))
203 if(rTr.ExistsBegin(
"IncludeAfter"))
205 FD_DCG(
"CodePrimitives::DoReadTargetConfiguration(): done");
217 token.SetEmpty(
"Prefix");
218 token.InsAttributeString(
"val",
mPrefix);
221 token.SetEmpty(
"WordType");
222 token.InsAttributeString(
"val",
mWordType);
225 token.SetEmpty(
"WordSize");
226 token.InsAttributeInteger(
"val",
mWordSize);
229 token.SetEmpty(
"IntegerType");
233 token.SetEmpty(
"IntegerSize");
237 token.SetEmpty(
"ArrayForTransitions");
241 token.SetEmpty(
"MaintainStateIndices");
245 token.SetEmpty(
"ArrayForBitmasks");
248 token.SetEmpty(
"ArrayForBitarray");
252 token.SetEmpty(
"BitAddressArithmetic");
256 token.SetEmpty(
"BisectionForBitfind");
260 token.SetEmpty(
"ArrayForState");
264 token.SetEmpty(
"EventsetsForPerformance");
268 token.SetEmpty(
"LoopPendingInputs");
272 token.SetEmpty(
"LoopEnabledOutputs");
276 token.SetEmpty(
"StrictEventSynchronisation");
280 token.SetEmpty(
"EventNameLookup");
284 token.SetEmpty(
"StateNameLookup");
287 token.SetEmpty(
"EventExecutionHook");
291 token.SetEmpty(
"StateUpdateHook");
306 for(
size_t gid=0; gid<
Size(); ++gid) {
307 const faudes::Generator& gen=
At(gid);
309 faudes::StateSet::Iterator sit=gen.StatesBegin();
310 for(;sit!=gen.StatesEnd();++sit)
311 mem += (
int) gen.StateName(*sit).size();
318 FCG_VERB0(
"CodeGenerator::Compile(): [" << gen.Name() <<
"] state names amount to #" 324 FCG_VERB1(
"CodePrimitives::Compile(): state update hook implies to maintain state indices as provided");
328 FCG_VERB1(
"CodePrimitives::Compile(): cannot generate lookup tables for the specified platforms");
332 FCG_VERB1(
"CodePrimitives::Compile(): no state names found --- will generate dummy loopkups only");
337 for(
size_t gid=0; gid<
Size(); ++gid) {
346 for(
size_t git=0; git<
Size(); ++git) {
347 if(
At(git).MaxStateIndex()==
At(git).States().Size())
continue;
349 FCG_VERB0(
"CodeGenerator::Generator(): generator [" <<
At(git).
Name() <<
"] " <<
350 "has non-consecutive state indices --- applying MinStateIndex()");
355 for(
size_t git=0; git<
Size(); ++git) {
356 int gap =
At(git).MaxStateIndex() -
At(git).States().Size();
359 FCG_VERB0(
"CodeGenerator::Generator(): generator [" <<
At(git).
Name() <<
"] " <<
360 "has non-consecutive state indices --- this will introduce an inefficient address table with #" 361 << gap <<
" dummy entries");
364 FCG_VERB0(
"CodeGenerator::Generator(): generator [" <<
At(git).
Name() <<
"] " <<
365 "has non-consecutive state indices --- this will introduce an inefficient symboltable with #" 366 << gap <<
" dummy entries");
continue;
374 FD_DCG(
"CodePrimitives(" <<
this <<
")::DoCompile()");
377 FCG_VERB1(
"CodePrimitives::Compile(): cannot generate compiled arrays for the specified target");
381 FCG_VERB1(
"CodePrimitives::Compile(): cannot generate compiled bit-masks for the specified target");
385 FCG_VERB1(
"CodePrimitives::Compile(): compiled bitmasks not recommended for word-size #" <<
mWordSize);
387 FCG_VERB1(
"CodePrimitives::Compile(): reject compiled bitmasks for word-size #" <<
mWordSize);
391 FCG_VERB1(
"CodePrimitives::Compile(): bit address-maths not available for the specified target");
395 FCG_VERB1(
"CodePrimitives::Compile(): reject option eventsets-for-performance for specified target");
404 FCG_VERB1(
"CodePrimitives::Compile(): option loop-enabled-outputs implies loop-enabled-inputs");
408 FCG_ERR(
"CodePrimitives::Compile(): option loop-enabled-outputs requires high priority for output events");
412 FCG_VERB1(
"CodePrimitives::Compile(): cannot generate lookup tables for the specified platform");
416 FCG_VERB1(
"CodePrimitives::Compile(): cannot implement state-update hook for the specified platform");
420 FCG_VERB1(
"CodePrimitives::Compile(): state-update hook implies array representation of overall state");
442 std::string::const_iterator sit=str.begin();
443 for(;sit!=str.end();++sit){
444 if(std::isalpha(*sit)) { res.push_back(*sit);
continue; };
445 if(std::isdigit(*sit) && res.size()>0) { res.push_back(*sit);
continue; }
446 if(res.size()>0) res.push_back(
'_');
486 Comment(
"************************************************");
487 Comment(
"* prepend code snippet from configuration *");
496 Comment(
"status (0x00 <> waiting, 0x01<>executing, 0x02<>err)");
497 WordDeclare(
AA(
"status"));
504 BooleanDeclare(
AA(
"reset"),
false);
510 Comment(
"recent event (0<>none)");
511 IntegerDeclare(
AA(
"recent_event"));
522 for(Idx gid=0; gid<
Size(); gid++)
523 IntegerDeclare(
AA(
"parallel_state").Sub(gid));
531 Comment(
"pending input events incl timer elapse");
532 EventSetDeclare(
AA(
"pending_events"));
534 Comment(
"events enabled by all generators");
535 EventSetDeclare(
AA(
"enabled_events"));
542 Comment(
"executed event (-1<>init, 0<>none)");
543 IntegerDeclare(
AA(
"exec_event"),-1);
546 Comment(
"scheduled event (0<>none)");
547 IntegerDeclare(
AA(
"sched_event"));
554 AA baddr =
AA(
"line_level").Sub(lit->second.mBitAddress);
555 BooleanDeclare(baddr);
562 BooleanDeclare(
AA(
"first_loop"));
573 TimerDeclare(
AA(tit->second.mAddress),tit->second.mInitialValue);
583 EventSetDeclare(
AA(
"aux_locenabled"));
584 IntegerDeclare(
AA(
"aux_parsetrans"));
585 IntegerDeclare(
AA(
"aux_parseevent"));
589 Comment(
"enabled events that can be executed");
590 EventSetDeclare(
AA(
"aux_executables"));
593 Comment(
"aux maths and stack variables ");
594 WordDeclare(
AA(
"aux_wordret"));
596 BooleanDeclare(
AA(
"aux_edge"));
599 IntegerDeclare(
AA(
"aux_wordaddr"));
600 IntegerDeclare(
AA(
"aux_bitaddr"));
603 WordDeclare(
AA(
"aux_bitmask"));
612 for(
size_t git=0; git<
Size(); ++git) {
613 const Generator& gen =
At(git);
614 Comment(
"generator [" + gen.Name() +
"]");
617 std::vector< int > statevect(gen.MaxStateIndex(),0);
618 IndexSet::Iterator sit= gen.StatesBegin();
619 for(;sit!=gen.StatesEnd();++sit)
622 CintarrayDeclare(
AA(
"generator_states").Sub(git),1,statevect);
646 std::vector<std::string> evlookup;\
648 faudes::EventSet::Iterator eit=
mUsedEvents.Begin();
651 if(((
int) evlookup.size())<tidx) evlookup.resize(tidx);
654 Comment(
"event name lookup table");
655 CstrarrayDeclare(
AA(
"event_lookup"),1,evlookup);
662 for(
size_t gid=0; gid<
Size(); ++gid) {
664 const faudes::Generator& gen=
At(gid);
665 std::vector<std::string> stlookup;\
666 faudes::StateSet::Iterator sit=gen.StatesBegin();
667 for(;sit!=gen.StatesEnd();++sit) {
669 if(((
int) stlookup.size())<tidx) stlookup.resize(tidx);
670 std::string name=gen.StateName(*sit);
671 if(name==
"") name=
"#"+ToStringInteger(tidx);
672 stlookup[tidx-1]=name;
675 Comment(
"state name lookup for generator [" +
At(gid).
Name() +
"]");
676 CstrarrayDeclare(
AA(
"state_lookup").Sub(gid),1,stlookup);
684 Comment(
"************************************************");
685 Comment(
"* reset internal state *");
687 Comment(
"set internal reset flag");
690 IntegerAssign(
AA(
"exec_event"),-1);
695 IfTrue(IntegerIsEq(
AA(
"exec_event"),-1));
697 IntegerAssign(
AA(
"status"),0);
699 for(Idx gid=0; gid<
Size(); gid++) {
704 statevar=
AA(
"parallel_state").Sub(gid);
707 Comment(
"clear scheduled event");
708 IntegerAssign(
AA(
"sched_event"),0);
710 IntegerAssign(
AA(
"recent_event"),0);
711 Comment(
"clear pending/enabled events");
712 EventSetClear(
AA(
"pending_events"));
713 EventSetClear(
AA(
"enabled_events"));
718 TimerStop(
AA(tit->second.mAddress));
719 TimerReset(
AA(tit->second.mAddress) ,tit->second.mInitialValue);
729 Comment(
"************************************************");
730 Comment(
"* bail out on external reset *");
747 Comment(
"************************************************");
748 Comment(
"* sense input events *");
751 EventSet::Iterator eit;
756 Comment(
"init: reset all line data and generate statics");
757 IfTrue(IntegerIsEq(
AA(
"exec_event"),-1));
760 AA baddr =
AA(
"line_level").Sub(lit->second.mBitAddress);
761 BooleanAssign(baddr,ReadInputLine(
AA(lit->second.mAddress)));
762 if(lit->second.mPosStatics.Empty() && lit->second.mNegStatics.Empty())
continue;
763 if(!lit->second.mPosStatics.Empty())
765 eit=lit->second.mPosStatics.Begin();
766 for(;eit!=lit->second.mPosStatics.End();++eit) {
768 EventSetInsert(
AA(
"pending_events"),*eit);
770 if(!lit->second.mPosStatics.Empty())
771 if(lit->second.mNegStatics.Empty())
773 if(!lit->second.mPosStatics.Empty())
774 if(!lit->second.mNegStatics.Empty())
776 if(lit->second.mPosStatics.Empty())
777 if(!lit->second.mNegStatics.Empty())
779 eit=lit->second.mNegStatics.Begin();
780 for(;eit!=lit->second.mNegStatics.End();++eit) {
782 EventSetInsert(
AA(
"pending_events"),*eit);
784 if(!lit->second.mNegStatics.Empty())
789 Comment(
"normal operation: read lines and detect edges");
790 IfTrue(IntegerIsNotEq(
AA(
"exec_event"),-1));
793 AA baddr =
AA(
"line_level").Sub(lit->second.mBitAddress);
794 Comment(
"read line [" + lit->second.mAddress +
"]");
795 BooleanAssign(
AA(
"aux_edge"),ReadInputLine(lit->second.mAddress));
796 IfTrue(BooleanIsNotEq(
AA(
"aux_edge"),baddr));
797 if(!lit->second.mPosEvents.Empty()) {
799 eit=lit->second.mPosEvents.Begin();
800 for(;eit!=lit->second.mPosEvents.End();++eit) {
802 EventSetInsert(
AA(
"pending_events"),*eit);
803 IntegerAssign(
AA(
"sched_event"),0);
807 if(!lit->second.mNegEvents.Empty()) {
809 eit=lit->second.mNegEvents.Begin();
810 for(;eit!=lit->second.mNegEvents.End();++eit) {
812 EventSetInsert(
AA(
"pending_events"),*eit);
813 IntegerAssign(
AA(
"sched_event"),0);
828 Comment(
"testing flag [" + fit->second.mAddress +
"]");
829 IfTrue(InputExpression(fit->second.mAddress));
830 eit=fit->second.mEvents.Begin();
831 for(;eit!=fit->second.mEvents.End();++eit) {
833 EventSetInsert(
AA(
"pending_events"),*eit);
834 IntegerAssign(
AA(
"sched_event"),0);
849 Comment(
"************************************************");
850 Comment(
"* sense timer elapse *");
855 IfTrue(TimerIsElapsed(
AA(tit->second.mAddress)));
856 TimerStop(
AA(tit->second.mAddress));
857 EventSetInsert(
AA(
"pending_events"),
EventIndex(tit->second.mElapseEvent));
858 IntegerAssign(
AA(
"sched_event"),0);
868 Comment(
"************************************************");
869 Comment(
"* event execution loop *");
871 Comment(
"clear status to waiting");
872 IntegerAssign(
AA(
"status"),0);
874 IntegerAssign(
AA(
"recent_event"),0);
876 BooleanAssign(
AA(
"first_loop"),
true);
885 Comment(
"************************************************");
886 Comment(
"* update enabled events after execution *");
889 Comment(
"if event was executed (and on initialisation)");
890 IfTrue(IntegerIsNotEq(
AA(
"exec_event"),0));
892 EventSetFull(
AA(
"enabled_events"));
895 for(Idx gid=0; gid<
Size(); gid++) {
896 Comment(
"restricting enabled events by [" +
At(gid).
Name() +
"]");
901 statevar=
AA(
"parallel_state").Sub(gid);
902 SwitchBegin(statevar);
904 StateSet::Iterator sit;
905 for(sit=
At(gid).StatesBegin(); sit!=
At(gid).StatesEnd(); sit++) {
906 EventSet disset=
At(gid).Alphabet();
907 disset.EraseSet(
At(gid).ActiveEventSet(*sit));
908 if(disset.Empty())
continue;
909 SwitchCase(statevar,*sit);
910 EventSetErase(
AA(
"enabled_events"),disset);
917 IntegerAssign(
AA(
"exec_event"),0);
918 IntegerAssign(
AA(
"sched_event"),0);
927 FCG_ERR(
"CodePrimitives::UpdateEnabledByInterpreter(): vector representation not available");
928 Comment(
"************************************************");
929 Comment(
"* update enabled events after execution *");
932 Comment(
"if event was executed (and on init)");
933 IfTrue(IntegerIsNotEq(
AA(
"exec_event"),0));
943 statevar=
AA(
"parallel_state").Sub(0);
944 AA gentrans=
AA(
"generator_transitions").Sub(0);
945 AA genstates=
AA(
"generator_states").Sub(0);
946 EventSetAssign(
AA(
"enabled_events"),empty);
950 IntegerAssign(
AA(
"aux_parsetrans"),
TargetExpression(CintarrayAccess(genstates,statevar)));
953 IntegerAssign(
AA(
"aux_parseevent"),
TargetExpression(CintarrayAccess(gentrans,
AA(
"aux_parsetrans"))));
954 LoopBreak(IntegerIsEq(
AA(
"aux_parseevent"),0));
955 EventSetInsert(
AA(
"enabled_events"),
AA(
"aux_parseevent"),
At(0).
Alphabet());
956 IntegerIncrement(
AA(
"aux_parsetrans"),2);
966 for(Idx gid=0; gid<
Size(); gid++) {
972 statevar=
AA(
"parallel_state").Sub(gid);
973 AA gentrans=
AA(
"generator_transitions").Sub(gid);
974 AA genstates=
AA(
"generator_states").Sub(gid);
979 IntegerAssign(
AA(
"aux_parsetrans"),
TargetExpression(CintarrayAccess(genstates,statevar)));
982 IntegerAssign(
AA(
"aux_parseevent"),
TargetExpression(CintarrayAccess(gentrans,
AA(
"aux_parsetrans"))));
983 LoopBreak(IntegerIsEq(
AA(
"aux_parseevent"),0));
984 EventSetInsert(
AA(
"aux_locenabled"),
AA(
"aux_parseevent"),
At(gid).
Alphabet());
985 IntegerIncrement(
AA(
"aux_parsetrans"),2);
987 Comment(
"restrict enabled events");
988 EventSetRestrict(
AA(
"enabled_events"),
AA(
"aux_locenabled"));
993 IntegerAssign(
AA(
"exec_event"),0);
994 IntegerAssign(
AA(
"sched_event"),0);
1010 Comment(
"************************************************");
1011 Comment(
"* schedule next event to execute *");
1013 IfTrue(IntegerIsEq(
AA(
"sched_event"),0));
1015 Comment(
"setup candidate set to \"pending or internal\"");
1017 Comment(
"restrict candidate set by \"enabled\"");
1018 EventSetRestrict(
AA(
"aux_executables"),
AA(
"enabled_events"));
1020 Comment(
"find highest priority event (lowest bitaddress)");
1021 EventSetFindHighestPriority(
AA(
"aux_executables"),
AA(
"sched_event"));
1023 Comment(
"remove scheduled event from pending events");
1024 IfTrue(IntegerIsGreater(
AA(
"sched_event"),0));
1025 EventSetErase(
AA(
"pending_events"),
AA(
"sched_event"));
1029 IfTrue(IntegerIsEq(
AA(
"sched_event"),0));
1030 EventSetIsNotEmpty(
AA(
"pending_events"),
AA(
"aux_wordret"));
1031 IfTrue(WordIsNotEq(
AA(
"aux_wordret"),0));
1032 WordOr(
AA(
"status"),WordConstant(0x02));
1037 Comment(
"cancel pending events if no event could be scheduled ");
1038 IfTrue(IntegerIsEq(
AA(
"sched_event"),0));
1039 EventSetClear(
AA(
"pending_events"));
1051 Comment(
"************************************************");
1052 Comment(
"* break execution loop *");
1054 LoopBreak(IntegerIsEq(
AA(
"sched_event"),0));
1059 LoopBreak(IntegerIsGreater(
AA(
"sched_event"),max));
1062 BooleanAssign(
AA(
"first_loop"),
false);
1069 FCG_ERR(
"CodePrimitives::InsertExecHooks(): no hooks supported by target platform");
1075 Comment(
"************************************************");
1076 Comment(
"* execute scheduled event *");
1078 IfTrue(IntegerIsNotEq(
AA(
"sched_event"),0));
1081 IntegerAssign(
AA(
"sched_event"),0);
1082 WordOr(
AA(
"status"),WordConstant(0x01));
1084 for(Idx gid=0; gid<
Size(); gid++) {
1091 statevar=
AA(
"parallel_state").Sub(gid);
1092 SwitchBegin(statevar);
1093 StateSet::Iterator sit;
1094 for(sit=
At(gid).StatesBegin(); sit!=
At(gid).StatesEnd(); sit++) {
1096 SwitchCase(statevar,*sit);
1098 std::map< int , int > casedata;
1099 std::set< std::set< int > > casesets;
1100 TransSet::Iterator tit;
1101 for(tit=
At(gid).TransRelBegin(*sit); tit!=
At(gid).TransRelEnd(*sit); tit++)
1103 ConsolidateCaseSets<int>(casedata,casesets);
1105 SwitchBegin(
AA(
"exec_event"));
1106 std::set< std::set<int> >::iterator cit=casesets.begin();
1107 for(; cit!=casesets.end(); ++cit) {
1108 SwitchCases(
AA(
"exec_event"),*cit);
1109 IntegerAssign(statevar,casedata[*cit->begin()]);
1130 Comment(
"************************************************");
1131 Comment(
"* execute scheduled event *");
1134 FCG_ERR(
"CodePrimitives::ExecuteByInterpreter(): vector representation not available");
1137 IfTrue(IntegerIsNotEq(
AA(
"sched_event"),0));
1140 IntegerAssign(
AA(
"sched_event"),0);
1141 WordOr(
AA(
"status"),WordConstant(0x01));
1143 for(Idx gid=0; gid<
Size(); gid++) {
1150 statevar=
AA(
"parallel_state").Sub(gid);
1151 AA gentrans=
AA(
"generator_transitions").Sub(gid);
1152 AA genstates=
AA(
"generator_states").Sub(gid);
1157 IntegerAssign(
AA(
"aux_parsetrans"),
TargetExpression(CintarrayAccess(genstates,statevar)));
1160 IntegerAssign(
AA(
"aux_parseevent"),
TargetExpression(CintarrayAccess(gentrans,
AA(
"aux_parsetrans"))));
1162 LoopBreak(IntegerIsEq(
AA(
"aux_parseevent"),0));
1163 IntegerIncrement(
AA(
"aux_parsetrans"),2);
1165 IfTrue(IntegerIsGreater(
AA(
"aux_parseevent"),0));
1166 IntegerIncrement(
AA(
"aux_parsetrans"));
1167 IntegerAssign(statevar,
TargetExpression(CintarrayAccess(gentrans,
AA(
"aux_parsetrans"))));
1193 Comment(
"************************************************");
1194 Comment(
"* operate timers *");
1197 std::map< int , TimerAction> casedata;
1198 std::set< std::set< int > > casesets;
1205 casedata[tev]= eit->second;
1207 ConsolidateCaseSets<TimerAction>(casedata,casesets);
1209 IfTrue(IntegerIsGreater(
AA(
"exec_event"),0));
1211 SwitchBegin(
AA(
"exec_event"));
1213 std::set< std::set< int > >::iterator cit;
1214 for(cit=casesets.begin(); cit!=casesets.end(); ++cit) {
1215 SwitchCases(
AA(
"exec_event"),*cit);
1217 std::set< std::string >::iterator ait;
1220 TimerStop(
AA(*ait));
1226 FCG_ERR(
"CodePrimitives: internal error on timer records -- sorry");
1228 TimerReset(
AA(*ait),tit->second.mInitialValue);
1232 TimerStart(
AA(*ait));
1244 Comment(
"************************************************");
1245 Comment(
"* operate outputs *");
1251 SwitchBegin(
AA(
"exec_event"));
1253 const std::vector<AttributeCodeGeneratorEvent::OutputAction>& actions =
mAlphabet.Attribute(*eit).mActions;
1254 if(actions.size()==0)
continue;
1257 for(
size_t i=0; i<actions.size(); i++) {
1258 if(actions[i].mSet) RunActionSet(actions[i].mAddress);
1259 if(actions[i].mClr) RunActionClr(actions[i].mAddress);
1260 if(actions[i].mExe) RunActionExe(
AX(actions[i].mAddress));
1275 Comment(
"************************************************");
1276 Comment(
"* end execution loop *");
1287 Comment(
"************************************************");
1288 Comment(
"* append code snippet from configuration *");
1297 FD_DCG(
"CodePrimitives(" <<
this <<
")::DoGenerateDeclarations()");
1298 Comment(
"************************************************");
1299 Comment(
"* declaration of variables and constants *");
1317 FD_DCG(
"CodePrimitives(" <<
this <<
")::DoGenerateResetCode()");
1318 Comment(
"************************************************");
1319 Comment(
"* executor core cyclic code: reset/initialise *");
1320 Comment(
"************************************************");
1329 FD_DCG(
"CodePrimitives(" <<
this <<
")::DoGenerateCyclicCode()");
1330 Comment(
"************************************************");
1331 Comment(
"* executor core cyclic code: begin *");
1332 Comment(
"************************************************");
1345 Comment(
"************************************************");
1346 Comment(
"* executor core cyclic code: end *");
1347 Comment(
"************************************************");
1386 FCG_ERR(
"CodePrimitives::VariableDeclare(): not implemented");
1394 FCG_ERR(
"CodePrimitives::VariableDeclare(): not implemented");
1398 void CodePrimitives::IntegerDecrement(
const AA& address,
int val) {
1399 IntegerIncrement(address,-val);
1406 FCG_ERR(
"CodePrimitives::Integer(): maths not available");
1412 FCG_ERR(
"CodePrimitives::Integer(): maths not available");
1417 FCG_ERR(
"CodePrimitives::Integer(): maths not available");
1420 bool CodePrimitives::HasIntmaths(
void) {
1426 FCG_ERR(
"CodePrimitives::Conditionals(): construct not available");
1432 FCG_ERR(
"CodePrimitives::Conditionals(): construct not available");
1438 FCG_ERR(
"CodePrimitives::Conditionals(): construct not available");
1444 FCG_ERR(
"CodePrimitives::Conditionals(): construct not available");
1450 FCG_ERR(
"CodePrimitives::Conditionals(): construct not available");
1456 FCG_ERR(
"CodePrimitives::Conditionals(): construct not available");
1462 void CodePrimitives::WordDeclare(
const AA& address) {
1464 FCG_ERR(
"CodePrimitives::Word(): word-of-bits type not available");
1466 void CodePrimitives::WordDeclare(
const AA& address,
word_t val) {
1469 FCG_ERR(
"CodePrimitives::Word(): word-of-bits type not available");
1471 void CodePrimitives::WordAssign(
const AA& address,
word_t val) {
1474 FCG_ERR(
"CodePrimitives::Word(): word-of-bits type not available");
1476 void CodePrimitives::WordAssign(
const AA& address,
const AX& expression) {
1479 FCG_ERR(
"CodePrimitives::Word(): word-of-bits type not available");
1481 void CodePrimitives::WordOr(
const AA& address,
word_t val) {
1484 FCG_ERR(
"CodePrimitives::Word(): word-of-bits type not available");
1486 void CodePrimitives::WordOr(
const AA& address,
const AX& expression) {
1489 FCG_ERR(
"CodePrimitives::Word(): word-of-bits type not available");
1491 void CodePrimitives::WordOr(
const AA& address,
const AA& op1,
const AA& op2) {
1495 FCG_ERR(
"CodePrimitives::Word(): word-of-bits type not available");
1497 void CodePrimitives::WordOr(
const AA& address,
const AA& op1,
word_t op2) {
1501 FCG_ERR(
"CodePrimitives::Word(): word-of-bits type not available");
1503 void CodePrimitives::WordAnd(
const AA& address,
word_t val) {
1506 FCG_ERR(
"CodePrimitives::Word(): word-of-bits type not available");
1508 void CodePrimitives::WordAnd(
const AA& address,
const AX& expression) {
1511 FCG_ERR(
"CodePrimitives::Word(): word-of-bits type not available");
1513 void CodePrimitives::WordAnd(
const AA& address,
const AA& op1,
const AA& op2) {
1517 FCG_ERR(
"CodePrimitives::Word(): word-of-bits type not available");
1519 void CodePrimitives::WordAnd(
const AA& address,
const AA& op1,
word_t op2) {
1523 FCG_ERR(
"CodePrimitives::Word(): word-of-bits type not available");
1525 void CodePrimitives::WordNand(
const AA& address,
const AX& expression) {
1528 FCG_ERR(
"CodePrimitives::Word(): word-of-bits type not available");
1533 FCG_ERR(
"CodePrimitives::Conditionals(): construct not available");
1539 FCG_ERR(
"CodePrimitives::Conditionals(): construct not available");
1545 FCG_ERR(
"CodePrimitives::Conditionals(): construct not available");
1551 FCG_ERR(
"CodePrimitives::Conditionals(): construct not available");
1557 FCG_ERR(
"CodePrimitives::Conditionals(): construct not available");
1562 FCG_ERR(
"CodePrimitives::Word(): word-of-bits type not available");
1568 void CodePrimitives::BooleanDeclare(
const AA& address) {
1569 IntegerDeclare(address);
1571 void CodePrimitives::BooleanDeclare(
const AA& address,
int val) {
1572 IntegerDeclare(address,val ? 1 : 0);
1574 void CodePrimitives::BooleanAssign(
const AA& address,
const AX& expression) {
1575 IntegerAssign(address,expression);
1577 void CodePrimitives::BooleanAssign(
const AA& address,
int val) {
1578 IntegerAssign(address, val ? 1 : 0);
1592 void CodePrimitives::CintarrayDeclare(
const AA& address,
int offset,
const std::vector<int>& val) {
1596 FCG_ERR(
"CodePrimitives::Cintarray(): constant-int-arrays not defined");
1601 FCG_ERR(
"CodePrimitives::Cintarray(): constant-int-arrays not defined");
1607 FCG_ERR(
"CodePrimitives::Cintarray(): constant-int-arrays not defined");
1610 bool CodePrimitives::HasCintarray(
void) {
1615 void CodePrimitives::CwordarrayDeclare(
const AA& address,
int offset,
const std::vector<word_t>& val) {
1619 FCG_ERR(
"CodePrimitives::Cwordarray(): constant-word-arrays not defined");
1624 FCG_ERR(
"CodePrimitives::Cwordarray(): constant-word-arrays not defined");
1630 FCG_ERR(
"CodePrimitives::Cwordarray(): constant-word-arrays not defined");
1633 bool CodePrimitives::HasCwordarray(
void) {
1639 void CodePrimitives::WordarrayDeclare(
const AA& address,
int offset,
int len) {
1643 FCG_ERR(
"CodePrimitives::Wordarray(): word-arrays not available");
1645 void CodePrimitives::WordarrayDeclare(
const AA& address,
int offset,
const std::vector<word_t>& val) {
1649 FCG_ERR(
"CodePrimitives::Wordarray(): word-arrays not available");
1654 FCG_ERR(
"CodePrimitives::Wordarray(): word-arrays not available");
1660 FCG_ERR(
"CodePrimitives::Wordarray(): word-arrays not available");
1663 bool CodePrimitives::HasWordarray(
void) {
1673 FCG_ERR(
"CodePrimitives::Intarray(): int-arrays not available");
1679 FCG_ERR(
"CodePrimitives::Intarray(): int-arrays not available");
1684 FCG_ERR(
"CodePrimitives::Intarray(): int-arrays not available");
1690 FCG_ERR(
"CodePrimitives::Intarray(): int-arrays not available");
1700 FCG_ERR(
"CodePrimitives::Cstrarray(): constant-str-arrays not defined");
1703 void CodePrimitives::CstrarrayDeclare(
const AA& address,
int offset,
const std::vector<std::string>& val) {
1707 FCG_ERR(
"CodePrimitives::Cstrarray(): constant-str-arrays not defined");
1712 FCG_ERR(
"CodePrimitives::Cstrarray(): constant-str-arrays not defined");
1718 FCG_ERR(
"CodePrimitives::Cstrarray(): constant-str-arrays not defined");
1721 bool CodePrimitives::HasCstrarray(
void) {
1727 void CodePrimitives::BitarrayDeclare(
const AA& address,
int blen) {
1732 WordarrayDeclare(address, 0, wlen);
1736 for(
int i=0; i<wlen; i++) {
1737 AA baddr= address.Sub(i);
1743 newbitarray.
blen= blen;
1748 void CodePrimitives::BitarrayDeclare(
const AA& address,
const std::vector<bool>& val) {
1750 int blen = (int) val.size();
1758 for(
int i=0; i<wlen; i++) {
1759 AA baddr = address.Sub(i);
1765 newbitarray.
blen= blen;
1766 newbitarray.
value= val;
1771 void CodePrimitives::BitarrayAssign(
const AA& address,
const std::vector<bool>& val) {
1776 for(
int i=0; i<wlen; ++i) {
1779 else waddr = address.Sub(i);
1781 WordAssign(waddr,wval);
1786 void CodePrimitives::BitarrayAssign(
const AA& address,
const AA& otherarray) {
1792 FCG_ERR(
"CodePrimitives(): BitarrayAssign(): internal error");
1795 for(
int i=0; i<wlen; ++i) {
1798 else waddr = address.Sub(i);
1801 else oaddr = address.Sub(i);
1807 void CodePrimitives::BitarrayClear(
const AA& address){
1812 for(
int i=0; i<wlen; i++) {
1815 else waddr = address.Sub(i);
1816 WordAssign(waddr, 0x0UL);
1821 void CodePrimitives::BitarrayFull(
const AA& address){
1825 int bllen = blen - (wlen-1) *
mWordSize;
1827 for(
int i=0; i<wlen; i++) {
1830 else waddr = address.Sub(i);
1832 if(i==wlen-1) val= (1ULL<<bllen)-1;
1833 WordAssign(waddr, val);
1838 void CodePrimitives::BitarrayOrAllWords(
const AA& address,
const AA& result) {
1842 int bllen = blen - (wlen-1) *
mWordSize;
1847 else waddr = address.Sub(0);
1852 for(
int i=0; i<wlen; i++) {
1855 else waddr = address.Sub(i);
1856 if(i==wlen-1) WordAnd(waddr,WordConstant((1ULL<<bllen)-1));
1863 void CodePrimitives::BitarraySetBit(
const AA& address,
int index){
1870 else waddr = address.Sub(windex);
1871 WordOr(waddr,WordConstant( 1UL << bindex));
1875 void CodePrimitives::BitarraySetBit(
const AA& address,
const AA& indexaddr,
int offset,
const std::vector<bool>& hint){
1879 bool gotaddress=
false;
1883 IntegerDecrement(
AA(
"aux_bitaddr"));
1884 IntegerAssign(
AA(
"aux_wordaddr"),
TargetExpression(CintarrayAccess(
AA(
"wordaddr_vector"),
AA(
"aux_bitaddr"))));
1885 IntegerAssign(
AA(
"aux_bitmask"),
TargetExpression(CwordarrayAccess(
AA(
"bitmask_vector"),
AA(
"aux_bitaddr"))));
1891 IntegerDecrement(
AA(
"aux_bitaddr"),offset);
1900 IntegerDecrement(
AA(
"aux_bitaddr"),offset);
1901 IntegerAssign(
AA(
"aux_bitmask"),
TargetExpression(CwordarrayAccess(
AA(
"bitmask_vector"),
AA(
"aux_bitaddr"))));
1907 IntegerDecrement(
AA(
"aux_bitaddr"),offset);
1919 if(gotaddress && (wlen > 1)) {
1920 SwitchBegin(
AA(
"aux_wordaddr"));
1921 for(
int i=0; i<wlen; i++) {
1924 SwitchCase(
AA(
"aux_wordadd"),i);
1925 AA waddr = address.Sub(i);
1933 if(gotaddress && (wlen == 1)) {
1934 AA waddr = address.Sub(0);
1939 SwitchBegin(indexaddr);
1941 for(baddr=0;baddr<blen;baddr++) {
1945 SwitchCase(indexaddr,baddr+offset);
1946 BitarraySetBit(address,baddr);
1953 void CodePrimitives::BitarrayIsBitSet(
const AA& address,
const AA& indexaddr,
const AA& result,
int offset,
const std::vector<bool>& hint){
1957 bool gotaddress=
false;
1961 IntegerDecrement(
AA(
"aux_bitaddr"),offset);
1962 IntegerAssign(
AA(
"aux_wordaddr"),
TargetExpression(CintarrayAccess(
AA(
"wordaddr_vector"),
AA(
"aux_bitaddr"))));
1963 IntegerAssign(
AA(
"aux_bitmask"),
TargetExpression(CwordarrayAccess(
AA(
"bitmask_vector"),
AA(
"aux_bitaddr"))));
1969 IntegerDecrement(
AA(
"aux_bitaddr"),offset);
1978 IntegerDecrement(
AA(
"aux_bitaddr"),offset);
1979 IntegerAssign(
AA(
"aux_bitmask"),
TargetExpression(CwordarrayAccess(
AA(
"bitmask_vector"),
AA(
"aux_bitaddr"))));
1985 IntegerDecrement(
AA(
"aux_bitaddr"),offset);
1993 WordAnd(result,WordarrayAccess(address,
AA(
"aux_wordaddr")),
AA(
"aux_bitmask"));
1996 if(gotaddress && (wlen > 1)) {
1997 SwitchBegin(
AA(
"aux_wordaddr"));
1998 for(
int i=0; i<wlen; i++) {
2001 SwitchCase(
AA(
"aux_wordadd"),i);
2002 AA waddr = address.Sub(i);
2003 WordAnd(result,waddr,
AA(
"aux_bitmask"));
2010 if(gotaddress && (wlen == 1)) {
2011 AA waddr = address.Sub(0);
2012 WordAnd(result,waddr,
AA(
"aux_bitmask"));
2016 FCG_ERR(
"CodePrimitives::Bitarray(): BitAddressArithmetic or ArrayForBitmasks required for test by variable");
2020 void CodePrimitives::BitarrayClrBit(
const AA& address,
int index){
2027 else waddr = address.Sub(windex);
2028 WordNand(waddr,WordConstant( 1UL << bindex));
2032 void CodePrimitives::BitarrayClrBit(
const AA& address,
const AA& indexaddr,
int offset,
const std::vector<bool>& hint){
2036 bool gotaddress=
false;
2040 IntegerDecrement(
AA(
"aux_bitaddr"),offset);
2041 IntegerAssign(
AA(
"aux_wordaddr"),
TargetExpression(CintarrayAccess(
AA(
"wordaddr_vector"),
AA(
"aux_bitaddr"))));
2042 IntegerAssign(
AA(
"aux_bitmask"),
TargetExpression(CwordarrayAccess(
AA(
"bitmask_vector"),
AA(
"aux_bitaddr"))));
2048 IntegerDecrement(
AA(
"aux_bitaddr"),offset);
2057 IntegerDecrement(
AA(
"aux_bitaddr"),offset);
2058 IntegerAssign(
AA(
"aux_bitmask"),
TargetExpression(CwordarrayAccess(
AA(
"bitmask_vector"),
AA(
"aux_bitaddr"))));
2064 IntegerDecrement(
AA(
"aux_bitaddr"),offset);
2076 if(gotaddress && (wlen > 1)) {
2077 SwitchBegin(
AA(
"aux_wordaddr"));
2078 for(
int i=0; i<wlen; i++) {
2081 SwitchCase(
AA(
"aux_wordadd"),i);
2082 AA waddr = address.Sub(i);
2090 if(gotaddress && (wlen == 1)) {
2091 AA waddr = address.Sub(0);
2096 SwitchBegin(indexaddr);
2098 for(baddr=0;baddr<blen;baddr++) {
2102 SwitchCase(indexaddr,baddr+offset);
2103 BitarrayClrBit(address,baddr);
2110 void CodePrimitives::BitarrayOr(
const AA& address,
const std::vector<bool>& val) {
2115 for(
int w=0; w<wlen; ++w) {
2117 if(wval==0)
continue;
2120 else waddr = address.Sub(w);
2127 void CodePrimitives::BitarrayOr(
const AA& address,
const AA &op1,
const std::vector<bool>& op2) {
2132 for(
int w=0; w<wlen; ++w) {
2137 else waddr = address.Sub(w);
2139 else wop1 = op1.Sub(w);
2141 WordOr(waddr,wop1,wval);
2148 void CodePrimitives::BitarrayAnd(
const AA& address,
const std::vector<bool>& val) {
2153 for(
int w=0; w<wlen; ++w) {
2155 if(wval== (1UL <<
mWordSize) - 1)
continue;
2158 else waddr = address.Sub(w);
2159 WordAnd(waddr,wval);
2164 void CodePrimitives::BitarrayAnd(
const AA& address,
const AA& otherarray) {
2169 for(
int w=0; w<wlen; ++w) {
2172 else waddr = address.Sub(w);
2175 else oaddr = otherarray.Sub(w);
2181 void CodePrimitives::BitarrayAnd(
const AA& address,
const AA &op1,
const std::vector<bool>& op2) {
2186 for(
int w=0; w<wlen; ++w) {
2191 else waddr = address.Sub(w);
2193 else wop1 = op1.Sub(w);
2195 WordAnd(waddr,wop1,wval);
2202 void CodePrimitives::BitarrayAnd(
const AA& address,
const AA& op1,
const AA& op2) {
2207 for(
int w=0; w<wlen; ++w) {
2210 else waddr = address.Sub(w);
2213 else op1addr = op1.Sub(w);
2216 else op2addr = op2.Sub(w);
2217 WordAnd(waddr,op1addr,op2addr);
2222 void CodePrimitives::BitarrayFindFirst(
const AA& address,
const AA& result,
int offset) {
2224 IntegerAssign(result,offset-1);
2231 else waddr = address.Sub(w);
2235 IfTrue(IntegerIsEq(result,offset-1));
2239 IfTrue(WordIsNotEq(waddr,0));
2243 IntegerAssign(result,w*
mWordSize+offset);
2244 for(;ifcnt>0;--ifcnt) IfEnd();
2250 int index=w*mWordSize + b;
2251 if(index>=blen)
break;
2253 IfTrue(WordIsBitSet(waddr,b));
2256 IfElseIfTrue(WordIsBitSet(waddr,b));
2258 IntegerAssign(result,index+offset);
2265 if(bleft>wsize) bleft=wsize;
2266 while(wsize/2>=bleft) wsize=wsize/2;
2270 while(size<=wsize) {
2272 if(!(pos<bleft))
break;
2276 while(pos+size/2>=bleft) size=size/2;
2281 if(hl && (size>2)) {
2282 word_t ltest= (1UL << size/2) -1;
2284 IfTrue(WordIsMaskSet(waddr,ltest));
2290 if(hl && (size==2)) {
2291 IfTrue(WordIsMaskSet(waddr,(1UL << pos)));
2292 IntegerAssign(result, w*mWordSize + pos + offset);
2294 IntegerAssign(result,w*mWordSize + pos + 1 + offset);
2301 if(hl && (size==1)) {
2302 IntegerAssign(result, w*mWordSize + pos + offset);
2308 if((!hl) && ((pos % size) == 0)) {
2312 if(pos<bleft) IfElse();
2316 if((!hl) && ((pos % size) != 0)) {
2325 for(;ifcnt>0;--ifcnt)
2332 void CodePrimitives::EventSetDeclare(
const AA& address) {
2337 void CodePrimitives::EventSetDeclare(
const AA& address,
const EventSet& evset) {
2339 BitarrayDeclare(address,evmask);
2343 void CodePrimitives::EventSetClear(
const AA& address) {
2344 BitarrayClear(address);
2348 void CodePrimitives::EventSetFull(
const AA& address) {
2349 BitarrayFull(address);
2353 void CodePrimitives::EventSetIsNotEmpty(
const AA& address,
const AA& result) {
2354 BitarrayOrAllWords(address,result);
2358 void CodePrimitives::EventSetAssign(
const AA& address,
const EventSet& evset) {
2360 BitarrayAssign(address,evmask);
2364 void CodePrimitives::EventSetInsert(
const AA& address,
const EventSet& evset) {
2366 BitarrayOr(address,evmask);
2370 void CodePrimitives::EventSetInsert(
const AA& address,
const AA& evaddrexpr) {
2371 BitarraySetBit(address,evaddrexpr,1);
2375 void CodePrimitives::EventSetInsert(
const AA& address,
const AA& evaddrexpr,
const EventSet& hint) {
2377 BitarraySetBit(address,evaddrexpr,1,evmask);
2381 void CodePrimitives::EventSetInsert(
const AA& address, Idx ev) {
2386 void CodePrimitives::EventSetErase(
const AA& address,
const EventSet& evset) {
2388 for(
size_t i=0; i<evmask.size(); i++) evmask[i]= ! evmask[i];
2389 BitarrayAnd(address,evmask);
2393 void CodePrimitives::EventSetErase(
const AA& address, Idx ev) {
2398 void CodePrimitives::EventSetErase(
const AA& address,
const AA& evaddr) {
2399 BitarrayClrBit(address,evaddr,1);
2403 void CodePrimitives::EventSetExists(
const AA& address,
const AA& evaddr,
const AA& result,
const EventSet& hint) {
2405 BitarrayIsBitSet(address,evaddr,result,1,evmask);
2409 void CodePrimitives::EventSetErase(
const AA& address,
const AA& evaddr,
const EventSet& hint) {
2411 BitarrayClrBit(address,evaddr,1,evmask);
2415 void CodePrimitives::EventSetRestrict(
const AA& address,
const AA& otherset) {
2416 BitarrayAnd(address,otherset);
2420 void CodePrimitives::EventSetUnion(
const AA& address,
const AA& op1,
const EventSet& op2) {
2422 BitarrayOr(address,op1,evmask);
2426 void CodePrimitives::EventSetIntersection(
const AA& address,
const AA& op1,
const EventSet& op2) {
2428 BitarrayAnd(address,op1,evmask);
2432 void CodePrimitives::EventSetFindHighestPriority(
const AA& address,
const AA& result) {
2433 BitarrayFindFirst(address,result,1);
2439 void CodePrimitives::IfTrue(
const AX& expression) {
2441 FCG_ERR(
"CodePrimitives::Conditionals(): construct not available");
2444 void CodePrimitives::IfFalse(
const AX& expression) {
2446 FCG_ERR(
"CodePrimitives::Conditionals(): construct not available");
2449 void CodePrimitives::IfWord(
const AX& expression) {
2451 FCG_ERR(
"CodePrimitives::Conditionals(): construct not available");
2453 void CodePrimitives::IfElse(
void) {
2454 FCG_ERR(
"CodePrimitives::Conditionals(): construct not available");
2457 void CodePrimitives::IfElseIfTrue(
const AX& expression) {
2459 FCG_ERR(
"CodePrimitives::Conditionals(): construct not available");
2461 void CodePrimitives::IfEnd(
void) {
2462 FCG_ERR(
"CodePrimitives::Conditionals(): construct not available");
2464 void CodePrimitives::LoopBegin(
void) {
2465 FCG_ERR(
"CodePrimitives::Loops(): construct not available");
2467 void CodePrimitives::LoopBreak(
const AX& expression) {
2469 FCG_ERR(
"CodePrimitives::Loops(): construct not available");
2471 void CodePrimitives::LoopEnd(
void) {
2472 FCG_ERR(
"CodePrimitives::Loops(): construct not available");
2474 void CodePrimitives::FunctionReturn(
void) {
2475 FCG_ERR(
"CodePrimitives::FunctionReturn(): construct not available");
2479 void CodePrimitives::SwitchBegin(
const AA& address){
2481 FCG_ERR(
"CodePrimitives::Conditionals(): switch not available");
2483 void CodePrimitives::SwitchCase(
const AA& address,
int val){
2486 FCG_ERR(
"CodePrimitives::Conditionals(): switch not available");
2488 void CodePrimitives::SwitchCases(
const AA& address,
int from,
int to){
2492 FCG_ERR(
"CodePrimitives::Conditionals(): switch not available");
2494 void CodePrimitives::SwitchCases(
const AA& address,
const std::set< int > & vals){
2497 FCG_ERR(
"CodePrimitives::Conditionals(): switch not available");
2499 void CodePrimitives::SwitchBreak(
void){
2500 FCG_ERR(
"CodePrimitives::Conditionals(): switch not available");
2502 void CodePrimitives::SwitchEnd(
void){
2503 FCG_ERR(
"CodePrimitives::Conditionals(): switch not available");
2505 bool CodePrimitives::HasMultiCase(
void){
2511 void CodePrimitives::RunActionSet(
const std::string& address) {
2513 FCG_ERR(
"CodePrimitives::RunAction(): action not available");
2515 void CodePrimitives::RunActionClr(
const std::string& address) {
2517 FCG_ERR(
"CodePrimitives::RunAction(): action not available");
2519 void CodePrimitives::RunActionExe(
const AX& expression) {
2521 FCG_ERR(
"CodePrimitives::RunAction(): action not available");
2530 return AX(expression);
2535 void CodePrimitives::TimerDeclare(
const AA& address,
const std::string &litval) {
2538 FCG_ERR(
"CodePrimitives::Timer(): not available");
2540 void CodePrimitives::TimerStart(
const AA& address) {
2542 FCG_ERR(
"CodePrimitives::Timer(): not available");
2544 void CodePrimitives::TimerStop(
const AA& address) {
2546 FCG_ERR(
"CodePrimitives::Timer(): not available");
2548 void CodePrimitives::TimerReset(
const AA& address,
const std::string &litval) {
2551 FCG_ERR(
"CodePrimitives::Timer(): not available");
2555 FCG_ERR(
"CodePrimitives::Timer(): not available");
std::string mWordType
target data type for word
bool mLoopEnabledOutputs
code option: loop until all enabled outputs are executed
virtual void DeclareRecentEvent(void)
Declare "recent_event".
std::map< std::string, TimerAction >::iterator TimerActionIterator
Access to timer records by iterator.
TimerActionIterator TimerActionsEnd()
Access to timer records by iterator.
std::map< std::string, FlagExpression >::iterator FlagIterator
Access to flag records by iterator.
std::vector< std::map< Idx, int > > mStateVectorAddress
mapping from faudes state idx to vector index
virtual bool HasIntarray(void)
default int-array: not supported
virtual void DeclareTimers(void)
Use target implementation to declare timers, typically "timer_run_*" and "timer_cnt_*".
Code-generation common base.
TimerIterator TimersEnd()
Access to timer records by iterator.
virtual void DeclareReset(void)
Declare "reset".
virtual void DoWriteTargetConfiguration(TokenWriter &rTw) const
re-implement token i/o for extra configuration
bool mBitAddressArithmetic
code option: compute bit and word address on target
virtual void OperateOutputs(void)
Operate output lines w.r.t. "exec_event".
virtual void InsertExecHooks(void)
Helper to insert target code for execution hooks.
Compiled record per event on how it affects timers.
std::vector< bool > mUsingVectorAddressStates
configuration of state indexing per generator
LineIterator LinesEnd()
Access to line records by iterator.
virtual void UpdateEnabled(void)
Update "enabled_events" from "parallel_state" if "exec_event" was set.
virtual AA IntarrayAccess(const AA &address, int index)
default int-array: not supported
virtual void DeclareSmallCarray(void)
Declare bit-mask loop-ups.
virtual void BeginExecutionLoop(void)
Execution Loop, begin.
virtual void DoReadTargetConfiguration(TokenReader &rTr)
re-implement token i/o for extra configuration
std::string mIntegerType
target data type for integer
virtual int StateTargetIdx(size_t git, Idx idx)
Overload base class to use the vector address only if the respective code option is active) ...
EventSet mUsedEvents
configured events that are referred to by some generator
virtual void DoReadTargetConfiguration(TokenReader &rTr)
Reads global configuration from TokenReader, excl.
virtual void IndentDec()
Indentation (convenience support for derived classes)
Abstract expression; see also Absstract_Addresses.
word_t WordFromBitVector(const std::vector< bool > &vect, int wordindex)
Extract individual word from boolean vector.
virtual void DoGenerateDeclarations(void)
cut-and-paste template for code snippet assembly
virtual void DeclareStatus(void)
Declare "status".
std::map< std::string, LineAddress >::iterator LineIterator
Access to line records by iterator.
virtual void DeclareLoopState(void)
Declare loop state, i.e. line levels, loop flag.
std::vector< word_t > WordVectorFromBitVector(const std::vector< bool > &vect)
Convert boolean vector to word array.
std::set< std::string > mTimerResets
timers to reset
virtual void DoCompile(void)
virtual hook to input parameter compilation
virtual void Clear(void)
Clear all data.
virtual void LiteralAppend(void)
Cosmetic: append literally from configuration.
const TimedGenerator & At(int i) const
Direct access for read-only access of generators.
std::map< std::string, TimerConfiguration > mTimers
timer definitions
std::string mStateUpdateHook
code option: state change hook
std::string mLiteralAppend
extra code to prepend
std::string EventName(Idx index) const
Faudes-event name lookup.
EventSet mInternalEvents
used events that are configured as internal events (excl.
bool mEventNameLookup
code option: event name lookup
virtual void ExecuteEventBySwitching(void)
Alternative implementation of ExecuteEvent()
virtual void IntarrayDeclare(const AA &address, int offset, int len)
default int-array: not supported
virtual Idx StateFaudesIdx(size_t git, int idx)
Get faudes state index (refer to vector representation as default, overload in CodePrimitives) ...
virtual int EventTargetIdx(Idx idx)
Get target event Idx from faudes Idx (use bit-address + 1)
bool mExistStateNames
record whether there exist statenames at all
virtual void Comment(const std::string &text)
Target comments (see EmbeddedcCodeGenerator for consistent reimplementation pattern) ...
std::map< std::string, bitarray_rec > mBitarrays
Record of all declared bit-arrays.
bool mArrayForBitarray
code option: use const array to represent bit-masks
virtual ~CodePrimitives(void)
Explicit destructor.
virtual void OperateTimers(void)
Start/stop/reset timers w.r.t. "exec_event".
int EventBitMaskSize(void)
Get overall number of events.
LineIterator LinesBegin()
Access to line records by iterator.
const cgEventSet & Alphabet(void) const
Access alphabet (incl event attributes)
EventSet mOutputEvents
used events that are configured as outputs
Idx Size(void) const
Number of generators.
virtual void DoGenerate(void)
cut-and-paste template for code snippet assembly
int mLastOutputEvent
highest bit-address with output event (-1 for none)
bool mLoopPendingInputs
code option: loop until all inputs are resolved
bool mArrayForState
code option: use int arrays to represent that overall state
bool mArrayForBitmasks
code option: use const array to represent bit-masks
std::vector< std::vector< int > > mTransitionVector
compiled transition-sets, represented as vectors of integers with 0 as separator
virtual void DeclareAux(void)
Declare variables local to the provided snippets, e.g. helpers for bit-mask computation.
std::vector< int > mWordAddressVector
Look-up table to map a bit-address to the word-index.
Idx EventIndex(const std::string &rName) const
Faudes-event index lookup.
virtual void DeclareLargeCarray(void)
Declare compiled transition relations.
std::vector< bool > value
initialisation value
Abstract address; see also Absstract_Addresses.
virtual void DeclareEventNameLookup(void)
Declare symbolic name lookup tables.
std::map< std::string, TimerAction > mTimerActions
timer actions by event name
std::string mPrefix
universal prefix (pseudo name space)
virtual void DoCompile(void)
virtual hook to extend compiled data
virtual std::ostream & Output(void)
Output stream.
virtual std::string TargetSymbol(const std::string &str)
Mangle string to valid target symbol.
virtual void ExecuteEventByInterpreter(void)
Alternative implementation of ExecuteEventBy()
virtual void SenseInputs(void)
Sense input events and add to "pending_events".
virtual void ScheduleEvent(void)
Select event to execute from "pending_and_enabled_events" or "enabled_events".
bool mEventsetsForPerformance
code option: eventsets for performance
int mWordSize
compressed boolean capacity of target type word
virtual void ExecuteEvent(void)
Take transition and figure new state.
virtual void EndExecutionLoop(void)
Loop end.
virtual void Clear(void)
Clear all data.
virtual void ResetReturn(void)
Reset bail out.
int mLastInputEvent
highest bit-address with input (or timer) event (-1 for none)
unsigned long word_t
Code-generator internal data type of target words.
CodePrimitives(void)
Constructor.
bool mMaintainStateIndices
code option: use state indices as provided
std::vector< bool > mHasStateNames
record per generator whether there is a lookup table
virtual void ResetState(void)
Reset state.
std::vector< bool > EventBitMask(Idx idx)
Get vector representation for a single faudes event Idx.
bool mStrictEventSynchronisation
code option: strict event synchronisation
TimerIterator TimersBegin()
Access to timer records by iterator.
bool mBisectionForBitfind
code option: use bisection to fing lowest set bit
virtual void Comment(const std::string &text)
Write a comment (reimplement in derived classes, call base)
virtual void LineFeed(int lines=1)
LineFeed (convenience support for derived classes)
virtual void VariableDeclare(const std::string &laddr, const std::string <ype)
declaration template (optional to facilitate declaration constructs)
virtual void DoGenerateCyclicCode(void)
cut-and-paste template for code snippet assembly
Record declared bit-arrays.
cgEventSet mAlphabet
event configuration by attributes
virtual void DeclarePendingEvents(void)
Declare "pending_events" and "enabled_events".
virtual void UpdateEnabledByInterpreter(void)
Alternative implementations UpdateEnabled()
std::string mEventExecutionHook
code option: event exec hook
Idx EventFaudesIdx(int idx)
Get faudes Idx from target Idx (aka from bit-address + 1)
FlagIterator FlagsEnd()
Access to flag records by iterator.
int EventBitAddress(Idx idx)
Get event bit-address from faudes Idx (consecutive, starts at 0)
std::string mLiteralPrepend
extra code to prepend
bool mArrayForTransitions
code option: use const array to represent transitions
bool mStateNameLookup
code option: state name lookup
std::set< std::string > mTimerStops
timers to stop
virtual void LiteralPrepend(void)
Cosmetic: prepend literally from configuration data.
TimerActionIterator TimerActionsBegin()
Access to timer records by iterator.
virtual void SenseTimerElapse(void)
Sense timer elapse vents and add to "pending_events".
Code-generator with abstract types and operations.
virtual Idx StateFaudesIdx(size_t git, int idx)
Overload base class to use the vector address only if the respective code option is active) ...
std::map< std::string, TimerConfiguration >::iterator TimerIterator
Access to timer records by iterator.
virtual void IndentInc()
Indentation (convenience support for derived classes)
FlagIterator FlagsBegin()
Access to flag records by iterator.
virtual void DoGenerateResetCode(void)
cut-and-paste template for code snippet assembly
virtual void BreakExecutionLoop(void)
Execution Loop, break.
std::vector< TimedGenerator > mGenerators
list of executors
std::vector< word_t > mBitMaskVector
Look-up table to map a bit-address to the word-bitmask.
virtual void UpdateEnabledBySwitching(void)
Alternative implementations UpdateEnabled()
std::set< std::string > mTimerStarts
timers to start
virtual int StateTargetIdx(size_t git, Idx idx)
Get target state index (refer to vector representation as default, overload in CodePrimitives) ...
virtual void DeclareStateNameLookup(void)
Declare symbolic name lookup tables.
virtual AX TargetExpression(const AA &address)=0
Convert abstract address to target expression of the respective value.
virtual void DeclareParallelState(void)
Declare "parallel_state".
virtual const std::string & Name(void) const
Get objects's name (reimplementing base faudes::Type)
int mIntegerSize
compressed boolean capacity of target type integer
virtual void DoWriteTargetConfiguration(TokenWriter &rTw) const
Write global configuration to TokenWriter, excl.