Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

problem about mixed-determined

problem about mixed-determined

I want write a block,which generate a vector with logic value.But compiler say, The given system is mixed-determined.   [index > 3].  I have no idea, how can i fix the bug. Can someone give me a suggest.

model vektor_maker

import L = Modelica.Electrical.Digital.Interfaces.Logic;
parameter Integer Step(start=1023);
parameter Integer Anzahl(start=500);
Modelica.Electrical.Digital.Interfaces.DigitalOutput out[Stufe] annotation(
    Placement(visible = true, transformation(origin = {110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));

initial algorithm

for i in 1:Step loop
  out[i]:= L.'0';
end for;

algorithm

  if Anzahl <= Step then
    for i in 1:Anzahl loop
    out[i] := L.'1';
  end for;
for i in Anzahl+1:Step loop
out[i] := L.'0';
end for;
   end if;
   
  if Anzahl > Step then
    for i in 1:Step loop
      out[i] := L.'1';
    end for;
  end if;

equation

end vektor_maker;


Thanks in advance.

Re: problem about mixed-determined

The problem is caused by the initial algorithm, although I see nothing wrong there. Do you really need this initial algorithm?
There is also a problem with the dimension of the out variable, it is Stufe, but Stufe is not declared at all. I have used max(Step, Anzahl).
It is also necessary to give the value of out between Step and Anzahl when Anzahl>Step (as you have done when Anzahl<=Step).

Re: problem about mixed-determined

i delete the initial algrorithm and it does work. thank!

There are 0 guests and 0 other users also viewing this topic
You are here: