Skip to content

Commit cfee592

Browse files
AndreasOpenModelica-Hudson
authored andcommitted
[OMSI] Preparing Code generation for C
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]: - OpenModelica/OMCompiler#2948
1 parent ea6c155 commit cfee592

File tree

8 files changed

+2128
-26
lines changed

8 files changed

+2128
-26
lines changed

Compiler/Stubs/SimCodeUtil.mo

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ end getSimCode;
2626

2727
function cref2simvar<A,B>
2828
input A inCref;
29-
input B simCode;
29+
input B inCrefToSimVarHT;
3030
output SimCodeVar.SimVar outSimVar;
3131
algorithm
3232
assert(false, getInstanceName());
@@ -40,13 +40,48 @@ algorithm
4040
assert(false, getInstanceName());
4141
end simVarFromHT;
4242

43+
function localCref2SimVar<A,B>
44+
input A inCref;
45+
input B inCrefToSimVarHT;
46+
output SimCodeVar.SimVar outSimVar;
47+
algorithm
48+
assert(false, getInstanceName());
49+
end localCref2SimVar;
50+
51+
function localCref2Index<A,B>
52+
input A inCref;
53+
input B inOMSIFunction;
54+
output String outIndex;
55+
algorithm
56+
assert(false, getInstanceName());
57+
end localCref2Index;
58+
4359
function codegenExpSanityCheck
4460
input output DAE.Exp e;
4561
input SimCodeFunction.Context context;
4662
algorithm
4763
/* Do nothing */
4864
end codegenExpSanityCheck;
4965

66+
function getValueReference
67+
input SimCodeVar.SimVar inSimVar;
68+
input SimCode.SimCode inSimCode;
69+
input Boolean inElimNegAliases;
70+
output String outValueReference;
71+
algorithm
72+
/* Do nothing */
73+
end getValueReference;
74+
75+
function getLocalValueReference<A>
76+
input SimCodeVar.SimVar inSimVar;
77+
input SimCode.SimCode inSimCode;
78+
input A inCrefToSimVarHT;
79+
input Boolean inElimNegAliases "=false to keep negative alias references";
80+
output String outValueReference;
81+
algorithm
82+
/* Do nothing */
83+
end getLocalValueReference;
84+
5085

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

0 commit comments

Comments
 (0)