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-cpci-ax/] [pcitb_stimgen.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dimamali
-----------------------------------------------------------------------------
2
-- Entity:      pcitb_stimgen
3
-- File:        pcitb_stimgen.vhd
4
-- Author:      Alf Vaerneus, Gaisler Research
5
-- Description: PCI Stimuli generator. Contains the test sequence.
6
------------------------------------------------------------------------------
7
 
8
library ieee;
9
use ieee.std_logic_1164.all;
10
--use ieee.std_logic_arith.all;
11
 
12
library grlib;
13
use grlib.stdlib.all;
14
 
15
library gaisler;
16
use gaisler.ambatest.all;
17
use gaisler.pcitb.all;
18
use gaisler.ahb_tb.all;
19
use gaisler.pci_tb.all;
20
 
21
--LIBRARY adpms_lib;
22
--USE adpms_lib.TEXTIO.ALL;
23
 
24
entity pcitb_stimgen is
25
  generic(
26
    slots : integer := 5;
27
    dbglevel : integer := 1);
28
  port(
29
    rsttrig   : out std_logic;
30
    tbi       : out tbi_array_type;
31
    tbo       : in  tbo_array_type
32
      );
33
end pcitb_stimgen;
34
 
35
architecture tb of pcitb_stimgen is
36
 
37
constant zero32 : std_logic_vector(31 downto 0) := (others => '0');
38
constant one32 : std_logic_vector(31 downto 0) := (others => '1');
39
 
40
type config_array_type is array(0 to slots-1) of config_header_type;
41
 
42
begin
43
 
44
  test_sequence : process
45
  variable ctrl : ctrl_type;
46
  variable i : integer;
47
  variable slotconf : config_array_type;
48
  begin
49
 
50
    ctrl := ctrl_init;
51
 
52
    -- Reset system
53
    rsttrig <= '0';
54
    wait for 30 ns;
55
    rsttrig <= '1';
56
    wait for 30 ns;
57
    rsttrig <= '0';
58
 
59
    wait for 2000 us;
60
    printf(" ");
61
    printf("-------------------------------");
62
    printf("PCI Test Start");
63
    printf(" ");
64
 
65
    ctrl.wfile := "pci_read.log      ";
66
    ctrl.usewfile := true;
67
    ctrl.userfile := false;
68
 
69
    -- Configure existing PCI units
70
    for i in 0 to slots-1 loop
71
      ctrl.address := (others => '0');
72
      ctrl.address((32-slots)+i) := '1';
73
      printf("Scanning slot %d",i);
74
      PCI_read_config(ctrl,tbi(0),tbo(0),dbglevel);
75
      if ctrl.status = OK then
76
        printf("Device found with ID %x",ctrl.data);
77
        slotconf(i).devid := ctrl.data(31 downto 16);
78
        slotconf(i).vendid := ctrl.data(15 downto 0);
79
        ctrl.address(7 downto 2) := conv_std_logic_vector(1,6);
80
        ctrl.data := (others => '1');
81
        PCI_write_config(ctrl,tbi(0),tbo(0),dbglevel);
82
        PCI_read_config(ctrl,tbi(0),tbo(0),dbglevel);
83
        slotconf(i).status  := ctrl.data(31 downto 16);
84
        slotconf(i).command := ctrl.data(15 downto 0);
85
        ctrl.address(7 downto 2) := conv_std_logic_vector(2,6);
86
        PCI_read_config(ctrl,tbi(0),tbo(0),dbglevel);
87
        slotconf(i).class_code := ctrl.data(31 downto 8);
88
        slotconf(i).revid := ctrl.data(7 downto 0);
89
        ctrl.address(7 downto 2) := conv_std_logic_vector(3,6);
90
        ctrl.data := (others => '1');
91
        PCI_write_config(ctrl,tbi(0),tbo(0),dbglevel);
92
        PCI_read_config(ctrl,tbi(0),tbo(0),dbglevel);
93
        slotconf(i).bist := ctrl.data(31 downto 24);
94
        slotconf(i).header_type := ctrl.data(23 downto 16);
95
        slotconf(i).lat_timer := ctrl.data(15 downto 8);
96
        slotconf(i).cache_lsize := ctrl.data(7 downto 0);
97
        for j in 0 to 5 loop
98
          ctrl.address(7 downto 2) := conv_std_logic_vector(j+4,6);
99
          ctrl.data := (others => '1');
100
          PCI_write_config(ctrl,tbi(0),tbo(0),dbglevel);
101
          PCI_read_config(ctrl,tbi(0),tbo(0),dbglevel);
102
          if ctrl.data > zero32 then
103
            ctrl.data := (others => '0');
104
            ctrl.data(31 downto 29) := conv_std_logic_vector(3,3);
105
            ctrl.data(28 downto 26) := conv_std_logic_vector(j,3);
106
            PCI_write_config(ctrl,tbi(0),tbo(0),dbglevel);
107
            PCI_read_config(ctrl,tbi(0),tbo(0),dbglevel);
108
            slotconf(i).bar(j) := ctrl.data;
109
            printf("BAR%d",j);
110
            printf("%x",ctrl.data);
111
          end if;
112
        end loop;
113
      else
114
        printf("No device found on slot %d",i);
115
        slotconf(i).vendid := (others => '1');
116
      end if;
117
    end loop;
118
 
119
    wait for 5 us;
120
 
121
    printf(" ");
122
    printf("-------------------------------");
123
    printf(" ");
124
    printf("Testcase 1: Read from target.");
125
    printf(" ");
126
 
127
    -- Set AHB register
128
    ctrl.address := conv_std_logic_vector_signed(16#60100000#,32);
129
    ctrl.no_words := 1;
130
    ctrl.data := conv_std_logic_vector_signed(16#60000000#,32);
131
    PCI_write_single(ctrl,tbi(0),tbo(0),dbglevel);
132
    if ctrl.status = OK then
133
      printf("AHB register set!");
134
    end if;
135
 
136
    -- Try to read from every unit
137
    for i in 0 to slots-1 loop
138
      if slotconf(i).vendid /= one32(15 downto 0) then
139
        ctrl.address := slotconf(i).bar(0);
140
        ctrl.no_words := 1;
141
        printf("Try to read from slot%d",i);
142
        PCI_read_single(ctrl,tbi(0),tbo(0),dbglevel);
143
        if ctrl.status = OK then
144
          printf("Read data %x",ctrl.data);
145
        else
146
          printf("Read failed!");
147
        end if;
148
      end if;
149
    end loop;
150
 
151
    wait for 5 us;
152
 
153
    printf(" ");
154
    printf("-------------------------------");
155
    printf(" ");
156
    printf("Testcase 2: Write to target and verify.");
157
    printf(" ");
158
 
159
 
160
    -- Try to read from every unit
161
    for i in 0 to slots-1 loop
162
      if slotconf(i).vendid /= one32(15 downto 0) then
163
        ctrl.address := slotconf(i).bar(0);
164
        ctrl.data := conv_std_logic_vector_signed(16#12345678#,32);
165
        printf("Try to write to slot%d",i);
166
        printf("Write data: %x",ctrl.data);
167
        PCI_write_single(ctrl,tbi(0),tbo(0),dbglevel);
168
        printf("Read and verify");
169
        ctrl.usewfile := true;
170
        ctrl.no_words := 1;
171
        ctrl.wfile := "pci_read.log      ";
172
        PCI_read_single(ctrl,tbi(0),tbo(0),dbglevel);
173
        if ctrl.status = OK then
174
          printf("Read data %x",ctrl.data);
175
        else
176
          printf("Read failed!");
177
        end if;
178
      end if;
179
    end loop;
180
 
181
    wait for 5 us;
182
 
183
    printf(" ");
184
    printf("-------------------------------");
185
    printf(" ");
186
    printf("Testcase 3: Write from file to target and verify.");
187
    printf(" ");
188
 
189
    ctrl.userfile := true;
190
 
191
    -- Try to write from file
192
    printf("Write data: %x",ctrl.data);
193
    ctrl.rfile := "pcisequence.seq   ";
194
    PCI_write_single(ctrl,tbi(0),tbo(0),dbglevel);
195
    printf("Read and verify");
196
    ctrl.rfile := "pcisequence2.seq  ";
197
    PCI_read_single(ctrl,tbi(0),tbo(0),dbglevel);
198
    if ctrl.status = OK then
199
      printf("Read data %x",ctrl.data);
200
    else
201
      printf("Read failed!");
202
    end if;
203
 
204
    ctrl.userfile := false;
205
 
206
    wait for 10 us;
207
 
208
    printf(" ");
209
    printf("-------------------------------");
210
    printf("PCI Test Complete");
211
    printf(" ");
212
    --assert false
213
    --  report "Simulation Finished"
214
    --  severity failure;
215
 
216
    wait;
217
  end process;
218
 
219
end;
220
 

powered by: WebSVN 2.1.0

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