You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

176 lines
5.3 KiB

  1. // firewire protocol with integer semantics
  2. // dxp/gxn 14/06/01
  3. // CLOCKS
  4. // x1 (x2) clock for node1 (node2)
  5. // y1 and y2 (z1 and z2) clocks for wire12 (wire21)
  6. mdp
  7. // maximum and minimum delays
  8. // fast
  9. const int rc_fast_max = 85;
  10. const int rc_fast_min = 76;
  11. // slow
  12. const int rc_slow_max = 167;
  13. const int rc_slow_min = 159;
  14. // delay caused by the wire length
  15. const int delay=3;
  16. // probability of choosing fast
  17. const double fast1; // = 0.5;
  18. const double slow1=1-fast1;
  19. const double fast2; // = 0.5;
  20. const double slow2=1-fast2;
  21. module wire12
  22. // local state
  23. w12 : [0..9];
  24. // 0 - empty
  25. // 1 - rec_req
  26. // 2 - rec_req_ack
  27. // 3 - rec_ack
  28. // 4 - rec_ack_idle
  29. // 5 - rec_idle
  30. // 6 - rec_idle_req
  31. // 7 - rec_ack_req
  32. // 8 - rec_req_idle
  33. // 9 - rec_idle_ack
  34. // clock for wire12
  35. y1 : [0..delay+1];
  36. y2 : [0..delay+1];
  37. // empty
  38. // do not need y1 and y2 to increase as always reset when this state is left
  39. // similarly can reset y1 and y2 when we re-enter this state
  40. [snd_req12] w12=0 -> (w12'=1) & (y1'=0) & (y2'=0);
  41. [snd_ack12] w12=0 -> (w12'=3) & (y1'=0) & (y2'=0);
  42. [snd_idle12] w12=0 -> (w12'=5) & (y1'=0) & (y2'=0);
  43. [time] w12=0 -> (w12'=w12);
  44. // rec_req
  45. [snd_req12] w12=1 -> (w12'=1);
  46. [rec_req12] w12=1 -> (w12'=0) & (y1'=0) & (y2'=0);
  47. [snd_ack12] w12=1 -> (w12'=2) & (y2'=0);
  48. [snd_idle12] w12=1 -> (w12'=8) & (y2'=0);
  49. [time] w12=1 & y2<delay -> (y1'=min(y1+1,delay+1)) & (y2'=min(y2+1,delay+1));
  50. // rec_req_ack
  51. [snd_ack12] w12=2 -> (w12'=2);
  52. [rec_req12] w12=2 -> (w12'=3);
  53. [time] w12=2 & y1<delay -> (y1'=min(y1+1,delay+1)) & (y2'=min(y2+1,delay+1));
  54. // rec_ack
  55. [snd_ack12] w12=3 -> (w12'=3);
  56. [rec_ack12] w12=3 -> (w12'=0) & (y1'=0) & (y2'=0);
  57. [snd_idle12] w12=3 -> (w12'=4) & (y2'=0);
  58. [snd_req12] w12=3 -> (w12'=7) & (y2'=0);
  59. [time] w12=3 & y2<delay -> (y1'=min(y1+1,delay+1)) & (y2'=min(y2+1,delay+1));
  60. // rec_ack_idle
  61. [snd_idle12] w12=4 -> (w12'=4);
  62. [rec_ack12] w12=4 -> (w12'=5);
  63. [time] w12=4 & y1<delay -> (y1'=min(y1+1,delay+1)) & (y2'=min(y2+1,delay+1));
  64. // rec_idle
  65. [snd_idle12] w12=5 -> (w12'=5);
  66. [rec_idle12] w12=5 -> (w12'=0) & (y1'=0) & (y2'=0);
  67. [snd_req12] w12=5 -> (w12'=6) & (y2'=0);
  68. [snd_ack12] w12=5 -> (w12'=9) & (y2'=0);
  69. [time] w12=5 & y2<delay -> (y1'=min(y1+1,delay+1)) & (y2'=min(y2+1,delay+1));
  70. // rec_idle_req
  71. [snd_req12] w12=6 -> (w12'=6);
  72. [rec_idle12] w12=6 -> (w12'=1);
  73. [time] w12=6 & y1<delay -> (y1'=min(y1+1,delay+1)) & (y2'=min(y2+1,delay+1));
  74. // rec_ack_req
  75. [snd_req12] w12=7 -> (w12'=7);
  76. [rec_ack12] w12=7 -> (w12'=1);
  77. [time] w12=7 & y1<delay -> (y1'=min(y1+1,delay+1)) & (y2'=min(y2+1,delay+1));
  78. // rec_req_idle
  79. [snd_idle12] w12=8 -> (w12'=8);
  80. [rec_req12] w12=8 -> (w12'=5);
  81. [time] w12=8 & y1<delay -> (y1'=min(y1+1,delay+1)) & (y2'=min(y2+1,delay+1));
  82. // rec_idle_ack
  83. [snd_ack12] w12=9 -> (w12'=9);
  84. [rec_idle12] w12=9 -> (w12'=3);
  85. [time] w12=9 & y1<delay -> (y1'=min(y1+1,delay+1)) & (y2'=min(y2+1,delay+1));
  86. endmodule
  87. module node1
  88. // clock for node1
  89. x1 : [0..168];
  90. // local state
  91. s1 : [0..8];
  92. // 0 - root contention
  93. // 1 - rec_idle
  94. // 2 - rec_req_fast
  95. // 3 - rec_req_slow
  96. // 4 - rec_idle_fast
  97. // 5 - rec_idle_slow
  98. // 6 - snd_req
  99. // 7- almost_root
  100. // 8 - almost_child
  101. // added resets to x1 when not considered again until after rest
  102. // removed root and child (using almost root and almost child)
  103. // root contention immediate state)
  104. [snd_idle12] s1=0 -> fast1 : (s1'=2) & (x1'=0) + slow1 : (s1'=3) & (x1'=0);
  105. [rec_idle21] s1=0 -> (s1'=1);
  106. // rec_idle immediate state)
  107. [snd_idle12] s1=1 -> fast1 : (s1'=4) & (x1'=0) + slow1 : (s1'=5) & (x1'=0);
  108. [rec_req21] s1=1 -> (s1'=0);
  109. // rec_req_fast
  110. [rec_idle21] s1=2 -> (s1'=4);
  111. [snd_ack12] s1=2 & x1>=rc_fast_min -> (s1'=7) & (x1'=0);
  112. [time] s1=2 & x1<rc_fast_max -> (x1'=min(x1+1,168));
  113. // rec_req_slow
  114. [rec_idle21] s1=3 -> (s1'=5);
  115. [snd_ack12] s1=3 & x1>=rc_slow_min -> (s1'=7) & (x1'=0);
  116. [time] s1=3 & x1<rc_slow_max -> (x1'=min(x1+1,168));
  117. // rec_idle_fast
  118. [rec_req21] s1=4 -> (s1'=2);
  119. [snd_req12] s1=4 & x1>=rc_fast_min -> (s1'=6) & (x1'=0);
  120. [time] s1=4 & x1<rc_fast_max -> (x1'=min(x1+1,168));
  121. // rec_idle_slow
  122. [rec_req21] s1=5 -> (s1'=3);
  123. [snd_req12] s1=5 & x1>=rc_slow_min -> (s1'=6) & (x1'=0);
  124. [time] s1=5 & x1<rc_slow_max -> (x1'=min(x1+1,168));
  125. // snd_req
  126. // do not use x1 until reset (in state 0 or in state 1) so do not need to increase x1
  127. // also can set x1 to 0 upon entering this state
  128. [rec_req21] s1=6 -> (s1'=0);
  129. [rec_ack21] s1=6 -> (s1'=8);
  130. [time] s1=6 -> (s1'=s1);
  131. // almost root (immediate)
  132. // loop in final states to remove deadlock
  133. [] s1=7 & s2=8 -> (s1'=s1);
  134. [] s1=8 & s2=7 -> (s1'=s1);
  135. [time] s1=7 -> (s1'=s1);
  136. [time] s1=8 -> (s1'=s1);
  137. endmodule
  138. // construct remaining automata through renaming
  139. module wire21=wire12[w12=w21, y1=z1, y2=z2,
  140. snd_req12=snd_req21, snd_idle12=snd_idle21, snd_ack12=snd_ack21,
  141. rec_req12=rec_req21, rec_idle12=rec_idle21, rec_ack12=rec_ack21]
  142. endmodule
  143. module node2=node1[s1=s2, s2=s1, x1=x2, fast1=fast2, slow1=slow2,
  144. rec_req21=rec_req12, rec_idle21=rec_idle12, rec_ack21=rec_ack12,
  145. snd_req12=snd_req21, snd_idle12=snd_idle21, snd_ack12=snd_ack21]
  146. endmodule
  147. // labels
  148. label "done" = (s1=8 & s2=7) | (s1=7 & s2=8);
  149. // reward structures
  150. // time
  151. rewards "time"
  152. [time] true : 1;
  153. endrewards
  154. // time nodes sending
  155. rewards "time_sending"
  156. [time] (w12>0 | w21>0) : 1;
  157. endrewards