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

Subversion Repositories mips_enhanced

[/] [mips_enhanced/] [trunk/] [grlib-gpl-1.0.19-b3188/] [lib/] [gaisler/] [pci/] [pci_tbfunct.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dimamali
------------------------------------------------------------------------------
2
--  This file is a part of the GRLIB VHDL IP LIBRARY
3
--  Copyright (C) 2003, Gaisler Research
4
--
5
--  This program is free software; you can redistribute it and/or modify
6
--  it under the terms of the GNU General Public License as published by
7
--  the Free Software Foundation; either version 2 of the License, or
8
--  (at your option) any later version.
9
--
10
--  This program is distributed in the hope that it will be useful,
11
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
--  GNU General Public License for more details.
14
--
15
--  You should have received a copy of the GNU General Public License
16
--  along with this program; if not, write to the Free Software
17
--  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
18
-----------------------------------------------------------------------------
19
-- Entity:      pci_tbfunct
20
-- File:        pci_tbfunct.vhd
21
-- Author:      Alf Vaerneus - Gaisler Research
22
-- Description: Various PCI test functions
23
-----------------------------------------------------------------------------
24
 
25
-- pragma translate_off
26
 
27
library ieee;
28
use ieee.std_logic_1164.all;
29
library gaisler;
30
use gaisler.ambatest.all;
31
 
32
package pci_tb is
33
 
34
procedure PCI_read_single(ctrl : inout ctrl_type; signal tbi : out tb_in_type; signal tbo : in tb_out_type; dbglevel : in integer);
35
 
36
procedure PCI_read_burst(ctrl : inout ctrl_type; signal tbi : out tb_in_type; signal tbo : in tb_out_type; dbglevel : in integer);
37
 
38
procedure PCI_write_single(ctrl : inout ctrl_type; signal tbi : out tb_in_type; signal tbo : in tb_out_type; dbglevel : in integer);
39
 
40
procedure PCI_write_burst(ctrl : inout ctrl_type; signal tbi : out tb_in_type; signal tbo : in tb_out_type; dbglevel : in integer);
41
 
42
procedure PCI_read_config(ctrl : inout ctrl_type; signal tbi : out tb_in_type; signal tbo : in tb_out_type; dbglevel : in integer);
43
 
44
procedure PCI_write_config(ctrl : inout ctrl_type; signal tbi : out tb_in_type; signal tbo : in tb_out_type; dbglevel : in integer);
45
 
46
end pci_tb;
47
 
48
package body pci_tb is
49
 
50
constant printlevel : integer := 2;
51
 
52
function string_inv(instring : string(18 downto 1)) return string is
53
  variable vstr : string(1 to 18);
54
  begin
55
 
56
    vstr(1 to 18) := instring(18 downto 1);
57
 
58
    return(vstr);
59
end string_inv;
60
 
61
procedure PCI_read_single(
62
  ctrl   : inout ctrl_type;
63
  signal tbi  : out tb_in_type;
64
  signal tbo  : in tb_out_type;
65
  dbglevel : in integer) is
66
 
67
  begin
68
 
69
  if tbo.ready = '1' then wait until tbo.ready = '0'; end if;
70
  tbi.address <= ctrl.address;
71
  tbi.command <= M_READ;
72
  tbi.no_words <= 1;
73
  tbi.userfile <= ctrl.userfile;
74
  tbi.rfile <= ctrl.rfile;
75
  if ctrl.userfile then
76
    if dbglevel >= printlevel then
77
      printf("PCIMST TB: PCI Read from file %s",string_inv(ctrl.rfile));
78
    end if;
79
  else
80
    if dbglevel >= printlevel then
81
      printf("PCIMST TB: PCI Read from address %x",ctrl.address);
82
    end if;
83
  end if;
84
  tbi.usewfile <= ctrl.usewfile;
85
  tbi.wfile <= ctrl.wfile;
86
  tbi.start <= '1';
87
  wait until tbo.ready = '1';
88
  ctrl.data := tbo.data;
89
  ctrl.status := tbo.status;
90
  if ctrl.status = ERR then
91
    if dbglevel >= printlevel then
92
      printf("PCIMST TB: #ERROR# Read access failed at %x",ctrl.address);
93
    end if;
94
  elsif ctrl.status = OK then
95
    if dbglevel >= printlevel then
96
      printf("PCIMST TB: Returned data: %x",ctrl.data);
97
    end if;
98
  end if;
99
  tbi.start <= '0';
100
 
101
end procedure;
102
 
103
procedure PCI_read_burst(
104
  ctrl   : inout ctrl_type;
105
  signal tbi  : out tb_in_type;
106
  signal tbo  : in tb_out_type;
107
  dbglevel : in integer) is
108
 
109
  variable i : integer;
110
  begin
111
 
112
  if tbo.ready = '1' then wait until tbo.ready = '0'; end if;
113
  tbi.address <= ctrl.address;
114
  tbi.command <= M_READ_MULT;
115
  tbi.no_words <= ctrl.no_words;
116
  tbi.userfile <= ctrl.userfile;
117
  tbi.rfile <= ctrl.rfile;
118
  if ctrl.userfile then
119
    if dbglevel >= printlevel then
120
      printf("PCIMST TB: PCI Read burst from file %s",string_inv(ctrl.rfile));
121
    end if;
122
  else
123
    if dbglevel >= printlevel then
124
      printf("PCIMST TB: PCI Read burst from address %x",ctrl.address);
125
    end if;
126
  end if;
127
  tbi.usewfile <= ctrl.usewfile;
128
  tbi.wfile <= ctrl.wfile;
129
  tbi.start <= '1';
130
  wait until tbo.ready = '1';
131
  ctrl.data := tbo.data;
132
  if ctrl.status = ERR then
133
    if dbglevel >= printlevel then
134
      printf("PCIMST TB: #ERROR# Read access failed at %x",ctrl.address);
135
    end if;
136
  elsif ctrl.status = OK then
137
    if dbglevel >= printlevel then
138
      printf("PCIMST TB: Returned data: %x",ctrl.data);
139
    end if;
140
  end if;
141
  ctrl.status := tbo.status;
142
  tbi.start <= '0';
143
 
144
end procedure;
145
 
146
procedure PCI_write_single(
147
  ctrl   : inout ctrl_type;
148
  signal tbi  : out tb_in_type;
149
  signal tbo  : in tb_out_type;
150
  dbglevel : in integer) is
151
 
152
  begin
153
 
154
  if tbo.ready = '1' then wait until tbo.ready = '0'; end if;
155
  tbi.address <= ctrl.address;
156
  tbi.data <= ctrl.data;
157
  tbi.command <= M_WRITE;
158
  tbi.no_words <= 1;
159
  tbi.userfile <= ctrl.userfile;
160
  tbi.rfile <= ctrl.rfile;
161
  if ctrl.userfile then
162
    if dbglevel >= printlevel then
163
      printf("PCIMST TB: PCI Write from file %s",string_inv(ctrl.rfile));
164
    end if;
165
  else
166
    if dbglevel >= printlevel then
167
      printf("PCIMST TB: PCI Write to address %x",ctrl.address);
168
    end if;
169
  end if;
170
  tbi.usewfile <= false; -- No log file for write accesses
171
  tbi.wfile <= ctrl.wfile;
172
  tbi.start <= '1';
173
  wait until tbo.ready = '1';
174
  ctrl.status := tbo.status;
175
  if ctrl.status = ERR then
176
    if dbglevel >= printlevel then
177
      printf("PCIMST TB: #ERROR# Write access failed at %x",ctrl.address);
178
    end if;
179
  elsif ctrl.status = OK then
180
    if dbglevel >= printlevel then
181
      printf("PCIMST TB: Write success!");
182
    end if;
183
  end if;
184
  tbi.start <= '0';
185
 
186
end procedure;
187
 
188
procedure PCI_write_burst(
189
  ctrl   : inout ctrl_type;
190
  signal tbi  : out tb_in_type;
191
  signal tbo  : in tb_out_type;
192
  dbglevel : in integer) is
193
 
194
  begin
195
 
196
  if tbo.ready = '1' then wait until tbo.ready = '0'; end if;
197
  tbi.address <= ctrl.address;
198
  tbi.data <= ctrl.data;
199
  tbi.command <= M_WRITE;
200
  tbi.no_words <= ctrl.no_words;
201
  tbi.userfile <= ctrl.userfile;
202
  tbi.rfile <= ctrl.rfile;
203
  if ctrl.userfile then
204
    if dbglevel >= printlevel then
205
      printf("PCIMST TB: PCI Write from file %s",string_inv(ctrl.rfile));
206
    end if;
207
  else
208
    if dbglevel >= printlevel then
209
      printf("PCIMST TB: PCI Write burst to address %x",ctrl.address);
210
    end if;
211
  end if;
212
  tbi.usewfile <= false; -- No log file for write accesses
213
  tbi.wfile <= ctrl.wfile;
214
  tbi.start <= '1';
215
  wait until tbo.ready = '1';
216
  ctrl.status := tbo.status;
217
  if ctrl.status = ERR then
218
    if dbglevel >= printlevel then
219
      printf("PCIMST TB: #ERROR# Write access failed at %x",ctrl.address);
220
    end if;
221
  elsif ctrl.status = OK then
222
    if dbglevel >= printlevel then
223
      printf("PCIMST TB: Write success!");
224
    end if;
225
  end if;
226
  tbi.start <= '0';
227
 
228
end procedure;
229
 
230
procedure PCI_read_config(
231
  ctrl   : inout ctrl_type;
232
  signal tbi  : out tb_in_type;
233
  signal tbo  : in tb_out_type;
234
  dbglevel : in integer) is
235
 
236
  begin
237
 
238
  if tbo.ready = '1' then wait until tbo.ready = '0'; end if;
239
  tbi.address <= ctrl.address;
240
  tbi.command <= C_READ;
241
  tbi.no_words <= 1;
242
  tbi.userfile <= ctrl.userfile;
243
  tbi.rfile <= ctrl.rfile;
244
  if ctrl.userfile then
245
    if dbglevel >= printlevel then
246
      printf("PCIMST TB: PCI Config Read from file %s",string_inv(ctrl.rfile));
247
    end if;
248
  else
249
    if dbglevel >= printlevel then
250
      printf("PCIMST TB: PCI Config Read from address %x",ctrl.address);
251
    end if;
252
  end if;
253
  tbi.usewfile <= ctrl.usewfile;
254
  tbi.wfile <= ctrl.wfile;
255
  tbi.start <= '1';
256
  wait until tbo.ready = '1';
257
  ctrl.data := tbo.data;
258
  ctrl.status := tbo.status;
259
  if ctrl.status = ERR then
260
    if dbglevel >= printlevel then
261
      printf("PCIMST TB: #ERROR# Read access failed at %x",ctrl.address);
262
    end if;
263
  elsif ctrl.status = OK then
264
    if dbglevel >= printlevel then
265
      printf("PCIMST TB: Returned data: %x",ctrl.data);
266
    end if;
267
  end if;
268
  tbi.start <= '0';
269
 
270
end procedure;
271
 
272
procedure PCI_write_config(
273
  ctrl   : inout ctrl_type;
274
  signal tbi  : out tb_in_type;
275
  signal tbo  : in tb_out_type;
276
  dbglevel : in integer) is
277
 
278
  begin
279
 
280
  if tbo.ready = '1' then wait until tbo.ready = '0'; end if;
281
  tbi.address <= ctrl.address;
282
  tbi.data <= ctrl.data;
283
  tbi.command <= C_WRITE;
284
  tbi.no_words <= 1;
285
  tbi.userfile <= ctrl.userfile;
286
  tbi.rfile <= ctrl.rfile;
287
  if ctrl.userfile then
288
    if dbglevel >= printlevel then
289
      printf("PCIMST TB: PCI Config Write from file %s",string_inv(ctrl.rfile));
290
    end if;
291
  else
292
    if dbglevel >= printlevel then
293
      printf("PCIMST TB: PCI Config Write to address %x",ctrl.address);
294
    end if;
295
  end if;
296
  tbi.usewfile <= false; -- No log file for write accesses
297
  tbi.wfile <= ctrl.wfile;
298
  tbi.start <= '1';
299
  wait until tbo.ready = '1';
300
  ctrl.status := tbo.status;
301
  if ctrl.status = ERR then
302
    if dbglevel >= printlevel then
303
      printf("PCIMST TB: #ERROR# Config write access failed at %x",ctrl.address);
304
    end if;
305
  elsif ctrl.status = OK then
306
    if dbglevel >= printlevel then
307
      printf("PCIMST TB: Config write success!");
308
    end if;
309
  end if;
310
  tbi.start <= '0';
311
 
312
end procedure;
313
 
314
end package body;
315
 
316
-- pragma translate_on

powered by: WebSVN 2.1.0

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