// ************************************************************************** //
//                                                                            //
//    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                                             //
//                                                                            //
// ************************************************************************** //
// filename:    ./ComputerArchitecture/AsynchronousCircuits/                  //
//              AsyncArbiterBoch82/ME_Element.qrz                             //
// author:      Manuel Gesell                                                 //
//                                                                            //
// description:                                                               //
// The Muller ME-element (mutual exclusion element) behaves                   //
// as follows:                                                                //
//  (1) The two outputs are never both high.                                  //
//  (2) When both inputs are low, so are the outputs.                         //
//  (3) When only one input is high, the corresponding                        //
//      output will eventually go high.                                       //
//  (4) When an input is high and the corresponding                           //
//      output is high, then the output remains high                          //
//      until the input goes low.                                             //
//  (5) When both inputs are high and the outputs are                         //
//      both low, then the ME element has the nondet.                         //
//      choice to raise one of them.                                          //
// Note that the assignments must be delayed ones since                       //
// otherwise there will be consistency problems in case                       //
// (in1&in2&!out1&!out2) holds.                                               //
// ************************************************************************** //
package ComputerArchitecture.AsynchronousCircuits.AsyncArbiterBoch82;

module ME_Element(bool ?in1,?in2,out1,out2){
    loop {
        if(!(in1&in2)) {
            next(out1) = in1;
            next(out2) = in2;
        } else if(in1&in2&!out1&!out2) {
            choose next(out1) = true;
            else   next(out2) = true;
        }
        pause;
    }
}