4
CS269: HW/SW Engineering of Embedded Systems, Winter02
An example medium
Medium IntM implements IntWriter, IntREader, IW, IR, IC, IS, IN {
   int storage, space, n;
   IntM ( ){ space = 1 ; n = 0 ; }
   update void writeInt(int data) {
      await ( space > 0 ; this.IW , this.IS ; this.IW )
         await ( true ; this.IC , this.IS , this.IN ; this.IC) {
            space = 0 ; n = 1; storage = data;
         }
   }
   update int readInt() {
      await ( n > 0 ; this.IR , this.IN ; this.IR )
         await (true ; this.IC , this.IS , this.IN ; this.IC ) {
            space = 1 ; n = 0 ; return storage;
         }
   }
   eval int space() {await(true;this.IW,this.IC;this.IS) return space;}
   eval int n() {await(true;this.IR,this.IC;this.IN) return n;}
}
interface IW extends Ports{}
interface IR extends Ports{}
interface IC extends Ports{}
Interface IS extends Ports {}
Interface IN extends Ports {}
c0
p0
p1
m0