Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

Commit

Permalink
[OMSI] Preparing Code generation for C
Browse files Browse the repository at this point in the history
Preparing OpenModelica/OMCompiler master for generating OMSUs with `simCodeTarget=omsic`.

- Compiler/Template/CodegenCFunctions.tpl
  - Use new C data structure for generated code for OMSUs.
  - Added function `crefOMSI` and C basic data types depending on `simCodeTarget`.
- Compiler/Template/CodegenUtil.tpl
  - Added `varKinds` `LOOP_ITERATION()` and `LOOP_SOLVED()`. Those are used for solving algebraic loops.
- Compiler/Template/CodegenUtilSimulation.tpl
  - Added function `template fullPathPrefix(SimCode simCode)` to get `fullPathPrefix` from `SimCode`. Used for generating OMSUs in specified folder.
  - Return `equationIndex` for `SES_ALGEBRAIC_SYSTEM`.
  - Added dump functions for `derivativeMatrix` and `OMSIFunction`.
- Compiler/Template/SimCodeTV.mo
  - Added optional `OMSIData` to `SimCode`
  - Added typeview for new records `OMSIData`, `SES_ALGEBRAIC_SYSTEM`, `DerivativeMatrix`, `OMSI_CONTEXT`, `LOOP_ITERATION`, `LOOP_SOLVED`
  - Added typeview for new functions `getLocalValueReference`, `localCref2SimVar`, crefPrefixPre
- Compiler/Stubs/SimCodeUtil.mo
  - Added `function localCref2SimVar<A,B>`, `function getValueReference`, `function getLocalValueReference<A>`

- Compiler/Template/CodegenOMSIC.tpl
  - Functions for code generation only used for `simCodeTarget=omsic`
- Compiler/Template/CodegenOMSIC_Equations.tpl
  - Mainly functions for code generation for equation code. Used for C and C++
- Compiler/Template/CodegenOMSI_common.tpl
  - Shared template functions, used for `simCodeTarget=omsic` and `simCodeTarget=omsicpp`

Co-authored-by: niklwors <niiklas.worschech@boschrexroth.de>
Co-authored-by: wibraun <wbraun@fh-bielefeld.de>

Belonging to [master]:
  - #2948
  • Loading branch information
AnHeuermann authored and OpenModelica-Hudson committed Mar 7, 2019
1 parent ea6c155 commit cfee592
Show file tree
Hide file tree
Showing 8 changed files with 2,128 additions and 26 deletions.
37 changes: 36 additions & 1 deletion Compiler/Stubs/SimCodeUtil.mo
Expand Up @@ -26,7 +26,7 @@ end getSimCode;

function cref2simvar<A,B>
input A inCref;
input B simCode;
input B inCrefToSimVarHT;
output SimCodeVar.SimVar outSimVar;
algorithm
assert(false, getInstanceName());
Expand All @@ -40,13 +40,48 @@ algorithm
assert(false, getInstanceName());
end simVarFromHT;

function localCref2SimVar<A,B>
input A inCref;
input B inCrefToSimVarHT;
output SimCodeVar.SimVar outSimVar;
algorithm
assert(false, getInstanceName());
end localCref2SimVar;

function localCref2Index<A,B>
input A inCref;
input B inOMSIFunction;
output String outIndex;
algorithm
assert(false, getInstanceName());
end localCref2Index;

function codegenExpSanityCheck
input output DAE.Exp e;
input SimCodeFunction.Context context;
algorithm
/* Do nothing */
end codegenExpSanityCheck;

function getValueReference
input SimCodeVar.SimVar inSimVar;
input SimCode.SimCode inSimCode;
input Boolean inElimNegAliases;
output String outValueReference;
algorithm
/* Do nothing */
end getValueReference;

function getLocalValueReference<A>
input SimCodeVar.SimVar inSimVar;
input SimCode.SimCode inSimCode;
input A inCrefToSimVarHT;
input Boolean inElimNegAliases "=false to keep negative alias references";
output String outValueReference;
algorithm
/* Do nothing */
end getLocalValueReference;


annotation(__OpenModelica_Interface="backend");
end SimCodeUtil;

0 comments on commit cfee592

Please sign in to comment.