Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.56 KB | None | 0 0
  1. // Test case 1
  2.  
  3. A = 8'10101010;
  4. B = 8'01010101;
  5. OP = 3'b110; // OR
  6.  
  7. #100; // wait for input signals to propagate through circuit
  8.  
  9. $display("MSIM>");
  10. if(Y == 8'b11111111 && C == 1'b0 && V == 1'b0 && N == 1'b1 && Z == 1'b0) begin
  11. $display("MSIM> AND (OP = %3b) is correct for A = %8b, B = %8b: Y = %8b, C = %1b, V = %1b, N = %1b, Z = %1b", OP, A, B, Y, C, V, N, Z);
  12. end
  13. else begin
  14. $display("MSIM> ERROR: AND (OP = %3b) is incorrect for A = %8b, B = %8b: Y = %8b (should be 11111111), C = %1b (should be 0), V = %1b (should be 0), N = %1b (should be 1), Z = %1b (should be 0)", OP, A, B, Y, C, V, N, Z);
  15. end
  16. $display("MSIM>");
  17.  
  18. // Test case 2
  19.  
  20. A = 8'00000000;
  21. B = 8'11111111;
  22. OP = 3'b101; // AND
  23.  
  24. #100; // wait for input signals to propagate through circuit
  25.  
  26. $display("MSIM>");
  27. if(Y == 8'b00000000 && C == 1'b0 && V == 1'b0 && N == 1'b0 && Z == 1'b1) begin
  28. $display("MSIM> AND (OP = %3b) is correct for A = %8b, B = %8b: Y = %8b, C = %1b, V = %1b, N = %1b, Z = %1b", OP, A, B, Y, C, V, N, Z);
  29. end
  30. else begin
  31. $display("MSIM> ERROR: AND (OP = %3b) is incorrect for A = %8b, B = %8b: Y = %8b (should be 00000000), C = %1b (should be 0), V = %1b (should be 0), N = %1b (should be 0), Z = %1b (should be 1)", OP, A, B, Y, C, V, N, Z);
  32. end
  33. $display("MSIM>");
  34.  
  35. // Test case 3
  36.  
  37. A = 8'00000000;
  38. B = 8'11111111;
  39. OP = 3'b101; // OR
  40.  
  41. #100; // wait for input signals to propagate through circuit
  42.  
  43. $display("MSIM>");
  44. if(Y == 8'b11111111 && C == 1'b0 && V == 1'b0 && N == 1'b1 && Z == 1'b0) begin
  45. $display("MSIM> AND (OP = %3b) is correct for A = %8b, B = %8b: Y = %8b, C = %1b, V = %1b, N = %1b, Z = %1b", OP, A, B, Y, C, V, N, Z);
  46. end
  47. else begin
  48. $display("MSIM> ERROR: AND (OP = %3b) is incorrect for A = %8b, B = %8b: Y = %8b (should be 11111111), C = %1b (should be 0), V = %1b (should be 0), N = %1b (should be 1), Z = %1b (should be 0)", OP, A, B, Y, C, V, N, Z);
  49. end
  50. $display("MSIM>");
  51.  
  52.  
  53. // Test case 4
  54.  
  55. A = 8'10101010;
  56. B = 8'11111111;
  57. OP = 3'b010; // SRA
  58.  
  59. #100; // wait for input signals to propagate through circuit
  60.  
  61. $display("MSIM>");
  62. if(Y == 8'b11010101 && C == 1'b0 && V == 1'b0 && N == 1'b1 && Z == 1'b0) begin
  63. $display("MSIM> AND (OP = %3b) is correct for A = %8b, B = %8b: Y = %8b, C = %1b, V = %1b, N = %1b, Z = %1b", OP, A, B, Y, C, V, N, Z);
  64. end
  65. else begin
  66. $display("MSIM> ERROR: AND (OP = %3b) is incorrect for A = %8b, B = %8b: Y = %8b (should be 11010101), C = %1b (should be 0), V = %1b (should be 0), N = %1b (should be 1), Z = %1b (should be 0)", OP, A, B, Y, C, V, N, Z);
  67. end
  68. $display("MSIM>");
  69.  
  70. // Test case 5
  71.  
  72. A = 8'11111111;
  73. B = 8'11111111;
  74. OP = 3'b010; // SRA
  75.  
  76. #100; // wait for input signals to propagate through circuit
  77.  
  78. $display("MSIM>");
  79. if(Y == 8'b11111111 && C == 1'b1 && V == 1'b0 && N == 1'b1 && Z == 1'b0) begin
  80. $display("MSIM> AND (OP = %3b) is correct for A = %8b, B = %8b: Y = %8b, C = %1b, V = %1b, N = %1b, Z = %1b", OP, A, B, Y, C, V, N, Z);
  81. end
  82. else begin
  83. $display("MSIM> ERROR: AND (OP = %3b) is incorrect for A = %8b, B = %8b: Y = %8b (should be 11111111), C = %1b (should be 1), V = %1b (should be 0), N = %1b (should be 1), Z = %1b (should be 0)", OP, A, B, Y, C, V, N, Z);
  84. end
  85. $display("MSIM>");
  86.  
  87.  
  88. // Test case 6
  89.  
  90. A = 8'11111111;
  91. B = 8'11111111;
  92. OP = 3'b011; // SRL
  93.  
  94. #100; // wait for input signals to propagate through circuit
  95.  
  96. $display("MSIM>");
  97. if(Y == 8'b01111111 && C == 1'b1 && V == 1'b0 && N == 1'b0 && Z == 1'b0) begin
  98. $display("MSIM> AND (OP = %3b) is correct for A = %8b, B = %8b: Y = %8b, C = %1b, V = %1b, N = %1b, Z = %1b", OP, A, B, Y, C, V, N, Z);
  99. end
  100. else begin
  101. $display("MSIM> ERROR: AND (OP = %3b) is incorrect for A = %8b, B = %8b: Y = %8b (should be 01111111), C = %1b (should be 1), V = %1b (should be 0), N = %1b (should be 0), Z = %1b (should be 0)", OP, A, B, Y, C, V, N, Z);
  102. end
  103. $display("MSIM>");
  104.  
  105. // Test case 7
  106.  
  107. A = 8'11111111;
  108. B = 8'11111111;
  109. OP = 3'b100; // SLL
  110.  
  111. #100; // wait for input signals to propagate through circuit
  112.  
  113. $display("MSIM>");
  114. if(Y == 8'b11111110 && C == 1'b1 && V == 1'b0 && N == 1'b1 && Z == 1'b0) begin
  115. $display("MSIM> AND (OP = %3b) is correct for A = %8b, B = %8b: Y = %8b, C = %1b, V = %1b, N = %1b, Z = %1b", OP, A, B, Y, C, V, N, Z);
  116. end
  117. else begin
  118. $display("MSIM> ERROR: AND (OP = %3b) is incorrect for A = %8b, B = %8b: Y = %8b (should be 11111110), C = %1b (should be 1), V = %1b (should be 0), N = %1b (should be 1), Z = %1b (should be 0)", OP, A, B, Y, C, V, N, Z);
  119. end
  120. $display("MSIM>");
  121.  
  122. // Test case 8
  123.  
  124. A = 8'01111110;
  125. B = 8'11111111;
  126. OP = 3'b100; // SLL
  127.  
  128. #100; // wait for input signals to propagate through circuit
  129.  
  130. $display("MSIM>");
  131. if(Y == 8'b11111100 && C == 1'b0 && V == 1'b0 && N == 1'b1 && Z == 1'b0) begin
  132. $display("MSIM> AND (OP = %3b) is correct for A = %8b, B = %8b: Y = %8b, C = %1b, V = %1b, N = %1b, Z = %1b", OP, A, B, Y, C, V, N, Z);
  133. end
  134. else begin
  135. $display("MSIM> ERROR: AND (OP = %3b) is incorrect for A = %8b, B = %8b: Y = %8b (should be 11111100), C = %1b (should be 0), V = %1b (should be 0), N = %1b (should be 1), Z = %1b (should be 0)", OP, A, B, Y, C, V, N, Z);
  136. end
  137. $display("MSIM>");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement