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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [axi4_lite_lib/] [sim/] [src/] [axi4_lite_agent_pkg.sv] - Blame information for rev 29

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 29 qaztronic
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// Copyright (C) 2015 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
 
29
package axi4_lite_agent_pkg;
30
 
31
  // --------------------------------------------------------------------
32
  //
33
  import axi4_transaction_pkg::*;
34
 
35
 
36
  // --------------------------------------------------------------------
37
  //
38
  class axi4_lite_agent_class #(A = 32, N = 8, I = 1, MW = 3);
39
 
40
    axi4_transaction_class        #(.A(A), .N(N), .I(I))  tr_h;
41
    virtual axi4_master_bfm_if    #(.A(A), .N(N), .I(I))  axi4_m;
42
    virtual axi4_lite_register_if #(.N(N), .MW(MW))       r_if;
43
 
44
 
45
    //--------------------------------------------------------------------
46
    localparam LB = (N == 8) ? 3 : 2;
47
    localparam UB = LB + MW - 1;
48
 
49
 
50
    //--------------------------------------------------------------------
51
    function new
52
      (
53
        virtual axi4_master_bfm_if    #(.A(A), .N(N), .I(I))  axi4_m,
54
        virtual axi4_lite_register_if #(.N(N), .MW(MW))       r_if
55
      );
56
 
57
      this.axi4_m = axi4_m;
58
      this.r_if   = r_if;
59
 
60
    endfunction: new
61
 
62
 
63
    // --------------------------------------------------------------------
64
    //
65
    task
66
      basic_read
67
      (
68
        input   logic [(A-1):0]   araddr,
69
        output  logic [(8*N)-1:0] data[],
70
        output  logic [1:0]       rresp
71
      );
72
 
73
      this.tr_h = new;
74
      this.tr_h.basic_read(araddr);
75
 
76
      axi4_m.ar_h.put(tr_h);
77
      axi4_m.r_h.put(tr_h);
78
 
79
      @(axi4_m.r_h.done);
80
      data = tr_h.data_h.w;
81
      rresp = tr_h.resp;
82
 
83
    endtask: basic_read
84
 
85
 
86
    // --------------------------------------------------------------------
87
    //
88
    task
89
      basic_write
90
      (
91
        input   logic [(A-1):0]   awaddr,
92
        input   logic [(8*N)-1:0] data[],
93
        output  logic [1:0]       bresp
94
      );
95
 
96
      this.tr_h = new;
97
      this.tr_h.basic_write(awaddr);
98
 
99
      foreach(this.tr_h.payload_h.w[i])
100
        this.tr_h.payload_h.w[i] = data[i];
101
 
102
      axi4_m.aw_h.put(tr_h);
103
      axi4_m.w_h.put(tr_h);
104
      axi4_m.b_h.put(tr_h);
105
 
106
    endtask: basic_write
107
 
108
 
109
    // --------------------------------------------------------------------
110
    //
111
    task
112
      basic_random_write
113
      (
114
        input   logic [(A-1):0]   awaddr,
115
        output  logic [1:0]       bresp
116
      );
117
 
118
      this.tr_h = new;
119
      this.tr_h.basic_write(awaddr);
120
 
121
      axi4_m.aw_h.put(tr_h);
122
      axi4_m.w_h.put(tr_h);
123
      axi4_m.b_h.put(tr_h);
124
 
125
      @(axi4_m.b_h.done);
126
 
127
      if(r_if.register_out[awaddr[UB:LB]] == this.tr_h.payload_h.w[0])
128
        $display("^^^ %16.t | @0x%08x | PASS!!!", $time, awaddr);
129
      else
130
        $display("^^^ %16.t | @0x%08x | FAIL!!!", $time, awaddr);
131
 
132
    endtask: basic_random_write
133
 
134
 
135
    // --------------------------------------------------------------------
136
    //
137
    function void
138
      init;
139
 
140
    endfunction: init
141
 
142
 
143
  // --------------------------------------------------------------------
144
  //
145
  endclass: axi4_lite_agent_class
146
 
147
 
148
// --------------------------------------------------------------------
149
//
150
endpackage: axi4_lite_agent_pkg
151
 

powered by: WebSVN 2.1.0

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