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

Subversion Repositories socwire

[/] [socwire/] [trunk/] [Testbench/] [switch_tb.vhd] - Blame information for rev 19

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 bjoerno
---====================== Start Copyright Notice ========================---
2
--==                                                                    ==--
3
--== Filename ..... switch_tb.vhd                                       ==--
4
--== Download ..... http://www.ida.ing.tu-bs.de                         ==--
5
--== Company ...... IDA TU Braunschweig, Prof. Dr.-Ing. Harald Michalik ==--
6
--== Authors ...... Björn Osterloh                                      ==--
7
--== Contact ...... Björn Osterloh (b.osterloh@tu-bs.de)                ==--
8
--== Copyright .... Copyright (c) 2008 IDA                              ==--
9
--== Project ...... SoCWire Switch Testbench                            ==--
10
--== Version ...... 1.00                                                ==--
11
--== Conception ... 22 April 2009                                       ==--
12
--== Modified ..... N/A                                                 ==--
13
--==                                                                    ==--
14
---======================= End Copyright Notice =========================---
15
 
16
LIBRARY ieee;
17
USE ieee.std_logic_1164.ALL;
18
USE ieee.std_logic_unsigned.all;
19
USE ieee.numeric_std.ALL;
20
 
21
USE WORK.ALL;
22
 
23
 
24
ENTITY switch_tb IS
25
  GENERIC(
26
          --== Number Of Ports ==--
27
          nports     : NATURAL RANGE 2 TO 32 := 4;
28
          --== Set Codec Speed to system clock in nanoseconds! ==--
29
                    --== DO NOT CHANGE THE GENERICS IN THE SUB MODULES!! ==--          
30
         datawidth            : NATURAL RANGE 8 TO 8192:=8;
31
         speed                      : NATURAL RANGE 1 TO 100:=10;               -- Set CODEC speed to system clock in nanoseconds !
32
         after64              : NATURAL RANGE 1 TO 6400:=64;   -- Spacewire Standard 6400 = 6.4 us
33
         after128             : NATURAL RANGE 1 TO 12800:=128; -- Spacewire Standard 12800 = 12.8 us                              
34
              disconnect_detection : NATURAL RANGE 1 TO 850:=85     -- Spacewire Standard 850 = 850 ns
35
         );
36
END switch_tb;
37
 
38
ARCHITECTURE behavior OF switch_tb IS
39
 
40
COMPONENT socwire_switch IS
41
  GENERIC(
42
          datawidth : NATURAL RANGE 8 TO 8192;
43
          nports     : NATURAL RANGE 2 TO 32;
44
          speed : NATURAL RANGE  1 TO 100
45
         );
46
  PORT(
47
       --==  General Interface (Sync Rst, 50MHz Clock) ==--
48
 
49
       rst        : IN  STD_LOGIC;
50
       clk        : IN  STD_LOGIC;
51
 
52
       --== Serial Receive Interface ==--
53
 
54
       rx         : IN  STD_LOGIC_VECTOR((datawidth+2)*nports-1 DOWNTO 0);
55
       rx_valid   : IN  STD_LOGIC_VECTOR(nports-1 DOWNTO 0);
56
 
57
       --== Serial Transmit Interface ==--
58
 
59
       tx         : OUT STD_LOGIC_VECTOR((datawidth+2)*nports-1 DOWNTO 0);
60
       tx_valid   : OUT STD_LOGIC_VECTOR(nports-1 DOWNTO 0);
61
 
62
       --== Active Interface ==--
63
 
64
       active     : OUT STD_LOGIC_VECTOR(nports-1 DOWNTO 0)
65
      );
66
END COMPONENT;
67
 
68
 
69
COMPONENT socwire_codec
70
  GENERIC(
71
         datawidth            : NATURAL RANGE 8 TO 8192;
72
         speed                      : NATURAL RANGE 1 TO 100;
73
         after64              : NATURAL RANGE 1 TO 6400;
74
         after128             : NATURAL RANGE 1 TO 12800;
75
              disconnect_detection : NATURAL RANGE 1 TO 850
76
         );
77
 
78
        PORT(
79
                rst : IN std_logic;
80
                clk : IN std_logic;
81
                socw_en : IN std_logic;
82
                socw_dis : IN std_logic;
83
                rx : IN std_logic_vector(datawidth+1 downto 0);
84
                rx_valid : IN std_logic;
85
                dat_nwrite : IN std_logic;
86
                dat_din : IN std_logic_vector(datawidth downto 0);
87
                dat_nread : IN std_logic;
88
                tx : OUT std_logic_vector(datawidth+1 downto 0);
89
                tx_valid : OUT std_logic;
90
                dat_full : OUT std_logic;
91
                dat_empty : OUT std_logic;
92
                dat_dout : OUT std_logic_vector(datawidth downto 0);
93
                active : OUT std_logic
94
                );
95
        END COMPONENT;
96
 
97
 
98
 
99
 
100
SIGNAL rst :   STD_LOGIC;
101
SIGNAL clk :   STD_LOGIC:= '0';
102
 
103
SIGNAL rx         : STD_LOGIC_VECTOR((datawidth+2)*nports-1 DOWNTO 0);
104
SIGNAL rx_valid   : STD_LOGIC_VECTOR(nports-1 DOWNTO 0);
105
SIGNAL tx         : STD_LOGIC_VECTOR((datawidth+2)*nports-1 DOWNTO 0);
106
SIGNAL tx_valid   : STD_LOGIC_VECTOR(nports-1 DOWNTO 0);
107
SIGNAL active_i   : STD_LOGIC_VECTOR(nports-1 DOWNTO 0);
108
SIGNAL active_ii  : STD_LOGIC_VECTOR(nports-1 DOWNTO 0);
109
 
110
SIGNAL socw_en     : STD_LOGIC;
111
SIGNAL socw_dis    : STD_LOGIC;
112
 
113
SIGNAL dat_full   : STD_LOGIC_VECTOR(nports-1 DOWNTO 0);
114
SIGNAL dat_nwrite : STD_LOGIC_VECTOR(nports-1 DOWNTO 0);
115
SIGNAL dat_din    : STD_LOGIC_VECTOR((datawidth+1)*nports-1 DOWNTO 0);
116
SIGNAL dat_nread  : STD_LOGIC_VECTOR(nports-1 DOWNTO 0);
117
SIGNAL dat_empty  : STD_LOGIC_VECTOR(nports-1 DOWNTO 0);
118
SIGNAL dat_dout   : STD_LOGIC_VECTOR((datawidth+1)*nports-1 DOWNTO 0);
119
 
120
SIGNAL dat_nwrite_P0 : STD_LOGIC;
121
SIGNAL dat_nwrite_P1 : STD_LOGIC;
122
SIGNAL dat_nwrite_P2 : STD_LOGIC;
123
SIGNAL dat_nwrite_P3 : STD_LOGIC;
124
SIGNAL dat_din_P0 : STD_LOGIC_VECTOR (datawidth downto 0);
125
SIGNAL dat_din_P1 : STD_LOGIC_VECTOR (datawidth downto 0);
126
SIGNAL dat_din_P2 : STD_LOGIC_VECTOR (datawidth downto 0);
127
SIGNAL dat_din_P3 : STD_LOGIC_VECTOR (datawidth downto 0);
128
 
129
 
130
 
131
BEGIN
132
 
133
        -- Component Declaration for the Unit Under Test (UUT)
134
 
135
  U0 : socwire_switch
136
    GENERIC MAP
137
      (
138
       datawidth =>datawidth,
139
       nports    => nports,
140
       speed      => speed
141
      )
142
    PORT MAP
143
      (--==  General Interface (Sync Rst) ==--
144
       clk      => clk,
145
       rst      => rst,
146
       rx       => tx,
147
       rx_valid => tx_valid,
148
       tx       => rx,
149
       tx_valid => rx_valid,
150
       active   => active_i
151
      );
152
 
153
  G0 : FOR i IN 0 TO nports-1 GENERATE
154
    U1 : socwire_codec
155
      GENERIC MAP
156
        (
157
         datawidth            =>datawidth,
158
         speed                      =>speed,
159
         after64              =>after64,
160
         after128             =>after128,
161
              disconnect_detection =>disconnect_detection
162
        )
163
      PORT MAP
164
        (--==  General Interface (Sync Rst, 50MHz Clock) ==--
165
         rst        => rst,
166
         clk        => clk,
167
         --== Link Enable Interface ==--
168
         socw_en     => socw_en,
169
         socw_dis    => socw_dis,
170
         --== Serial Receive Interface ==--
171
         rx         => rx((i+1)*10-1 DOWNTO i*10),
172
         rx_valid   => rx_valid(i),
173
         --== Serial Transmit Interface ==--
174
         tx         => tx((i+1)*10-1 DOWNTO i*10),
175
                 tx_valid   => tx_valid(i),
176
         --== Data Input Interface ==--
177
         dat_full   => dat_full(i),
178
         dat_nwrite => dat_nwrite(i),
179
         dat_din    => dat_din((i+1)*9-1 DOWNTO i*9),
180
         --== Data Output Interface ==--
181
         dat_nread  => dat_nread(i),
182
         dat_empty  => dat_empty(i),
183
         dat_dout   => dat_dout((i+1)*9-1 DOWNTO i*9),
184
         --== Active Interface ==--
185
         active     => active_ii(i)
186
        );
187
  END GENERATE G0;
188
 
189
    socw_en  <= '1';
190
    socw_dis <= '0';
191
 
192
 
193
        clk <= not clk after 5 ns;
194
 
195
        dat_nwrite(0)<=dat_nwrite_P0;
196
        dat_nwrite(1)<=dat_nwrite_P1;
197
        dat_nwrite(2)<=dat_nwrite_P2;
198
        dat_nwrite(3)<=dat_nwrite_P3;
199
        dat_din(8 downto 0)  <=dat_din_P0;
200
        dat_din(17 downto 9) <=dat_din_P1;
201
        dat_din(26 downto 18)<=dat_din_P2;
202
        dat_din(35 downto 27)<=dat_din_P3;
203
 
204
 
205
        tb : PROCESS
206
 
207
        BEGIN
208
 
209
                rst <= '1';
210
                dat_nwrite_P0<='1';
211
                dat_nwrite_P1<='1';
212
                dat_nwrite_P2<='1';
213
                dat_nwrite_P3<='1';
214
                dat_din_P0<=(others=>'0');
215
                dat_din_P1<=(others=>'0');
216
                dat_din_P2<=(others=>'0');
217
                dat_din_P3<=(others=>'0');
218
                dat_nread  <= (others => '1');
219
                wait for 100 ns;
220
                rst <= '0';
221
                wait for 1 us;
222
                dat_nread  <= (others => '0');
223
 
224
--         Send Packet from Port 0 to Port 1                    
225
      dat_nwrite_P0<='0';
226
                dat_din_P0<="000000001"; -- Port 1
227
                wait for 10 ns;
228
      dat_din_P0<="000001010"; -- Data 0                
229
                wait for 10 ns;
230
                dat_din_P0<="000001011"; -- Data 1                      
231
                wait for 10 ns;
232
                dat_din_P0<="100000000"; -- EOP                 
233
           wait for 10 ns;
234
                dat_nwrite_P0<='1';
235
 
236
--         Send Packet from Port 2 to Port 3                    
237
      dat_nwrite_P2<='0';
238
                dat_din_P2<="000000011"; -- Port 3
239
                wait for 10 ns;
240
      dat_din_P2<="000001100"; -- Data 0                
241
                wait for 10 ns;
242
                dat_din_P2<="000001101"; -- Data 1                      
243
                wait for 10 ns;
244
                dat_din_P2<="100000000"; -- EOP                 
245
           wait for 10 ns;
246
                dat_nwrite_P2<='1';
247
 
248
--         Send Packet from Port 0 and Port 1 to Port 2 and Port 3                      
249
      dat_nwrite_P0<='0';
250
                dat_din_P0<="000000010"; -- Port 2
251
                dat_nwrite_P1<='0';
252
                dat_din_P1<="000000011"; -- Port 3
253
                wait for 10 ns;
254
      dat_din_P0<="000001110"; -- Data 0                
255
                dat_din_P1<="000001010"; -- Data 0              
256
                wait for 10 ns;
257
                dat_din_P0<="000001111"; -- Data 1                      
258
                dat_din_P1<="000001011"; -- Data 1              
259
                wait for 10 ns;
260
                dat_din_P0<="100000000"; -- EOP                 
261
                dat_din_P1<="100000000"; -- EOP                 
262
           wait for 10 ns;
263
                dat_nwrite_P0<='1';
264
                dat_nwrite_P1<='1';
265
 
266
 
267
 
268
 
269
 
270
 
271
 
272
 
273
 
274
 
275
 
276
                wait for 1000 ms; --wait very long      
277
 
278
        END PROCESS;
279
 
280
END;

powered by: WebSVN 2.1.0

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