Variable declaration order

Altair Forum User
Altair Forum User
Altair Employee
edited November 2020 in Community Q&A

Submitted by ctedie on Wed, 11/23/2011 - 20:03

 

     <p>      Hi,<br/>      I would like to know why my variables are not declared in the order i want.<br/>      I join my Vissim diagram and the C code<br/>      It's in <i>CarteMicroAmbiance.vsm::Micro d'ambiance.Compound.RX/TX.Data</i><br/>      And the declarations are at line 164-167 in CarteMicroAmbiance.c<br/>      </p>

 

Unable to find an attachment - read this blog

Tagged:

Answers

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited June 2016

    Submitted by Anders89 on Tue, 11/29/2011 - 20:38.

    OK, I see the problem. You expected that the variables R1,R2,R3,R4 would be assigned in order as they connected to the compound block edge. The problem is that the R variables have multiple consumers, and ordering is enforced by either vertical position of consumer or edge connection to an enabled/custom rate compound. Normal compounds that do not have custom execution (no enabling or custom rate) have no effect on execution order.
    To fix this, put the 4 SCI reads into a compound that is enabled and trigger with a constant 1 as in the attached update to your diagram.
    Another problem with your diagram was you used an int cast in an expression block that created 32 bit long word out of 4 packet bytes. The int type is only 16 bits on the c2000 so you must use long as your cast.
    See attached update to your diagram.

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited June 2016

    Submitted by ctedie on Tue, 11/29/2011 - 20:59.

    Ok, thank you very much!