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

Subversion Repositories rio

[/] [rio/] [branches/] [2.0.0-development/] [rtl/] [vhdl/] [RioSwitch.vhd] - Blame information for rev 48

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

Line No. Rev Author Line
1 2 magro732
-------------------------------------------------------------------------------
2
-- 
3
-- RapidIO IP Library Core
4
-- 
5
-- This file is part of the RapidIO IP library project
6
-- http://www.opencores.org/cores/rio/
7
-- 
8
-- Description
9
-- Containing RapidIO packet switching functionality contained in the top
10
-- entity RioSwitch.
11
-- 
12
-- To Do:
13 46 magro732
-- - Add support for portWrite maintenance packets.
14
-- - Add a real crossbar as interconnect.
15
-- - Change the internal addressing to one-hot.
16
-- - Remove acknowledge cycle when transfering packets between ports to double
17
--   the bandwidth.
18
-- - Add hot-swap.
19
-- - Connect linkInitialized to all ports and read it from the source port
20
--   using the interconnect. This will allow alternative routes since the
21
--   sending port can see if a receiving port is up or not.
22
-- - Add support for extended route.
23
-- - Add validity-bit to know if a route has been activly set for a particular
24 48 magro732
--   deviceId. Currently, we rely on that the routing table memory is
25
--   initialized in the enumeration or at device startup.
26 2 magro732
-- 
27
-- Author(s): 
28
-- - Magnus Rosenius, magro732@opencores.org 
29
-- 
30
-------------------------------------------------------------------------------
31
-- 
32
-- Copyright (C) 2013 Authors and OPENCORES.ORG 
33
-- 
34
-- This source file may be used and distributed without 
35
-- restriction provided that this copyright statement is not 
36
-- removed from the file and that any derivative work contains 
37
-- the original copyright notice and the associated disclaimer. 
38
-- 
39
-- This source file is free software; you can redistribute it 
40
-- and/or modify it under the terms of the GNU Lesser General 
41
-- Public License as published by the Free Software Foundation; 
42
-- either version 2.1 of the License, or (at your option) any 
43
-- later version. 
44
-- 
45
-- This source is distributed in the hope that it will be 
46
-- useful, but WITHOUT ANY WARRANTY; without even the implied 
47
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
48
-- PURPOSE. See the GNU Lesser General Public License for more 
49
-- details. 
50
-- 
51
-- You should have received a copy of the GNU Lesser General 
52
-- Public License along with this source; if not, download it 
53
-- from http://www.opencores.org/lgpl.shtml 
54
-- 
55
-------------------------------------------------------------------------------
56
 
57
 
58
-------------------------------------------------------------------------------
59
-- RioSwitch
60
-------------------------------------------------------------------------------
61
library ieee;
62
use ieee.std_logic_1164.all;
63
use ieee.numeric_std.all;
64
use work.rio_common.all;
65
 
66
-------------------------------------------------------------------------------
67
-- Entity for RioSwitch.
68
-------------------------------------------------------------------------------
69
entity RioSwitch is
70
  generic(
71
    SWITCH_PORTS : natural range 3 to 255 := 4;
72
    DEVICE_IDENTITY : std_logic_vector(15 downto 0);
73
    DEVICE_VENDOR_IDENTITY : std_logic_vector(15 downto 0);
74
    DEVICE_REV : std_logic_vector(31 downto 0);
75
    ASSY_IDENTITY : std_logic_vector(15 downto 0);
76
    ASSY_VENDOR_IDENTITY : std_logic_vector(15 downto 0);
77
    ASSY_REV : std_logic_vector(15 downto 0));
78
  port(
79
    clk : in std_logic;
80
    areset_n : in std_logic;
81
 
82
    writeFrameFull_i : in Array1(SWITCH_PORTS-1 downto 0);
83
    writeFrame_o : out Array1(SWITCH_PORTS-1 downto 0);
84
    writeFrameAbort_o : out Array1(SWITCH_PORTS-1 downto 0);
85
    writeContent_o : out Array1(SWITCH_PORTS-1 downto 0);
86
    writeContentData_o : out Array32(SWITCH_PORTS-1 downto 0);
87
 
88
    readFrameEmpty_i : in Array1(SWITCH_PORTS-1 downto 0);
89
    readFrame_o : out Array1(SWITCH_PORTS-1 downto 0);
90
    readFrameRestart_o : out Array1(SWITCH_PORTS-1 downto 0);
91
    readFrameAborted_i : in Array1(SWITCH_PORTS-1 downto 0);
92
    readContentEmpty_i : in Array1(SWITCH_PORTS-1 downto 0);
93
    readContent_o : out Array1(SWITCH_PORTS-1 downto 0);
94
    readContentEnd_i : in Array1(SWITCH_PORTS-1 downto 0);
95
    readContentData_i : in Array32(SWITCH_PORTS-1 downto 0);
96
 
97
    portLinkTimeout_o : out std_logic_vector(23 downto 0);
98
 
99
    linkInitialized_i : in Array1(SWITCH_PORTS-1 downto 0);
100
    outputPortEnable_o : out Array1(SWITCH_PORTS-1 downto 0);
101
    inputPortEnable_o : out Array1(SWITCH_PORTS-1 downto 0);
102
 
103
    localAckIdWrite_o : out Array1(SWITCH_PORTS-1 downto 0);
104
    clrOutstandingAckId_o : out Array1(SWITCH_PORTS-1 downto 0);
105
    inboundAckId_o : out Array5(SWITCH_PORTS-1 downto 0);
106
    outstandingAckId_o : out Array5(SWITCH_PORTS-1 downto 0);
107
    outboundAckId_o : out Array5(SWITCH_PORTS-1 downto 0);
108
    inboundAckId_i : in Array5(SWITCH_PORTS-1 downto 0);
109
    outstandingAckId_i : in Array5(SWITCH_PORTS-1 downto 0);
110
    outboundAckId_i : in Array5(SWITCH_PORTS-1 downto 0);
111
 
112
    configStb_o : out std_logic;
113
    configWe_o : out std_logic;
114
    configAddr_o : out std_logic_vector(23 downto 0);
115
    configData_o : out std_logic_vector(31 downto 0);
116 47 magro732
    configData_i : in std_logic_vector(31 downto 0);
117
    configAck_i : in std_logic);
118 2 magro732
end entity;
119
 
120
 
121
-------------------------------------------------------------------------------
122
-- Architecture for RioSwitch.
123
-------------------------------------------------------------------------------
124
architecture RioSwitchImpl of RioSwitch is
125
 
126
  component RouteTableInterconnect is
127
    generic(
128
      WIDTH : natural range 1 to 256 := 8);
129
    port(
130
      clk : in std_logic;
131
      areset_n : in std_logic;
132
 
133
      stb_i : in Array1(WIDTH-1 downto 0);
134
      addr_i : in Array16(WIDTH-1 downto 0);
135
      dataM_o : out Array8(WIDTH-1 downto 0);
136
      ack_o : out Array1(WIDTH-1 downto 0);
137
 
138
      stb_o : out std_logic;
139
      addr_o : out std_logic_vector(15 downto 0);
140
      dataS_i : in std_logic_vector(7 downto 0);
141
      ack_i : in std_logic);
142
  end component;
143
 
144
  component SwitchPortInterconnect is
145
    generic(
146
      WIDTH : natural range 1 to 256 := 8);
147
    port(
148
      clk : in std_logic;
149
      areset_n : in std_logic;
150
 
151
      masterCyc_i : in Array1(WIDTH-1 downto 0);
152
      masterStb_i : in Array1(WIDTH-1 downto 0);
153
      masterWe_i : in Array1(WIDTH-1 downto 0);
154
      masterAddr_i : in Array10(WIDTH-1 downto 0);
155
      masterData_i : in Array32(WIDTH-1 downto 0);
156
      masterData_o : out Array1(WIDTH-1 downto 0);
157
      masterAck_o : out Array1(WIDTH-1 downto 0);
158
 
159
      slaveCyc_o : out Array1(WIDTH-1 downto 0);
160
      slaveStb_o : out Array1(WIDTH-1 downto 0);
161
      slaveWe_o : out Array1(WIDTH-1 downto 0);
162
      slaveAddr_o : out Array10(WIDTH-1 downto 0);
163
      slaveData_o : out Array32(WIDTH-1 downto 0);
164
      slaveData_i : in Array1(WIDTH-1 downto 0);
165
      slaveAck_i : in Array1(WIDTH-1 downto 0));
166
  end component;
167
 
168
  component SwitchPortMaintenance is
169
    generic(
170
      SWITCH_PORTS : natural range 0 to 255;
171
      DEVICE_IDENTITY : std_logic_vector(15 downto 0);
172
      DEVICE_VENDOR_IDENTITY : std_logic_vector(15 downto 0);
173
      DEVICE_REV : std_logic_vector(31 downto 0);
174
      ASSY_IDENTITY : std_logic_vector(15 downto 0);
175
      ASSY_VENDOR_IDENTITY : std_logic_vector(15 downto 0);
176
      ASSY_REV : std_logic_vector(15 downto 0));
177
    port(
178
      clk : in std_logic;
179
      areset_n : in std_logic;
180
 
181
      lookupStb_i : in std_logic;
182
      lookupAddr_i : in std_logic_vector(15 downto 0);
183
      lookupData_o : out std_logic_vector(7 downto 0);
184
      lookupAck_o : out std_logic;
185
 
186
      masterCyc_o : out std_logic;
187
      masterStb_o : out std_logic;
188
      masterWe_o : out std_logic;
189
      masterAddr_o : out std_logic_vector(9 downto 0);
190
      masterData_o : out std_logic_vector(31 downto 0);
191
      masterData_i : in std_logic;
192
      masterAck_i : in std_logic;
193
 
194
      slaveCyc_i : in std_logic;
195
      slaveStb_i : in std_logic;
196
      slaveWe_i : in std_logic;
197
      slaveAddr_i : in std_logic_vector(9 downto 0);
198
      slaveData_i : in std_logic_vector(31 downto 0);
199
      slaveData_o : out std_logic;
200
      slaveAck_o : out std_logic;
201
 
202
      lookupStb_o : out std_logic;
203
      lookupAddr_o : out std_logic_vector(15 downto 0);
204
      lookupData_i : in std_logic_vector(7 downto 0);
205
      lookupAck_i : in std_logic;
206
 
207
      portLinkTimeout_o : out std_logic_vector(23 downto 0);
208
 
209
      linkInitialized_i : in Array1(SWITCH_PORTS-1 downto 0);
210
      outputPortEnable_o : out Array1(SWITCH_PORTS-1 downto 0);
211
      inputPortEnable_o : out Array1(SWITCH_PORTS-1 downto 0);
212
      localAckIdWrite_o : out Array1(SWITCH_PORTS-1 downto 0);
213
      clrOutstandingAckId_o : out Array1(SWITCH_PORTS-1 downto 0);
214
      inboundAckId_o : out Array5(SWITCH_PORTS-1 downto 0);
215
      outstandingAckId_o : out Array5(SWITCH_PORTS-1 downto 0);
216
      outboundAckId_o : out Array5(SWITCH_PORTS-1 downto 0);
217
      inboundAckId_i : in Array5(SWITCH_PORTS-1 downto 0);
218
      outstandingAckId_i : in Array5(SWITCH_PORTS-1 downto 0);
219
      outboundAckId_i : in Array5(SWITCH_PORTS-1 downto 0);
220
 
221
      configStb_o : out std_logic;
222
      configWe_o : out std_logic;
223
      configAddr_o : out std_logic_vector(23 downto 0);
224
      configData_o : out std_logic_vector(31 downto 0);
225 47 magro732
      configData_i : in std_logic_vector(31 downto 0);
226
      configAck_i : in std_logic);
227 2 magro732
  end component;
228
 
229
  component SwitchPort is
230
    generic(
231 46 magro732
      MAINTENANCE_LOOKUP : boolean;
232 2 magro732
      PORT_INDEX : natural);
233
    port(
234
      clk : in std_logic;
235
      areset_n : in std_logic;
236
 
237
      masterCyc_o : out std_logic;
238
      masterStb_o : out std_logic;
239
      masterWe_o : out std_logic;
240
      masterAddr_o : out std_logic_vector(9 downto 0);
241
      masterData_o : out std_logic_vector(31 downto 0);
242
      masterData_i : in std_logic;
243
      masterAck_i : in std_logic;
244
 
245
      slaveCyc_i : in std_logic;
246
      slaveStb_i : in std_logic;
247
      slaveWe_i : in std_logic;
248
      slaveAddr_i : in std_logic_vector(9 downto 0);
249
      slaveData_i : in std_logic_vector(31 downto 0);
250
      slaveData_o : out std_logic;
251
      slaveAck_o : out std_logic;
252
 
253
      lookupStb_o : out std_logic;
254
      lookupAddr_o : out std_logic_vector(15 downto 0);
255
      lookupData_i : in std_logic_vector(7 downto 0);
256
      lookupAck_i : in std_logic;
257
 
258
      readFrameEmpty_i : in std_logic;
259
      readFrame_o : out std_logic;
260
      readFrameRestart_o : out std_logic;
261
      readFrameAborted_i : in std_logic;
262
      readContentEmpty_i : in std_logic;
263
      readContent_o : out std_logic;
264
      readContentEnd_i : in std_logic;
265
      readContentData_i : in std_logic_vector(31 downto 0);
266 46 magro732
      writeFramePort_o : out std_logic_vector(9 downto 0);
267 2 magro732
      writeFrameFull_i : in std_logic;
268
      writeFrame_o : out std_logic;
269
      writeFrameAbort_o : out std_logic;
270
      writeContent_o : out std_logic;
271
      writeContentData_o : out std_logic_vector(31 downto 0));
272
  end component;
273
 
274
  signal masterLookupStb : Array1(SWITCH_PORTS downto 0);
275
  signal masterLookupAddr : Array16(SWITCH_PORTS downto 0);
276
  signal masterLookupData : Array8(SWITCH_PORTS downto 0);
277
  signal masterLookupAck : Array1(SWITCH_PORTS downto 0);
278
 
279
  signal slaveLookupStb : std_logic;
280
  signal slaveLookupAddr : std_logic_vector(15 downto 0);
281
  signal slaveLookupData : std_logic_vector(7 downto 0);
282
  signal slaveLookupAck : std_logic;
283
 
284
  signal masterCyc : Array1(SWITCH_PORTS downto 0);
285
  signal masterStb : Array1(SWITCH_PORTS downto 0);
286
  signal masterWe : Array1(SWITCH_PORTS downto 0);
287
  signal masterAddr : Array10(SWITCH_PORTS downto 0);
288
  signal masterDataWrite : Array32(SWITCH_PORTS downto 0);
289
  signal masterDataRead : Array1(SWITCH_PORTS downto 0);
290
  signal masterAck : Array1(SWITCH_PORTS downto 0);
291
 
292
  signal slaveCyc : Array1(SWITCH_PORTS downto 0);
293
  signal slaveStb : Array1(SWITCH_PORTS downto 0);
294
  signal slaveWe : Array1(SWITCH_PORTS downto 0);
295
  signal slaveAddr : Array10(SWITCH_PORTS downto 0);
296
  signal slaveDataWrite : Array32(SWITCH_PORTS downto 0);
297
  signal slaveDataRead : Array1(SWITCH_PORTS downto 0);
298
  signal slaveAck : Array1(SWITCH_PORTS downto 0);
299
 
300
begin
301
 
302
  -----------------------------------------------------------------------------
303
  -- The routing table interconnect.
304
  -----------------------------------------------------------------------------
305
  RouteInterconnect: RouteTableInterconnect
306
    generic map(
307
      WIDTH=>SWITCH_PORTS+1)
308
    port map(
309
      clk=>clk, areset_n=>areset_n,
310
      stb_i=>masterLookupStb, addr_i=>masterLookupAddr,
311
      dataM_o=>masterLookupData, ack_o=>masterLookupAck,
312
      stb_o=>slaveLookupStb, addr_o=>slaveLookupAddr,
313
      dataS_i=>slaveLookupData, ack_i=>slaveLookupAck);
314
 
315
  -----------------------------------------------------------------------------
316
  -- The port interconnect.
317
  -----------------------------------------------------------------------------
318
  PortInterconnect: SwitchPortInterconnect
319
    generic map(
320
      WIDTH=>SWITCH_PORTS+1)
321
    port map(
322
      clk=>clk, areset_n=>areset_n,
323
      masterCyc_i=>masterCyc, masterStb_i=>masterStb, masterWe_i=>masterWe, masterAddr_i=>masterAddr,
324
      masterData_i=>masterDataWrite, masterData_o=>masterDataRead, masterAck_o=>masterAck,
325
      slaveCyc_o=>slaveCyc, slaveStb_o=>slaveStb, slaveWe_o=>slaveWe, slaveAddr_o=>slaveAddr,
326
      slaveData_o=>slaveDataWrite, slaveData_i=>slaveDataRead, slaveAck_i=>slaveAck);
327
 
328
  -----------------------------------------------------------------------------
329
  -- Data relaying port instantiation.
330
  -----------------------------------------------------------------------------
331
  PortGeneration: for portIndex in 0 to SWITCH_PORTS-1 generate
332
    PortInst: SwitchPort
333
      generic map(
334 46 magro732
        MAINTENANCE_LOOKUP=>false,
335 2 magro732
        PORT_INDEX=>portIndex)
336
      port map(
337
        clk=>clk, areset_n=>areset_n,
338
        masterCyc_o=>masterCyc(portIndex), masterStb_o=>masterStb(portIndex),
339
        masterWe_o=>masterWe(portIndex), masterAddr_o=>masterAddr(portIndex),
340
        masterData_o=>masterDataWrite(portIndex),
341
        masterData_i=>masterDataRead(portIndex), masterAck_i=>masterAck(portIndex),
342
        slaveCyc_i=>slaveCyc(portIndex), slaveStb_i=>slaveStb(portIndex),
343
        slaveWe_i=>slaveWe(portIndex), slaveAddr_i=>slaveAddr(portIndex),
344
        slaveData_i=>slaveDataWrite(portIndex),
345
        slaveData_o=>slaveDataRead(portIndex), slaveAck_o=>slaveAck(portIndex),
346
        lookupStb_o=>masterLookupStb(portIndex),
347
        lookupAddr_o=>masterLookupAddr(portIndex),
348
        lookupData_i=>masterLookupData(portIndex), lookupAck_i=>masterLookupAck(portIndex),
349
        readFrameEmpty_i=>readFrameEmpty_i(portIndex), readFrame_o=>readFrame_o(portIndex),
350
        readFrameRestart_o=>readFrameRestart_o(portIndex),
351
        readFrameAborted_i=>readFrameAborted_i(portIndex),
352
        readContentEmpty_i=>readContentEmpty_i(portIndex), readContent_o=>readContent_o(portIndex),
353
        readContentEnd_i=>readContentEnd_i(portIndex), readContentData_i=>readContentData_i(portIndex),
354 46 magro732
        writeFramePort_o=>open,
355 2 magro732
        writeFrameFull_i=>writeFrameFull_i(portIndex), writeFrame_o=>writeFrame_o(portIndex),
356
        writeFrameAbort_o=>writeFrameAbort_o(portIndex), writeContent_o=>writeContent_o(portIndex),
357
        writeContentData_o=>writeContentData_o(portIndex));
358
  end generate;
359
 
360
  -----------------------------------------------------------------------------
361
  -- Maintenance port instantiation.
362
  -----------------------------------------------------------------------------
363
  MaintenancePort: SwitchPortMaintenance
364
    generic map(
365
      SWITCH_PORTS=>SWITCH_PORTS,
366
      DEVICE_IDENTITY=>DEVICE_IDENTITY,
367
      DEVICE_VENDOR_IDENTITY=>DEVICE_VENDOR_IDENTITY,
368
      DEVICE_REV=>DEVICE_REV,
369
      ASSY_IDENTITY=>ASSY_IDENTITY,
370
      ASSY_VENDOR_IDENTITY=>ASSY_VENDOR_IDENTITY,
371
      ASSY_REV=>ASSY_REV)
372
    port map(
373
      clk=>clk, areset_n=>areset_n,
374
      lookupStb_i=>slaveLookupStb, lookupAddr_i=>slaveLookupAddr,
375
      lookupData_o=>slaveLookupData, lookupAck_o=>slaveLookupAck,
376
      masterCyc_o=>masterCyc(SWITCH_PORTS), masterStb_o=>masterStb(SWITCH_PORTS),
377
      masterWe_o=>masterWe(SWITCH_PORTS), masterAddr_o=>masterAddr(SWITCH_PORTS),
378
      masterData_o=>masterDataWrite(SWITCH_PORTS),
379
      masterData_i=>masterDataRead(SWITCH_PORTS), masterAck_i=>masterAck(SWITCH_PORTS),
380
      slaveCyc_i=>slaveCyc(SWITCH_PORTS), slaveStb_i=>slaveStb(SWITCH_PORTS),
381
      slaveWe_i=>slaveWe(SWITCH_PORTS), slaveAddr_i=>slaveAddr(SWITCH_PORTS),
382
      slaveData_i=>slaveDataWrite(SWITCH_PORTS),
383
      slaveData_o=>slaveDataRead(SWITCH_PORTS), slaveAck_o=>slaveAck(SWITCH_PORTS),
384
      lookupStb_o=>masterLookupStb(SWITCH_PORTS),
385
      lookupAddr_o=>masterLookupAddr(SWITCH_PORTS),
386
      lookupData_i=>masterLookupData(SWITCH_PORTS), lookupAck_i=>masterLookupAck(SWITCH_PORTS),
387
      portLinkTimeout_o=>portLinkTimeout_o,
388
      linkInitialized_i=>linkInitialized_i,
389
      outputPortEnable_o=>outputPortEnable_o, inputPortEnable_o=>inputPortEnable_o,
390
      localAckIdWrite_o=>localAckIdWrite_o, clrOutstandingAckId_o=>clrOutstandingAckId_o,
391
      inboundAckId_o=>inboundAckId_o, outstandingAckId_o=>outstandingAckId_o,
392
      outboundAckId_o=>outboundAckId_o, inboundAckId_i=>inboundAckId_i,
393
      outstandingAckId_i=>outstandingAckId_i, outboundAckId_i=>outboundAckId_i,
394
      configStb_o=>configStb_o, configWe_o=>configWe_o, configAddr_o=>configAddr_o,
395 47 magro732
      configData_o=>configData_o, configData_i=>configData_i, configAck_i=>configAck_i);
396 2 magro732
 
397
end architecture;
398
 
399
 
400
 
401
-------------------------------------------------------------------------------
402 46 magro732
-- SwitchPort.
403 2 magro732
-------------------------------------------------------------------------------
404
library ieee;
405
use ieee.std_logic_1164.all;
406
use ieee.numeric_std.all;
407
use work.rio_common.all;
408
 
409
 
410
-------------------------------------------------------------------------------
411
-- Entity for SwitchPort.
412
-------------------------------------------------------------------------------
413
entity SwitchPort is
414
  generic(
415 46 magro732
    MAINTENANCE_LOOKUP : boolean;
416 2 magro732
    PORT_INDEX : natural);
417
  port(
418
    clk : in std_logic;
419
    areset_n : in std_logic;
420
 
421
    -- Master port signals.
422
    -- Write frames to other ports.
423
    masterCyc_o : out std_logic;
424
    masterStb_o : out std_logic;
425
    masterWe_o : out std_logic;
426
    masterAddr_o : out std_logic_vector(9 downto 0);
427
    masterData_o : out std_logic_vector(31 downto 0);
428
    masterData_i : in std_logic;
429
    masterAck_i : in std_logic;
430
 
431
    -- Slave port signals.
432
    -- Receives frames from other ports.
433
    slaveCyc_i : in std_logic;
434
    slaveStb_i : in std_logic;
435
    slaveWe_i : in std_logic;
436
    slaveAddr_i : in std_logic_vector(9 downto 0);
437
    slaveData_i : in std_logic_vector(31 downto 0);
438
    slaveData_o : out std_logic;
439
    slaveAck_o : out std_logic;
440
 
441
    -- Address-lookup interface.
442
    lookupStb_o : out std_logic;
443
    lookupAddr_o : out std_logic_vector(15 downto 0);
444
    lookupData_i : in std_logic_vector(7 downto 0);
445
    lookupAck_i : in std_logic;
446
 
447
    -- Physical port frame buffer interface.
448
    readFrameEmpty_i : in std_logic;
449
    readFrame_o : out std_logic;
450
    readFrameRestart_o : out std_logic;
451
    readFrameAborted_i : in std_logic;
452
    readContentEmpty_i : in std_logic;
453
    readContent_o : out std_logic;
454
    readContentEnd_i : in std_logic;
455
    readContentData_i : in std_logic_vector(31 downto 0);
456 46 magro732
    writeFramePort_o : out std_logic_vector(7 downto 0);
457 2 magro732
    writeFrameFull_i : in std_logic;
458
    writeFrame_o : out std_logic;
459
    writeFrameAbort_o : out std_logic;
460
    writeContent_o : out std_logic;
461
    writeContentData_o : out std_logic_vector(31 downto 0));
462
end entity;
463
 
464
 
465
-------------------------------------------------------------------------------
466
-- Architecture for SwitchPort.
467
-------------------------------------------------------------------------------
468
architecture SwitchPortImpl of SwitchPort is
469
 
470
  type MasterStateType is (STATE_IDLE,
471
                           STATE_WAIT_HEADER_0, STATE_READ_HEADER_0,
472
                           STATE_READ_PORT_LOOKUP,
473
                           STATE_READ_TARGET_PORT,
474
                           STATE_WAIT_TARGET_PORT,
475
                           STATE_WAIT_TARGET_WRITE,
476
                           STATE_WAIT_COMPLETE);
477
  signal masterState : MasterStateType;
478 46 magro732
  alias ftype : std_logic_vector(3 downto 0) is readContentData_i(19 downto 16);
479
  alias tt : std_logic_vector(1 downto 0) is readContentData_i(21 downto 20);
480
 
481 2 magro732
  type SlaveStateType is (STATE_IDLE, STATE_SEND_ACK);
482
  signal slaveState : SlaveStateType;
483
 
484
begin
485
 
486
  -----------------------------------------------------------------------------
487
  -- Master interface process.
488
  -----------------------------------------------------------------------------
489
  Master: process(clk, areset_n)
490
  begin
491
    if (areset_n = '0') then
492
      masterState <= STATE_IDLE;
493
 
494
      lookupStb_o <= '0';
495
      lookupAddr_o <= (others => '0');
496
 
497
      masterCyc_o <= '0';
498
      masterStb_o <= '0';
499
      masterWe_o <= '0';
500
      masterAddr_o <= (others => '0');
501
      masterData_o <= (others => '0');
502
 
503
      readContent_o <= '0';
504
      readFrame_o <= '0';
505
      readFrameRestart_o <= '0';
506
    elsif (clk'event and clk = '1') then
507
      readContent_o <= '0';
508
      readFrame_o <= '0';
509
      readFrameRestart_o <= '0';
510
 
511
      case masterState is
512
 
513
        when STATE_IDLE =>
514
          ---------------------------------------------------------------------
515
          -- Wait for a new packet or content of a new packet.
516
          ---------------------------------------------------------------------
517
 
518
          -- Reset bus signals.
519
          masterCyc_o <= '0';
520
          masterStb_o <= '0';
521
 
522
          -- Wait for frame content to be available.
523
          -- Use different signals to trigger the forwarding of packets depending
524
          -- on the switch philosofy.
525
          if (readFrameEmpty_i = '0') then
526
            readContent_o <= '1';
527
            masterState <= STATE_WAIT_HEADER_0;
528
          end if;
529
 
530
        when STATE_WAIT_HEADER_0 =>
531
          ---------------------------------------------------------------------
532
          -- Wait for the frame buffer output to be updated.
533
          ---------------------------------------------------------------------
534
 
535
          -- Wait for frame buffer output to be updated.
536
          masterState <= STATE_READ_HEADER_0;
537
 
538
        when STATE_READ_HEADER_0 =>
539
          ---------------------------------------------------------------------
540
          -- Check the FTYPE and forward it to the maintenance port if it is a
541
          -- maintenance packet. Otherwise, initiate an address lookup and wait
542
          -- for the result.
543
          ---------------------------------------------------------------------
544
 
545
          -- Check if the frame has ended.
546
          if (readContentEnd_i = '0') then
547
            -- The frame has not ended.
548
            -- This word contains the header and the source id.
549
 
550
            -- Read the tt-field to check the source and destination id size.
551
            if (tt = "01") then
552
              -- This frame contains 16-bit addresses.
553
 
554
              -- Read the new content.
555
              readContent_o <= '1';
556
 
557
              -- Save the content of the header and destination.
558
              masterData_o <= readContentData_i;
559
 
560
              -- Check if this is a maintenance frame.
561 46 magro732
              if ((not MAINTENANCE_LOOKUP) and (ftype = FTYPE_MAINTENANCE_CLASS)) then
562 2 magro732
                -- This is a maintenance frame.
563
 
564
                -- Always route these frames to the maintenance module in the
565
                -- switch by setting the MSB bit of the port address.
566
                masterAddr_o <= '1' & std_logic_vector(to_unsigned(PORT_INDEX, 8)) & '0';
567
 
568
                -- Start an access to the maintenance port.
569
                masterState <= STATE_READ_TARGET_PORT;
570
              else
571
                -- This is not a maintenance frame.
572
 
573
                -- Lookup the destination address and proceed to wait for the
574
                -- result.
575
                lookupStb_o <= '1';
576
                lookupAddr_o <= readContentData_i(15 downto 0);
577
 
578
                -- Wait for the port lookup to return a result.
579
                masterState <= STATE_READ_PORT_LOOKUP;
580
              end if;
581
            else
582
              -- Unsupported tt-value, discard the frame.
583
              readFrame_o <= '1';
584
              masterState <= STATE_IDLE;
585
            end if;
586
          else
587
            -- End of frame.
588
            -- The frame is too short to contain a valid frame. Discard it.
589
            readFrame_o <= '1';
590
            masterState <= STATE_IDLE;
591
          end if;
592
 
593
        when STATE_READ_PORT_LOOKUP =>
594
          ---------------------------------------------------------------------
595
          -- Wait for the address lookup to be complete.
596
          ---------------------------------------------------------------------
597
 
598
          -- Wait for the routing table to complete the request.
599
          if (lookupAck_i = '1') then
600
            -- The address lookup is complete.
601
 
602
            -- Terminate the lookup cycle.
603
            lookupStb_o <= '0';
604
 
605
            -- Proceed to read the target port.
606
            masterAddr_o <= '0' & lookupData_i & '0';
607
            masterState <= STATE_READ_TARGET_PORT;
608
          else
609
            -- Wait until the address lookup is complete.
610
            -- REMARK: Timeout here???
611
          end if;
612
 
613
        when STATE_READ_TARGET_PORT =>
614
          ---------------------------------------------------------------------
615
          -- Initiate an access to the target port.
616
          ---------------------------------------------------------------------
617
 
618
          -- Read the status of the target port using the result from the
619
          -- lookup in the routing table.
620
          masterCyc_o <= '1';
621
          masterStb_o <= '1';
622
          masterWe_o <= '0';
623
          masterState <= STATE_WAIT_TARGET_PORT;
624
 
625
        when STATE_WAIT_TARGET_PORT =>
626
          ---------------------------------------------------------------------
627
          -- Wait to get access to the target port. When the port is ready
628
          -- check if it is ready to accept a new frame. If it cannot accept a
629
          -- new frame, terminate the access and go back and start a new one.
630
          -- This is to free the interconnect to let other ports access it if
631
          -- it is a shared bus. If the port is ready, initiate a write access
632
          -- to the selected port.
633
          ---------------------------------------------------------------------
634
 
635
          -- Wait for the target port to complete the request.
636
          if (masterAck_i = '1') then
637
            -- Target port has completed the request.
638
 
639
            -- Check the status of the target port.
640
            if (masterData_i = '0') then
641
              -- The target port has empty buffers to receive the frame.
642
 
643
              -- Hold the bus with cyc until the cycle is complete.
644
              -- Write the first word of the frame to the target port.
645
              -- The masterData_o has already been assigned.
646
              masterCyc_o <= '1';
647
              masterStb_o <= '1';
648
              masterWe_o <= '1';
649
              masterAddr_o(0) <= '1';
650
 
651
              -- Change state to transfer the frame.
652
              masterState <= STATE_WAIT_TARGET_WRITE;
653
            else
654
              -- The target port has no empty buffer to receive the frame.
655
              -- Terminate the cycle and retry later.
656
              masterCyc_o <= '0';
657
              masterStb_o <= '0';
658
              masterState <= STATE_READ_TARGET_PORT;
659
            end if;
660
          else
661
            -- Target port has not completed the request.
662
            -- Dont to anything.
663
          end if;
664
 
665
        when STATE_WAIT_TARGET_WRITE =>
666
          ---------------------------------------------------------------------
667
          -- Wait for the write access to complete. When complete, write the
668
          -- next content and update the content to the next. If the frame does
669
          -- not have any more data ready, terminate the access but keep the
670
          -- cycle active and proceed to wait for new data.
671
          ---------------------------------------------------------------------
672
 
673
          -- Wait for the target port to complete the request.
674 48 magro732
          -- REMARK: Remove the ack-condition to increase performance, we know
675
          -- that the write takes one cycle.
676 2 magro732
          if (masterAck_i = '1') then
677
            -- The target port is ready.
678
 
679
            -- Check if the frame has ended.
680
            if (readContentEnd_i = '0') then
681
              -- The frame has not ended.
682
 
683
              -- There are more data to transfer.
684
              masterData_o <= readContentData_i;
685
              readContent_o <= '1';
686
            else
687
              -- There are no more data to transfer.
688
 
689
              -- Update to the next frame.
690
              readFrame_o <= '1';
691
 
692
              -- Tell the target port that the frame is complete.
693
              masterWe_o <= '1';
694
              masterAddr_o(0) <= '0';
695
              masterData_o <= x"00000001";
696
 
697
              -- Change state to wait for the target port to finalize the write
698
              -- of the full frame.
699
              masterState <= STATE_WAIT_COMPLETE;
700
            end if;
701
          else
702
            -- Wait for the target port to reply.
703
            -- Dont do anything.
704
          end if;
705
 
706
        when STATE_WAIT_COMPLETE =>
707
          ---------------------------------------------------------------------
708
          -- Wait for the target port to signal that the frame has been
709
          -- completed.
710
          ---------------------------------------------------------------------
711
 
712
          -- Wait for the target port to complete the final request.
713
          if (masterAck_i = '1') then
714
            -- The target port has finalized the write of the frame.
715
 
716
            -- Reset master bus signals.
717
            masterCyc_o <= '0';
718
            masterStb_o <= '0';
719
            masterState <= STATE_IDLE;
720
          else
721
            -- Wait for the target port to reply.
722
            -- REMARK: Timeout here???
723
          end if;
724
 
725
        when others =>
726
          ---------------------------------------------------------------------
727
          -- 
728
          ---------------------------------------------------------------------
729
      end case;
730
    end if;
731
  end process;
732
 
733
  -----------------------------------------------------------------------------
734
  -- Slave interface process.
735
  -- Addr |  Read  | Write
736
  --    0 |  full  | abort & complete
737
  --    1 |  full  | frameData
738 46 magro732
  -----------------------------------------------------------------------------
739 2 magro732
  writeContentData_o <= slaveData_i;
740
  Slave: process(clk, areset_n)
741
  begin
742
    if (areset_n = '0') then
743
      slaveState <= STATE_IDLE;
744
 
745
      slaveData_o <= '0';
746
 
747 46 magro732
      writeFramePort_o <= (others=>'0');
748 2 magro732
      writeFrame_o <= '0';
749
      writeFrameAbort_o <= '0';
750
      writeContent_o <= '0';
751
    elsif (clk'event and clk = '1') then
752
      writeFrame_o <= '0';
753
      writeFrameAbort_o <= '0';
754
      writeContent_o <= '0';
755
 
756
      case slaveState is
757
 
758
        when STATE_IDLE =>
759
          ---------------------------------------------------------------------
760
          -- Wait for an access from a master.
761
          ---------------------------------------------------------------------
762
 
763
          -- Check if any cycle is active.
764
          if ((slaveCyc_i = '1') and (slaveStb_i = '1')) then
765
            -- Cycle is active.
766
 
767
            -- Check if the cycle is accessing the status- or data address.
768
            if (slaveAddr_i(0) = '0') then
769
              -- Accessing port status address.
770
 
771
              -- Check if writing.
772
              if (slaveWe_i = '1') then
773
                -- Writing the status address.
774
                -- Update the buffering output signals according to the input
775
                -- data.
776 46 magro732
                writeFramePort_o <= slaveAddr_i(8 downto 1);
777 2 magro732
                writeFrame_o <= slaveData_i(0);
778
                writeFrameAbort_o <= slaveData_i(1);
779
              else
780
                -- Reading the status address.
781
                slaveData_o <= writeFrameFull_i;
782
              end if;
783
            else
784
              -- Accessing port data address.
785
 
786
              -- Check if writing.
787
              if (slaveWe_i = '1') then
788
                -- Write frame content into the frame buffer.
789
                writeContent_o <= '1';
790
              else
791
                slaveData_o <= writeFrameFull_i;
792
              end if;
793
            end if;
794
 
795
            -- Change state to send an ack to the master.
796
            slaveState <= STATE_SEND_ACK;
797
          end if;
798
 
799
        when STATE_SEND_ACK =>
800
          ---------------------------------------------------------------------
801
          -- Wait for acknowledge to be received by the master.
802
          ---------------------------------------------------------------------
803
 
804
          -- Go back to the idle state and wait for a new cycle.
805
          slaveState <= STATE_IDLE;
806
 
807
        when others =>
808
          ---------------------------------------------------------------------
809
          -- 
810
          ---------------------------------------------------------------------
811
          null;
812
 
813
      end case;
814
    end if;
815
  end process;
816
 
817
  -- Assign the acknowledge depending on the current slave state.
818
  slaveAck_o <= '1' when (slaveState = STATE_SEND_ACK) else '0';
819
 
820
end architecture;
821
 
822
 
823
 
824 46 magro732
 
825
 
826 2 magro732
-------------------------------------------------------------------------------
827
-- SwitchPortMaintenance
828
-------------------------------------------------------------------------------
829
 
830
library ieee;
831
use ieee.std_logic_1164.all;
832
use ieee.numeric_std.all;
833
use work.rio_common.all;
834
 
835
 
836
-------------------------------------------------------------------------------
837
-- Entity for SwitchPortMaintenance.
838
-------------------------------------------------------------------------------
839
entity SwitchPortMaintenance is
840
  generic(
841
    SWITCH_PORTS : natural range 0 to 255;
842
    DEVICE_IDENTITY : std_logic_vector(15 downto 0);
843
    DEVICE_VENDOR_IDENTITY : std_logic_vector(15 downto 0);
844
    DEVICE_REV : std_logic_vector(31 downto 0);
845
    ASSY_IDENTITY : std_logic_vector(15 downto 0);
846
    ASSY_VENDOR_IDENTITY : std_logic_vector(15 downto 0);
847
    ASSY_REV : std_logic_vector(15 downto 0));
848
  port(
849
    clk : in std_logic;
850
    areset_n : in std_logic;
851
 
852
    -- Routing table port lookup signals.
853
    lookupStb_i : in std_logic;
854
    lookupAddr_i : in std_logic_vector(15 downto 0);
855
    lookupData_o : out std_logic_vector(7 downto 0);
856
    lookupAck_o : out std_logic;
857
 
858
    -- Master port signals.
859
    -- Write frames to other ports.
860
    masterCyc_o : out std_logic;
861
    masterStb_o : out std_logic;
862
    masterWe_o : out std_logic;
863
    masterAddr_o : out std_logic_vector(9 downto 0);
864
    masterData_o : out std_logic_vector(31 downto 0);
865
    masterData_i : in std_logic;
866
    masterAck_i : in std_logic;
867
 
868
    -- Slave port signals.
869
    -- Receives frames from other ports.
870
    slaveCyc_i : in std_logic;
871
    slaveStb_i : in std_logic;
872
    slaveWe_i : in std_logic;
873
    slaveAddr_i : in std_logic_vector(9 downto 0);
874
    slaveData_i : in std_logic_vector(31 downto 0);
875
    slaveData_o : out std_logic;
876
    slaveAck_o : out std_logic;
877
 
878
    -- Address-lookup interface.
879
    lookupStb_o : out std_logic;
880
    lookupAddr_o : out std_logic_vector(15 downto 0);
881
    lookupData_i : in std_logic_vector(7 downto 0);
882
    lookupAck_i : in std_logic;
883
 
884
    -- Port common access interface.
885
    portLinkTimeout_o : out std_logic_vector(23 downto 0);
886
 
887
    -- Port specific access interface.
888
    linkInitialized_i : in Array1(SWITCH_PORTS-1 downto 0);
889
    outputPortEnable_o : out Array1(SWITCH_PORTS-1 downto 0);
890
    inputPortEnable_o : out Array1(SWITCH_PORTS-1 downto 0);
891
    localAckIdWrite_o : out Array1(SWITCH_PORTS-1 downto 0);
892
    clrOutstandingAckId_o : out Array1(SWITCH_PORTS-1 downto 0);
893
    inboundAckId_o : out Array5(SWITCH_PORTS-1 downto 0);
894
    outstandingAckId_o : out Array5(SWITCH_PORTS-1 downto 0);
895
    outboundAckId_o : out Array5(SWITCH_PORTS-1 downto 0);
896
    inboundAckId_i : in Array5(SWITCH_PORTS-1 downto 0);
897
    outstandingAckId_i : in Array5(SWITCH_PORTS-1 downto 0);
898
    outboundAckId_i : in Array5(SWITCH_PORTS-1 downto 0);
899
 
900
    -- Configuration space for implementation-defined space.
901
    configStb_o : out std_logic;
902
    configWe_o : out std_logic;
903
    configAddr_o : out std_logic_vector(23 downto 0);
904
    configData_o : out std_logic_vector(31 downto 0);
905 47 magro732
    configData_i : in std_logic_vector(31 downto 0);
906
    configAck_i : in std_logic);
907 2 magro732
end entity;
908
 
909
 
910
-------------------------------------------------------------------------------
911
-- Architecture for SwitchPort.
912
-------------------------------------------------------------------------------
913
architecture SwitchPortMaintenanceImpl of SwitchPortMaintenance is
914
 
915 46 magro732
  component SwitchPort is
916 2 magro732
    generic(
917 46 magro732
      MAINTENANCE_LOOKUP : boolean;
918
      PORT_INDEX : natural);
919 2 magro732
    port(
920 46 magro732
      clk : in std_logic;
921
      areset_n : in std_logic;
922 2 magro732
 
923 46 magro732
      masterCyc_o : out std_logic;
924
      masterStb_o : out std_logic;
925
      masterWe_o : out std_logic;
926
      masterAddr_o : out std_logic_vector(9 downto 0);
927
      masterData_o : out std_logic_vector(31 downto 0);
928
      masterData_i : in std_logic;
929
      masterAck_i : in std_logic;
930
 
931
      slaveCyc_i : in std_logic;
932
      slaveStb_i : in std_logic;
933
      slaveWe_i : in std_logic;
934
      slaveAddr_i : in std_logic_vector(9 downto 0);
935
      slaveData_i : in std_logic_vector(31 downto 0);
936
      slaveData_o : out std_logic;
937
      slaveAck_o : out std_logic;
938
 
939
      lookupStb_o : out std_logic;
940
      lookupAddr_o : out std_logic_vector(15 downto 0);
941
      lookupData_i : in std_logic_vector(7 downto 0);
942
      lookupAck_i : in std_logic;
943
 
944
      readFrameEmpty_i : in std_logic;
945
      readFrame_o : out std_logic;
946
      readFrameRestart_o : out std_logic;
947
      readFrameAborted_i : in std_logic;
948
      readContentEmpty_i : in std_logic;
949
      readContent_o : out std_logic;
950
      readContentEnd_i : in std_logic;
951
      readContentData_i : in std_logic_vector(31 downto 0);
952
      writeFramePort_o : out std_logic_vector(7 downto 0);
953
      writeFrameFull_i : in std_logic;
954
      writeFrame_o : out std_logic;
955
      writeFrameAbort_o : out std_logic;
956
      writeContent_o : out std_logic;
957
      writeContentData_o : out std_logic_vector(31 downto 0));
958 2 magro732
  end component;
959 46 magro732
 
960
  -----------------------------------------------------------------------------
961
  -- Signals between the port and the packet-queue.
962
  -----------------------------------------------------------------------------
963 2 magro732
 
964 47 magro732
  signal outboundFramePort, outboundFramePort0 : std_logic_vector(7 downto 0);
965 46 magro732
  signal outboundReadFrameEmpty : std_logic;
966
  signal outboundReadFrame : std_logic;
967
  signal outboundReadContent : std_logic;
968
  signal outboundReadContentEnd : std_logic;
969
  signal outboundReadContentData : std_logic_vector(31 downto 0);
970 47 magro732
  signal inboundFramePort, inboundFramePort0 : std_logic_vector(7 downto 0);
971 46 magro732
  signal inboundWriteFrameFull : std_logic;
972
  signal inboundWriteFrame : std_logic;
973
  signal inboundWriteFrameAbort : std_logic;
974
  signal inboundWriteContent : std_logic;
975
  signal inboundWriteContentData : std_logic_vector(31 downto 0);
976 2 magro732
 
977 46 magro732
  -----------------------------------------------------------------------------
978
  -- Signals between the packet-queue and RioLogicalCommon.
979
  -----------------------------------------------------------------------------
980 2 magro732
 
981 46 magro732
  signal inboundReadFrameEmpty : std_logic;
982
  signal inboundReadFrame : std_logic;
983
  signal inboundReadContent : std_logic;
984
  signal inboundReadContentEnd : std_logic;
985
  signal inboundReadContentData : std_logic_vector(31 downto 0);
986
  signal outboundWriteFrameFull : std_logic;
987
  signal outboundWriteFrame : std_logic;
988
  signal outboundWriteFrameAbort : std_logic;
989
  signal outboundWriteContent : std_logic;
990
  signal outboundWriteContentData : std_logic_vector(31 downto 0);
991 2 magro732
 
992 46 magro732
  -----------------------------------------------------------------------------
993
  -- Signals between RioLogicalCommon and PacketHandler.
994
  -----------------------------------------------------------------------------
995 2 magro732
 
996 46 magro732
  signal inboundStb : std_logic;
997 48 magro732
  signal inboundAdr : std_logic_vector(3 downto 0);
998 46 magro732
  signal inboundDat : std_logic_vector(31 downto 0);
999 48 magro732
  signal inboundStall : std_logic;
1000 46 magro732
  signal outboundStb : std_logic_vector(0 downto 0);
1001 48 magro732
  signal outboundAdr : std_logic_vector(0 downto 0);
1002 46 magro732
  signal outboundDat : std_logic_vector(31 downto 0);
1003 48 magro732
  signal outboundStall : std_logic_vector(0 downto 0);
1004 2 magro732
 
1005 46 magro732
  -----------------------------------------------------------------------------
1006
  -- Signals between PacketHandlers and maintenance controllers.
1007
  -----------------------------------------------------------------------------
1008 2 magro732
 
1009
  signal vc : std_logic;
1010
  signal crf : std_logic;
1011
  signal prio : std_logic_vector(1 downto 0);
1012
  signal tt : std_logic_vector(1 downto 0);
1013 46 magro732
  signal tid : std_logic_vector(7 downto 0);
1014 47 magro732
  signal status : std_logic_vector(3 downto 0);
1015 2 magro732
 
1016 46 magro732
  signal readRequestInbound : std_logic;
1017
  signal writeRequestInbound : std_logic;
1018
  signal readResponseInbound : std_logic;
1019
  signal writeResponseInbound : std_logic;
1020
  signal portWriteInbound : std_logic;
1021
  signal dstIdInbound : std_logic_vector(31 downto 0);
1022
  signal srcIdInbound : std_logic_vector(31 downto 0);
1023 47 magro732
  signal sizeInbound : std_logic_vector(3 downto 0);
1024
  signal statusInbound : std_logic_vector(3 downto 0);
1025 46 magro732
  signal hopInbound : std_logic_vector(7 downto 0);
1026
  signal offsetInbound : std_logic_vector(20 downto 0);
1027
  signal wdptrInbound: std_logic;
1028 47 magro732
  signal payloadLengthInbound : std_logic_vector(2 downto 0);
1029
  signal payloadIndexInbound : std_logic_vector(2 downto 0);
1030
  signal payloadInbound : std_logic_vector(63 downto 0);
1031 46 magro732
  signal doneInbound : std_logic;
1032
 
1033
  signal readRequestOutbound : std_logic;
1034
  signal writeRequestOutbound : std_logic;
1035
  signal readResponseOutbound : std_logic;
1036
  signal writeResponseOutbound : std_logic;
1037
  signal portWriteOutbound : std_logic;
1038
  signal dstIdOutbound : std_logic_vector(31 downto 0);
1039
  signal srcIdOutbound : std_logic_vector(31 downto 0);
1040 47 magro732
  signal statusOutbound : std_logic_vector(3 downto 0);
1041 46 magro732
  signal hopOutbound : std_logic_vector(7 downto 0);
1042 47 magro732
  signal payloadLengthOutbound : std_logic_vector(2 downto 0);
1043
  signal payloadIndexOutbound : std_logic_vector(2 downto 0);
1044
  signal payloadOutbound : std_logic_vector(63 downto 0);
1045 46 magro732
  signal doneOutbound : std_logic;
1046
 
1047
  signal readRequestMaint : std_logic;
1048
  signal writeRequestMaint : std_logic;
1049
  signal readResponseMaint : std_logic;
1050
  signal writeResponseMaint : std_logic;
1051 47 magro732
  signal statusMaint : std_logic_vector(3 downto 0);
1052
  signal payloadLengthMaint : std_logic_vector(2 downto 0);
1053
  signal payloadIndexMaint : std_logic_vector(2 downto 0);
1054
  signal payloadMaint : std_logic_vector(63 downto 0);
1055 46 magro732
  signal doneMaint : std_logic;
1056
 
1057 2 magro732
  -----------------------------------------------------------------------------
1058 46 magro732
  -- 
1059
  -----------------------------------------------------------------------------
1060
 
1061
  signal sendPacket : std_logic;
1062
  signal forwardPacket : std_logic;
1063
 
1064
  -----------------------------------------------------------------------------
1065 2 magro732
  -- Route table access signals.
1066
  -----------------------------------------------------------------------------
1067
 
1068
  signal lookupEnable : std_logic;
1069
  signal lookupAddress : std_logic_vector(10 downto 0);
1070
  signal lookupData : std_logic_vector(7 downto 0);
1071
  signal lookupAck : std_logic;
1072
 
1073
  signal routeTableEnable : std_logic;
1074
  signal routeTableWrite : std_logic;
1075
  signal routeTableAddress : std_logic_vector(10 downto 0);
1076
  signal routeTablePortWrite : std_logic_vector(7 downto 0);
1077
  signal routeTablePortRead : std_logic_vector(7 downto 0);
1078
 
1079
  signal routeTablePortDefault : std_logic_vector(7 downto 0);
1080
 
1081
  -----------------------------------------------------------------------------
1082
  -- Configuration space signals.
1083
  -----------------------------------------------------------------------------
1084 46 magro732
 
1085 47 magro732
  signal configStb, configStbInternal : std_logic;
1086 46 magro732
  signal configWe : std_logic;
1087
  signal configAdr : std_logic_vector(23 downto 0);
1088
  signal configDataWrite : std_logic_vector(31 downto 0);
1089
  signal configDataRead, configDataReadInternal : std_logic_vector(31 downto 0);
1090 47 magro732
  signal configAck, configAckInternal : std_logic;
1091 46 magro732
 
1092 2 magro732
  signal discovered : std_logic;
1093
  signal hostBaseDeviceIdLocked : std_logic;
1094
  signal hostBaseDeviceId : std_logic_vector(15 downto 0);
1095
  signal componentTag : std_logic_vector(31 downto 0);
1096
  signal portLinkTimeout : std_logic_vector(23 downto 0);
1097
  signal outputPortEnable : Array1(SWITCH_PORTS-1 downto 0);
1098
  signal inputPortEnable : Array1(SWITCH_PORTS-1 downto 0);
1099
 
1100
begin
1101
 
1102
  -----------------------------------------------------------------------------
1103 46 magro732
  -- Normal switch port instance interfacing the switch interconnect.
1104 2 magro732
  -----------------------------------------------------------------------------
1105 48 magro732
  -- Note that PORT_INDEX is not used in this instantiation and set to zero.
1106 46 magro732
  PortInst: SwitchPort
1107 2 magro732
    generic map(
1108 46 magro732
      MAINTENANCE_LOOKUP=>true,
1109
      PORT_INDEX=>0)
1110 2 magro732
    port map(
1111 46 magro732
      clk=>clk, areset_n=>areset_n,
1112
      masterCyc_o=>masterCyc_o,
1113
      masterStb_o=>masterStb_o,
1114
      masterWe_o=>masterWe_o,
1115
      masterAddr_o=>masterAddr_o,
1116
      masterData_o=>masterData_o,
1117
      masterData_i=>masterData_i,
1118
      masterAck_i=>masterAck_i,
1119
      slaveCyc_i=>slaveCyc_i,
1120
      slaveStb_i=>slaveStb_i,
1121
      slaveWe_i=>slaveWe_i,
1122
      slaveAddr_i=>slaveAddr_i,
1123
      slaveData_i=>slaveData_i,
1124
      slaveData_o=>slaveData_o,
1125
      slaveAck_o=>slaveAck_o,
1126
      lookupStb_o=>open,
1127
      lookupAddr_o=>open,
1128 47 magro732
      lookupData_i=>outboundFramePort0,
1129 46 magro732
      lookupAck_i=>'1',
1130
      readFrameEmpty_i=>outboundReadFrameEmpty,
1131
      readFrame_o=>outboundReadFrame,
1132
      readFrameRestart_o=>open,
1133
      readFrameAborted_i=>'0',
1134
      readContentEmpty_i=>'0',
1135
      readContent_o=>outboundReadContent,
1136
      readContentEnd_i=>outboundReadContentEnd,
1137
      readContentData_i=>outboundReadContentData,
1138 47 magro732
      writeFramePort_o=>inboundFramePort0,
1139 46 magro732
      writeFrameFull_i=>inboundWriteFrameFull,
1140
      writeFrame_o=>inboundWriteFrame,
1141
      writeFrameAbort_o=>inboundWriteFrameAbort,
1142
      writeContent_o=>inboundWriteContent,
1143
      writeContentData_o=>inboundWriteContentData);
1144
 
1145 47 magro732
  process(clk)
1146
  begin
1147
    if (clk'event and clk = '1') then
1148
      if (inboundReadFrame = '1') then
1149
        inboundFramePort <= inboundFramePort0;
1150
      end if;
1151
      if (outboundWriteFrame = '1') then
1152
        outboundFramePort0 <= outboundFramePort;
1153
      end if;
1154
    end if;
1155
  end process;
1156
 
1157 46 magro732
  -----------------------------------------------------------------------------
1158
  -- Packet queue.
1159
  -- This queue should only contain one packet.
1160
  -----------------------------------------------------------------------------
1161 48 magro732
  -- REMARK: Use a packet-buffer with a configurable maximum sized packet. The
1162
  -- size of the resulting memory is larger than needed since maintenance
1163
  -- packets never contain more than 8 double-words.
1164 46 magro732
  PacketQueue: RioPacketBuffer
1165
    generic map(SIZE_ADDRESS_WIDTH=>1, CONTENT_ADDRESS_WIDTH=>7)
1166
    port map(
1167
      clk=>clk, areset_n=>areset_n,
1168
      inboundWriteFrameFull_o=>inboundWriteFrameFull,
1169
      inboundWriteFrame_i=>inboundWriteFrame,
1170
      inboundWriteFrameAbort_i=>inboundWriteFrameAbort,
1171
      inboundWriteContent_i=>inboundWriteContent,
1172
      inboundWriteContentData_i=>inboundWriteContentData,
1173
      inboundReadFrameEmpty_o=>inboundReadFrameEmpty,
1174
      inboundReadFrame_i=>inboundReadFrame,
1175
      inboundReadFrameRestart_i=>'0',
1176
      inboundReadFrameAborted_o=>open,
1177
      inboundReadContentEmpty_o=>open,
1178
      inboundReadContent_i=>inboundReadContent,
1179
      inboundReadContentEnd_o=>inboundReadContentEnd,
1180
      inboundReadContentData_o=>inboundReadContentData,
1181
      outboundWriteFrameFull_o=>outboundWriteFrameFull,
1182
      outboundWriteFrame_i=>outboundWriteFrame,
1183
      outboundWriteFrameAbort_i=>outboundWriteFrameAbort,
1184
      outboundWriteContent_i=>outboundWriteContent,
1185
      outboundWriteContentData_i=>outboundWriteContentData,
1186
      outboundReadFrameEmpty_o=>outboundReadFrameEmpty,
1187
      outboundReadFrame_i=>outboundReadFrame,
1188
      outboundReadFrameRestart_i=>'0',
1189
      outboundReadFrameAborted_o=>open,
1190
      outboundReadContentEmpty_o=>open,
1191
      outboundReadContent_i=>outboundReadContent,
1192
      outboundReadContentEnd_o=>outboundReadContentEnd,
1193
      outboundReadContentData_o=>outboundReadContentData);
1194 2 magro732
 
1195
  -----------------------------------------------------------------------------
1196 46 magro732
  -- Logical common packet parser.
1197
  -- This module removes CRC and unpack addresses in the inbound direction and
1198
  -- adds CRC and packs addresses in the outbound direction.
1199 2 magro732
  -----------------------------------------------------------------------------
1200 46 magro732
  LogicalCommon: RioLogicalCommon
1201
    generic map(PORTS=>1)
1202
    port map(
1203
      clk=>clk, areset_n=>areset_n, enable=>'1',
1204
      readFrameEmpty_i=>inboundReadFrameEmpty,
1205
      readFrame_o=>inboundReadFrame,
1206
      readContent_o=>inboundReadContent,
1207
      readContentEnd_i=>inboundReadContentEnd,
1208
      readContentData_i=>inboundReadContentData,
1209
      writeFrameFull_i=>outboundWriteFrameFull,
1210
      writeFrame_o=>outboundWriteFrame,
1211
      writeFrameAbort_o=>outboundWriteFrameAbort,
1212
      writeContent_o=>outboundWriteContent,
1213
      writeContentData_o=>outboundWriteContentData,
1214
      inboundStb_o=>inboundStb,
1215
      inboundAdr_o=>inboundAdr,
1216
      inboundDat_o=>inboundDat,
1217 48 magro732
      inboundStall_i=>inboundStall,
1218
      outboundStb_i=>outboundStb,
1219
      outboundAdr_i=>outboundAdr,
1220 46 magro732
      outboundDat_i=>outboundDat,
1221 48 magro732
      outboundStall_o=>outboundStall);
1222 2 magro732
 
1223 46 magro732
  -----------------------------------------------------------------------------
1224
  -- Inbound maintenance packet parser.
1225
  -- Unpack inbound maintenance packets.
1226
  -----------------------------------------------------------------------------
1227
  payloadIndexInbound <= payloadIndexOutbound when (forwardPacket = '1') else payloadIndexMaint;
1228
  doneInbound <= doneOutbound when (forwardPacket = '1') else doneMaint;
1229
  InboundPacket: MaintenanceInbound
1230 2 magro732
    port map(
1231 46 magro732
      clk=>clk, areset_n=>areset_n, enable=>'1',
1232
      readRequestReady_o=>readRequestInbound,
1233
      writeRequestReady_o=>writeRequestInbound,
1234
      readResponseReady_o=>readResponseInbound,
1235
      writeResponseReady_o=>writeResponseInbound,
1236
      portWriteReady_o=>portWriteInbound,
1237
      vc_o=>vc,
1238
      crf_o=>crf,
1239
      prio_o=>prio,
1240
      tt_o=>tt,
1241
      dstid_o=>dstIdInbound,
1242
      srcid_o=>srcIdInbound,
1243 47 magro732
      size_o=>sizeInbound,
1244
      status_o=>statusInbound,
1245 46 magro732
      tid_o=>tid,
1246
      hop_o=>hopInbound,
1247
      offset_o=>offsetInbound,
1248
      wdptr_o=>wdptrInbound,
1249
      payloadLength_o=>payloadLengthInbound,
1250
      payloadIndex_i=>payloadIndexInbound,
1251
      payload_o=>payloadInbound,
1252
      done_i=>doneInbound,
1253
      inboundStb_i=>inboundStb,
1254
      inboundAdr_i=>inboundAdr,
1255
      inboundDat_i=>inboundDat,
1256 48 magro732
      inboundStall_o=>inboundStall);
1257 46 magro732
 
1258
  -----------------------------------------------------------------------------
1259
  -- Outbound maintenance packet generator.
1260
  -----------------------------------------------------------------------------
1261
  readRequestOutbound <= (readRequestInbound and sendPacket) when (forwardPacket = '1') else '0';
1262
  writeRequestOutbound <= (writeRequestInbound and sendPacket) when (forwardPacket = '1') else '0';
1263
  readResponseOutbound <= (readResponseInbound and sendPacket) when (forwardPacket = '1') else readResponseMaint;
1264
  writeResponseOutbound <= (writeResponseInbound and sendPacket) when (forwardPacket = '1') else writeResponseMaint;
1265
  portWriteOutbound <= (portWriteInbound and sendPacket) when (forwardPacket = '1') else '0';
1266
  srcIdOutbound <= srcIdInbound when (forwardPacket = '1') else dstIdInbound;
1267
  dstIdOutbound <= dstIdInbound when (forwardPacket = '1') else srcIdInbound;
1268 47 magro732
  statusOutbound <= statusInbound when (forwardPacket = '1') else statusMaint;
1269 46 magro732
  hopOutbound <= std_logic_vector(unsigned(hopInbound)-1) when (forwardPacket = '1') else x"ff";
1270
  payloadLengthOutbound <= payloadLengthInbound when (forwardPacket = '1') else payloadLengthMaint;
1271
  payloadOutbound <= payloadInbound when (forwardPacket = '1') else payloadMaint;
1272
  OutboundPacket: MaintenanceOutbound
1273 2 magro732
    port map(
1274 46 magro732
      clk=>clk, areset_n=>areset_n, enable=>'1',
1275
      readRequestReady_i=>readRequestOutbound,
1276
      writeRequestReady_i=>writeRequestOutbound,
1277
      readResponseReady_i=>readResponseOutbound,
1278
      writeResponseReady_i=>writeResponseOutbound,
1279
      portWriteReady_i=>portWriteOutbound,
1280
      vc_i=>vc,
1281
      crf_i=>crf,
1282
      prio_i=>prio,
1283
      tt_i=>tt,
1284
      dstid_i=>dstIdOutbound,
1285
      srcid_i=>srcIdOutbound,
1286 47 magro732
      size_i=>sizeInbound,
1287
      status_i=>statusOutbound,
1288 46 magro732
      tid_i=>tid,
1289
      hop_i=>hopOutbound,
1290
      offset_i=>offsetInbound,
1291 47 magro732
      wdptr_i=>wdptrInbound,
1292 46 magro732
      payloadLength_i=>payloadLengthOutbound,
1293
      payloadIndex_o=>payloadIndexOutbound,
1294
      payload_i=>payloadOutbound,
1295
      done_o=>doneOutbound,
1296 48 magro732
      outboundStb_o=>outboundStb(0),
1297
      outboundAdr_o=>outboundAdr(0),
1298 46 magro732
      outboundDat_o=>outboundDat,
1299 48 magro732
      outboundStall_i=>outboundStall(0));
1300 46 magro732
 
1301 2 magro732
  -----------------------------------------------------------------------------
1302 46 magro732
  -- Main switch maintenance controller.
1303
  -- This controller decides when to forward packets and when to consume and
1304
  -- produce responses instead.
1305
  -- It also determines when portWrite-packets are allowed to be sent.
1306 2 magro732
  -----------------------------------------------------------------------------
1307 46 magro732
  RioSwitchMaintenance: process(clk, areset_n)
1308
    type MasterStateType is (STATE_IDLE,
1309
                             STATE_START_PORT_LOOKUP,
1310 48 magro732
                             STATE_WAIT_PORT_LOOKUP,
1311 46 magro732
                             STATE_WAIT_COMPLETE);
1312
    variable masterState : MasterStateType;
1313 2 magro732
  begin
1314
    if (areset_n = '0') then
1315 46 magro732
      masterState := STATE_IDLE;
1316 2 magro732
 
1317 46 magro732
      sendPacket <= '0';
1318
      forwardPacket <= '0';
1319
      outboundFramePort <= (others=>'0');
1320
 
1321 2 magro732
      lookupStb_o <= '0';
1322
      lookupAddr_o <= (others => '0');
1323
    elsif (clk'event and clk = '1') then
1324
      case masterState is
1325
 
1326
        when STATE_IDLE =>
1327
          ---------------------------------------------------------------------
1328 48 magro732
          -- Wait for frame to be available.
1329 2 magro732
          ---------------------------------------------------------------------
1330 46 magro732
          -- REMARK: Discard erronous frames.
1331
          sendPacket <= '0';
1332
          if (((readRequestInbound = '1') or (writeRequestInbound = '1')) and (hopInbound = x"00")) then
1333
            masterState := STATE_WAIT_COMPLETE;
1334
            forwardPacket <= '0';
1335
            outboundFramePort <= inboundFramePort;
1336 48 magro732
          elsif ((readResponseInbound = '1') or
1337
                 ((readRequestInbound = '1') and (hopInbound /= x"00")) or
1338
                 (writeResponseInbound = '1') or
1339
                 ((writeRequestInbound = '1') and (hopInbound /= x"00")) or
1340 46 magro732
                 (portWriteInbound = '1')) then
1341
            masterState := STATE_START_PORT_LOOKUP;
1342
            forwardPacket <= '1';
1343 2 magro732
          end if;
1344
 
1345
        when STATE_START_PORT_LOOKUP =>
1346
          ---------------------------------------------------------------------
1347 48 magro732
          -- The destination port of the packet should be read from the routing
1348
          -- table.
1349 2 magro732
          ---------------------------------------------------------------------
1350
 
1351
          -- Initiate a port-lookup of the destination address.
1352
          lookupStb_o <= '1';
1353 46 magro732
          lookupAddr_o <= dstIdInbound(15 downto 0);
1354 48 magro732
          masterState := STATE_WAIT_PORT_LOOKUP;
1355 2 magro732
 
1356 48 magro732
        when STATE_WAIT_PORT_LOOKUP =>
1357 2 magro732
          ---------------------------------------------------------------------
1358 48 magro732
          -- Wait for the destination port lookup to complete.
1359 2 magro732
          ---------------------------------------------------------------------
1360
 
1361
          if (lookupAck_i = '1') then
1362
            -- The address lookup is complete.
1363
 
1364
            -- Terminate the lookup cycle.
1365
            lookupStb_o <= '0';
1366
 
1367
            -- Wait for the target port to reply.
1368 46 magro732
            outboundFramePort <= lookupData_i;
1369
            masterState := STATE_WAIT_COMPLETE;
1370 2 magro732
          else
1371
            -- Wait until the address lookup is complete.
1372
            -- REMARK: Timeout here???
1373
          end if;
1374
 
1375
        when STATE_WAIT_COMPLETE =>
1376
          ---------------------------------------------------------------------
1377 48 magro732
          -- Indicate that the packet can be sent and wait for it to be
1378
          -- transmitted.
1379 2 magro732
          ---------------------------------------------------------------------
1380 46 magro732
          sendPacket <= '1';
1381 47 magro732
          if (doneInbound = '1') then
1382 46 magro732
            masterState := STATE_IDLE;
1383 2 magro732
          end if;
1384
 
1385
        when others =>
1386
          ---------------------------------------------------------------------
1387
          -- 
1388
          ---------------------------------------------------------------------
1389
      end case;
1390
    end if;
1391
  end process;
1392
 
1393
  -----------------------------------------------------------------------------
1394 46 magro732
  -- Bridge between the inbound RapidIO maintenance packets to the internal
1395
  -- config-space bus.
1396 2 magro732
  -----------------------------------------------------------------------------
1397 46 magro732
  readRequestMaint <= (readRequestInbound and sendPacket) when (forwardPacket = '0') else '0';
1398
  writeRequestMaint <= (writeRequestInbound and sendPacket) when (forwardPacket = '0') else '0';
1399
  MaintenanceBridge: RioLogicalMaintenance
1400 2 magro732
    port map(
1401 46 magro732
      clk=>clk, areset_n=>areset_n, enable=>'1',
1402
      readRequestReady_i=>readRequestMaint,
1403 47 magro732
      writeRequestReady_i=>writeRequestMaint,
1404
      size_i=>sizeInbound,
1405 46 magro732
      offset_i=>offsetInbound,
1406
      wdptr_i=>wdptrInbound,
1407
      payloadLength_i=>payloadLengthInbound,
1408
      payloadIndex_o=>payloadIndexMaint,
1409
      payload_i=>payloadInbound,
1410
      done_o=>doneMaint,
1411
      readResponseReady_o=>readResponseMaint,
1412 47 magro732
      writeResponseReady_o=>writeResponseMaint,
1413
      status_o=>statusMaint,
1414 46 magro732
      payloadLength_o=>payloadLengthMaint,
1415
      payloadIndex_i=>payloadIndexOutbound,
1416
      payload_o=>payloadMaint,
1417
      done_i=>doneOutbound,
1418
      configStb_o=>configStb,
1419
      configWe_o=>configWe,
1420
      configAdr_o=>configAdr(23 downto 2),
1421
      configDat_o=>configDataWrite,
1422
      configDat_i=>configDataRead,
1423
      configAck_i=>configAck);
1424
  configAdr(1 downto 0) <= "00";
1425 2 magro732
 
1426
  -----------------------------------------------------------------------------
1427 46 magro732
  -- Switch configuration memory.
1428 2 magro732
  -----------------------------------------------------------------------------
1429
  portLinkTimeout_o <= portLinkTimeout;
1430
  outputPortEnable_o <= outputPortEnable;
1431
  inputPortEnable_o <= inputPortEnable;
1432 46 magro732
 
1433
  configStb_o <= '1' when ((configStb = '1') and (configAdr(23 downto 16) /= x"00")) else '0';
1434 47 magro732
  configStbInternal <= '1' when ((configStb = '1') and (configAdr(23 downto 16) = x"00")) else '0';
1435 46 magro732
  configWe_o <= configWe;
1436
  configAddr_o <= configAdr;
1437 2 magro732
  configData_o <= configDataWrite;
1438 47 magro732
  configDataRead <= configData_i when (configStbInternal = '0') else configDataReadInternal;
1439
  configAck <= configAck_i when (configStbInternal = '0') else configAckInternal;
1440 2 magro732
 
1441
  ConfigMemory: process(areset_n, clk)
1442
  begin
1443
    if (areset_n = '0') then
1444
      configDataReadInternal <= (others => '0');
1445 47 magro732
      configAckInternal <= '0';
1446 2 magro732
 
1447
      routeTableEnable <= '1';
1448
      routeTableWrite <= '0';
1449
      routeTableAddress <= (others => '0');
1450
      routeTablePortWrite <= (others => '0');
1451
      routeTablePortDefault <= (others => '0');
1452
 
1453
      discovered <= '0';
1454
 
1455
      hostBaseDeviceIdLocked <= '0';
1456
      hostBaseDeviceId <= (others => '1');
1457
      componentTag <= (others => '0');
1458
 
1459
      portLinkTimeout <= (others => '1');
1460
 
1461
      -- REMARK: These should be set to zero when a port gets initialized...
1462
      outputPortEnable <= (others => '0');
1463
      inputPortEnable <= (others => '0');
1464
 
1465
      localAckIdWrite_o <= (others => '0');
1466
    elsif (clk'event and clk = '1') then
1467
      routeTableWrite <= '0';
1468
      localAckIdWrite_o <= (others => '0');
1469
 
1470 47 magro732
      if (configAckInternal = '0') then
1471
        if (configStbInternal = '1') then
1472
          configAckInternal <= '1';
1473 2 magro732
 
1474 46 magro732
          -- Check if the access is into implementation defined space or if the
1475
          -- access should be handled here.
1476
          if (configAdr(23 downto 16) /= x"00") then
1477
            -- Accessing implementation defined space.
1478
            -- Make an external access and return the resonse.
1479
            configDataReadInternal <= (others=>'0');
1480
          else
1481
            -- Access should be handled here.
1482
 
1483
            case (configAdr) is
1484
              when x"000000" =>
1485
                -----------------------------------------------------------------
1486
                -- Device Identity CAR. Read-only.
1487
                -----------------------------------------------------------------
1488 2 magro732
 
1489 46 magro732
                configDataReadInternal(31 downto 16) <= DEVICE_IDENTITY;
1490
                configDataReadInternal(15 downto 0) <= DEVICE_VENDOR_IDENTITY;
1491
 
1492
              when x"000004" =>
1493
                -----------------------------------------------------------------
1494
                -- Device Information CAR. Read-only.
1495
                -----------------------------------------------------------------
1496 2 magro732
 
1497 46 magro732
                configDataReadInternal(31 downto 0) <= DEVICE_REV;
1498
 
1499
              when x"000008" =>
1500
                -----------------------------------------------------------------
1501
                -- Assembly Identity CAR. Read-only.
1502
                -----------------------------------------------------------------
1503 2 magro732
 
1504 46 magro732
                configDataReadInternal(31 downto 16) <= ASSY_IDENTITY;
1505
                configDataReadInternal(15 downto 0) <= ASSY_VENDOR_IDENTITY;
1506
 
1507
              when x"00000c" =>
1508
                -----------------------------------------------------------------
1509
                -- Assembly Informaiton CAR. Read-only.
1510
                -----------------------------------------------------------------
1511 2 magro732
 
1512 46 magro732
                configDataReadInternal(31 downto 16) <= ASSY_REV;
1513
                configDataReadInternal(15 downto 0) <= x"0100";
1514
 
1515
              when x"000010" =>
1516
                -----------------------------------------------------------------
1517
                -- Processing Element Features CAR. Read-only.
1518
                -----------------------------------------------------------------
1519
 
1520
                -- Bridge.
1521
                configDataReadInternal(31) <= '0';
1522
 
1523
                -- Memory.
1524
                configDataReadInternal(30) <= '0';
1525
 
1526
                -- Processor.
1527
                configDataReadInternal(29) <= '0';
1528
 
1529
                -- Switch.
1530
                configDataReadInternal(28) <= '1';
1531
 
1532
                -- Reserved.
1533
                configDataReadInternal(27 downto 10) <= (others => '0');
1534
 
1535
                -- Extended route table configuration support.
1536
                configDataReadInternal(9) <= '0';
1537
 
1538
                -- Standard route table configuration support.
1539
                configDataReadInternal(8) <= '1';
1540
 
1541
                -- Reserved.
1542
                configDataReadInternal(7 downto 5) <= (others => '0');
1543
 
1544
                -- Common transport large system support.
1545
                configDataReadInternal(4) <= '1';
1546
 
1547
                -- Extended features.
1548
                configDataReadInternal(3) <= '1';
1549
 
1550
                -- Extended addressing support.
1551
                -- Not a processing element.
1552
                configDataReadInternal(2 downto 0) <= "000";
1553
 
1554
              when x"000014" =>
1555
                -----------------------------------------------------------------
1556
                -- Switch Port Information CAR. Read-only.
1557
                -----------------------------------------------------------------
1558 2 magro732
 
1559 46 magro732
                -- Reserved.
1560
                configDataReadInternal(31 downto 16) <= (others => '0');
1561 2 magro732
 
1562 46 magro732
                -- PortTotal.
1563
                configDataReadInternal(15 downto 8) <=
1564
                  std_logic_vector(to_unsigned(SWITCH_PORTS, 8));
1565 2 magro732
 
1566 46 magro732
                -- PortNumber.
1567
                configDataReadInternal(7 downto 0) <= inboundFramePort;
1568
 
1569
              when x"000034" =>
1570
                -----------------------------------------------------------------
1571
                -- Switch Route Table Destination ID Limit CAR.
1572
                -----------------------------------------------------------------
1573 2 magro732
 
1574 46 magro732
                -- Max_destId.
1575
                -- Support 2048 addresses.
1576
                configDataReadInternal(15 downto 0) <= x"0800";
1577
 
1578
              when x"000068" =>
1579
                -----------------------------------------------------------------
1580
                -- Host Base Device ID Lock CSR.
1581
                -----------------------------------------------------------------
1582 2 magro732
 
1583 46 magro732
                if (configWe = '1') then
1584
                  -- Check if this field has been written before.
1585
                  if (hostBaseDeviceIdLocked = '0') then
1586
                    -- The field has not been written.
1587
                    -- Lock the field and set the host base device id.
1588
                    hostBaseDeviceIdLocked <= '1';
1589
                    hostBaseDeviceId <= configDataWrite(15 downto 0);
1590 2 magro732
                  else
1591 46 magro732
                    -- The field has been written.
1592
                    -- Check if the written data is the same as the stored.
1593
                    if (hostBaseDeviceId = configDataWrite(15 downto 0)) then
1594
                      -- Same as stored, reset the value to its initial value.
1595
                      hostBaseDeviceIdLocked <= '0';
1596
                      hostBaseDeviceId <= (others => '1');
1597
                    else
1598
                      -- Not writing the same as the stored value.
1599
                      -- Ignore the write.
1600
                    end if;
1601 2 magro732
                  end if;
1602
                end if;
1603 46 magro732
 
1604
                configDataReadInternal(31 downto 16) <= (others => '0');
1605
                configDataReadInternal(15 downto 0) <= hostBaseDeviceId;
1606
 
1607
              when x"00006c" =>
1608
                -----------------------------------------------------------------
1609
                -- Component TAG CSR.
1610
                -----------------------------------------------------------------
1611 2 magro732
 
1612 46 magro732
                if (configWe = '1') then
1613
                  componentTag <= configDataWrite;
1614
                end if;
1615
 
1616
                configDataReadInternal <= componentTag;
1617
 
1618
              when x"000070" =>
1619
                -----------------------------------------------------------------
1620
                -- Standard Route Configuration Destination ID Select CSR.
1621
                -----------------------------------------------------------------             
1622 2 magro732
 
1623 46 magro732
                if (configWe = '1') then
1624
                  -- Write the address to access the routing table.
1625
                  routeTableAddress <= configDataWrite(10 downto 0);
1626
                end if;
1627
 
1628
                configDataReadInternal(31 downto 11) <= (others => '0');
1629
                configDataReadInternal(10 downto 0) <= routeTableAddress;
1630
 
1631
              when x"000074" =>
1632
                -----------------------------------------------------------------
1633
                -- Standard Route Configuration Port Select CSR.
1634
                -----------------------------------------------------------------
1635 2 magro732
 
1636 46 magro732
                if (configWe = '1') then
1637
                  -- Write the port information for the address selected by the
1638
                  -- above register.
1639
                  routeTableWrite <= '1';
1640
                  routeTablePortWrite <= configDataWrite(7 downto 0);
1641
                end if;
1642 2 magro732
 
1643 46 magro732
                configDataReadInternal(31 downto 8) <= (others => '0');
1644
                configDataReadInternal(7 downto 0) <= routeTablePortRead;
1645
 
1646
              when x"000078" =>
1647
                -----------------------------------------------------------------
1648
                -- Standard Route Default Port CSR.
1649
                -----------------------------------------------------------------
1650 2 magro732
 
1651 46 magro732
                if (configWe = '1') then
1652
                  -- Write the default route device id.
1653
                  routeTablePortDefault <= configDataWrite(7 downto 0);
1654
                end if;
1655
 
1656
                configDataReadInternal(31 downto 8) <= (others => '0');
1657
                configDataReadInternal(7 downto 0) <= routeTablePortDefault;
1658
 
1659
              when x"000100" =>
1660
                -----------------------------------------------------------------
1661
                -- Extended features. LP-Serial Register Block Header.
1662
                -----------------------------------------------------------------
1663 2 magro732
 
1664 46 magro732
                -- One feature only, 0x0003=Generic End Point Free Device.
1665
                configDataReadInternal(31 downto 16) <= x"0000";
1666
                configDataReadInternal(15 downto 0) <= x"0003";
1667
 
1668
              when x"000120" =>
1669
                -----------------------------------------------------------------
1670
                -- Port Link Timeout Control CSR.
1671
                -----------------------------------------------------------------
1672 2 magro732
 
1673 46 magro732
                if (configWe = '1') then
1674
                  portLinkTimeout <= configDataWrite(31 downto 8);
1675
                end if;
1676
 
1677
                configDataReadInternal(31 downto 8) <= portLinkTimeout;
1678
                configDataReadInternal(7 downto 0) <= x"00";
1679
 
1680
              when x"00013c" =>
1681
                -----------------------------------------------------------------
1682
                -- Port General Control CSR.
1683
                -----------------------------------------------------------------
1684 2 magro732
 
1685 46 magro732
                if (configWe = '1') then
1686
                  discovered <= configDataWrite(29);
1687
                end if;
1688
 
1689
                configDataReadInternal(31 downto 30) <= "00";
1690
                configDataReadInternal(29) <= discovered;
1691
                configDataReadInternal(28 downto 0) <= (others => '0');
1692 2 magro732
 
1693 46 magro732
              when others =>
1694
                -----------------------------------------------------------------
1695
                -- Other port specific registers.
1696
                -----------------------------------------------------------------
1697
 
1698
                -- Make sure the output is always set to something.
1699
                configDataReadInternal <= (others=>'0');
1700 2 magro732
 
1701 46 magro732
                -- Iterate through all active ports.
1702
                for portIndex in 0 to SWITCH_PORTS-1 loop
1703 2 magro732
 
1704 46 magro732
                  if(unsigned(configAdr) = (x"000148" + (x"000020"*portIndex))) then
1705
                    -----------------------------------------------------------------
1706
                    -- Port N Local ackID CSR.
1707
                    -----------------------------------------------------------------
1708
                    if (configWe = '1') then
1709
                      localAckIdWrite_o(portIndex) <= '1';
1710
                      clrOutstandingAckId_o(portIndex) <= configDataWrite(31);
1711
                      inboundAckId_o(portIndex) <= configDataWrite(28 downto 24);
1712
                      outstandingAckId_o(portIndex) <= configDataWrite(12 downto 8);
1713
                      outboundAckId_o(portIndex) <= configDataWrite(4 downto 0);
1714
                    end if;
1715
                    configDataReadInternal(31 downto 29) <= (others => '0');
1716
                    configDataReadInternal(28 downto 24) <= inboundAckId_i(portIndex);
1717
                    configDataReadInternal(23 downto 13) <= (others => '0');
1718
                    configDataReadInternal(12 downto 8) <= outstandingAckId_i(portIndex);
1719
                    configDataReadInternal(7 downto 5) <= (others => '0');
1720
                    configDataReadInternal(4 downto 0) <= outboundAckId_i(portIndex);
1721
 
1722
                  elsif(unsigned(configAdr) = (x"000154" + (x"000020"*portIndex))) then
1723
                    -----------------------------------------------------------------
1724
                    -- Port N Control 2 CSR.
1725
                    -----------------------------------------------------------------
1726
                    configDataReadInternal <= (others => '0');
1727
 
1728
                  elsif(unsigned(configAdr) = (x"000158" + (x"000020"*portIndex))) then
1729
                    -----------------------------------------------------------------
1730
                    -- Port N Error and Status CSR.
1731
                    -----------------------------------------------------------------
1732
                    -- Idle Sequence 2 Support.
1733
                    configDataReadInternal(31) <= '0';
1734
 
1735
                    -- Idle Sequence 2 Enable.
1736
                    configDataReadInternal(30) <= '0';
1737
 
1738
                    -- Idle Sequence.
1739
                    configDataReadInternal(29) <= '0';
1740
 
1741
                    -- Reserved.
1742
                    configDataReadInternal(28) <= '0';
1743
 
1744
                    -- Flow Control Mode.
1745
                    configDataReadInternal(27) <= '0';
1746
 
1747
                    -- Reserved.
1748
                    configDataReadInternal(26 downto 21) <= (others => '0');
1749
 
1750
                    -- Output retry-encountered.
1751
                    configDataReadInternal(20) <= '0';
1752
 
1753
                    -- Output retried.
1754
                    configDataReadInternal(19) <= '0';
1755
 
1756
                    -- Output retried-stopped.
1757
                    configDataReadInternal(18) <= '0';
1758
 
1759
                    -- Output error-encountered.
1760
                    configDataReadInternal(17) <= '0';
1761
 
1762
                    -- Output error-stopped.
1763
                    configDataReadInternal(16) <= '0';
1764
 
1765
                    -- Reserved.
1766
                    configDataReadInternal(15 downto 11) <= (others => '0');
1767
 
1768
                    -- Input retry-stopped.
1769
                    configDataReadInternal(10) <= '0';
1770
 
1771
                    -- Input error-encountered.
1772
                    configDataReadInternal(9) <= '0';
1773
 
1774
                    -- Input error-stopped.
1775
                    configDataReadInternal(8) <= '0';
1776 2 magro732
 
1777 46 magro732
                    -- Reserved.
1778
                    configDataReadInternal(7 downto 5) <= (others => '0');
1779 2 magro732
 
1780 46 magro732
                    -- Port-write pending.
1781
                    configDataReadInternal(4) <= '0';
1782
 
1783
                    -- Port unavailable.
1784
                    configDataReadInternal(3) <= '0';
1785
 
1786
                    -- Port error.
1787
                    configDataReadInternal(2) <= '0';
1788
 
1789
                    -- Port OK.
1790
                    configDataReadInternal(1) <= linkInitialized_i(portIndex);
1791
 
1792
                    -- Port uninitialized.
1793
                    configDataReadInternal(0) <= not linkInitialized_i(portIndex);
1794
 
1795
                  elsif(unsigned(configAdr) = (x"00015c" + (x"000020"*portIndex))) then
1796
                    -----------------------------------------------------------------
1797
                    -- Port N Control CSR.
1798
                    -----------------------------------------------------------------
1799
 
1800
                    -- Port Width Support.
1801
                    configDataReadInternal(31 downto 30) <= (others=>'0');
1802 2 magro732
 
1803 46 magro732
                    -- Initialized Port Width.
1804
                    configDataReadInternal(29 downto 27) <= (others=>'0');
1805 2 magro732
 
1806 46 magro732
                    -- Port Width Override.
1807
                    configDataReadInternal(26 downto 24) <= (others=>'0');
1808 2 magro732
 
1809 46 magro732
                    -- Port disable.
1810
                    configDataReadInternal(23) <= '0';
1811
 
1812
                    -- Output Port Enable.
1813
                    if (configWe = '1') then
1814
                      outputPortEnable(portIndex) <= configDataWrite(22);
1815
                    end if;
1816
                    configDataReadInternal(22) <= outputPortEnable(portIndex);
1817
 
1818
                    -- Input Port Enable.
1819
                    if (configWe = '1') then
1820
                      inputPortEnable(portIndex) <= configDataWrite(21);
1821
                    end if;
1822
                    configDataReadInternal(21) <= inputPortEnable(portIndex);
1823 2 magro732
 
1824 46 magro732
                    -- Error Checking Disabled.
1825
                    configDataReadInternal(20) <= '0';
1826
 
1827
                    -- Multicast-event Participant.
1828
                    configDataReadInternal(19) <= '0';
1829
 
1830
                    -- Reserved.
1831
                    configDataReadInternal(18) <= '0';
1832
 
1833
                    -- Enumeration Boundry.
1834
                    configDataReadInternal(17) <= '0';
1835 2 magro732
 
1836 46 magro732
                    -- Reserved.
1837
                    configDataReadInternal(16) <= '0';
1838 2 magro732
 
1839 46 magro732
                    -- Extended Port Width Override.
1840
                    configDataReadInternal(15 downto 14) <= (others=>'0');
1841 2 magro732
 
1842 46 magro732
                    -- Extended Port Width Support.
1843
                    configDataReadInternal(13 downto 12) <= (others=>'0');
1844
 
1845
                    -- Implementation defined.
1846
                    configDataReadInternal(11 downto 4) <= (others=>'0');
1847 2 magro732
 
1848 46 magro732
                    -- Reserved.
1849
                    configDataReadInternal(3 downto 1) <= (others=>'0');
1850 2 magro732
 
1851 46 magro732
                    -- Port Type.
1852
                    configDataReadInternal(0) <= '1';
1853
                  end if;
1854
                end loop;
1855 2 magro732
 
1856 46 magro732
            end case;
1857
          end if;
1858
        else
1859
          -- Config memory not enabled.
1860 2 magro732
        end if;
1861
      else
1862 47 magro732
        configAckInternal <= '0';
1863 2 magro732
      end if;
1864
    end if;
1865
  end process;
1866
 
1867 46 magro732
  -----------------------------------------------------------------------------
1868
  -- Logic implementing the routing table access.
1869
  -----------------------------------------------------------------------------
1870
 
1871
  -- Lookup interface port memory signals.
1872
  lookupEnable <= '1' when (lookupStb_i = '1') and (lookupAddr_i(15 downto 11) = "00000") else '0';
1873
  lookupAddress <= lookupAddr_i(10 downto 0);
1874
  lookupData_o <= lookupData when (lookupEnable = '1') else routeTablePortDefault;
1875
  lookupAck_o <= lookupAck;
1876
  LookupProcess: process(clk, areset_n)
1877
  begin
1878
    if (areset_n = '0') then
1879
      lookupAck <= '0';
1880
    elsif (clk'event and clk = '1') then
1881
      if ((lookupStb_i = '1') and (lookupAck = '0')) then
1882
        lookupAck <= '1';
1883
      else
1884
        lookupAck <= '0';
1885
      end if;
1886
    end if;
1887
  end process;
1888
 
1889
  -- Dual port memory containing the routing table.
1890
  RoutingTable: MemoryDualPort
1891
    generic map(
1892
      ADDRESS_WIDTH=>11, DATA_WIDTH=>8)
1893
    port map(
1894
      clkA_i=>clk, enableA_i=>routeTableEnable, writeEnableA_i=>routeTableWrite,
1895
      addressA_i=>routeTableAddress,
1896
      dataA_i=>routeTablePortWrite, dataA_o=>routeTablePortRead,
1897
      clkB_i=>clk, enableB_i=>lookupEnable,
1898
      addressB_i=>lookupAddress, dataB_o=>lookupData);
1899
 
1900 2 magro732
end architecture;
1901
 
1902
 
1903
-------------------------------------------------------------------------------
1904
-- 
1905
-------------------------------------------------------------------------------
1906
 
1907
library ieee;
1908
use ieee.std_logic_1164.all;
1909
use ieee.numeric_std.all;
1910
use work.rio_common.all;
1911
 
1912
 
1913
-------------------------------------------------------------------------------
1914
-- 
1915
-------------------------------------------------------------------------------
1916
entity RouteTableInterconnect is
1917
  generic(
1918
    WIDTH : natural range 1 to 256 := 8);
1919
  port(
1920
    clk : in std_logic;
1921
    areset_n : in std_logic;
1922
 
1923
    stb_i : in Array1(WIDTH-1 downto 0);
1924
    addr_i : in Array16(WIDTH-1 downto 0);
1925
    dataM_o : out Array8(WIDTH-1 downto 0);
1926
    ack_o : out Array1(WIDTH-1 downto 0);
1927
 
1928
    stb_o : out std_logic;
1929
    addr_o : out std_logic_vector(15 downto 0);
1930
    dataS_i : in std_logic_vector(7 downto 0);
1931
    ack_i : in std_logic);
1932
end entity;
1933
 
1934
 
1935
-------------------------------------------------------------------------------
1936
-- 
1937
-------------------------------------------------------------------------------
1938
architecture RouteTableInterconnectImpl of RouteTableInterconnect is
1939
  signal activeCycle : std_logic;
1940
  signal selectedMaster : natural range 0 to WIDTH-1;
1941
begin
1942
 
1943
  -----------------------------------------------------------------------------
1944
  -- Arbitration.
1945
  -----------------------------------------------------------------------------
1946
  Arbiter: process(areset_n, clk)
1947
  begin
1948
    if (areset_n = '0') then
1949
      activeCycle <= '0';
1950
      selectedMaster <= 0;
1951
    elsif (clk'event and clk = '1') then
1952
      if (activeCycle = '0') then
1953
        for i in 0 to WIDTH-1 loop
1954
          if (stb_i(i) = '1') then
1955
            activeCycle <= '1';
1956
            selectedMaster <= i;
1957
          end if;
1958
        end loop;
1959
      else
1960
        if (stb_i(selectedMaster) = '0') then
1961
          activeCycle <= '0';
1962
        end if;
1963
      end if;
1964
    end if;
1965
  end process;
1966
 
1967
  -----------------------------------------------------------------------------
1968
  -- Interconnection.
1969
  -----------------------------------------------------------------------------
1970
  stb_o <= stb_i(selectedMaster);
1971
  addr_o <= addr_i(selectedMaster);
1972
 
1973
  Interconnect: for i in 0 to WIDTH-1 generate
1974
    dataM_o(i) <= dataS_i;
1975
    ack_o(i) <= ack_i when (selectedMaster = i) else '0';
1976
  end generate;
1977
 
1978
end architecture;
1979
 
1980
 
1981
-------------------------------------------------------------------------------
1982
-- 
1983
-------------------------------------------------------------------------------
1984
 
1985
library ieee;
1986
use ieee.std_logic_1164.all;
1987
use ieee.numeric_std.all;
1988
use work.rio_common.all;
1989
 
1990
 
1991
-------------------------------------------------------------------------------
1992
-- 
1993
-------------------------------------------------------------------------------
1994
entity SwitchPortInterconnect is
1995
  generic(
1996
    WIDTH : natural range 1 to 256 := 8);
1997
  port(
1998
    clk : in std_logic;
1999
    areset_n : in std_logic;
2000
 
2001
    masterCyc_i : in Array1(WIDTH-1 downto 0);
2002
    masterStb_i : in Array1(WIDTH-1 downto 0);
2003
    masterWe_i : in Array1(WIDTH-1 downto 0);
2004
    masterAddr_i : in Array10(WIDTH-1 downto 0);
2005
    masterData_i : in Array32(WIDTH-1 downto 0);
2006
    masterData_o : out Array1(WIDTH-1 downto 0);
2007
    masterAck_o : out Array1(WIDTH-1 downto 0);
2008
 
2009
    slaveCyc_o : out Array1(WIDTH-1 downto 0);
2010
    slaveStb_o : out Array1(WIDTH-1 downto 0);
2011
    slaveWe_o : out Array1(WIDTH-1 downto 0);
2012
    slaveAddr_o : out Array10(WIDTH-1 downto 0);
2013
    slaveData_o : out Array32(WIDTH-1 downto 0);
2014
    slaveData_i : in Array1(WIDTH-1 downto 0);
2015
    slaveAck_i : in Array1(WIDTH-1 downto 0));
2016
end entity;
2017
 
2018
 
2019
-------------------------------------------------------------------------------
2020
-- 
2021
-------------------------------------------------------------------------------
2022
architecture SwitchPortInterconnectImpl of SwitchPortInterconnect is
2023
  --component ChipscopeIcon1 is
2024
  --  port (
2025
  --    CONTROL0 : inout STD_LOGIC_VECTOR ( 35 downto 0 )
2026
  --    );
2027
  --end component;
2028
  --component ChipscopeIlaWb is
2029
  --  port (
2030
  --    CLK : in STD_LOGIC := 'X';
2031
  --    TRIG0 : in STD_LOGIC_VECTOR ( 46 downto 0);
2032
  --    CONTROL : inout STD_LOGIC_VECTOR ( 35 downto 0 ) 
2033
  --    );
2034
  --end component;
2035
  --signal control : std_logic_vector(35 downto 0);
2036
  --signal trig : std_logic_vector(46 downto 0);
2037
 
2038
  signal activeCycle : std_logic;
2039
  signal selectedMaster : natural range 0 to WIDTH-1;
2040
  signal selectedSlave : natural range 0 to WIDTH-1;
2041
 
2042
begin
2043
 
2044
  -----------------------------------------------------------------------------
2045
  -- Arbitration process.
2046
  -----------------------------------------------------------------------------
2047
 
2048
  RoundRobinArbiter: process(areset_n, clk)
2049
    variable index : natural range 0 to WIDTH-1;
2050
  begin
2051
    if (areset_n = '0') then
2052
      activeCycle <= '0';
2053
      selectedMaster <= 0;
2054
    elsif (clk'event and clk = '1') then
2055
      -- Check if a cycle is ongoing.
2056
      if (activeCycle = '0') then
2057
        -- No ongoing cycles.
2058
 
2059
        -- Iterate through all ports and check if any new cycle has started.
2060
        for i in 0 to WIDTH-1 loop
2061
          if ((selectedMaster+i) >= WIDTH) then
2062
            index := (selectedMaster+i) - WIDTH;
2063
          else
2064
            index := (selectedMaster+i);
2065
          end if;
2066
 
2067
          if (masterCyc_i(index) = '1') then
2068
            activeCycle <= '1';
2069
            selectedMaster <= index;
2070
          end if;
2071
        end loop;
2072
      else
2073
        -- Ongoing cycle.
2074
 
2075
        -- Check if the cycle has ended.
2076
        if (masterCyc_i(selectedMaster) = '0') then
2077
          -- Cycle has ended.
2078
          activeCycle <= '0';
2079
 
2080
          -- Check if a new cycle has started from another master.
2081
          -- Start to check from the one that ended its cycle, this way, the
2082
          -- ports will be scheduled like round-robin.
2083
          for i in 0 to WIDTH-1 loop
2084
            if ((selectedMaster+i) >= WIDTH) then
2085
              index := (selectedMaster+i) - WIDTH;
2086
            else
2087
              index := (selectedMaster+i);
2088
            end if;
2089
 
2090
            if (masterCyc_i(index) = '1') then
2091
              activeCycle <= '1';
2092
              selectedMaster <= index;
2093
            end if;
2094
          end loop;
2095
        end if;
2096
      end if;
2097
    end if;
2098
  end process;
2099
 
2100
  -----------------------------------------------------------------------------
2101
  -- Address decoding.
2102
  -----------------------------------------------------------------------------
2103
 
2104
  -- Select the last port when the top bit is set.
2105
  -- The last port must be the maintenance slave port.
2106
  selectedSlave <= WIDTH-1 when masterAddr_i(selectedMaster)(9) = '1' else
2107
                   to_integer(unsigned(masterAddr_i(selectedMaster)(8 downto 1)));
2108
 
2109
  -----------------------------------------------------------------------------
2110
  -- Interconnection matrix.
2111
  -----------------------------------------------------------------------------
2112
  Interconnect: for i in 0 to WIDTH-1 generate
2113
    slaveCyc_o(i) <= masterCyc_i(selectedMaster) when (selectedSlave = i) else '0';
2114
    slaveStb_o(i) <= masterStb_i(selectedMaster) when (selectedSlave = i) else '0';
2115
    slaveWe_o(i) <= masterWe_i(selectedMaster);
2116
    slaveAddr_o(i) <= masterAddr_i(selectedMaster);
2117
    slaveData_o(i) <= masterData_i(selectedMaster);
2118
    masterData_o(i) <= slaveData_i(selectedSlave);
2119
    masterAck_o(i) <= slaveAck_i(selectedSlave) when (selectedMaster = i) else '0';
2120
  end generate;
2121
 
2122
  -----------------------------------------------------------------------------
2123
  -- Chipscope debugging probe.
2124
  -----------------------------------------------------------------------------
2125
  --trig <= masterCyc_i(selectedMaster) & masterStb_i(selectedMaster) &
2126
  --        masterWe_i(selectedMaster) &  masterAddr_i(selectedMaster) &
2127
  --        masterData_i(selectedMaster) & slaveData_i(selectedSlave) &
2128
  --        slaveAck_i(selectedSlave);
2129
  --ChipscopeIconInst: ChipscopeIcon1
2130
  --  port map(CONTROL0=>control);
2131
  --ChipscopeIlaInst: ChipscopeIlaWb
2132
  --  port map(CLK=>clk, TRIG0=>trig, CONTROL=>control);
2133
 
2134
end architecture;
2135
 
2136
 
2137
 

powered by: WebSVN 2.1.0

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