Advertisement
Guest User

Untitled

a guest
Feb 16th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. `timescale 1ns / 1ps
  2.  
  3. module tb_Mux_behavioral;
  4.  
  5. // Inputs to be defned as registers
  6. reg s0;
  7. reg s1;
  8. reg i0;
  9. reg i1;
  10. reg i2;
  11. reg i3;
  12.  
  13. // Outputs to be defined as wires
  14. wire d;
  15.  
  16. // Instantiate the Unit Under Test (UUT)
  17. Mux_behavioral uut (
  18. .s0(s0),
  19. .s1(s1),
  20. .i0(i0),
  21. .i1(i1),
  22. .i2(i2),
  23. .i3(i3),
  24. .d(d)
  25. );
  26.  
  27. initial begin
  28. // Initialize inputs
  29. s0 = 0;
  30. s1 = 0;
  31. i0 = 0;
  32. i1 = 0;
  33. i2 = 0;
  34. i3 = 0;
  35.  
  36. // Wait 50ns for global reset to finish
  37. #50;
  38.  
  39. // Stimulus - all input combinations followed by some wait time to observe the o/p
  40.  
  41. // For when i0 is chosen
  42. s0 = 0;
  43. s1 = 0;
  44. i0 = 0;
  45. i1 = 0;
  46. i2 = 0;
  47. i3 = 0;
  48. #50;
  49. $display("TC00");
  50. if(d != 1'b0) $display("Result is wrong");
  51.  
  52. s0 = 0;
  53. s1 = 0;
  54. i0 = 1;
  55. i1 = 0;
  56. i2 = 0;
  57. i3 = 0;
  58. #50;
  59. $display("TC01");
  60. if(d != 1'b1) $display("Result is wrong");
  61.  
  62. // For when i1 is chosen
  63. s0 = 1;
  64. s1 = 0;
  65. i0 = 0;
  66. i1 = 0;
  67. i2 = 0;
  68. i3 = 0;
  69. #50;
  70. $display("TC10");
  71. if(d != 1'b0) $display("Result is wrong");
  72.  
  73. s0 = 1;
  74. s1 = 0;
  75. i0 = 0;
  76. i1 = 1;
  77. i2 = 0;
  78. i3 = 0;
  79. #50;
  80. $display("TC11");
  81. if(d != 1'b1) $display("Result is wrong");
  82.  
  83. // For when i2 is chosen
  84. s0 = 0;
  85. s1 = 1;
  86. i0 = 0;
  87. i1 = 0;
  88. i2 = 0;
  89. i3 = 0;
  90. #50;
  91. $display("TC20");
  92. if(d != 1'b0) $display("Result is wrong");
  93.  
  94. s0 = 0;
  95. s1 = 1;
  96. i0 = 0;
  97. i1 = 0;
  98. i2 = 1;
  99. i3 = 0;
  100. #50;
  101. $display("TC21");
  102. if(d != 1'b1) $display("Result is wrong");
  103.  
  104. // For when i3 is chosen
  105. s0 = 1;
  106. s1 = 1;
  107. i0 = 1;
  108. i1 = 0;
  109. i2 = 0;
  110. i3 = 0;
  111. #50;
  112. $display("TC30");
  113. if(d != 1'b0) $display("Result is wrong");
  114.  
  115. s0 = 1;
  116. s1 = 1;
  117. i0 = 0;
  118. i1 = 0;
  119. i2 = 0;
  120. i3 = 1;
  121. #50;
  122. $display("TC31");
  123. if(d != 1'b1) $display("Result is wrong");
  124.  
  125. // Note other combinations, eg. when i1 & i2 are 1 simultaneously
  126. // were ignored, as this does not have any influence on the output - which is
  127. // only influenced by the select bits that map the appropriate i/p (only one)
  128. // to the o/p
  129.  
  130. end
  131.  
  132. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement