summaryrefslogtreecommitdiff
path: root/lab_5/SRC/monitor.sv
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-13 23:45:28 -0800
committerFuwn <[email protected]>2026-02-13 23:45:28 -0800
commit73a3a25f2cf521084a21dfe759205b1b09460332 (patch)
treee83d65f8e7de15e75eadeb288128e28e539cea65 /lab_5/SRC/monitor.sv
parentfeat(lab_5): Add markdown files (diff)
downloadcst456-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.sv39
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