Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Test case 1
- A = 8'10101010;
- B = 8'01010101;
- OP = 3'b110; // OR
- #100; // wait for input signals to propagate through circuit
- $display("MSIM>");
- if(Y == 8'b11111111 && C == 1'b0 && V == 1'b0 && N == 1'b1 && Z == 1'b0) begin
- $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);
- end
- else begin
- $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);
- end
- $display("MSIM>");
- // Test case 2
- A = 8'00000000;
- B = 8'11111111;
- OP = 3'b101; // AND
- #100; // wait for input signals to propagate through circuit
- $display("MSIM>");
- if(Y == 8'b00000000 && C == 1'b0 && V == 1'b0 && N == 1'b0 && Z == 1'b1) begin
- $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);
- end
- else begin
- $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);
- end
- $display("MSIM>");
- // Test case 3
- A = 8'00000000;
- B = 8'11111111;
- OP = 3'b101; // OR
- #100; // wait for input signals to propagate through circuit
- $display("MSIM>");
- if(Y == 8'b11111111 && C == 1'b0 && V == 1'b0 && N == 1'b1 && Z == 1'b0) begin
- $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);
- end
- else begin
- $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);
- end
- $display("MSIM>");
- // Test case 4
- A = 8'10101010;
- B = 8'11111111;
- OP = 3'b010; // SRA
- #100; // wait for input signals to propagate through circuit
- $display("MSIM>");
- if(Y == 8'b11010101 && C == 1'b0 && V == 1'b0 && N == 1'b1 && Z == 1'b0) begin
- $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);
- end
- else begin
- $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);
- end
- $display("MSIM>");
- // Test case 5
- A = 8'11111111;
- B = 8'11111111;
- OP = 3'b010; // SRA
- #100; // wait for input signals to propagate through circuit
- $display("MSIM>");
- if(Y == 8'b11111111 && C == 1'b1 && V == 1'b0 && N == 1'b1 && Z == 1'b0) begin
- $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);
- end
- else begin
- $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);
- end
- $display("MSIM>");
- // Test case 6
- A = 8'11111111;
- B = 8'11111111;
- OP = 3'b011; // SRL
- #100; // wait for input signals to propagate through circuit
- $display("MSIM>");
- if(Y == 8'b01111111 && C == 1'b1 && V == 1'b0 && N == 1'b0 && Z == 1'b0) begin
- $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);
- end
- else begin
- $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);
- end
- $display("MSIM>");
- // Test case 7
- A = 8'11111111;
- B = 8'11111111;
- OP = 3'b100; // SLL
- #100; // wait for input signals to propagate through circuit
- $display("MSIM>");
- if(Y == 8'b11111110 && C == 1'b1 && V == 1'b0 && N == 1'b1 && Z == 1'b0) begin
- $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);
- end
- else begin
- $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);
- end
- $display("MSIM>");
- // Test case 8
- A = 8'01111110;
- B = 8'11111111;
- OP = 3'b100; // SLL
- #100; // wait for input signals to propagate through circuit
- $display("MSIM>");
- if(Y == 8'b11111100 && C == 1'b0 && V == 1'b0 && N == 1'b1 && Z == 1'b0) begin
- $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);
- end
- else begin
- $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);
- end
- $display("MSIM>");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement