// ************************************************************************** //
//                                                                            //
//    eses                   eses                                             //
//   eses                     eses                                            //
//  eses    eseses  esesese    eses   Embedded Systems Group                  //
//  ese    ese  ese ese         ese                                           //
//  ese    eseseses eseseses    ese   Department of Computer Science          //
//  eses   eses          ese   eses                                           //
//   eses   eseses  eseseses  eses    University of Kaiserslautern            //
//    eses                   eses                                             //
//                                                                            //
// ************************************************************************** //
// This example has been taken from [Edwa02]. The first thread generates      //
// requests "req" in response to an external request "wish", and the second   //
// thread responds to them via signal "ack" in alternate cycles. The output   //
// "receipt" indicates that the first thread has received the acknowledege    //
// signal of the second thread. Finally, the input reset resets both threads. //
// ************************************************************************** //

module Edwards02(event ?reset,?wish,!receipt){
   event ack,req;
   every(reset) {
        {await(wish);
         weak immediate abort {
            always emit(req);
         } when(ack);
         emit(receipt);
        }
      ||
         loop {
            pause;
            pause;
            if(req) emit(ack);
         }
   }
} satisfies {
   s1: assert A ((G !reset) -> (G !receipt));
   s2: assert A X (reset & G !reset & F wish -> F receipt);
   s3: assert A X (reset & G !reset -> G (wish -> receipt | X receipt));
   s4: assert A G (receipt -> wish | PSX wish);
}