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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [BFM/] [src/] [axis_video_frame/] [avf_master_driver.svh] - Blame information for rev 45

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 45 qaztronic
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// Copyright (C) 2018 Authors and OPENCORES.ORG                 ////
4
////                                                              ////
5
//// This source file may be used and distributed without         ////
6
//// restriction provided that this copyright statement is not    ////
7
//// removed from the file and that any derivative work contains  ////
8
//// the original copyright notice and the associated disclaimer. ////
9
////                                                              ////
10
//// This source file is free software; you can redistribute it   ////
11
//// and/or modify it under the terms of the GNU Lesser General   ////
12
//// Public License as published by the Free Software Foundation; ////
13
//// either version 2.1 of the License, or (at your option) any   ////
14
//// later version.                                               ////
15
////                                                              ////
16
//// This source is distributed in the hope that it will be       ////
17
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
18
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
19
//// PURPOSE.  See the GNU Lesser General Public License for more ////
20
//// details.                                                     ////
21
////                                                              ////
22
//// You should have received a copy of the GNU Lesser General    ////
23
//// Public License along with this source; if not, download it   ////
24
//// from http://www.opencores.org/lgpl.shtml                     ////
25
////                                                              ////
26
//////////////////////////////////////////////////////////////////////
27
 
28
class avf_master_driver #(N, U)
29
  extends uvm_driver #(avf_sequence_item);
30
   `uvm_component_param_utils(avf_master_driver #(N, U))
31
 
32
  // --------------------------------------------------------------------
33
  virtual axis_if #(.N(N), .U(U)) vif;
34
  video_frame_class f_h;
35
 
36
  //--------------------------------------------------------------------
37
  function void set_default;
38
    vif.cb_m.tvalid <= 0;
39
    vif.cb_m.tdata  <= 'x;
40
    vif.cb_m.tstrb  <= {N{1'b1}};
41
    vif.cb_m.tkeep  <= {N{1'b1}};
42
    vif.cb_m.tlast  <= 'x;
43
    vif.cb_m.tid    <= 0;
44
    vif.cb_m.tdest  <= 0;
45
    vif.cb_m.tuser  <= 'x;
46
  endfunction: set_default
47
 
48
  //--------------------------------------------------------------------
49
  virtual task run_phase(uvm_phase phase);
50
    avf_sequence_item item;
51
    logic [(8*N)-1:0] tdata;
52
    int offset;
53
 
54
    super.run_phase(phase);
55
 
56
    set_default();
57
 
58
    forever
59
    begin
60
      wait(vif.aresetn);
61
      seq_item_port.get_next_item(item);
62
 
63
      while(item.frame_buffer.try_get(f_h))
64
      begin
65
        vif.zero_cycle_delay();
66
        repeat(item.delay_h.get(item.sof_delay))
67
          @(vif.cb_m);
68
        vif.cb_m.tvalid <= 1;
69
 
70
        foreach(f_h.lines[l])
71
          for(int p = 0; p < f_h.pixels_per_line; p += f_h.pixels_per_clk)
72
          begin
73
            if(l == 0 && p == 0)
74
              vif.cb_m.tuser[0] <= 1;
75
            else
76
              vif.cb_m.tuser[0] <= 0;
77
 
78
            if(p == 0)
79
              vif.cb_m.tuser[1] <= 1;
80
            else
81
              vif.cb_m.tuser[1] <= 0;
82
 
83
            if(p + f_h.pixels_per_clk >= f_h.pixels_per_line && l + 1 >= f_h.lines_per_frame)
84
              vif.cb_m.tuser[2] <= 1;
85
            else
86
              vif.cb_m.tuser[2] <= 0;
87
 
88
            if(p + f_h.pixels_per_clk >= f_h.pixels_per_line)
89
              vif.cb_m.tlast <= 1;
90
            else
91
              vif.cb_m.tlast <= 0;
92
 
93
            for(int i = 0; i < f_h.pixels_per_clk; i++)
94
            begin
95
              offset = i * f_h.bytes_per_pixel * 8;
96
              for(int k = 0; k < f_h.bytes_per_pixel; k++)
97
                tdata[offset + (k * 8) +: 8] = f_h.lines[l].pixel[p + i][k * 8 +: 8];
98
            end
99
 
100
            vif.cb_m.tdata <= tdata;
101
            @(vif.cb_m iff vif.cb_m.tready);
102
 
103
            vif.cb_m.tvalid <= 0;
104
            repeat(item.get_delay(vif.cb_s.tlast, vif.cb_s.tuser[2]))
105
              @(vif.cb_m);
106
            vif.cb_m.tvalid <= 1;
107
          end
108
 
109
        vif.cb_m.tuser[2] <= 0;
110
        vif.cb_m.tlast    <= 0;
111
        vif.cb_m.tvalid   <= 0;
112
      end
113
 
114
      seq_item_port.item_done();
115
    end
116
  endtask : run_phase
117
 
118
  //--------------------------------------------------------------------
119
  function new(string name, uvm_component parent);
120
    super.new(name, parent);
121
  endfunction
122
 
123
// --------------------------------------------------------------------
124
endclass : avf_master_driver

powered by: WebSVN 2.1.0

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