Hello Johan
First of all, thank you for your reply. I am really glad you did what you did, because it highlights the crux of the problem I am having. The reason I wrote the code the way I did is that I am trying to make the number of FF variable. Think of it as something like the code below:
model test
import D = Modelica.Electrical.Digital;
import L = Modelica.Electrical.Digital.Interfaces.Logic;
import S = Modelica.Electrical.Digital.Interfaces.Strength;
parameter Integer n = 1;
parameter Integer nn(min = 1) = 2 "Number of bits";
parameter Modelica.SIunits.Time tHL = 0.1 "High->Low delay";
parameter Modelica.SIunits.Time tLH = 0.1 "Low->High delay";
parameter D.Interfaces.Strength strength = S.'S_X01' "output strength";
D.Registers.DFFREG FF[nn](each tHL = tHL, each tLH = tLH);
D.Gates.InvGate INV (tHL= tHL, tLH = tLH, y0 = L.'1');
D.Interfaces.DigitalInput reset ;
D.Interfaces.DigitalInput clock ;
D.Interfaces.DigitalOutput q[nn] ;
equation
connect(clock, FF[1].clock);
connect(reset, FF[1].reset);
connect(FF[1].dataOut[1], q[1]);
connect(FF[nn].dataOut[1], INV.x);
connect(INV.y, FF[2].dataIn[1]);
for i in 2:nn loop
connect(clock, FF[i].clock);
connect(reset, FF[i].reset);
connect(FF[i].dataOut[1], q[i]);
connect(FF[i-1].dataOut[1], FF[i].dataIn[1]);
end for
end test;
As you can see, this defaults to the original code for nn=2 and, as in the original form, the checker complains that there is mismatch between the number of variables and the number of equations. I had noticed that writing the code in the form you suggested takes care of the problem but doing so removes, I think, the ability of making the number of FFs variable. So why is there a difference? To my, admittedly, uneducated eye, the two formulations should be equivalent and I am not sure why they are not.
Thank you,
Fulvio