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
|
20 |
|
|
-- File: pci.vhd
|
21 |
|
|
-- Author: Jiri Gaisler - Gaisler Research
|
22 |
|
|
-- Description: Package with component and type declarations for PCI testbench
|
23 |
|
|
-- modules
|
24 |
|
|
------------------------------------------------------------------------------
|
25 |
|
|
|
26 |
|
|
-- pragma translate_off
|
27 |
|
|
|
28 |
|
|
library ieee;
|
29 |
|
|
use ieee.std_logic_1164.all;
|
30 |
|
|
library grlib;
|
31 |
|
|
use grlib.stdlib.all;
|
32 |
|
|
library gaisler;
|
33 |
|
|
use gaisler.ambatest.all;
|
34 |
|
|
|
35 |
|
|
package pcitb is
|
36 |
|
|
|
37 |
|
|
type bar_type is array(0 to 5) of std_logic_vector(31 downto 0);
|
38 |
|
|
constant bar_init : bar_type := ((others => '0'),(others => '0'),(others => '0'),(others => '0'),(others => '0'),(others => '0'));
|
39 |
|
|
type config_header_type is record
|
40 |
|
|
devid : std_logic_vector(15 downto 0);
|
41 |
|
|
vendid : std_logic_vector(15 downto 0);
|
42 |
|
|
status : std_logic_vector(15 downto 0);
|
43 |
|
|
command : std_logic_vector(15 downto 0);
|
44 |
|
|
class_code : std_logic_vector(23 downto 0);
|
45 |
|
|
revid : std_logic_vector(7 downto 0);
|
46 |
|
|
bist : std_logic_vector(7 downto 0);
|
47 |
|
|
header_type : std_logic_vector(7 downto 0);
|
48 |
|
|
lat_timer : std_logic_vector(7 downto 0);
|
49 |
|
|
cache_lsize : std_logic_vector(7 downto 0);
|
50 |
|
|
bar : bar_type;
|
51 |
|
|
cis_p : std_logic_vector(31 downto 0);
|
52 |
|
|
subid : std_logic_vector(15 downto 0);
|
53 |
|
|
subvendid : std_logic_vector(15 downto 0);
|
54 |
|
|
exp_rom_ba : std_logic_vector(31 downto 0);
|
55 |
|
|
max_lat : std_logic_vector(7 downto 0);
|
56 |
|
|
min_gnt : std_logic_vector(7 downto 0);
|
57 |
|
|
int_pin : std_logic_vector(7 downto 0);
|
58 |
|
|
int_line : std_logic_vector(7 downto 0);
|
59 |
|
|
end record;
|
60 |
|
|
|
61 |
|
|
constant config_init : config_header_type := (
|
62 |
|
|
devid => conv_std_logic_vector(16#0BAD#,16),
|
63 |
|
|
vendid => conv_std_logic_vector(16#AFFE#,16),
|
64 |
|
|
status => (others => '0'),
|
65 |
|
|
command => (others => '0'),
|
66 |
|
|
class_code => conv_std_logic_vector(16#050000#,24),
|
67 |
|
|
revid => conv_std_logic_vector(16#01#,8),
|
68 |
|
|
bist => (others => '0'),
|
69 |
|
|
header_type => (others => '0'),
|
70 |
|
|
lat_timer => (others => '0'),
|
71 |
|
|
cache_lsize => (others => '0'),
|
72 |
|
|
bar => bar_init,
|
73 |
|
|
cis_p => (others => '0'),
|
74 |
|
|
subid => (others => '0'),
|
75 |
|
|
subvendid => (others => '0'),
|
76 |
|
|
exp_rom_ba => (others => '0'),
|
77 |
|
|
max_lat => (others => '0'),
|
78 |
|
|
min_gnt => (others => '0'),
|
79 |
|
|
int_pin => (others => '0'),
|
80 |
|
|
int_line => (others => '0'));
|
81 |
|
|
|
82 |
|
|
|
83 |
|
|
-- These types defines the TB PCI bus
|
84 |
|
|
type pci_ad_type is record
|
85 |
|
|
ad : std_logic_vector(31 downto 0);
|
86 |
|
|
cbe : std_logic_vector(3 downto 0);
|
87 |
|
|
par : std_logic;
|
88 |
|
|
end record;
|
89 |
|
|
constant ad_const : pci_ad_type := (
|
90 |
|
|
ad => (others => 'Z'),
|
91 |
|
|
cbe => (others => 'Z'),
|
92 |
|
|
par => 'Z');
|
93 |
|
|
|
94 |
|
|
type pci_ifc_type is record
|
95 |
|
|
frame : std_logic;
|
96 |
|
|
irdy : std_logic;
|
97 |
|
|
trdy : std_logic;
|
98 |
|
|
stop : std_logic;
|
99 |
|
|
devsel : std_logic;
|
100 |
|
|
idsel : std_logic_vector(20 downto 0);
|
101 |
|
|
lock : std_logic;
|
102 |
|
|
end record;
|
103 |
|
|
constant ifc_const : pci_ifc_type := (
|
104 |
|
|
frame => 'H',
|
105 |
|
|
irdy => 'H',
|
106 |
|
|
trdy => 'H',
|
107 |
|
|
stop => 'H',
|
108 |
|
|
lock => 'H',
|
109 |
|
|
idsel => (others => 'L'),
|
110 |
|
|
devsel => 'H');
|
111 |
|
|
|
112 |
|
|
type pci_err_type is record
|
113 |
|
|
perr : std_logic;
|
114 |
|
|
serr : std_logic;
|
115 |
|
|
end record;
|
116 |
|
|
constant err_const : pci_err_type := (
|
117 |
|
|
perr => 'H',
|
118 |
|
|
serr => 'H');
|
119 |
|
|
|
120 |
|
|
type pci_arb_type is record
|
121 |
|
|
req : std_logic_vector(20 downto 0);
|
122 |
|
|
gnt : std_logic_vector(20 downto 0);
|
123 |
|
|
end record;
|
124 |
|
|
constant arb_const : pci_arb_type := (
|
125 |
|
|
req => (others => 'H'),
|
126 |
|
|
gnt => (others => 'H'));
|
127 |
|
|
|
128 |
|
|
type pci_syst_type is record
|
129 |
|
|
clk : std_logic;
|
130 |
|
|
rst : std_logic;
|
131 |
|
|
end record;
|
132 |
|
|
constant syst_const : pci_syst_type := (
|
133 |
|
|
clk => 'H',
|
134 |
|
|
rst => 'H');
|
135 |
|
|
|
136 |
|
|
type pci_ext64_type is record
|
137 |
|
|
ad : std_logic_vector(63 downto 32);
|
138 |
|
|
cbe : std_logic_vector(7 downto 4);
|
139 |
|
|
par64 : std_logic;
|
140 |
|
|
req64 : std_logic;
|
141 |
|
|
ack64 : std_logic;
|
142 |
|
|
end record;
|
143 |
|
|
constant ext64_const : pci_ext64_type := (
|
144 |
|
|
ad => (others => 'Z'),
|
145 |
|
|
cbe => (others => 'Z'),
|
146 |
|
|
par64 => 'Z',
|
147 |
|
|
req64 => 'Z',
|
148 |
|
|
ack64 => 'Z');
|
149 |
|
|
|
150 |
|
|
type pci_int_type is record
|
151 |
|
|
inta : std_logic;
|
152 |
|
|
intb : std_logic;
|
153 |
|
|
intc : std_logic;
|
154 |
|
|
intd : std_logic;
|
155 |
|
|
end record;
|
156 |
|
|
constant int_const : pci_int_type := (
|
157 |
|
|
inta => 'H',
|
158 |
|
|
intb => 'H',
|
159 |
|
|
intc => 'H',
|
160 |
|
|
intd => 'H');
|
161 |
|
|
|
162 |
|
|
type pci_cache_type is record
|
163 |
|
|
sbo : std_logic;
|
164 |
|
|
sdone : std_logic;
|
165 |
|
|
end record;
|
166 |
|
|
|
167 |
|
|
constant cache_const : pci_cache_type := (
|
168 |
|
|
sbo => 'U',
|
169 |
|
|
sdone => 'U');
|
170 |
|
|
|
171 |
|
|
type pci_type is record
|
172 |
|
|
ad : pci_ad_type;
|
173 |
|
|
ifc : pci_ifc_type;
|
174 |
|
|
err : pci_err_type;
|
175 |
|
|
arb : pci_arb_type;
|
176 |
|
|
syst : pci_syst_type;
|
177 |
|
|
ext64 : pci_ext64_type;
|
178 |
|
|
int : pci_int_type;
|
179 |
|
|
cache : pci_cache_type;
|
180 |
|
|
end record;
|
181 |
|
|
|
182 |
|
|
constant pci_idle : pci_type := ( ad_const, ifc_const, err_const, arb_const,
|
183 |
|
|
syst_const, ext64_const, int_const, cache_const);
|
184 |
|
|
|
185 |
|
|
-- PCI emulators for TB
|
186 |
|
|
|
187 |
|
|
component pcitb_clkgen
|
188 |
|
|
generic (
|
189 |
|
|
mhz66 : boolean := false; -- PCI clock frequency. false = 33MHz, true = 66MHz
|
190 |
|
|
rstclocks : integer := 20); -- How long (in clks) the rst signal is asserted
|
191 |
|
|
port (
|
192 |
|
|
rsttrig : in std_logic; -- Asynchronous reset trig, active high
|
193 |
|
|
systclk : out pci_syst_type); -- clock and reset outputs
|
194 |
|
|
end component;
|
195 |
|
|
|
196 |
|
|
component pcitb_master -- A PCI master that is accessed through a Testbench vector
|
197 |
|
|
generic (
|
198 |
|
|
slot : integer := 0; -- Slot number for this unit
|
199 |
|
|
tval : time := 7 ns; -- Output delay for signals that are driven by this unit
|
200 |
|
|
dbglevel : integer := 1); -- Debug level. Higher value means more debug information
|
201 |
|
|
port (
|
202 |
|
|
pciin : in pci_type;
|
203 |
|
|
pciout : out pci_type;
|
204 |
|
|
tbi : in tb_in_type;
|
205 |
|
|
tbo : out tb_out_type
|
206 |
|
|
);
|
207 |
|
|
end component;
|
208 |
|
|
|
209 |
|
|
component pcitb_master_script
|
210 |
|
|
generic (
|
211 |
|
|
slot : integer := 0; -- Slot number for this unit
|
212 |
|
|
tval : time := 7 ns; -- Output delay for signals that are driven by this unit
|
213 |
|
|
dbglevel : integer := 2; -- Debug level. Higher value means more debug information
|
214 |
|
|
maxburst : integer := 1024;
|
215 |
|
|
filename : string := "pci.cmd");
|
216 |
|
|
port (
|
217 |
|
|
pciin : in pci_type;
|
218 |
|
|
pciout : out pci_type
|
219 |
|
|
);
|
220 |
|
|
end component;
|
221 |
|
|
|
222 |
|
|
component pcitb_target -- Represents a simple memory on the PCI bus
|
223 |
|
|
generic (
|
224 |
|
|
slot : integer := 0; -- Slot number for this unit
|
225 |
|
|
abits : integer := 10; -- Memory size. Size is 2^abits 32-bit words
|
226 |
|
|
bars : integer := 1; -- Number of bars for this target. Min 1, Max 6
|
227 |
|
|
resptime : integer := 2; -- The initial response time in clks for this target
|
228 |
|
|
latency : integer := 0; -- The latency in clks for every dataphase for a burst access
|
229 |
|
|
rbuf : integer := 8; -- The maximum no of words this target can transfer in a continuous burst
|
230 |
|
|
stopwd : boolean := true; -- Target disconnect type. true = disconnect WITH data, false = disconnect WITHOUT data
|
231 |
|
|
tval : time := 7 ns; -- Output delay for signals that are driven by this unit
|
232 |
|
|
conf : config_header_type := config_init; -- The reset condition of the configuration space of this target
|
233 |
|
|
dbglevel : integer := 1); -- Debug level. Higher value means more debug information
|
234 |
|
|
port (
|
235 |
|
|
pciin : in pci_type;
|
236 |
|
|
pciout : out pci_type;
|
237 |
|
|
tbi : in tb_in_type;
|
238 |
|
|
tbo : out tb_out_type
|
239 |
|
|
);
|
240 |
|
|
end component;
|
241 |
|
|
|
242 |
|
|
component pcitb_stimgen
|
243 |
|
|
generic (
|
244 |
|
|
slots : integer := 5; -- The number of slots in the test system
|
245 |
|
|
dbglevel : integer := 1); -- Debug level. Higher value means more debug information
|
246 |
|
|
port (
|
247 |
|
|
rsttrig : out std_logic;
|
248 |
|
|
tbi : out tbi_array_type;
|
249 |
|
|
tbo : in tbo_array_type
|
250 |
|
|
);
|
251 |
|
|
end component;
|
252 |
|
|
|
253 |
|
|
component pcitb_arb
|
254 |
|
|
generic (
|
255 |
|
|
slots : integer := 5; -- The number of slots in the test system
|
256 |
|
|
tval : time := 7 ns); -- Output delay for signals that are driven by this unit
|
257 |
|
|
port (
|
258 |
|
|
systclk : in pci_syst_type;
|
259 |
|
|
ifcin : in pci_ifc_type;
|
260 |
|
|
arbin : in pci_arb_type;
|
261 |
|
|
arbout : out pci_arb_type);
|
262 |
|
|
end component;
|
263 |
|
|
|
264 |
|
|
component pcitb_monitor is
|
265 |
|
|
generic (dbglevel : integer := 1); -- Debug level. Higher value means more debug information
|
266 |
|
|
port (pciin : in pci_type);
|
267 |
|
|
end component;
|
268 |
|
|
|
269 |
|
|
end;
|
270 |
|
|
|
271 |
|
|
-- pragma translate_on
|