Commit fc0c3c1e authored by Malte Heithoff's avatar Malte Heithoff
Browse files

Basic Library

parent 91b6b4e6
Pipeline #392533 failed with stage
in 1 minute and 23 seconds
......@@ -235,6 +235,8 @@ public class GeneratorCPP implements EMAMGenerator {
// setGenerateMainClass(true);
}
addSemantics(taggingResolver, componentInstanceSymbol);
String lastNameWithoutArrayPart = "";
if (!streamTestGenerationMode) {
for (EMAComponentInstanceSymbol instanceSymbol : componentInstanceSymbol.getSubComponents()) {
......@@ -327,16 +329,10 @@ public class GeneratorCPP implements EMAMGenerator {
EMAComponentInstanceSymbol.KIND).isPresent()) {
EMAComponentInstanceSymbol componentInstanceSymbol = (EMAComponentInstanceSymbol) taggingResolver.resolve(componentFullName,
EMAComponentInstanceSymbol.KIND).get();
ExecutionSemantics semantics = new ExecutionSemantics(taggingResolver, componentInstanceSymbol);
semantics.addExecutionSemantics();
fileContents.addAll(generateStrings(taggingResolver, componentInstanceSymbol));
}
}
} else {
ExecutionSemantics semantics = new ExecutionSemantics(taggingResolver, rootModel);
semantics.addExecutionSemantics();
searchForCVEverywhere(componentSymbol, taggingResolver);
fileContents = generateStrings(taggingResolver, componentSymbol);
}
......@@ -365,6 +361,13 @@ public class GeneratorCPP implements EMAMGenerator {
return files;
}
public void addSemantics(TaggingResolver taggingResolver, EMAComponentInstanceSymbol component) {
if (component.getOrderOutput().isEmpty()) {
ExecutionSemantics semantics = new ExecutionSemantics(taggingResolver, component);
semantics.addExecutionSemantics();
}
}
protected List<File> generateCMakeFiles(EMAComponentInstanceSymbol componentInstanceSymbol) {
List<File> files = new ArrayList<>();
if (componentInstanceSymbol != null) {
......
......@@ -5,6 +5,8 @@ package de.monticore.lang.monticar.generator.cpp;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.cpp.resolver.Resolver;
import de.monticore.lang.monticar.generator.order.simulator.AbstractSymtab;
import de.monticore.lang.monticar.semantics.Constants;
import de.monticore.lang.monticar.semantics.util.BasicLibrary;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import de.se_rwth.commons.logging.Log;
import org.apache.commons.cli.CommandLine;
......@@ -303,7 +305,7 @@ public final class GeneratorCppCli {
Path modelsDirPath = Paths.get(cliArgs.getOptionValue(OPTION_MODELS_PATH.getOpt()));
String rootModelName = cliArgs.getOptionValue(OPTION_ROOT_MODEL.getOpt());
String outputPath = cliArgs.getOptionValue(OPTION_OUTPUT_PATH.getOpt());
TaggingResolver symTab = AbstractSymtab.createSymTabAndTaggingResolver(modelsDirPath.toString());
TaggingResolver symTab = getSymTabAndTaggingResolver(modelsDirPath);
Resolver resolver = new Resolver(symTab);
EMAComponentInstanceSymbol componentSymbol = resolveSymbol(resolver, rootModelName);
......@@ -391,6 +393,12 @@ public final class GeneratorCppCli {
}
private static TaggingResolver getSymTabAndTaggingResolver(Path modelsDirPath) {
BasicLibrary.extract();
return AbstractSymtab.createSymTabAndTaggingResolver(modelsDirPath.toString(),
Constants.SYNTHESIZED_COMPONENTS_ROOT, BasicLibrary.BASIC_LIBRARY_ROOT);
}
private static EMAComponentInstanceSymbol resolveSymbol(Resolver resolver, String rootModelName) {
EMAComponentInstanceSymbol componentSymbol = resolver.getExpandedComponentInstanceSymbol(rootModelName).orElse(null);
if (componentSymbol == null) {
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.semantics.library.arithmetic;
component Add<T,N1 n=2> {
port
in T summand[n],
out T sum1;
implementation Math{
sum1 = sum(summand);
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.semantics.library.arithmetic;
component Constant<T>(T cvalue) {
port
out T value;
implementation Math{
value = cvalue;
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.semantics.library.arithmetic;
component Division<T> {
port
in T dividend,
in T divisor,
out T division;
implementation Math{
division * divisor == dividend;
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.semantics.library.arithmetic;
component Gain<T>(T gainValue) {
port
in T input,
out T output;
implementation Math{
output = input * gainValue;
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.semantics.library.arithmetic;
component Max<T,N1 n=2> {
port
in T in1[n],
out T maximum;
implementation Math{
T maxVal = in1(1);
for i=1:n
maxVal=max(maxVal,in1(i));
end
maximum=maxVal;
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.semantics.library.arithmetic;
component Min<T,N1 n=2> {
port
in T input[n],
out T minimum;
implementation Math{
T minVal=input(1);
for i=1:n
minVal=min(minVal,input(i));
end
minimum=minVal;
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.semantics.library.arithmetic;
component Mod<T> {
port
in T input1,
in T input2,
out T output;
implementation Math{
output == modulo(input1,input2);
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.semantics.library.arithmetic;
component Multiplication<T,N1 n=2> {
port
in T factor[n],
out T product1;
implementation Math{
product1 == product(factor);
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.semantics.library.arithmetic;
/* The Saturation block imposes upper and lower bounds on a signal. When the input signal is within the range specified by the Lower limit and Upper limit parameters, the input signal passes through unchanged. When the input signal is outside these bounds, the signal is clipped to the upper or lower bound.
*/
component Saturation<T> (T minValue, T maxValue){
port
in T input,
out T output;
implementation Math {
output = min(max(input, minValue), maxValue);
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.semantics.library.arithmetic;
component Subtract<T> {
ports
in T minuend,
in T subtrahend,
out T difference;
implementation Math {
difference = minuend - subtrahend;
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.semantics.library.basicLibrary;
non-df component Delay<T>(T dvalue = 0) {
port
in T input,
out T output;
implementation Math {
static delayed = dvalue;
output = dvalue;
dvalue = input;
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.semantics.library.basicLibrary;
component LookUp<T, N1 n = 1> (Q^{1,n} lookuptable) {
ports
in T input,
out T output;
implementation Math{
output = lookuptable(input);
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.semantics.library.differential;
component Derivation<T>(T dvalue = 0) {
port
in T input,
out T output;
implementation Math{
input(t=0) = dvalue;
diff(input) == output;
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.semantics.library.differential;
component Integrator<T>(T dvalue = 0) {
port
in T input,
out T output;
implementation Math{
output(t=0) = dvalue;
diff(output) == input;
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.semantics.library.logic;
component And<N1 n=2> {
port
in B input[n],
out B output;
implementation Math{
output = and(input);
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.semantics.library.logic;
component Equals<T> {
port
in T input1,
in T input2,
out B output;
implementation Math{
output=equal(input1,input2);
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.semantics.library.logic;
component Greater<T> {
port
in T input1,
in T input2,
out B output;
implementation Math{
output=input1>input2;
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.semantics.library.logic;
component GreaterEquals<T> {
port
in T input1,
in T input2,
out B output;
implementation Math{
output=input1>=input2;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment