CompileDES  3.13
Executable-Code Generation from Synchronised libFAUDES Automata
EmbeddedcCodeGenerator Class Reference

Implementation of code primitives by generic C-code. More...

#include <cgp_embeddedc.h>

Inheritance diagram for EmbeddedcCodeGenerator:
Inheritance graph

Protected Member Functions

void DoCompile (void)
 add my preferences to DoCompile
 
void DoGenerate (void)
 virtual hook for generate
 
virtual void DecrementTimers (void)
 re-implemented/additional code blocks
 
void InsertExecHooks (void)
 Helper to insert target code for execution hooks.
 
virtual std::string TargetAddress (const AA &address)
 abstract address conversion
 
virtual AX TargetExpression (const AA &address)
 abstract address conversion
 
AX IntarrayConstant (int offset, const std::vector< int > &val)
 
AX WordarrayConstant (int offset, const std::vector< word_t > &val)
 
AX StrarrayConstant (int offset, const std::vector< std::string > &val)
 
virtual void DoReadTargetConfiguration (TokenReader &rTr)
 File i/o. More...
 
virtual void DoWriteTargetConfiguration (TokenWriter &rTw) const
 File i/o. More...
 
- Protected Member Functions inherited from CodePrimitives
virtual void DoGenerateDeclarations (void)
 cut-and-paste template for code snippet assembly

 
virtual void DoGenerateResetCode (void)
 cut-and-paste template for code snippet assembly

 
virtual void DoGenerateCyclicCode (void)
 cut-and-paste template for code snippet assembly

 
virtual void LiteralPrepend (void)
 Cosmetic: prepend literally from configuration data.
 
virtual void DeclareStatus (void)
 Declare "status".
 
virtual void DeclareReset (void)
 Declare "reset".
 
virtual void DeclareRecentEvent (void)
 Declare "recent_event".
 
virtual void DeclareParallelState (void)
 Declare "parallel_state".
 
virtual void DeclarePendingEvents (void)
 Declare "pending_events" and "enabled_events".
 
virtual void DeclareLoopState (void)
 Declare loop state, i.e. line levels, loop flag.
 
virtual void DeclareTimers (void)
 Use target implementation to declare timers, typically "timer_run_*" and "timer_cnt_*".
 
virtual void DeclareAux (void)
 Declare variables local to the provided snippets, e.g. helpers for bit-mask computation.
 
virtual void DeclareLargeCarray (void)
 Declare compiled transition relations.
 
virtual void DeclareSmallCarray (void)
 Declare bit-mask loop-ups.
 
virtual void DeclareEventNameLookup (void)
 Declare symbolic name lookup tables.
 
virtual void DeclareStateNameLookup (void)
 Declare symbolic name lookup tables.
 
virtual void ResetState (void)
 Reset state.
 
virtual void ResetReturn (void)
 Reset bail out.
 
virtual void SenseInputs (void)
 Sense input events and add to "pending_events".
 
virtual void SenseTimerElapse (void)
 Sense timer elapse vents and add to "pending_events".
 
virtual void BeginExecutionLoop (void)
 Execution Loop, begin.
 
virtual void UpdateEnabled (void)
 Update "enabled_events" from "parallel_state" if "exec_event" was set.
 
virtual void ScheduleEvent (void)
 Select event to execute from "pending_and_enabled_events" or "enabled_events".
 
virtual void BreakExecutionLoop (void)
 Execution Loop, break.
 
virtual void ExecuteEvent (void)
 Take transition and figure new state.
 
virtual void OperateTimers (void)
 Start/stop/reset timers w.r.t. "exec_event".
 
virtual void OperateOutputs (void)
 Operate output lines w.r.t. "exec_event".
 
virtual void EndExecutionLoop (void)
 Loop end.
 
virtual void LiteralAppend (void)
 Cosmetic: append literally from configuration.
 
virtual void ExecuteEventBySwitching (void)
 Alternative implementation of ExecuteEvent()
 
virtual void ExecuteEventByInterpreter (void)
 Alternative implementation of ExecuteEventBy()
 
virtual void UpdateEnabledBySwitching (void)
 Alternative implementations UpdateEnabled()
 
virtual void UpdateEnabledByInterpreter (void)
 Alternative implementations UpdateEnabled()
 
virtual std::string TargetSymbol (const std::string &str)
 Mangle string to valid target symbol.
 
virtual void IntegerDecrement (const AA &address, int val=1)
 
virtual void BooleanDeclare (const AA &address)
 
virtual void BooleanDeclare (const AA &address, int val)
 
virtual void BooleanAssign (const AA &address, int val)
 
virtual void BooleanAssign (const AA &address, const AX &expression)
 
virtual AX BooleanIsEq (const AA &op1, const AA &op2)
 
virtual AX BooleanIsNotEq (const AA &op1, const AA &op2)
 
virtual void BitarrayDeclare (const AA &address, int blen)
 
virtual void BitarrayDeclare (const AA &address, const std::vector< bool > &val)
 
virtual void BitarrayAssign (const AA &address, const std::vector< bool > &val)
 
virtual void BitarrayAssign (const AA &address, const AA &otherarray)
 
virtual void BitarrayClear (const AA &address)
 
virtual void BitarrayFull (const AA &address)
 
virtual void BitarraySetBit (const AA &address, int bitaddr)
 
virtual void BitarraySetBit (const AA &address, const AA &indexaddr, int offset=0, const std::vector< bool > &hint=std::vector< bool >())
 
virtual void BitarrayClrBit (const AA &address, int bitaddr)
 
virtual void BitarrayClrBit (const AA &address, const AA &indexaddr, int offset=0, const std::vector< bool > &hint=std::vector< bool >())
 
virtual void BitarrayIsBitSet (const AA &address, const AA &indexaddr, const AA &result, int offset=0, const std::vector< bool > &hint=std::vector< bool >())
 
virtual void BitarrayOr (const AA &address, const std::vector< bool > &val)
 
virtual void BitarrayOr (const AA &address, const AA &op1, const std::vector< bool > &op2)
 
virtual void BitarrayOrAllWords (const AA &address, const AA &result)
 
virtual void BitarrayAnd (const AA &address, const std::vector< bool > &val)
 
virtual void BitarrayAnd (const AA &address, const AA &otherarray)
 
virtual void BitarrayAnd (const AA &address, const AA &op1, const AA &op2)
 
virtual void BitarrayAnd (const AA &address, const AA &op1, const std::vector< bool > &op2)
 
virtual void BitarrayFindFirst (const AA &address, const AA &result, int offset=0)
 
virtual void EventSetDeclare (const AA &address)
 
virtual void EventSetDeclare (const AA &address, const EventSet &evset)
 
virtual void EventSetAssign (const AA &address, const EventSet &evset)
 
virtual void EventSetInsert (const AA &address, const EventSet &evset)
 
virtual void EventSetInsert (const AA &address, Idx ev)
 
virtual void EventSetInsert (const AA &address, const AA &evaddr)
 
virtual void EventSetInsert (const AA &address, const AA &evaddr, const EventSet &hint)
 
virtual void EventSetErase (const AA &address, const EventSet &evset)
 
virtual void EventSetErase (const AA &address, Idx ev)
 
virtual void EventSetErase (const AA &address, const AA &evaddr)
 
virtual void EventSetErase (const AA &address, const AA &evaddr, const EventSet &hint)
 
virtual void EventSetExists (const AA &address, const AA &evaddr, const AA &result, const EventSet &hint)
 
virtual void EventSetRestrict (const AA &address, const AA &otherset)
 
virtual void EventSetUnion (const AA &address, const AA &op1, const EventSet &op2)
 
virtual void EventSetIntersection (const AA &address, const AA &op1, const EventSet &op2)
 
virtual void EventSetClear (const AA &address)
 
virtual void EventSetFull (const AA &address)
 
virtual void EventSetIsNotEmpty (const AA &address, const AA &result)
 
virtual void EventSetFindHighestPriority (const AA &address, const AA &result)
 
virtual AX ReadInputLine (const std::string &address)
 
virtual AX InputExpression (const std::string &expression)
 
virtual int StateTargetIdx (size_t git, Idx idx)
 Overload base class to use the vector address only if the respective code option is active)
 
virtual Idx StateFaudesIdx (size_t git, int idx)
 Overload base class to use the vector address only if the respective code option is active)
 
virtual void VariableDeclare (const std::string &laddr, const std::string &ltype)
 declaration template (optional to facilitate declaration constructs)
 
virtual void VariableDeclare (const std::string &laddr, const std::string &ltype, const std::string &lval)
 Overload base class to use the vector address only if the respective code option is active)
 
- Protected Member Functions inherited from CodeGenerator
virtual void DoRead (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 Read the configuration from TokenReader, see faudes Type for public wrappers. More...
 
virtual void DoWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Writes the configuration to TokenWriter, see faudes Type for public wrappers. More...
 

Basic Class Maintenance

 EmbeddedcCodeGenerator (void)
 Constructor.
 
virtual ~EmbeddedcCodeGenerator (void)
 Explicit destructor.
 
virtual void Clear (void)
 Clear all data.
 

Re-Implement Primitives

virtual void Comment (const std::string &text)
 Target comments (see EmbeddedcCodeGenerator for consistent reimplementation pattern)
 
virtual void IntegerDeclare (const AA &address)
 
virtual void IntegerDeclare (const AA &address, int val)
 
virtual void IntegerAssign (const AA &address, int val)
 
virtual void IntegerAssign (const AA &address, const AX &expression)
 
virtual void IntegerIncrement (const AA &address, int val=1)
 
virtual AX IntegerQuotient (const AX &expression, int val)
 
virtual AX IntegerRemainder (const AX &expression, int val)
 
virtual AX IntegerBitmask (const AX &expression)
 
virtual AX IntegerIsEq (const AA &address, int val)
 
virtual AX IntegerIsEq (const AA &address, const AX &expression)
 
virtual AX IntegerIsNotEq (const AA &address, int val)
 
virtual AX IntegerIsNotEq (const AA &address, const AX &expression)
 
virtual AX IntegerIsGreater (const AA &address, int val)
 
virtual AX IntegerIsLess (const AA &address, int val)
 
virtual AX IntegerConstant (int val)
 
virtual bool HasIntmaths (void)
 
virtual void WordDeclare (const AA &address)
 
virtual void WordDeclare (const AA &address, word_t val)
 
virtual void WordAssign (const AA &address, word_t val)
 
virtual void WordAssign (const AA &address, const AX &expression)
 
virtual void WordOr (const AA &address, word_t val)
 
virtual void WordOr (const AA &address, const AX &expression)
 
virtual void WordOr (const AA &address, const AA &op1, const AA &op2)
 
virtual void WordOr (const AA &address, const AA &op1, word_t op2)
 
virtual void WordAnd (const AA &address, word_t val)
 
virtual void WordAnd (const AA &address, const AX &expression)
 
virtual void WordAnd (const AA &address, const AA &op1, const AA &op2)
 
virtual void WordAnd (const AA &address, const AA &op1, word_t op2)
 
virtual void WordNand (const AA &address, const AX &expression)
 
virtual AX WordIsBitSet (const AA &address, int idx)
 
virtual AX WordIsBitClr (const AA &address, int idx)
 
virtual AX WordIsMaskSet (const AA &address, word_t mask)
 
virtual AX WordIsEq (const AA &address, word_t val)
 
virtual AX WordIsNotEq (const AA &address, word_t val)
 
virtual AX WordConstant (word_t val)
 
virtual AX StringConstant (const std::string &val)
 
virtual void CintarrayDeclare (const AA &address, int offset, const std::vector< int > &val)
 
virtual AA CintarrayAccess (const AA &address, int index)
 
virtual AA CintarrayAccess (const AA &address, const AA &indexaddr)
 
virtual bool HasCintarray (void)
 
virtual void CwordarrayDeclare (const AA &address, int offset, const std::vector< word_t > &val)
 
virtual AA CwordarrayAccess (const AA &address, int index)
 
virtual AA CwordarrayAccess (const AA &address, const AA &indexaddr)
 
virtual bool HasCwordarray (void)
 
virtual void CstrarrayDeclare (const AA &address, int offset, const std::vector< std::string > &val)
 
virtual AA CstrarrayAccess (const AA &address, int index)
 
virtual AA CstrarrayAccess (const AA &address, const AA &indexaddr)
 
virtual bool HasCstrarray (void)
 
virtual void IntarrayDeclare (const AA &address, int offset, int len)
 default int-array: not supported
 
virtual void IntarrayDeclare (const AA &address, int offset, const std::vector< int > &val)
 default int-array: not supported
 
virtual AA IntarrayAccess (const AA &address, int index)
 default int-array: not supported
 
virtual AA IntarrayAccess (const AA &address, const AA &indexaddr)
 default int-array: not supported
 
virtual bool HasIntarray (void)
 default int-array: not supported
 
virtual void WordarrayDeclare (const AA &address, int offset, int len)
 
virtual void WordarrayDeclare (const AA &address, int offset, const std::vector< word_t > &val)
 
virtual AA WordarrayAccess (const AA &address, int index)
 
virtual AA WordarrayAccess (const AA &address, const AA &indexaddr)
 
virtual bool HasWordarray (void)
 
virtual void IfTrue (const AX &expression)
 
virtual void IfFalse (const AX &expression)
 
virtual void IfWord (const AX &expression)
 
virtual void IfElse (void)
 
virtual void IfElseIfTrue (const AX &expression)
 
virtual void IfEnd (void)
 
virtual void SwitchBegin (const AA &address)
 
virtual void SwitchCase (const AA &address, int val)
 
virtual void SwitchCases (const AA &address, int from, int to)
 
virtual void SwitchCases (const AA &address, const std::set< int > &vals)
 
virtual void SwitchBreak (void)
 
virtual void SwitchEnd (void)
 
virtual bool HasMultiCase (void)
 
virtual void LoopBegin (void)
 
virtual void LoopBreak (const AX &expression)
 
virtual void LoopEnd (void)
 
virtual void FunctionReturn (void)
 
virtual void RunActionSet (const std::string &address)
 
virtual void RunActionClr (const std::string &address)
 
virtual void RunActionExe (const AX &expression)
 
virtual void TimerDeclare (const AA &address, const std::string &litval)
 
virtual void TimerStart (const AA &address)
 
virtual void TimerStop (const AA &address)
 
virtual void TimerReset (const AA &address, const std::string &litval)
 
virtual AX TimerIsElapsed (const AA &address)
 

Additional Inherited Members

- Public Types inherited from CodeGenerator
enum  OutSink { CONSOLE , FILE , STRING }
 
typedef std::vector< TimedGenerator >::const_iterator Iterator
 Iterator for read-only access of generators.
 
typedef unsigned long word_t
 Code-generator internal data type of target words.
 
typedef std::map< std::string, LineAddress >::iterator LineIterator
 Access to line records by iterator.
 
typedef std::map< std::string, FlagExpression >::iterator FlagIterator
 Access to flag records by iterator.
 
typedef std::map< std::string, TimerConfiguration >::iterator TimerIterator
 Access to timer records by iterator.
 
typedef std::map< std::string, ActionAddress >::iterator ActionAddressIterator
 Access to action record by iterator.
 
typedef std::map< std::string, TimerAction >::iterator TimerActionIterator
 Access to timer records by iterator.
 
- Public Member Functions inherited from CodePrimitives
 CodePrimitives (void)
 Constructor.
 
virtual ~CodePrimitives (void)
 Explicit destructor.
 
- Public Member Functions inherited from CodeGenerator
Idx Size (void) const
 Number of generators.
 
void Insert (const std::string &file)
 Add a Generator from file. More...
 
void Insert (const TimedGenerator &rGen)
 Add a generator by reference. More...
 
const TimedGenerator & At (int i) const
 Direct access for read-only access of generators.
 
Iterator Begin (void) const
 Begin-iterator for read-only access of generators.
 
Iterator End (void) const
 End-iterator for read-only access of generators.
 
virtual int EventTargetIdx (Idx idx)
 Get target event Idx from faudes Idx (use bit-address + 1)
 
virtual int EventTargetIdx (const std::string &ev)
 Get target event Idx from faudes name (use bit-address + 1)
 
int EventBitAddress (Idx idx)
 Get event bit-address from faudes Idx (consecutive, starts at 0)
 
Idx EventFaudesIdx (int idx)
 Get faudes Idx from target Idx (aka from bit-address + 1)
 
std::vector< bool > EventBitMask (Idx idx)
 Get vector representation for a single faudes event Idx.
 
std::vector< bool > EventBitMask (const EventSet &eset)
 Get vector representation for faudes event set.
 
int EventBitMaskSize (void)
 Get overall number of events.
 
word_t WordFromBitVector (const std::vector< bool > &vect, int wordindex)
 Extract individual word from boolean vector.
 
std::vector< word_tWordVectorFromBitVector (const std::vector< bool > &vect)
 Convert boolean vector to word array.
 
LineIterator LinesBegin ()
 Access to line records by iterator.
 
LineIterator LinesEnd ()
 Access to line records by iterator.
 
FlagIterator FlagsBegin ()
 Access to flag records by iterator.
 
FlagIterator FlagsEnd ()
 Access to flag records by iterator.
 
TimerIterator TimersBegin ()
 Access to timer records by iterator.
 
TimerIterator TimersEnd ()
 Access to timer records by iterator.
 
ActionAddressIterator ActionAddressesBegin ()
 Access to action addresses by iterator.
 
ActionAddressIterator ActionAddressesEnd ()
 Access to action addresses by iterator.
 
TimerActionIterator TimerActionsBegin ()
 Access to timer records by iterator.
 
TimerActionIterator TimerActionsEnd ()
 Access to timer records by iterator.
 
 CodeGenerator (void)
 Constructor.
 
virtual ~CodeGenerator (void)
 Destructor.
 
virtual void Name (const std::string &rName)
 Set objects's name (reimplementing base faudes::Type) More...
 
virtual const std::string & Name (void) const
 Get objects's name (reimplementing base faudes::Type) More...
 
virtual void Compile (void)
 Compile input data for alternative representation. More...
 
Idx EventIndex (const std::string &rName) const
 Faudes-event index lookup. More...
 
std::string EventName (Idx index) const
 Faudes-event name lookup. More...
 
const AttributeCodeGeneratorEventEventAttribute (Idx ev) const
 Event configuration attribute lookup. More...
 
void EventAttribute (Idx ev, const AttributeCodeGeneratorEvent &attr)
 Set event attribute. More...
 
void Alphabet (const cgEventSet &rAlphabet)
 Set all event attributes. More...
 
const cgEventSetAlphabet (void) const
 Access alphabet (incl event attributes) More...
 
const std::vector< int > & TransitionVector (size_t git)
 Get target state index (refer to vector representation as default, overload in CodePrimitives)
 
virtual void Generate (void)
 Generate code. More...
 
void Verbose (int level, std::ostream *altout=0)
 Set verbosity level. More...
 
virtual void OutputMode (const std::string &mode)
 Set code output mode. More...
 
std::string OutputMode (void)
 Report code output mode. More...
 
virtual std::ostream & Output (void)
 Output stream. More...
 
const std::string & OutputString (void)
 Get accumulated output as string. More...
 
void OutputString (const std::string &strbuf)
 Set output to string. More...
 
virtual void MuteMode (char mode)
 Set current mute mode. More...
 
virtual void MuteCond (char mode)
 Set mode condition. More...
 
virtual void LineFeed (int lines=1)
 LineFeed (convenience support for derived classes)
 
virtual std::string LineCount (void)
 LineFeed (convenience support for derived classes)
 
virtual void IndentInc ()
 Indentation (convenience support for derived classes)
 
virtual void IndentDec ()
 Indentation (convenience support for derived classes)
 
std::string RecentComment (void)
 Recent muted comment (convenience support for derived classes)
 
virtual void XmlTextEscape (bool on)
 XmlTextEscape (escape "<", ">", "&", "\"" and "'")
 
virtual void XmlCdataEscape (bool on)
 XmlCdataEscape (escape "]]>")
 
virtual void MuteComments (bool on)
 Mute comments (convenience support for derived classes)
 
virtual void MuteVspace (bool on)
 Mute empty lines (convenience support for derived classes)
 
- Static Public Member Functions inherited from CodeGenerator
static std::string VersionString (void)
 Version (refers to macro COMPILEDES_VERSION, defined in cgp_codegenerator.h)
 
static void Register (const std::string &type, CodeGenerator *(*newcg)(void))
 Insert derived class in the registry. More...
 
static std::vector< std::string > Registry (void)
 Access registry contents. More...
 
static CodeGeneratorNew (const std::string &type)
 Instantiate by identifier (returns 0 on unknown class) More...
 
- Public Attributes inherited from CodeGenerator
std::vector< int > mWordAddressVector
 Look-up table to map a bit-address to the word-index.
 
std::vector< word_tmBitMaskVector
 Look-up table to map a bit-address to the word-bitmask.
 
- Protected Attributes inherited from CodePrimitives
std::string mWordType
 target data type for word

 
std::string mIntegerType
 target data type for integer

 
std::string mPrefix
 universal prefix (pseudo name space)
 
bool mArrayForTransitions
 code option: use const array to represent transitions
 
bool mMaintainStateIndices
 code option: use state indices as provided
 
bool mBitAddressArithmetic
 code option: compute bit and word address on target
 
bool mArrayForBitmasks
 code option: use const array to represent bit-masks
 
bool mArrayForBitarray
 code option: use const array to represent bit-masks
 
bool mBisectionForBitfind
 code option: use bisection to fing lowest set bit
 
bool mArrayForState
 code option: use int arrays to represent that overall state
 
bool mEventsetsForPerformance
 code option: eventsets for performance
 
bool mLoopPendingInputs
 code option: loop until all inputs are resolved
 
bool mLoopEnabledOutputs
 code option: loop until all enabled outputs are executed
 
bool mStrictEventSynchronisation
 code option: strict event synchronisation
 
bool mEventNameLookup
 code option: event name lookup
 
bool mStateNameLookup
 code option: state name lookup
 
std::vector< bool > mHasStateNames
 record per generator whether there is a lookup table
 
bool mExistStateNames
 record whether there exist statenames at all
 
std::string mEventExecutionHook
 code option: event exec hook
 
std::string mStateUpdateHook
 code option: state change hook
 
std::string mLiteralPrepend
 extra code to prepend
 
std::string mLiteralAppend
 extra code to prepend
 
std::map< std::string, bitarray_recmBitarrays
 Record of all declared bit-arrays.
 
- Protected Attributes inherited from CodeGenerator
std::string mName
 faudes object name (aka project name)
 
std::vector< TimedGenerator > mGenerators
 list of executors
 
std::vector< std::string > mGeneratorNames
 list of filenames when generator are read from file
 
cgEventSet mAlphabet
 event configuration by attributes
 
int mWordSize
 compressed boolean capacity of target type word
 
int mIntegerSize
 compressed boolean capacity of target type integer
 
std::map< Idx, int > mEventBitAddress
 mapping from faudes event idx to bit address (descending priority, range 0 . More...
 
std::map< int, Idx > mEventFaudesIdx
 mapping from bit address to faudes event idx

 
int mLastInputEvent
 highest bit-address with input (or timer) event (-1 for none)
 
int mLastOutputEvent
 highest bit-address with output event (-1 for none)
 
std::vector< std::map< Idx, int > > mStateVectorAddress
 mapping from faudes state idx to vector index
 
std::vector< std::map< int, Idx > > mStateFaudesIndex
 mapping from vector state idx to faudes index
 
std::vector< bool > mUsingVectorAddressStates
 configuration of state indexing per generator
 
std::vector< std::vector< int > > mTransitionVector
 compiled transition-sets, represented as vectors of integers with 0 as separator
 
EventSet mUsedEvents
 configured events that are referred to by some generator
 
EventSet mOutputEvents
 used events that are configured as outputs
 
EventSet mInputEvents
 used events that are configured as inputs (incl timer)
 
EventSet mInternalEvents
 used events that are configured as internal events (excl. More...
 
std::map< std::string, LineAddressmLines
 input event generation
 
std::map< std::string, FlagExpressionmFlags
 input event generation
 
std::map< std::string, TimerConfigurationmTimers
 timer definitions
 
std::map< std::string, ActionAddressmActionAddresses
 action addresses
 
std::map< std::string, TimerActionmTimerActions
 timer actions by event name
 
int mVerbLevel
 diagnpstic-output level

 
std::string mOutMode
 output file name (base)
 
char mMuteMode
 current output mode
 
bool mMuteComments
 mute comments
 
std::string mRecentMutedComment
 recent muted comment

 
std::ostream * pOutStream
 output stream
 
std::ostream * pErrStream
 error stream
 

Detailed Description

Since the CodePrimitives have been designed with C in mind, the implementation as C-code is straight forward. Regarding top-level code organisation, EmbeddedcCodeGenerator will produce global variable declarations along side with the two functions

void PREFIX_cyclic(void);
void PREFIX_timerdec(int);

where PREFIX is specified by the configuration. The prototypical use-case is to include the generated code in a host C-source with an entry-point main() to periodically invoke PREFIX_cycle() to sense and execute events as well as PREFIX_timerdec(int) to pass on the elapsed physical time. Example

#include <.. time includes ..>
#include "generated_code.c"
int main(void){
[.. time type ..] recent = [.. get system time ..];
while(1) {
PREFIX_cyclic();
[.. time type ..] now = [.. get system time ..];
int elapsed = [.. time op difference ..](now,recent);
recent = now;
PREFIX_timerdec(elapsed);
}
return 0;
}

In particular, time is of an abstract unit in the context of the configuration. The relation to an actual physical unit is established by the conversion of system-time duration to the C-type int for the assignment of elapsed.

For convenience, the configuration options IncludeBefore and IncludeAfter can be used to generate the entire code in one self contained file. See the provided example blink_atm.cgc for a complete example configuration.

Definition at line 71 of file cgp_embeddedc.h.

Member Function Documentation

◆ DoReadTargetConfiguration()

void EmbeddedcCodeGenerator::DoReadTargetConfiguration ( TokenReader &  rTr)
protectedvirtual

Reads global configuration from TokenReader, excl. label

Parameters
rTrTokenReader to read from
Exceptions
Exception
  • token mismatch (id 502)
  • IO error (id 1)

Reimplemented from CodePrimitives.

Reimplemented in KinetisCodeGenerator, and ATmegaCodeGenerator.

Definition at line 55 of file cgp_embeddedc.cpp.

◆ DoWriteTargetConfiguration()

void EmbeddedcCodeGenerator::DoWriteTargetConfiguration ( TokenWriter &  rTw) const
protectedvirtual

Write global configuration to TokenWriter, excl. label

Parameters
rTwReference to TokenWriter
Exceptions
Exception
  • IO errors (id 2)

Reimplemented from CodePrimitives.

Reimplemented in KinetisCodeGenerator, and ATmegaCodeGenerator.

Definition at line 62 of file cgp_embeddedc.cpp.


The documentation for this class was generated from the following files: