diff options
Diffstat (limited to 'homework_2/SRC/driver.sv')
| -rw-r--r-- | homework_2/SRC/driver.sv | 70 |
1 files changed, 37 insertions, 33 deletions
diff --git a/homework_2/SRC/driver.sv b/homework_2/SRC/driver.sv index 37d0583..03d17b8 100644 --- a/homework_2/SRC/driver.sv +++ b/homework_2/SRC/driver.sv @@ -1,33 +1,37 @@ -// The driver is responsible for driving transactions to the DUT
-// All it does is to get a transaction from the mailbox if it is
-// available and drive it out into the DUT interface.
-class driver extends uvm_driver #(Item);
- `uvm_component_utils(driver)
- function new(string name = "driver", uvm_component parent=null);
- super.new(name, parent);
- endfunction
-
- 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("DRV", "Could not get vif")
- endfunction
-
- virtual task run_phase(uvm_phase phase);
- super.run_phase(phase);
- forever begin
- Item m_item;
- `uvm_info("DRV", $sformatf("Wait for item from sequencer"), UVM_HIGH)
- seq_item_port.get_next_item(m_item);
- drive_item(m_item);
- seq_item_port.item_done();
- end
- endtask
-
- virtual task drive_item(Item m_item);
- @(vif.cb);
- vif.cb.in <= m_item.in;
- endtask
-endclass
\ No newline at end of file +// The driver is responsible for driving transactions to the DUT +// All it does is to get a transaction from the mailbox if it is +// available and drive it out into the DUT interface. +class driver extends uvm_driver #(Item); + `uvm_component_utils(driver) + function new(string name = "driver", uvm_component parent = null); + super.new(name, parent); + endfunction + + 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("DRV", "Could not get vif") + endfunction + + virtual task run_phase(uvm_phase phase); + super.run_phase(phase); + forever begin + Item m_item; + + `uvm_info("DRV", $sformatf("Wait for item from sequencer"), UVM_HIGH) + + seq_item_port.get_next_item(m_item); + drive_item(m_item); + seq_item_port.item_done(); + end + endtask + + virtual task drive_item(Item m_item); + @(vif.cb); + + vif.cb.inp <= m_item.inp; + endtask +endclass |