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/] [ambatest/] [ahb_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
 
20
-- pragma translate_off
21
 
22
library ieee;
23
use ieee.std_logic_1164.all;
24
library grlib;
25
use grlib.amba.all;
26
library gaisler;
27
use gaisler.ambatest.all;
28
 
29
package ahb_tb is
30
 
31
procedure AHB_read_single(ctrl : inout ctrl_type; signal tbi : out tb_in_type; signal tbo : in tb_out_type; dbglevel : in integer);
32
 
33
procedure AHB_read_burst(ctrl : inout ctrl_type; signal tbi : out tb_in_type; signal tbo : in tb_out_type; dbglevel : in integer);
34
 
35
procedure AHB_write_single(ctrl : inout ctrl_type; signal tbi : out tb_in_type; signal tbo : in tb_out_type; dbglevel : in integer);
36
 
37
procedure AHB_write_burst(ctrl : inout ctrl_type; signal tbi : out tb_in_type; signal tbo : in tb_out_type; dbglevel : in integer);
38
 
39
end ahb_tb;
40
 
41
package body ahb_tb is
42
 
43
constant printlevel : integer := 2;
44
 
45
function string_inv(instring : string(18 downto 1)) return string is
46
  variable vstr : string(1 to 18);
47
  begin
48
 
49
    vstr(1 to 18) := instring(18 downto 1);
50
 
51
    return(vstr);
52
end string_inv;
53
 
54
procedure AHB_read_single(
55
  ctrl   : inout ctrl_type;
56
  signal tbi  : out tb_in_type;
57
  signal tbo  : in tb_out_type;
58
  dbglevel : in integer) is
59
 
60
  begin
61
 
62
  if tbo.ready = '1' then wait until tbo.ready = '0'; end if;
63
  tbi.address <= ctrl.address;
64
  tbi.command <= RD_SINGLE;
65
  tbi.no_words <= 1;
66
  tbi.userfile <= ctrl.userfile;
67
  tbi.rfile <= ctrl.rfile;
68
  if dbglevel >= printlevel then
69
    if ctrl.userfile then
70
      printf("AHBMST TB: AHB Read from file %s",string_inv(ctrl.rfile));
71
    else
72
      printf("AHBMST TB: AHB Read from address %x",ctrl.address);
73
    end if;
74
  end if;
75
  tbi.usewfile <= ctrl.usewfile;
76
  tbi.wfile <= ctrl.wfile;
77
  tbi.start <= '1';
78
  wait until tbo.ready = '1';
79
  ctrl.data := tbo.data;
80
  ctrl.status := tbo.status;
81
  if ctrl.status = ERR then
82
    printf("AHBMST TB: #ERROR# Read access failed at %x",ctrl.address);
83
  elsif ctrl.status = TIMEOUT then
84
    printf("AHBMST TB: #ERROR# Timeout received for read access at %x",ctrl.address);
85
  elsif ctrl.status = OK then
86
    if dbglevel >= printlevel then
87
      printf("AHBMST TB: Returned data: %x",ctrl.data);
88
    end if;
89
  end if;
90
  tbi.start <= '0';
91
 
92
end procedure;
93
 
94
procedure AHB_read_burst(
95
  ctrl   : inout ctrl_type;
96
  signal tbi  : out tb_in_type;
97
  signal tbo  : in tb_out_type;
98
  dbglevel : in integer) is
99
 
100
  variable i : integer;
101
  begin
102
 
103
  if tbo.ready = '1' then wait until tbo.ready = '0'; end if;
104
  tbi.address <= ctrl.address;
105
  tbi.command <= RD_INCR;
106
  tbi.no_words <= ctrl.no_words;
107
  tbi.userfile <= ctrl.userfile;
108
  tbi.rfile <= ctrl.rfile;
109
  if dbglevel >= printlevel then
110
    if ctrl.userfile then
111
      printf("AHBMST TB: AHB Read burst from file %s",string_inv(ctrl.rfile));
112
    else
113
      printf("AHBMST TB: AHB Read burst from address %x",ctrl.address);
114
    end if;
115
  end if;
116
  tbi.usewfile <= ctrl.usewfile;
117
  tbi.wfile <= ctrl.wfile;
118
  tbi.start <= '1';
119
  wait until tbo.ready = '1';
120
  ctrl.data := tbo.data;
121
  ctrl.status := tbo.status;
122
  if ctrl.status = ERR then
123
    printf("AHBMST TB: #ERROR# Read access failed at %x",ctrl.address);
124
  elsif ctrl.status = TIMEOUT then
125
    printf("AHBMST TB: #ERROR# Timeout received for read access at %x",ctrl.address);
126
  elsif ctrl.status = OK then
127
    if dbglevel >= printlevel then
128
      printf("AHBMST TB: Returned data: %x",ctrl.data);
129
    end if;
130
  end if;
131
  ctrl.status := tbo.status;
132
  tbi.start <= '0';
133
 
134
end procedure;
135
 
136
procedure AHB_write_single(
137
  ctrl   : inout ctrl_type;
138
  signal tbi  : out tb_in_type;
139
  signal tbo  : in tb_out_type;
140
  dbglevel : in integer) is
141
 
142
  begin
143
 
144
  if tbo.ready = '1' then wait until tbo.ready = '0'; end if;
145
  tbi.address <= ctrl.address;
146
  tbi.data <= ctrl.data;
147
  tbi.command <= WR_SINGLE;
148
  tbi.no_words <= 1;
149
  tbi.userfile <= ctrl.userfile;
150
  tbi.rfile <= ctrl.rfile;
151
  if dbglevel >= printlevel then
152
    if ctrl.userfile then
153
      printf("AHBMST TB: AHB Write from file %s",string_inv(ctrl.rfile));
154
    else
155
      printf("AHBMST TB: AHB Write to address %x",ctrl.address);
156
    end if;
157
  end if;
158
  tbi.usewfile <= false; -- No log file for write accesses
159
  tbi.wfile <= ctrl.wfile;
160
  tbi.start <= '1';
161
  wait until tbo.ready = '1';
162
  ctrl.status := tbo.status;
163
  if ctrl.status = ERR then
164
    printf("AHBMST TB: #ERROR# Write access failed at %x",ctrl.address);
165
  elsif ctrl.status = TIMEOUT then
166
    printf("AHBMST TB: #ERROR# Timeout received for write access at %x",ctrl.address);
167
  elsif ctrl.status = OK then
168
    if dbglevel >= printlevel then
169
      printf("AHBMST TB: Write success!");
170
    end if;
171
  end if;
172
  tbi.start <= '0';
173
 
174
end procedure;
175
 
176
procedure AHB_write_burst(
177
  ctrl   : inout ctrl_type;
178
  signal tbi  : out tb_in_type;
179
  signal tbo  : in tb_out_type;
180
  dbglevel : in integer) is
181
 
182
  begin
183
 
184
  if tbo.ready = '1' then wait until tbo.ready = '0'; end if;
185
  tbi.address <= ctrl.address;
186
  tbi.data <= ctrl.data;
187
  tbi.command <= WR_INCR;
188
  tbi.no_words <= ctrl.no_words;
189
  tbi.userfile <= ctrl.userfile;
190
  tbi.rfile <= ctrl.rfile;
191
  if dbglevel >= printlevel then
192
    if ctrl.userfile then
193
      printf("AHBMST TB: AHB Write from file %s",string_inv(ctrl.rfile));
194
    else
195
      printf("AHBMST TB: AHB Write burst to address %x",ctrl.address);
196
    end if;
197
  end if;
198
  tbi.usewfile <= false; -- No log file for write accesses
199
  tbi.wfile <= ctrl.wfile;
200
  tbi.start <= '1';
201
  wait until tbo.ready = '1';
202
  ctrl.status := tbo.status;
203
  if ctrl.status = ERR then
204
    printf("AHBMST TB: #ERROR# Write access failed at %x",ctrl.address);
205
  elsif ctrl.status = TIMEOUT then
206
    printf("AHBMST TB: #ERROR# Timeout received for write access at %x",ctrl.address);
207
  elsif ctrl.status = OK then
208
    if dbglevel >= printlevel then
209
      printf("AHBMST TB: Write success!");
210
    end if;
211
  end if;
212
  tbi.start <= '0';
213
 
214
end procedure;
215
 
216
end package body;
217
 
218
 
219
-- pragma translate_on

powered by: WebSVN 2.1.0

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