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

Subversion Repositories mips_enhanced

[/] [mips_enhanced/] [trunk/] [grlib-gpl-1.0.19-b3188/] [designs/] [leon3-gr-pci-xc2v3000/] [testbench.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dimamali
------------------------------------------------------------------------------
2
--  LEON3 Demonstration design test bench
3
--  Copyright (C) 2004 Jiri Gaisler, 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
 
16
library ieee;
17
use ieee.std_logic_1164.all;
18
library gaisler;
19
use gaisler.libdcom.all;
20
use gaisler.sim.all;
21
library techmap;
22
use techmap.gencomp.all;
23
library micron;
24
use micron.components.all;
25
use work.debug.all;
26
 
27
use work.config.all;    -- configuration
28
 
29
entity testbench is
30
  generic (
31
    fabtech   : integer := CFG_FABTECH;
32
    memtech   : integer := CFG_MEMTECH;
33
    padtech   : integer := CFG_PADTECH;
34
    clktech   : integer := CFG_CLKTECH;
35
    disas     : integer := CFG_DISAS;   -- Enable disassembly to console
36
    dbguart   : integer := CFG_DUART;   -- Print UART on console
37
    pclow     : integer := CFG_PCLOW;
38
 
39
    clkperiod : integer := 20;          -- system clock period
40
    romwidth  : integer := 32;          -- rom data width (8/32)
41
    romdepth  : integer := 16;          -- rom address depth
42
    sramwidth  : integer := 32;         -- ram data width (8/16/32)
43
    sramdepth  : integer := 18;         -- ram address depth
44
    srambanks  : integer := 2           -- number of ram banks
45
  );
46
  port (
47
    pci_rst     : inout std_logic;      -- PCI bus
48
    pci_clk     : in std_logic;
49
    pci_gnt     : in std_logic;
50
    pci_idsel   : in std_logic;
51
    pci_lock    : inout std_logic;
52
    pci_ad      : inout std_logic_vector(31 downto 0);
53
    pci_cbe     : inout std_logic_vector(3 downto 0);
54
    pci_frame   : inout std_logic;
55
    pci_irdy    : inout std_logic;
56
    pci_trdy    : inout std_logic;
57
    pci_devsel  : inout std_logic;
58
    pci_stop    : inout std_logic;
59
    pci_perr    : inout std_logic;
60
    pci_par     : inout std_logic;
61
    pci_req     : inout std_logic;
62
    pci_serr    : inout std_logic;
63
    pci_host    : in std_logic;
64
    pci_66      : in std_logic
65
  );
66
end;
67
 
68
architecture behav of testbench is
69
 
70
constant promfile  : string := "prom.srec";  -- rom contents
71
constant sramfile  : string := "sram.srec";  -- ram contents
72
constant sdramfile : string := "sdram.srec"; -- sdram contents
73
 
74
signal clk : std_logic := '0';
75
signal Rst    : std_logic := '0';                        -- Reset
76
constant ct : integer := clkperiod/2;
77
 
78
signal address  : std_logic_vector(27 downto 0);
79
signal data     : std_logic_vector(31 downto 0);
80
 
81
signal ramsn    : std_logic_vector(4 downto 0);
82
signal ramoen   : std_logic_vector(4 downto 0);
83
signal rwen     : std_logic_vector(3 downto 0);
84
signal rwenx    : std_logic_vector(3 downto 0);
85
signal romsn    : std_logic_vector(1 downto 0);
86
signal iosn     : std_logic;
87
signal oen      : std_logic;
88
signal read     : std_logic;
89
signal writen   : std_logic;
90
signal brdyn    : std_logic;
91
signal bexcn    : std_logic;
92
signal wdog     : std_logic;
93
signal dsuen, dsutx, dsurx, dsubre, dsuact : std_logic;
94
signal dsurst   : std_logic;
95
signal test     : std_logic;
96
signal error    : std_logic;
97
signal gpio     : std_logic_vector(7 downto 0);
98
signal GND      : std_logic := '0';
99
signal VCC      : std_logic := '1';
100
signal NC       : std_logic := 'Z';
101
signal clk2     : std_logic := '1';
102
 
103
signal sdcke    : std_logic_vector ( 1 downto 0);  -- clk en
104
signal sdcsn    : std_logic_vector ( 1 downto 0);  -- chip sel
105
signal sdwen    : std_logic;                       -- write en
106
signal sdrasn   : std_logic;                       -- row addr stb
107
signal sdcasn   : std_logic;                       -- col addr stb
108
signal sddqm    : std_logic_vector ( 3 downto 0);  -- data i/o mask
109
signal sdclk    : std_logic;
110
signal plllock    : std_logic;
111
signal txd1, rxd1 : std_logic;
112
signal txd2, rxd2 : std_logic;
113
 
114
signal etx_clk, erx_clk, erx_dv, erx_er, erx_col, erx_crs, etx_en, etx_er : std_logic:='0';
115
signal erxd, etxd: std_logic_vector(3 downto 0):=(others=>'0');
116
signal erxdt, etxdt: std_logic_vector(7 downto 0):=(others=>'0');
117
signal emdc, emdio: std_logic;
118
signal gtx_clk : std_logic;
119
 
120
constant lresp : boolean := false;
121
 
122
signal pci_arb_req, pci_arb_gnt : std_logic_vector(0 to 3);
123
 
124
signal pllref   : std_logic;
125
 
126
signal spw_rxd  : std_logic_vector(0 to 1) := "00";
127
signal spw_rxs  : std_logic_vector(0 to 1) := "00";
128
signal spw_txd  : std_logic_vector(0 to 1);
129
signal spw_txs  : std_logic_vector(0 to 1);
130
 
131
begin
132
 
133
-- clock and reset
134
 
135
  spw_rxd(0) <= spw_txd(0);
136
  spw_rxs(0) <= spw_txs(0);
137
  clk <= not clk after ct * 1 ns;
138
  rst <= dsurst;
139
  dsuen <= '1'; dsubre <= '0'; rxd1 <= '1';
140
  pllref <= sdclk;
141
 
142
  d3 : entity work.leon3mp
143
        generic map ( fabtech, memtech, padtech, clktech,
144
        disas, dbguart, pclow )
145
        port map (rst, clk, pllref,  error, address(27 downto 0), data,
146
        sdclk, sdcke, sdcsn, sdwen, sdrasn, sdcasn, sddqm,
147
        dsutx, dsurx, dsuen, dsubre, dsuact, txd1, rxd1, txd2, rxd2,
148
        ramsn, ramoen, rwen, oen, writen, read, iosn, romsn, gpio,
149
        emdio, etx_clk, erx_clk, erxd, erx_dv, erx_er, erx_col, erx_crs,
150
        etxd, etx_en, etx_er, emdc,
151
        pci_rst, pci_clk, pci_gnt, pci_idsel, pci_lock, pci_ad, pci_cbe,
152
        pci_frame, pci_irdy, pci_trdy, pci_devsel, pci_stop, pci_perr, pci_par,
153
        pci_req, pci_serr, pci_host, pci_66, pci_arb_req, pci_arb_gnt,
154
        spw_rxd, spw_rxs, spw_txd, spw_txs);
155
 
156
-- sdram
157
 
158
    u0: mt48lc16m16a2 generic map (index => 0, fname => sdramfile)
159
        PORT MAP(
160
            Dq => data(31 downto 16), Addr => address(14 downto 2),
161
            Ba => address(16 downto 15), Clk => sdclk, Cke => sdcke(0),
162
            Cs_n => sdcsn(0), Ras_n => sdrasn, Cas_n => sdcasn, We_n => sdwen,
163
            Dqm => sddqm(3 downto 2));
164
    u1: mt48lc16m16a2 generic map (index => 16, fname => sdramfile)
165
        PORT MAP(
166
            Dq => data(15 downto 0), Addr => address(14 downto 2),
167
            Ba => address(16 downto 15), Clk => sdclk, Cke => sdcke(0),
168
            Cs_n => sdcsn(0), Ras_n => sdrasn, Cas_n => sdcasn, We_n => sdwen,
169
            Dqm => sddqm(1 downto 0));
170
    u2: mt48lc16m16a2 generic map (index => 0, fname => sdramfile)
171
        PORT MAP(
172
            Dq => data(31 downto 16), Addr => address(14 downto 2),
173
            Ba => address(16 downto 15), Clk => sdclk, Cke => sdcke(0),
174
            Cs_n => sdcsn(1), Ras_n => sdrasn, Cas_n => sdcasn, We_n => sdwen,
175
            Dqm => sddqm(3 downto 2));
176
    u3: mt48lc16m16a2 generic map (index => 16, fname => sdramfile)
177
        PORT MAP(
178
            Dq => data(15 downto 0), Addr => address(14 downto 2),
179
            Ba => address(16 downto 15), Clk => sdclk, Cke => sdcke(0),
180
            Cs_n => sdcsn(1), Ras_n => sdrasn, Cas_n => sdcasn, We_n => sdwen,
181
            Dqm => sddqm(1 downto 0));
182
 
183
    prom0 : for i in 0 to (romwidth/8)-1 generate
184
      sr0 : sram generic map (index => i, abits => romdepth, fname => promfile)
185
        port map (address(romdepth+1 downto 2), data(31-i*8 downto 24-i*8), romsn(0),
186
                  rwen(i), oen);
187
    end generate;
188
 
189
    sram0 : for i in 0 to (sramwidth/8)-1 generate
190
      sr0 : sram generic map (index => i, abits => sramdepth, fname => sramfile)
191
        port map (address(sramdepth+1 downto 2), data(31-i*8 downto 24-i*8), ramsn(0),
192
                  rwen(0), ramoen(0));
193
    end generate;
194
 
195
  phy0 : if (CFG_GRETH = 1) generate
196
    emdio <= 'H';
197
    erxd <= erxdt(3 downto 0);
198
    etxdt <= "0000" & etxd;
199
 
200
    p0: phy
201
      generic map(base1000_t_fd => 0, base1000_t_hd => 0)
202
      port map(rst, emdio, etx_clk, erx_clk, erxdt, erx_dv,
203
      erx_er, erx_col, erx_crs, etxdt, etx_en, etx_er, emdc, gtx_clk);
204
  end generate;
205
  error <= 'H';                   -- ERROR pull-up
206
 
207
   iuerr : process
208
   begin
209
     wait for 2500 ns;
210
     if to_x01(error) = '1' then wait on error; end if;
211
     assert (to_x01(error) = '1')
212
       report "*** IU in error mode, simulation halted ***"
213
         severity failure ;
214
   end process;
215
 
216
  data <= buskeep(data), (others => 'H') after 250 ns;
217
 
218
  test0 :  grtestmod
219
    port map ( rst, clk, error, address(21 downto 2), data,
220
               iosn, oen, writen, brdyn);
221
 
222
 
223
  dsucom : process
224
    procedure dsucfg(signal dsurx : in std_logic; signal dsutx : out std_logic) is
225
    variable w32 : std_logic_vector(31 downto 0);
226
    variable c8  : std_logic_vector(7 downto 0);
227
    constant txp : time := 160 * 1 ns;
228
    begin
229
    dsutx <= '1';
230
    dsurst <= '0';
231
    wait for 500 ns;
232
    dsurst <= '1';
233
    wait;
234
    wait for 5000 ns;
235
    txc(dsutx, 16#55#, txp);            -- sync uart
236
 
237
--    txc(dsutx, 16#c0#, txp);
238
--    txa(dsutx, 16#90#, 16#00#, 16#00#, 16#00#, txp);
239
--    txa(dsutx, 16#00#, 16#00#, 16#02#, 16#ae#, txp);
240
--    txc(dsutx, 16#c0#, txp);
241
--    txa(dsutx, 16#91#, 16#00#, 16#00#, 16#00#, txp);
242
--    txa(dsutx, 16#00#, 16#00#, 16#06#, 16#ae#, txp);
243
--    txc(dsutx, 16#c0#, txp);
244
--    txa(dsutx, 16#90#, 16#00#, 16#00#, 16#24#, txp);
245
--    txa(dsutx, 16#00#, 16#00#, 16#06#, 16#03#, txp);
246
--    txc(dsutx, 16#c0#, txp);
247
--    txa(dsutx, 16#90#, 16#00#, 16#00#, 16#20#, txp);
248
--    txa(dsutx, 16#00#, 16#00#, 16#06#, 16#fc#, txp);
249
 
250
    txc(dsutx, 16#c0#, txp);
251
    txa(dsutx, 16#90#, 16#00#, 16#00#, 16#00#, txp);
252
    txa(dsutx, 16#00#, 16#00#, 16#00#, 16#2f#, txp);
253
    txc(dsutx, 16#c0#, txp);
254
    txa(dsutx, 16#91#, 16#00#, 16#00#, 16#00#, txp);
255
    txa(dsutx, 16#00#, 16#00#, 16#00#, 16#6f#, txp);
256
    txc(dsutx, 16#c0#, txp);
257
    txa(dsutx, 16#90#, 16#11#, 16#00#, 16#00#, txp);
258
    txa(dsutx, 16#00#, 16#00#, 16#00#, 16#00#, txp);
259
    txc(dsutx, 16#c0#, txp);
260
    txa(dsutx, 16#90#, 16#40#, 16#00#, 16#04#, txp);
261
    txa(dsutx, 16#00#, 16#02#, 16#20#, 16#01#, txp);
262
    txc(dsutx, 16#c0#, txp);
263
    txa(dsutx, 16#90#, 16#00#, 16#00#, 16#20#, txp);
264
    txa(dsutx, 16#00#, 16#00#, 16#00#, 16#02#, txp);
265
 
266
    txc(dsutx, 16#c0#, txp);
267
    txa(dsutx, 16#90#, 16#00#, 16#00#, 16#20#, txp);
268
    txa(dsutx, 16#00#, 16#00#, 16#00#, 16#0f#, txp);
269
 
270
    txc(dsutx, 16#c0#, txp);
271
    txa(dsutx, 16#40#, 16#00#, 16#43#, 16#10#, txp);
272
    txa(dsutx, 16#00#, 16#00#, 16#00#, 16#0f#, txp);
273
 
274
    txc(dsutx, 16#c0#, txp);
275
    txa(dsutx, 16#91#, 16#40#, 16#00#, 16#24#, txp);
276
    txa(dsutx, 16#00#, 16#00#, 16#00#, 16#24#, txp);
277
    txc(dsutx, 16#c0#, txp);
278
    txa(dsutx, 16#91#, 16#70#, 16#00#, 16#00#, txp);
279
    txa(dsutx, 16#00#, 16#00#, 16#00#, 16#03#, txp);
280
 
281
 
282
 
283
 
284
 
285
    txc(dsutx, 16#c0#, txp);
286
    txa(dsutx, 16#90#, 16#00#, 16#00#, 16#20#, txp);
287
    txa(dsutx, 16#00#, 16#00#, 16#ff#, 16#ff#, txp);
288
 
289
    txc(dsutx, 16#c0#, txp);
290
    txa(dsutx, 16#90#, 16#40#, 16#00#, 16#48#, txp);
291
    txa(dsutx, 16#00#, 16#00#, 16#00#, 16#12#, txp);
292
 
293
    txc(dsutx, 16#c0#, txp);
294
    txa(dsutx, 16#90#, 16#40#, 16#00#, 16#60#, txp);
295
    txa(dsutx, 16#00#, 16#00#, 16#12#, 16#10#, txp);
296
 
297
    txc(dsutx, 16#80#, txp);
298
    txa(dsutx, 16#90#, 16#00#, 16#00#, 16#00#, txp);
299
    rxi(dsurx, w32, txp, lresp);
300
 
301
    txc(dsutx, 16#a0#, txp);
302
    txa(dsutx, 16#40#, 16#00#, 16#00#, 16#00#, txp);
303
    rxi(dsurx, w32, txp, lresp);
304
 
305
    end;
306
 
307
  begin
308
 
309
    dsucfg(dsutx, dsurx);
310
 
311
    wait;
312
  end process;
313
end ;
314
 

powered by: WebSVN 2.1.0

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