Advertisement
Ailrun

Untitled

May 31st, 2015
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 1`timescale 1ns / 1ps
  2. 2.   
  3. 3module EleCont_Test;
  4. 4.   
  5. 5.     // Inputs
  6. 6.     reg clk;
  7. 7.     reg reset;
  8. 8.     reg [11:0] nRFB;
  9. 9.     reg [9:1]  nIB1;
  10. 10.    reg [9:1]  nIB2;
  11. 11.  
  12. 12.    // Outputs
  13. 13.    wire [2:0] currentFloor1;
  14. 14.    wire [2:0] currentFloor2;
  15. 15.    wire [1:0] currentDirection1;
  16. 16.    wire [1:0] currentDirection2;
  17. 17.    wire [11:0] currentRealFloorButton;
  18. 18.    wire [9:1]  currentInternalButton1;
  19. 19.    wire [9:1]  currentInternalButton2;
  20. 20.    wire        doorState1;
  21. 21.    wire        doorState2;
  22. 22.  
  23. 23.    // Instantiate the Unit Under Test (UUT)
  24. 24.    ElevatorController#(40,40,0) uut
  25. 25.      (
  26. 26.       .clk(clk),
  27. 27.       .reset(reset),
  28. 28.       .newRealFloorButton(nRFB),
  29. 29.       .newInternalButton1(nIB1),
  30. 30.       .newInternalButton2(nIB2),
  31. 31.       .currentFloor1(currentFloor1),
  32. 32.       .currentFloor2(currentFloor2),
  33. 33.       .currentDirection1(currentDirection1),
  34. 34.       .currentDirection2(currentDirection2),
  35. 35.       .currentRealFloorButton(currentRealFloorButton),
  36. 36.       .currentInternalButton1(currentInternalButton1),
  37. 37.       .currentInternalButton2(currentInternalButton2),
  38. 38.       .doorState1(doorState1),
  39. 39.       .doorState2(doorState2),
  40. 40.       );
  41. 41.  
  42. 42.  
  43. 43.    initial begin
  44. 44.       clk = 0;
  45. 45.       reset = 1;
  46. 46.       nRFB = 0;
  47. 47.       nIB1 = 0;
  48. 48.       nIB2 = 0;
  49. 49.       #10000; //after 10 us
  50. 50.       reset = 0;
  51. 51.  
  52. 52.       #10000; //after 20 us
  53. 53.       nRFB = 12'b0_00_01_01_00_00_1;//1
  54. 54.       #100;
  55. 55.       nRFB = 0;
  56. 56.  
  57. 57.       #20000;//after 40 us
  58. 58.       nIB1 = 9'b00_000_1010;//2
  59. 59.       nIB2 = 9'b00_000_1001;//2
  60. 60.       #100;
  61. 61.       nIB1 = 0;//2
  62. 62.       nIB2 = 0;//2
  63. 63.  
  64. 64.       #20000;//after 60 us
  65. 65.       nIB1 = 9'b10_000_0010;//3
  66. 66.       nIB2 = 9'b00_001_0010;//3
  67. 67.       nRFB = 12'b1_00_00_01_00_10_0;//3
  68. 68.       #100;
  69. 69.       nIB1 = 0;//3
  70. 70.       nIB2 = 0;//3
  71. 71.       nRFB = 0;//3
  72. 72.  
  73. 73.       #10000;//after 70 us
  74. 74.       nRFB = 12'b0_10_00_00_01_00_0;//4
  75. 75.       #100;
  76. 76.       nRFB = 0;
  77. 77.  
  78. 78.       #30000;//after 100 us
  79. 79.       nIB1 = 9'b00_000_0101;//5
  80. 80.       nIB2 = 9'b10_000_1001;//5
  81. 81.       nRFB = 12'b0_00_00_00_00_10_0;//5
  82. 82.       #100;
  83. 83.       nIB1 = 0;
  84. 84.       nIB2 = 0;
  85. 85.       nRFB = 0;
  86. 86.  
  87. 87.       #20000;//after 120 us
  88. 88.       nIB1 = 9'b00_000_0100;//6
  89. 89.       nRFB = 12'b0_00_00_10_00_01_0;//6
  90. 90.       #100;
  91. 91.       nIB1 = 0;
  92. 92.       nRFB = 0;
  93. 93.  
  94. 94.       #40000;//after 160 us
  95. 95.       nIB1 = 9'b00_000_0100;//7
  96. 96.       nIB2 = 9'b00_000_0100;
  97. 97.       nRFB = 12'b0_00_11_00_01_00_0;
  98. 98.       #100;
  99. 99.       nIB1 = 0;
  100. 100.          nIB2 = 0;
  101. 101.          nRFB = 0;
  102. 102.     
  103. 103.          #40000;//after 200 us
  104. 104.          nIB1 = 9'b10_000_1010;//8
  105. 105.          nIB2 = 9'b00_001_1000;
  106. 106.          nRFB = 12'b0_00_00_00_10_00_0;
  107. 107.          #100;
  108. 108.          nIB1 = 0;
  109. 109.          nIB2 = 0;
  110. 110.          nRFB = 0;
  111. 111.     
  112. 112.          #10000;//after 210 us
  113. 113.          nIB1 = 9'b00_000_0100;//9
  114. 114.          nRFB = 12'b1_00_00_10_00_11_0;
  115. 115.          #100;
  116. 116.          nIB1 = 0;
  117. 117.          nRFB = 0;
  118. 118.     
  119. 119.          #20000; //after 230 us
  120. 120.          nIB1 = 9'b00_001_0100;//10
  121. 121.          nIB2 = 9'b00_001_0000;
  122. 122.          #100;
  123. 123.          nIB1 = 0;
  124. 124.          nIB2 = 0;
  125. 125.     
  126. 126.          #100000;//after 330 us
  127. 127.          nIB2 = 9'b10_000_0000;//11
  128. 128.          nRFB = 12'b0_00_01_00_01_10_0;
  129. 129.          #100;
  130. 130.          nIB2 = 0;
  131. 131.          nRFB = 0;
  132. 132.     
  133. 133.          #10000;//after 340 us
  134. 134.          nRFB = 12'b0_00_00_01_00_10_0;//12
  135. 135.          #100;
  136. 136.          nRFB = 0;
  137. 137.     
  138. 138.          #10000;//after 350 us
  139. 139.          nIB1 = 9'b00_000_0001;//13
  140. 140.          nIB2 = 9'b00_000_1001;
  141. 141.          #100;
  142. 142.          nIB1 = 0;
  143. 143.          nIB2 = 0;
  144. 144.     
  145. 145.          #10000;//after 360 us
  146. 146.          nIB2 = 9'b00_000_1001;//14
  147. 147.          #100;
  148. 148.          nIB2 = 0;
  149. 149.     
  150. 150.          #20000;//after 390 us
  151. 151.          nRFB = 12'b0_00_00_00_01_10_0;//15
  152. 152.          #100;
  153. 153.          nRFB = 0;
  154. 154.     
  155. 155.          #20000;//after 410 us
  156. 156.          nIB1 = 9'b00_001_0000;//16
  157. 157.          nRFB = 12'b0_00_00_01_00_00_0;
  158. 158.          #100;
  159. 159.          nIB1 = 0;
  160. 160.          nRFB = 0;
  161. 161.     
  162. 162.          #200000;
  163. 163.          $finish;
  164. 164.       end
  165. 165.     
  166. 166.       always begin
  167. 167.          #25 clk = ~clk;
  168. 168.       end
  169. 169.     
  170. 170.    endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement