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

Subversion Repositories hssdrc

[/] [hssdrc/] [trunk/] [testbench/] [sdram_agent_class.sv] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 des00
//
2
// Project      : High-Speed SDRAM Controller with adaptive bank management and command pipeline
3
//
4
// Project Nick : HSSDRC
5
//
6
// Version      : 1.0-beta
7
//
8
// Revision     : $Revision: 1.1 $
9
//
10
// Date         : $Date: 2008-03-06 13:54:00 $
11
//
12
// Workfile     : sdram_agent_class.sv
13
//
14
// Description  : agent for connect with hssdrc controller via driver
15
//
16
// HSSDRC is licensed under MIT License
17
//
18
// Copyright (c) 2007-2008, Denis V.Shekhalev (des00@opencores.org)
19
//
20
// Permission  is hereby granted, free of charge, to any person obtaining a copy of
21
// this  software  and  associated documentation files (the "Software"), to deal in
22
// the  Software  without  restriction,  including without limitation the rights to
23
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
24
// the  Software, and to permit persons to whom the Software is furnished to do so,
25
// subject to the following conditions:
26
//
27
// The  above  copyright notice and this permission notice shall be included in all
28
// copies or substantial portions of the Software.
29
//
30
// THE  SOFTWARE  IS  PROVIDED  "AS  IS",  WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
32
// FOR  A  PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
33
// COPYRIGHT  HOLDERS  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
34
// IN  AN  ACTION  OF  CONTRACT,  TORT  OR  OTHERWISE,  ARISING  FROM, OUT OF OR IN
35
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36
//
37
 
38
 
39
 
40
`include "tb_define.svh"
41
`include "sdram_transaction_class.sv"
42
 
43
class sdram_agent_class;
44
 
45
  // to hssdrc_driver
46
  sdram_tr_mbx in_mbx;
47
 
48
  // input transaction
49
  sdram_tr_mbx write_tr_mbx;
50
  sdram_tr_mbx read_tr_mbx;
51
 
52
  // tb syncronization : transaction done numbers
53
  int write_tr_done_num;
54
  int  read_tr_done_num;
55
 
56
  // acknowledge from driver
57
  sdram_tr_ack_mbx done_mbx;
58
 
59
  //
60
  //
61
  //
62
 
63
  function new (sdram_tr_mbx in_mbx, sdram_tr_ack_mbx done_mbx, sdram_tr_mbx write_tr_mbx, read_tr_mbx);
64
 
65
    this.in_mbx   = in_mbx;
66
 
67
    this.done_mbx = done_mbx;
68
 
69
    this.write_tr_mbx = write_tr_mbx;
70
    this.read_tr_mbx  = read_tr_mbx;
71
 
72
  endfunction
73
 
74
  //
75
  //
76
  //
77
 
78
  task SetTransaction (sdram_transaction_class tr);
79
    tr_type_e_t ret_code;
80
 
81
    in_mbx.put (tr);
82
 
83
    case (tr.tr_type)
84
      cTR_WRITE_LOCKED, cTR_READ_LOCKED, cTR_REFR_LOCKED : done_mbx.get (ret_code);
85
      default : begin end
86
    endcase
87
 
88
  endtask
89
 
90
  //
91
  //
92
  //
93
 
94
  task run_write_read ();
95
 
96
    fork
97
      write_read();
98
    join_none
99
 
100
  endtask
101
 
102
  //
103
  //
104
  //
105
 
106
  task stop_write_read ();
107
    disable this.run_write_read;
108
  endtask
109
 
110
  //
111
  //
112
  //
113
 
114
  task write_read ();
115
    const int sequental_tr_max_num = 6;
116
 
117
    int tr_num;
118
 
119
    int write_tr_max_num;
120
    int  read_tr_max_num;
121
 
122
    int avail_read_tr_num;
123
 
124
    sdram_transaction_class write_tr;
125
    sdram_transaction_class read_tr;
126
 
127
    write_tr_done_num = 0;
128
    read_tr_done_num  = 0;
129
 
130
    forever begin
131
 
132
      //
133
      // if there is something to write
134
      //
135
      assert ( std::randomize(write_tr_max_num) with {write_tr_max_num inside {[1:sequental_tr_max_num]};} )
136
 
137
      for (tr_num = 0; tr_num < write_tr_max_num; tr_num++) begin : write_state
138
 
139
        if (!write_tr_mbx.try_get (write_tr))
140
          break;
141
 
142
        SetTransaction (write_tr);
143
 
144
        write_tr_done_num++;
145
      end : write_state
146
 
147
      //
148
      // read
149
      //
150
 
151
      assert ( std::randomize(read_tr_max_num) with {read_tr_max_num inside {[1:sequental_tr_max_num]};} );
152
 
153
      avail_read_tr_num = write_tr_done_num - read_tr_done_num;
154
 
155
      if (read_tr_max_num > avail_read_tr_num)
156
        read_tr_max_num = avail_read_tr_num;
157
 
158
      for (tr_num = 0; tr_num < read_tr_max_num; tr_num++) begin : read_state
159
 
160
        if (!read_tr_mbx.try_get(read_tr))
161
          break;
162
 
163
        SetTransaction (read_tr);
164
 
165
        read_tr_done_num++;
166
      end : read_state
167
 
168
      #10;
169
    end
170
 
171
  endtask
172
 
173
endclass

powered by: WebSVN 2.1.0

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