Jump to content


Mutual Exclusivity?


  • You cannot reply to this topic
2 replies to this topic

#1 Jonathan

    Member

  • Members
  • PipPip
  • 25 posts

Posted 17 July 2009 - 01:13 PM

Is there any way for me to specify that though two portions of code near each other may both try to write to a variable, only one will? I.E.,

CODE
if ( EventA ) {
   Var = 1;
}
if ( EventB ) {
   Var = 2;
}
if ( EventC ) {
   Var = 3;
}


Where P( A | B ) = P( B | A ) = 0, and same for A and C, and B and C? My worry is that what I'm doing will be almost certainly impossible for Impulse C to detect as mutually exclusive events, and so Impulse C, in trying to preserve C language semantics, will stagger these if statements. In VHDL I would use a low-impedance signal whenever the event in question wasn't occurring, and so only the one that responds would get its value written to the register...

-Jonathan

#2 RalphBodenner

    Advanced Member

  • Admin
  • PipPipPip
  • 348 posts

Posted 27 July 2009 - 07:33 PM

Sorry, there's no way to do this in Impulse C other than to use an if-else if block.

Ralph Bodenner
Impulse Accelerated Technologies, Inc.

#3 RalphBodenner

    Advanced Member

  • Admin
  • PipPipPip
  • 348 posts

Posted 28 July 2009 - 11:14 AM

To clarify: you can cause the evaluation of all the if-else conditions in a block to be computed concurrently (as possible), ignoring the C language requirements for short-circuit evaluation, by applying the CO FLATTEN pragma to the block.

This still doesn't allow you to scatter mutually exclusive conditionals throughout your code, but I believe it may help address the design problem you are after.
Ralph Bodenner
Impulse Accelerated Technologies, Inc.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users