summaryrefslogtreecommitdiff
path: root/lab_5/SRC/monitor.sv
blob: 29801250f3a93283cb142d1fb916bb8104eb5dab (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//create a monitor class
import typedef_pkg::*;

class monitor;
  scoreboard sb;

  function new(scoreboard sb_in);
    sb = sb_in;
  endfunction

  task check();
    automatic result_t expected_result;

    case (sb.operation)
      ADD: begin
        expected_result = (sb.operand_a + sb.operand_b) & 16'h01FF;
        `FAIL_UNLESS_EQUAL(expected_result, sb.result & 16'h01FF, $sformatf(
                           "ADD a=%0d b=%0d", sb.operand_a, sb.operand_b))
      end
      MULT: begin
        expected_result = sb.operand_a * sb.operand_b;
        `FAIL_UNLESS_EQUAL(expected_result, sb.result, $sformatf(
                           "MULT a=%0d b=%0d", sb.operand_a, sb.operand_b))
      end
      OR: begin
        expected_result = (sb.operand_a | sb.operand_b) & 16'h00FF;
        `FAIL_UNLESS_EQUAL(expected_result, sb.result & 16'h00FF, $sformatf(
                           "OR a=%0d b=%0d", sb.operand_a, sb.operand_b))
      end
      AND: begin
        expected_result = (sb.operand_a & sb.operand_b) & 16'h00FF;
        `FAIL_UNLESS_EQUAL(expected_result, sb.result & 16'h00FF, $sformatf(
                           "AND a=%0d b=%0d", sb.operand_a, sb.operand_b))
      end
      default: `FAIL($sformatf("Unknown operation: %0d", sb.operation))
    endcase
  endtask
endclass