The source code and dockerfile for the GSW2024 AI Lab.
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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

169 lines
5.4 KiB

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