diff options
| author | Fuwn <[email protected]> | 2026-02-13 23:45:28 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-13 23:45:28 -0800 |
| commit | 73a3a25f2cf521084a21dfe759205b1b09460332 (patch) | |
| tree | e83d65f8e7de15e75eadeb288128e28e539cea65 /lab_5/SRC/monitor.sv | |
| parent | feat(lab_5): Add markdown files (diff) | |
| download | cst456-73a3a25f2cf521084a21dfe759205b1b09460332.tar.xz cst456-73a3a25f2cf521084a21dfe759205b1b09460332.zip | |
feat(lab_5): Implement lab
Diffstat (limited to 'lab_5/SRC/monitor.sv')
| -rw-r--r-- | lab_5/SRC/monitor.sv | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/lab_5/SRC/monitor.sv b/lab_5/SRC/monitor.sv index 2ce97c7..2980125 100644 --- a/lab_5/SRC/monitor.sv +++ b/lab_5/SRC/monitor.sv @@ -1 +1,38 @@ -//create a monitor class
\ No newline at end of file +//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 |