diff options
| author | Fuwn <[email protected]> | 2026-02-24 19:55:11 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-24 19:55:11 -0800 |
| commit | 871c6eae5ffda0ada6b1798209cb784c20afea06 (patch) | |
| tree | a24590b45440f62c67c0aa9aadf408a3bb207659 /homework_2/SRC/monitor.sv | |
| parent | feat(midterm): Add implementation (diff) | |
| download | cst456-871c6eae5ffda0ada6b1798209cb784c20afea06.tar.xz cst456-871c6eae5ffda0ada6b1798209cb784c20afea06.zip | |
feat(homework_2): Add initial files
Diffstat (limited to 'homework_2/SRC/monitor.sv')
| -rw-r--r-- | homework_2/SRC/monitor.sv | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/homework_2/SRC/monitor.sv b/homework_2/SRC/monitor.sv new file mode 100644 index 0000000..cb848ec --- /dev/null +++ b/homework_2/SRC/monitor.sv @@ -0,0 +1,37 @@ +// The monitor has a virtual interface handle with which
+// it can monitor the events happening on the interface.
+// It sees new transactions and then captures information
+// into a packet and sends it to the scoreboard
+// using another mailbox.
+class monitor extends uvm_monitor;
+ `uvm_component_utils(monitor)
+ function new(string name="monitor", uvm_component parent=null);
+ super.new(name, parent);
+ endfunction
+
+ uvm_analysis_port #(Item) mon_analysis_port;
+ virtual des_if vif;
+
+ virtual function void build_phase(uvm_phase phase);
+ super.build_phase(phase);
+ if (!uvm_config_db#(virtual des_if)::get(this, "", "des_vif", vif))
+ `uvm_fatal("MON", "Could not get vif")
+ mon_analysis_port = new ("mon_analysis_port", this);
+ endfunction
+
+ virtual task run_phase(uvm_phase phase);
+ super.run_phase(phase);
+ // This task monitors the interface for a complete
+ // transaction and writes into analysis port when complete
+ forever begin
+ @ (vif.cb);
+ if (vif.rstn) begin
+ Item item = Item::type_id::create("item");
+ item.in = vif.in;
+ item.out = vif.cb.out;
+ mon_analysis_port.write(item);
+ `uvm_info("MON", $sformatf("Saw item %s", item.convert2str()), UVM_HIGH)
+ end
+ end
+ endtask
+endclass
|