OpenCores
URL https://opencores.org/ocsvn/qaz_libs/qaz_libs/trunk

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [BFM/] [src/] [axis_video_frame/] [legacy/] [avf_agent_class_pkg.sv] - Rev 45

Compare with Previous | Blame | View Log

//////////////////////////////////////////////////////////////////////
////                                                              ////
//// Copyright (C) 2015 Authors and OPENCORES.ORG                 ////
////                                                              ////
//// This source file may be used and distributed without         ////
//// restriction provided that this copyright statement is not    ////
//// removed from the file and that any derivative work contains  ////
//// the original copyright notice and the associated disclaimer. ////
////                                                              ////
//// This source file is free software; you can redistribute it   ////
//// and/or modify it under the terms of the GNU Lesser General   ////
//// Public License as published by the Free Software Foundation; ////
//// either version 2.1 of the License, or (at your option) any   ////
//// later version.                                               ////
////                                                              ////
//// This source is distributed in the hope that it will be       ////
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
//// PURPOSE.  See the GNU Lesser General Public License for more ////
//// details.                                                     ////
////                                                              ////
//// You should have received a copy of the GNU Lesser General    ////
//// Public License along with this source; if not, download it   ////
//// from http://www.opencores.org/lgpl.shtml                     ////
////                                                              ////
//////////////////////////////////////////////////////////////////////


package avf_agent_class_pkg;

  // --------------------------------------------------------------------
  //
  import video_frame_pkg::*;
  import axis_video_frame_bfm_pkg::*;


  // --------------------------------------------------------------------
  //
  class avf_agent_class #(BYTES_PER_PIXEL, OUTPUTS_PER_TILE = 1, AVF_U = 3);

    localparam AVF_N = BYTES_PER_PIXEL * OUTPUTS_PER_TILE;  // data bus width in bytes
    localparam AVF_B = BYTES_PER_PIXEL * 8;                 // bits per pixel on TDATA

    virtual axis_if #(.N(AVF_N), .U(AVF_U)) avf_axis_in_if[];
    virtual axis_if #(.N(AVF_N), .U(AVF_U)) avf_axis_out_if[];

    avf_config_class c_h;

    avf_tx_class #(BYTES_PER_PIXEL, OUTPUTS_PER_TILE, AVF_U) tx_h;
    avf_rx_class #(BYTES_PER_PIXEL, OUTPUTS_PER_TILE, AVF_U) rx_h;

    video_frame_class clone_h;
    video_frame_class sent_f_h;
    video_frame_class rx_f_h;

    mailbox #(video_frame_class) q[];


    // --------------------------------------------------------------------
    //
    virtual task
      queue_frame
      (
        string pattern = "",
        int pixel = 0
      );

        if(pattern != "")
          tx_h.make_frame(pattern, pixel);

        foreach(tx_h.tx_bfm_h[i])
        begin
          clone_h = tx_h.tx_bfm_h[i].f_h.clone();
          tx_h.tx_bfm_h[i].put(clone_h);
          q[i].put(clone_h);
        end

        $display("^^^ %16.t | %m | using %s pattern", $time, pattern);

    endtask: queue_frame


    // --------------------------------------------------------------------
    //
    virtual task automatic
      compare_frame;

      int mismatch_count;

      $display("^^^ %16.t | %m", $time);

      foreach(rx_h.rx_bfm_h[i])
      begin
        q[i].get(sent_f_h);
        rx_h.rx_bfm_h[i].get(rx_f_h);
        mismatch_count = sent_f_h.compare(8, rx_f_h);
      end

    endtask: compare_frame


    // --------------------------------------------------------------------
    //
    virtual task set_tready(input tready);
      $display("^^^ %16.t | %m", $time);
      foreach(rx_h.rx_bfm_h[i])
        rx_h.rx_bfm_h[i].set_tready(tready);
    endtask: set_tready


    // --------------------------------------------------------------------
    //
    virtual task flush_sent_frame;
      $display("^^^ %16.t | %m", $time);
      foreach(rx_h.rx_bfm_h[i])
        q[i].get(sent_f_h);
    endtask: flush_sent_frame


    // --------------------------------------------------------------------
    //
    virtual task rx_flush_frame;
      $display("^^^ %16.t | %m", $time);
      foreach(rx_h.rx_bfm_h[i])
        rx_h.rx_bfm_h[i].get(rx_f_h);
    endtask: rx_flush_frame


    //--------------------------------------------------------------------
    //
    function void init(avf_config_class c_h);

      rx_h = new(c_h, avf_axis_in_if);
      tx_h = new(c_h, avf_axis_out_if);

      this.q = new[$size(avf_axis_out_if)];
      foreach(q[i])
        this.q[i] = new();

    endfunction: init


    //--------------------------------------------------------------------
    //
    function new
      (
        virtual axis_if #(.N(AVF_N), .U(AVF_U)) avf_axis_in_if[],
        virtual axis_if #(.N(AVF_N), .U(AVF_U)) avf_axis_out_if[]
      );

      this.avf_axis_in_if = avf_axis_in_if;
      this.avf_axis_out_if = avf_axis_out_if;
    endfunction: new


    // --------------------------------------------------------------------
    //

  endclass: avf_agent_class

endpackage: avf_agent_class_pkg





Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.