CppGenerator.xtend 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. package be.uantwerpen.ansymo.semanticadaptation.cg.cpp.generation
  2. import be.uantwerpen.ansymo.semanticadaptation.generator.SemanticAdaptationGenerator
  3. import org.eclipse.xtext.generator.IFileSystemAccess2
  4. import org.eclipse.xtext.generator.IGeneratorContext
  5. import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.SemanticAdaptation
  6. import org.eclipse.emf.ecore.resource.Resource
  7. import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Adaptation
  8. import java.util.ArrayList
  9. import java.util.LinkedHashMap
  10. import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.MappedScalarVariable
  11. import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.InnerFMU
  12. import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.exceptions.IncorrectAmountOfElementsException
  13. import java.io.File
  14. import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.SAScalarVariable
  15. import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.InputOutputType
  16. import org.eclipse.emf.common.util.EList
  17. import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Port
  18. import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.SVCausality
  19. import java.util.Collection
  20. import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.InOutRules
  21. import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.InRulesBlock
  22. import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.InOutRulesBlockResult
  23. import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.OutRulesBlock
  24. import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.GlobalInOutVariable
  25. import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.ControlRuleBlock
  26. import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.RulesBlockResult
  27. import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.ScalarVariable
  28. import java.util.List
  29. import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.SVType
  30. import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.ParamDeclarations
  31. class CppGenerator extends SemanticAdaptationGenerator {
  32. private var IFileSystemAccess2 fsa;
  33. private List<File> resourcePaths = newArrayList();
  34. override void doGenerate(Resource resource, IFileSystemAccess2 fsa, IGeneratorContext context) {
  35. this.fsa = fsa;
  36. for (SemanticAdaptation type : resource.allContents.toIterable.filter(SemanticAdaptation)) {
  37. type.compile;
  38. }
  39. }
  40. def List<File> getResourcePaths(){
  41. return resourcePaths;
  42. }
  43. // TODO: Verify adaptation.name is not a C++ keyword
  44. def void compile(SemanticAdaptation adaptation) {
  45. for (Adaptation type : adaptation.elements.filter(Adaptation)) {
  46. // Value used for scoping variables in the .sa file
  47. val adapInteralRefName = type.name;
  48. // The CPP class name
  49. val adapClassName = type.name.toFirstUpper;
  50. // This is the external name used in the model description file for the semantic adaptation FMU.
  51. val adapExternalName = type.type.name;
  52. // List of FMUs with a pairing between its name and its type.name.
  53. var ArrayList<Pair<String, String>> fmus = newArrayList();
  54. // TODO: Currently only 1 inner fmu is supported
  55. val innerFmus = type.inner.eAllContents.toList.filter(InnerFMU);
  56. if (innerFmus.size > 1) {
  57. throw new IncorrectAmountOfElementsException("Only one InnerFmu is supported.")
  58. }
  59. if (innerFmus.isEmpty) {
  60. throw new IncorrectAmountOfElementsException("The adaptation does not contain any InnerFMUs.")
  61. }
  62. /*
  63. * This map will contain scalar variables from the FMUs defined in InnerFMU.
  64. * The structure is fmuName -> (SVName -> mappedSV) where SVName = mappedSV.name for easy lookup.
  65. * The mappedSV contains the original scalar variable and extra data such as define name.
  66. */
  67. var LinkedHashMap<String, LinkedHashMap<String, MappedScalarVariable>> mappedScalarVariables = newLinkedHashMap();
  68. /*
  69. * Loading the FMU defined in InnerFMU, the related model description file and its scalar variables.
  70. */
  71. // TODO: Add support for multiple inner fmus
  72. var ModelDescription md;
  73. for (fmu : type.inner.eAllContents.toList.filter(InnerFMU)) {
  74. val fmuFile = new File(fmu.path.replace('\"', ''));
  75. this.resourcePaths.add(fmuFile);
  76. md = new ModelDescription(fmu.name, fmu.type.name, fmuFile);
  77. fmus.add(fmu.name -> fmu.type.name);
  78. val LinkedHashMap<String, MappedScalarVariable> mSV = newLinkedHashMap();
  79. for (sv : md.sv.values) {
  80. var mappedSv = new MappedScalarVariable(sv);
  81. mappedSv.define = (mappedSv.mappedSv.owner + mappedSv.mappedSv.name).toUpperCase;
  82. mSV.put(mappedSv.mappedSv.name, mappedSv);
  83. }
  84. mappedScalarVariables.put(fmu.name, mSV);
  85. }
  86. // C++ Defines for accessing FMU scalar variables.
  87. val String fmusDefines = calcDefines(mappedScalarVariables);
  88. // Compile Params
  89. var LinkedHashMap<String, GlobalInOutVariable> params = newLinkedHashMap;
  90. val String paramsConstructorSource = compileParams(params, type.params);
  91. /*
  92. * This map contains all the ScalarVariables for the semantic adaptation.
  93. * The are not populated yet, but they will be during the compilation of the in and out rule blocks.
  94. */
  95. var LinkedHashMap<String, SAScalarVariable> SASVs = calcSASVsFromInportsOutports(adapInteralRefName,
  96. type.inports, type.outports)
  97. // C++ defines for accessing semantic adaptation scalar variables
  98. val String SADefines = calcSADefines(SASVs.values);
  99. // Compile the in rules
  100. val inRuleResult = compileInOutRuleBlocks(InputOutputType.Input, adaptation.eAllContents.toIterable.filter(
  101. InRulesBlock).map[x|x as InOutRules], adapClassName, adapInteralRefName, mappedScalarVariables, SASVs,
  102. params);
  103. // Compile the out rules
  104. val outRuleResult = compileInOutRuleBlocks(InputOutputType.Output, adaptation.eAllContents.toIterable.
  105. filter(OutRulesBlock).map[x|x as InOutRules], adapClassName, adapInteralRefName, mappedScalarVariables,
  106. SASVs, params);
  107. // Compile the Control Rules
  108. val crtlRuleResult = compileControlRuleBlock(adaptation.eAllContents.toIterable.filter(ControlRuleBlock),
  109. adapClassName, adapInteralRefName, SASVs);
  110. /*
  111. * Compile the constructor, destructor and initialize functions
  112. */
  113. val String deAndConstructorAndInitializeSource = compileDeAndConstructorAndInitialize(
  114. adapClassName,
  115. fmus.head.key,
  116. fmus.head.value,
  117. md.guid,
  118. paramsConstructorSource,
  119. inRuleResult.constructorInitialization,
  120. outRuleResult.constructorInitialization
  121. );
  122. /*
  123. * Compile getRuleThis function
  124. */
  125. val String getRuleThisSource = compileGetRuleThis(adapClassName);
  126. /*
  127. * The in and out rules have populated the semantic adaptation scalar variables we can generate the getFmiValue* and setFmiValue functions.
  128. */
  129. val String getFuncsSource = compileGetFmiValueFunctions(adapClassName, SASVs);
  130. val String setFuncsSource = compileSetFmiValueFunctions(adapClassName, SASVs);
  131. // Compile the source file
  132. val String sourceInclude = '''#include "«adapClassName».h"''';
  133. val sourceFile = compileSource(
  134. sourceInclude,
  135. deAndConstructorAndInitializeSource,
  136. getRuleThisSource,
  137. getFuncsSource,
  138. setFuncsSource,
  139. inRuleResult.generatedCpp,
  140. outRuleResult.generatedCpp,
  141. crtlRuleResult.generatedCpp
  142. );
  143. fsa.generateFile(adapClassName + ".cpp", sourceFile);
  144. // Merge the global variables for use in compiling the header file.
  145. // TODO: Check for duplicates
  146. var LinkedHashMap<String, GlobalInOutVariable> allGVars = newLinkedHashMap();
  147. allGVars.putAll(params);
  148. allGVars.putAll(outRuleResult.gVars);
  149. allGVars.putAll(inRuleResult.gVars);
  150. // Compile the header file
  151. val headerFile = compileHeader(
  152. adapClassName,
  153. fmusDefines,
  154. SADefines,
  155. inRuleResult.functionSignatures,
  156. outRuleResult.functionSignatures,
  157. crtlRuleResult.functionSignatures,
  158. allGVars,
  159. fmus,
  160. SASVs.values.map[CalcSVar()].toList
  161. );
  162. fsa.generateFile(adapClassName + ".h", headerFile);
  163. // Compile the model description file
  164. val modelDescCreator = new ModelDescriptionCreator(adapExternalName);
  165. val modelDescription = modelDescCreator.generateModelDescription(SASVs.values);
  166. fsa.generateFile("modelDescription.xml", modelDescription);
  167. // Compile the fmu.cpp file
  168. val fmuCppFile = StaticGenerators.GenFmuCppFile(adapClassName);
  169. fsa.generateFile("Fmu.cpp", fmuCppFile);
  170. }
  171. }
  172. def String compileParams(LinkedHashMap<String, GlobalInOutVariable> gVars, EList<ParamDeclarations> params) {
  173. val paramsConditionSwitch = new ParamConditionSwitch(gVars);
  174. var String paramsConstructorSource = "";
  175. for (paramDecl : params) {
  176. val doSwitchRes = paramsConditionSwitch.doSwitch(paramDecl);
  177. paramsConstructorSource += doSwitchRes.code;
  178. }
  179. return paramsConstructorSource;
  180. }
  181. def calcSADefines(Collection<SAScalarVariable> variables) {
  182. var ArrayList<String> defines = newArrayList();
  183. for (SASV : variables) {
  184. defines.add("#define " + SASV.defineName + " " + SASV.valueReference);
  185. }
  186. return defines.join("\n");
  187. }
  188. def calcDefines(LinkedHashMap<String, LinkedHashMap<String, MappedScalarVariable>> map) {
  189. var ArrayList<String> defines = newArrayList();
  190. for (fmuEntries : map.entrySet) {
  191. for (MappedScalarVariable mSV : fmuEntries.value.values) {
  192. defines.add("#define " + mSV.define + " " + mSV.valueReference);
  193. }
  194. }
  195. return defines.join("\n");
  196. }
  197. // Compiles the final source file
  198. def String compileSource(String include, String constructor, String getRuleThis, String getFunctions,
  199. String setFunctions, String inFunctions, String outFunctions, String controlFunction) {
  200. return '''
  201. «include»
  202. namespace adaptation
  203. {
  204. «constructor»
  205. «getRuleThis»
  206. «getFunctions»
  207. «setFunctions»
  208. «inFunctions»
  209. «controlFunction»
  210. «outFunctions»
  211. }
  212. '''
  213. }
  214. /*
  215. * Compiles the header file split into two: The first part contains the includes and using namespace definitions and start the ,
  216. * the second part contains the class
  217. */
  218. def String compileHeader(String adapClassName, String fmusDefines, String SADefines, List<String> inRulesFuncSig,
  219. List<String> outRulesFuncSig, List<String> crtlRulesFuncSig,
  220. LinkedHashMap<String, GlobalInOutVariable> globalVariables, ArrayList<Pair<String, String>> fmus,
  221. Collection<ScalarVariable> sVars) {
  222. return '''
  223. #ifndef SRC_«adapClassName.toUpperCase»_H
  224. #define SRC_«adapClassName.toUpperCase»_H
  225. #include "SemanticAdaptation.h"
  226. #include <memory>
  227. #include "Fmu.h"
  228. using namespace std;
  229. using namespace fmi2;
  230. namespace adaptation
  231. {
  232. «fmusDefines»
  233. «SADefines»
  234. class «adapClassName» : public SemanticAdaptation<«adapClassName»>, public enable_shared_from_this<«adapClassName»>
  235. {
  236. public:
  237. «adapClassName»(shared_ptr<string> resourceLocation, const fmi2CallbackFunctions* functions);
  238. void initialize();
  239. virtual ~«adapClassName»();
  240. void setFmiValue(fmi2ValueReference id, int value);
  241. void setFmiValue(fmi2ValueReference id, bool value);
  242. void setFmiValue(fmi2ValueReference id, double value);
  243. void setFmiValue(fmi2ValueReference id, string value);
  244. int getFmiValueInteger(fmi2ValueReference id);
  245. bool getFmiValueBoolean(fmi2ValueReference id);
  246. double getFmiValueReal(fmi2ValueReference id);
  247. string getFmiValueString(fmi2ValueReference id);
  248. private:
  249. «adapClassName»* getRuleThis();
  250. /*in rules*/
  251. «inRulesFuncSig.map[x | x+";"].join("\n")»
  252. /*out rules*/
  253. «outRulesFuncSig.map[x | x+";"].join("\n")»
  254. «crtlRulesFuncSig.map[x | x+";"].join("\n")»
  255. «FOR fmu : fmus»
  256. shared_ptr<FmuComponent> «fmu.key»;
  257. «ENDFOR»
  258. «FOR sv : sVars»
  259. «Conversions.fmiTypeToCppType(sv.type)» «sv.name»;
  260. «IF sv.causality == SVCausality.input»
  261. bool isSet«sv.name»;
  262. «ENDIF»
  263. «ENDFOR»
  264. «FOR v : globalVariables.entrySet»
  265. «Conversions.fmiTypeToCppType(v.value.type)» «v.key»;
  266. «ENDFOR»
  267. };
  268. }
  269. #endif
  270. ''';
  271. }
  272. /*
  273. * Compiles the source file constructor, destructor and the initialize function
  274. */
  275. def String compileDeAndConstructorAndInitialize(String adapClassName, String fmuName, String fmuTypeName,
  276. String guid, String paramsCons, String inCons, String outCons) {
  277. return '''
  278. «adapClassName»::«adapClassName»(shared_ptr<string> resourceLocation, const fmi2CallbackFunctions* functions) :
  279. SemanticAdaptation(resourceLocation, createInputRules(),createOutputRules(), functions)
  280. {
  281. «paramsCons»
  282. «inCons»
  283. «outCons»
  284. }
  285. void «adapClassName»::initialize()
  286. {
  287. auto path = Fmu::combinePath(resourceLocation, make_shared<string>("«fmuTypeName».fmu"));
  288. auto «fmuName»Fmu = make_shared<fmi2::Fmu>(*path);
  289. «fmuName»Fmu->initialize();
  290. this->«fmuName» = «fmuName»Fmu->instantiate("«fmuName»",fmi2CoSimulation, "«guid»", true, true, shared_from_this());
  291. if(this->«fmuName»->component == NULL)
  292. this->lastErrorState = fmi2Fatal;
  293. this->instances->push_back(this->«fmuName»);
  294. }
  295. «adapClassName»::~«adapClassName»()
  296. {
  297. }
  298. ''';
  299. }
  300. /*
  301. * Compiles the source file function getRuleThis
  302. */
  303. def String compileGetRuleThis(String adaptationName) {
  304. return '''
  305. «adaptationName»* «adaptationName»::getRuleThis()
  306. {
  307. return this;
  308. }
  309. '''
  310. }
  311. /*
  312. * Compiles the source file functions getFmiValue<double, int, string, bool>
  313. */
  314. def String compileGetFmiValueFunctions(String adaptationName, LinkedHashMap<String, SAScalarVariable> variables) {
  315. var ArrayList<String> cpp = newArrayList();
  316. var List<ScalarVariable> convertedSASVs = variables.values.map[CalcSVar()].toList;
  317. var convertedSASVsOrdered = convertedSASVs.filter[causality === SVCausality.output].groupBy[type];
  318. for (SVType type : SVType.values) {
  319. val functionSignature = '''«Conversions.fmiTypeToCppType(type)» «adaptationName»::getFmiValue«type.toString»(fmi2ValueReference id)''';
  320. val functionReturn = '''return «Conversions.fmiTypeToCppDefaultValue(type)»''';
  321. if (convertedSASVsOrdered.containsKey(type)) {
  322. cpp.add(
  323. '''
  324. «functionSignature»
  325. {
  326. switch (id)
  327. {
  328. «FOR svInner : convertedSASVsOrdered.get(type)»
  329. case «variables.get(svInner.name).defineName»:
  330. {
  331. return this->«svInner.name»;
  332. }
  333. «ENDFOR»
  334. default:
  335. {
  336. «functionReturn»;
  337. }
  338. }
  339. }
  340. '''
  341. );
  342. } else {
  343. cpp.add(
  344. '''
  345. «functionSignature»
  346. {
  347. «functionReturn»;
  348. }
  349. '''
  350. );
  351. }
  352. }
  353. return cpp.join("\n");
  354. }
  355. /*
  356. * Compiles the source file functions setFmiValue<double, int, string, bool>*
  357. */
  358. def String compileSetFmiValueFunctions(String adapClassName, LinkedHashMap<String, SAScalarVariable> variables) {
  359. var ArrayList<String> cpp = newArrayList();
  360. var List<ScalarVariable> convertedSASVs = variables.values.map[CalcSVar()].filter [
  361. causality === SVCausality.input
  362. ].toList;
  363. var convertedSASVsOrdered = convertedSASVs.groupBy[type];
  364. for (SVType type : SVType.values) {
  365. cpp.add(
  366. '''
  367. void «adapClassName»::setFmiValue(fmi2ValueReference id, «Conversions.fmiTypeToCppType(type)» value)
  368. {
  369. «IF convertedSASVsOrdered.containsKey(type)»
  370. switch (id)
  371. {
  372. «FOR svInner : convertedSASVsOrdered.get(type)»
  373. case «variables.get(svInner.name).defineName»:
  374. {
  375. this->«svInner.name» = value;
  376. this->isSet«svInner.name» = true;
  377. break;
  378. }
  379. «ENDFOR»
  380. default:
  381. {
  382. }
  383. }
  384. «ENDIF»
  385. }
  386. '''
  387. );
  388. }
  389. return cpp.join("\n");
  390. }
  391. /*
  392. * Compiles the source file function executeInternalControlFlow.
  393. * Calculates necessary information on function signatures necessary for generation of the header file.
  394. */
  395. def RulesBlockResult compileControlRuleBlock(Iterable<ControlRuleBlock> crtlRuleBlocks, String adaptationClassName,
  396. String adaptationName, LinkedHashMap<String, SAScalarVariable> SASVs) {
  397. var cpp = "";
  398. val visitor = new ControlConditionSwitch(adaptationClassName, adaptationName, SASVs);
  399. for (crtlRule : crtlRuleBlocks) {
  400. cpp += visitor.doSwitch(crtlRule).code;
  401. }
  402. return new RulesBlockResult(cpp, visitor.functionSignatures);
  403. }
  404. def String SplitAtSpaceAndRemoveFirst(String content) {
  405. content.substring(content.indexOf(" ") + 1, content.length);
  406. }
  407. def String removeEmptyArgumentParenthesis(String content) {
  408. return content.substring(0, content.length - 2);
  409. }
  410. /*
  411. * Compiles the source file functions <in/out>_rule_<condition, body, flush>.
  412. * Calculates necessary information on global in/out variables necessary for generation of the header file.
  413. * Calculates necessary information on function signatures necessary for generation of the header file.
  414. */
  415. def InOutRulesBlockResult compileInOutRuleBlocks(InputOutputType ioType, Iterable<InOutRules> rulesBlocks,
  416. String adaptationClassName, String adaptationName,
  417. LinkedHashMap<String, LinkedHashMap<String, MappedScalarVariable>> mSVars,
  418. LinkedHashMap<String, SAScalarVariable> SASVs, LinkedHashMap<String, GlobalInOutVariable> params) {
  419. val visitor = if (ioType == InputOutputType.Input)
  420. new InRulesConditionSwitch(adaptationClassName, adaptationName, mSVars, SASVs, params)
  421. else
  422. new OutRulesConditionSwitch(adaptationClassName, adaptationName, mSVars, SASVs, params);
  423. val functionName = "create" + ioType + "Rules()";
  424. var String cpp = "";
  425. val ruleBlock = rulesBlocks.head;
  426. if (ruleBlock !== null) {
  427. cpp += visitor.doSwitch(ruleBlock).code;
  428. if (!visitor.functionSignatures.empty) {
  429. var ArrayList<String> createRulesFunction = newArrayList();
  430. for (var int i = 0; i < (visitor.functionSignatures.length); i += 3) {
  431. createRulesFunction.add(
  432. '''
  433. list->push_back(
  434. (Rule<«adaptationClassName»>){
  435. &«adaptationClassName»::«visitor.functionSignatures.get(i).SplitAtSpaceAndRemoveFirst.removeEmptyArgumentParenthesis»,
  436. &«adaptationClassName»::«visitor.functionSignatures.get(i+1).SplitAtSpaceAndRemoveFirst.removeEmptyArgumentParenthesis»,
  437. &«adaptationClassName»::«visitor.functionSignatures.get(i+2).SplitAtSpaceAndRemoveFirst.removeEmptyArgumentParenthesis»
  438. });
  439. ''');
  440. }
  441. val functionPrefix = '''shared_ptr<list<Rule<«adaptationClassName»>>>''';
  442. visitor.functionSignatures.add(functionPrefix + " " + functionName)
  443. cpp += '''
  444. «functionPrefix» «adaptationClassName»::«functionName»
  445. {
  446. auto list = make_shared<std::list<Rule<«adaptationClassName»>>>();
  447. «createRulesFunction.join("\n")»
  448. return list;
  449. }
  450. '''
  451. }
  452. }
  453. return new InOutRulesBlockResult(cpp, visitor.functionSignatures, visitor.getGlobalVars,
  454. visitor.constructorInitialization);
  455. }
  456. /*
  457. * Calculates the semantic adaptation scalar variables via input ports and output ports.
  458. * Note: These a not fully populated yet as the in rules and out rules must be compiled first.
  459. */
  460. def LinkedHashMap<String, SAScalarVariable> calcSASVsFromInportsOutports(String definePrefix, EList<Port> inports,
  461. EList<Port> outports) {
  462. var LinkedHashMap<String, SAScalarVariable> saSVs = newLinkedHashMap();
  463. var int valueReference = 0;
  464. for (inport : inports) {
  465. var saSV = new SAScalarVariable();
  466. saSV.SetPartOfMD(true);
  467. saSV.valueReference = valueReference++;
  468. saSV.name = inport.name;
  469. saSV.defineName = (definePrefix + inport.name).toUpperCase
  470. saSV.causality = SVCausality.input;
  471. saSVs.put(saSV.name, saSV);
  472. }
  473. for (outport : outports) {
  474. var saSV = new SAScalarVariable();
  475. saSV.SetPartOfMD(true);
  476. saSV.valueReference = valueReference++;
  477. saSV.defineName = (definePrefix + outport.name).toUpperCase
  478. saSV.name = outport.name;
  479. saSV.causality = SVCausality.output;
  480. saSVs.put(saSV.name, saSV);
  481. }
  482. return saSVs;
  483. }
  484. }