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_tx.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                     ////
////                                                              ////
//////////////////////////////////////////////////////////////////////


import axis_video_frame_bfm_pkg::*;

module
  avf_tx
  #(
    BYTES_PER_PIXEL  = 2,
    AVF_OUTPUTS      = 4,
    AVF_TILES        = 1
  )
  (
    ref axis_video_frame_bfm_class f_tx_h[AVF_TILES],
    ref axis_video_frame_bfm_class f_rx_h[AVF_TILES]
  );

  // --------------------------------------------------------------------
  //
  localparam AVF_VERTICAL_BLANKING = 20;

  task automatic
    init_avf_tx;

      foreach(f_tx_h[i])
        f_tx_h[i].avf_vertical_blanking = AVF_VERTICAL_BLANKING;

      f_tx_h[0].run_tx_q(RIGHT_DOWN, 0);
      f_tx_h[1].run_tx_q(RIGHT_UP, 0);
      f_tx_h[2].run_tx_q(LEFT_DOWN, 0);
      f_tx_h[3].run_tx_q(LEFT_UP, 0);

  endtask: init_avf_tx


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

  video_frame_class clone_h;


  // --------------------------------------------------------------------
  //
  task automatic
    make_frame
    (
      string pattern,
      int pixel = 0
    );

      case(pattern.tolower)
        "constant":   foreach(f_tx_h[i]) f_tx_h[i].f_h.make_constant(pixel);
        "counting":   foreach(f_tx_h[i]) f_tx_h[i].f_h.make_counting();
        "horizontal": foreach(f_tx_h[i]) f_tx_h[i].f_h.make_horizontal();
        "vertical":   foreach(f_tx_h[i]) f_tx_h[i].f_h.make_vertical();
        "random":     foreach(f_tx_h[i]) f_tx_h[i].f_h.make_random();
        default:      $display("^^^ %16.t | %m | ERROR! %s pattern not supported", $time, pattern);
      endcase

  endtask: make_frame


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

  task automatic
    queue_frame
    (
      string pattern = ""
    );

      if(pattern != "")
        make_frame(pattern);

      foreach(f_tx_h[i])
      begin
        clone_h = f_tx_h[i].f_h.clone();
        f_tx_h[i].avf_q.put(clone_h);
        f_rx_h[i].avf_q.put(clone_h);
      end

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

  endtask: queue_frame


  // --------------------------------------------------------------------
  //
  task
    wait_for_tx_frames
    (
      input int unsigned count
    );

    repeat(count)
      @(f_tx_h[0].tx_frame_done);

  endtask: wait_for_tx_frames


  // --------------------------------------------------------------------
  //
  logic put_frame_active = 0;
  semaphore put_frame_semaphore = new(1);

  task automatic
    put_frame;

      if(put_frame_semaphore.try_get() == 0)
      begin
        $display("^^^ %16.t | %m | ERROR! Already put a frame.", $time);
        return;
      end

      $display("^^^ %16.t | %m | Putting a frame.", $time);
      put_frame_active = 1;

      fork
      begin

        f_tx_h[0].avf_fork_tx(RIGHT_DOWN, 0);
        f_tx_h[1].avf_fork_tx(RIGHT_UP, 0);
        f_tx_h[2].avf_fork_tx(LEFT_DOWN, 0);
        f_tx_h[3].avf_fork_tx(LEFT_UP, 0);

        wait fork;
        put_frame_active = 0;
        $display("^^^ %16.t | %m | Put a frame.", $time);
        put_frame_semaphore.put();

      end
      join_none

  endtask: put_frame


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


endmodule




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.