| // Copyright lowRISC contributors. |
| // Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| // SPDX-License-Identifier: Apache-2.0 |
| |
| class i2c_driver extends dv_base_driver #(i2c_item, i2c_agent_cfg); |
| `uvm_component_utils(i2c_driver) |
| |
| // the base class provides the following handles for use: |
| i2c_agent_cfg cfg; |
| |
| `uvm_component_new |
| |
| virtual task run_phase(uvm_phase phase); |
| // base class forks off reset_signals() and get_and_drive() tasks |
| super.run_phase(phase); |
| reset_signals(); |
| get_and_drive(); |
| endtask |
| |
| // reset signals |
| virtual task reset_signals(); |
| cfg.vif.scl_i <= 1'b1; |
| cfg.vif.sda_i <= 1'b1; |
| endtask : reset_signals |
| |
| // drive trans received from sequencer |
| virtual task get_and_drive(); |
| forever begin |
| seq_item_port.get_next_item(req); |
| $cast(rsp, req.clone()); |
| rsp.set_id_info(req); |
| `uvm_info(`gfn, $sformatf("rcvd item:\n%0s", req.sprint()), UVM_HIGH) |
| // TODO: do the driving part |
| // |
| // send rsp back to seq |
| `uvm_info(`gfn, "item sent", UVM_HIGH) |
| seq_item_port.item_done(rsp); |
| end |
| endtask |
| |
| endclass : i2c_driver |