# avt_channel2tlm example

This example uses an avt_channel2tlm to connect an VMM producer (generator) to an OVM consumer. With this adapter, any VMM producer using a vmm_channel to inject transactions can be connected to any OVM consumer that uses TLM port and exports.

../../../../examples/01_adapters/03_channel2tlm.sv

    `define OVM_ON_TOP

    `include "ovm_vmm_pkg.sv"

    `include "ovm_apb_rw.sv"
    `include "vmm_apb_rw.sv"
    `include "apb_rw_converters.sv"
    `include "apb_scoreboard.sv"

    `include "ovm_consumers.sv"

    class env extends ovm_component;

      `ovm_component_utils(env)

      vmm_apb_rw_atomic_gen      v_prod;
      ovm_consumer #(ovm_apb_rw) o_cons;
      apb_channel2tlm            adapter;
      apb_scoreboard             compare;

      bit PASS  = 0;

      function new (string name="env",ovm_component parent=null);
        super.new(name,parent);
      endfunction

      virtual function void build();
        v_prod   = new("v_prod",1);
        o_cons   = new("o_cons", this);
        adapter  = new("adapter",this,v_prod.out_chan);
        compare  = new("comparator", this,v_prod.out_chan);
        v_prod.out_chan.tee_mode(1);
      endfunction

      virtual function void connect();
        o_cons.blocking_get_port.connect(adapter.get_peek_export);
        o_cons.analysis_port.connect(compare.ovm_in);
      endfunction

      virtual task run();
        vmm_apb_rw vtr;
        v_prod.start_xactor();
        @(o_cons.num_trans == 5);
        ovm_top.stop_request();
      endtask

      virtual function void check();
        if(compare.m_matches == 5 && compare.m_mismatches == 0)
          PASS  = 1;
      endfunction // check

      virtual function void report();
        if(PASS == 1) begin
          `OVM_REPORT_INFO("PASS","Test PASSED");
        end
        else begin
          `OVM_REPORT_ERROR("FAIL","Test FAILED");
        end
      endfunction // report

    endclass

    module example_03_channel2tlm;

      env e = new;

      initial run_test();

    endmodule

> class avt_channel2tlm #(
> | type | VMM_REQ | = | int,
> |  | OVM_REQ | = | int,
> |  | VMM2OVM_REQ | = | int,
> |  | OVM_RSP | = | OVM_REQ,
> |  | VMM_RSP | = | VMM_REQ,
> |  | OVM2VMM_RSP | = | avt_converter #(OVM_RSP,VMM_RSP),
> |  | OVM_MATCH_REQ_RSP | = | avt_match_ovm_id
> ) extends ovm_component

Use this class to connect a VMM producer to an OVM consumer.