i want to allot a value of 1 or 0 to the digital output y in the following text view
if u > 2 ^ 2 then
y := logic ('1');
elseif u < 2 ^ 2 then
y := logic ('0');
If you insist on using an algorithm section inside a model, then this is one way to do it:
if u > 4 then
y := y.'1';
elseif u < 4 then
y := y.'0';
no john, if you will see this is not a block, but the modelica language script. the question is how in script i can allot a logic value '1' to a digital signal
In the pasted Modelica text you are using a DigitalOutput. If this is what you want the Modelica.Electrical.Digital.Converters.RealToLogic converts between a real valued signal and a digital interface.
In the attached model you are using RealInput and BooleanOutput that seems to be constructed to switch between true and false depending on a threshold value (2^2) Is that the type of component you want? If so, I'd recommend to use the Modelica.Blocks.Logical.GreaterEqualThreshold component instead, which does that.