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

Added semantics first try

parent aa44fded
package de.monticore.lang.monticar.semantics.loops;
import de.monticore.lang.monticar.semantics.library.arithmetic.Gain;
component GainComponent<T>(T gainValue) {
port
in Q in1,
out Q out1;
instance Gain<T>(gainValue) gain;
connect in1 -> gain.in1;
connect gain.out1 -> out1;
}
\ No newline at end of file
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.semantics.loops;
component Oscillation {
port
out Q out1;
instance de.monticore.lang.monticar.semantics.library.differential.Integration<(-oo:d:oo)>{out1 = 3} y;
instance de.monticore.lang.monticar.semantics.library.differential.Integration<(-oo:d:oo)>(0) yDiff;
instance de.monticore.lang.monticar.semantics.library.arithmetic.Gain<(-oo:d:oo)>(-2/5) yDiffDiff;
connect y.out1 -> yDiffDiff.in1, out1;
connect yDiffDiff.out1 -> yDiff.in1;
connect yDiff.out1 -> y.in1;
}
\ No newline at end of file
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.semantics.loops;
component OscillationAsSymbol {
port
in Q in1,
out Q out1;
implementation Math {
symbolic Q y;
symbolic Q yDiff;
symbolic Q yDiffDiff;
y(t=0) = 2;
yDiff(t=0) = 0;
diff(y) == yDiff;
diff(yDiff) == yDiffDiff;
yDiffDiff == -2/5*y;
out1 == y;
}
}
\ No newline at end of file
package de.monticore.lang.monticar.semantics.loops;
import de.monticore.lang.monticar.semantics.library.arithmetic.*;
component ParallelLoop {
port
in Q in1,
out Q out1;
instance SimpleLoop simple1, simple2;
instance Difference<Q> difference;
instance Sum<Q,2> sum;
connect in1 -> difference.in1;
connect difference.out1 -> simple1.in1, simple2.in1;
connect simple1.out1 -> sum.in1[1];
connect simple2.out1 -> sum.in1[2];
connect sum.out1 -> difference.in2, out1;
}
\ No newline at end of file
package de.monticore.lang.monticar.semantics.loops;
import de.monticore.lang.monticar.semantics.library.arithmetic.Difference;
component SerialLoop {
port
in Q in1,
out Q out1;
instance SimpleLoop simple1;
instance SimpleLoop simple2;
instance Difference<Q> difference;
connect in1 -> difference.in1;
connect difference.out1 -> simple1.in1;
connect simple1.out1 -> simple2.in1;
connect simple2.out1 -> out1, difference.in2;
}
\ No newline at end of file
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.semantics.loops;
component SerialLoopAsSymbol {
port
in Q in1,
out Q out1;
implementation Math {
x_0 == in1-x_3;
x_3 == x_1-x_4;
x_4 == 2*x_3;
x_1 == x_0-x_2;
x_2 == 3*x_1;
out1 == x_3;
}
}
\ No newline at end of file
package de.monticore.lang.monticar.semantics.loops;
import de.monticore.lang.monticar.semantics.library.arithmetic.Difference;
import de.monticore.lang.monticar.semantics.loops.GainComponent;
component SimpleLoop {
port
in Q in1,
out Q out1;
instance Difference<Q> difference;
instance GainComponent<Q>(2) gain;
connect in1 -> difference.in1;
connect difference.out1 -> gain.in1, out1;
connect gain.out1 -> difference.in2;
}
\ No newline at end of file
package de.monticore.lang.monticar.semantics.loops;
import de.monticore.lang.monticar.semantics.library.arithmetic.*;
import de.monticore.lang.monticar.semantics.library.differential.Integration;
// see https://de.mathworks.com/help/simulink/ug/sorted_order_example_car_dynamics.png
component SimulinkExample2 {
port
in Q in1,
out Q out1;
instance Constant<1> one;
instance Difference<Q> diff;
instance Division<Q> div;
instance Gain<1> gain;
instance Integration<Q> integration;
connect in1 -> diff.in1;
connect one.out1 -> div.in1;
connect diff.out1 -> div.in2;
connect div.out1 -> integration.in1;
connect integration.out1 -> out1, gain.in1;
connect gain.out1 -> diff.in2;
}
\ No newline at end of file
package de.monticore.lang.monticar.semantics.loops;
import de.monticore.lang.monticar.semantics.library.arithmetic.*;
component SumComponent<T,N1 n=2> {
port
in T in1[n],
out T out1;
instance Sum<T, n> sum;
connect in1[:] -> sum.in1[:];
connect sum.out1 -> out1;
}
\ No newline at end of file
package de.monticore.lang.monticar.semantics.loops;
import de.monticore.lang.monticar.semantics.library.arithmetic.*;
component Test01 {
port
out Q out1;
instance Constant<1> one;
instance Difference difference;
instance GainComponent<1> gain;
instance SumComponent<Q,2> sum;
connect one.out1 -> sum.in1[2];
connect difference.out1 -> gain.in1, sum.in1[1], out1;
connect gain.out1 -> difference.in2;
connect sum.out1 -> difference.in1;
}
\ No newline at end of file
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.semantics.loops;
import de.monticore.lang.monticar.semantics.library.arithmetic.*;
component Test02 {
port
in Q in1,
in Q in2,
out Q out1;
instance Difference<Q> difference;
instance Multiplication<Q,2> mult;
connect in1 -> difference.in1;
connect in2 -> mult.in1[1];
connect difference.out1 -> out1, mult.in1[2];
connect mult.out1 -> difference.in2;
}
\ No newline at end of file
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.semantics.loops;
component UnderSpecification {
port
in Q in1,
out Q out1,
out Q out2;
implementation Math {
in1 == out1 + out2;
}
}
\ No newline at end of file
package de.monticore.lang.monticar.semantics.loops;
import de.monticore.lang.monticar.semantics.library.arithmetic.*;
import de.monticore.lang.monticar.semantics.library.differential.Integration;
// see https://de.mathworks.com/help/simulink/ug/vdp_sorted_order.png
component VanDerPolEquation {
port
out Q out1,
out Q out2;
instance Constant<1> one;
instance Difference<Q> diff1;
instance Difference<Q> diff2;
instance Gain<1> gain;
instance Integration<Q> integration1, integration2;
instance Multiplication<Q, 2> uSqaure, mult;
connect one.out1 -> diff1.in1;
connect uSqaure.out1 -> diff1.in2;
connect diff1.out1 -> mult.in1[1];
connect mult.out1 -> gain.in1;
connect gain.out1 -> diff2.in1;
connect diff2.out1 -> integration1.in1;
connect integration1.out1 -> integration2.in1, mult.in1[2], out2;
connect integration2.out1 -> out1, diff2.in2, uSqaure.in1[1], uSqaure.in1[2];
}
\ No newline at end of file
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