1 |
6 |
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 a bridge between a RapidIO network and a Wishbone bus. Packets
|
10 |
39 |
magro732 |
-- NWRITE, NWRITER and NREAD are currently supported.
|
11 |
6 |
magro732 |
--
|
12 |
|
|
-- To Do:
|
13 |
47 |
magro732 |
-- - Add support for addressing to implementation defined config space by
|
14 |
|
|
-- adding interface to top entity.
|
15 |
46 |
magro732 |
-- - Add support for the lock_o to be sure to transfer all the packet
|
16 |
|
|
-- content atomically?
|
17 |
|
|
-- - Add support for EXTENDED_ADDRESS.
|
18 |
|
|
-- - Use the baseDeviceId when sending packets? Currently, all responses
|
19 |
|
|
-- are sent with destination<->source exchanged so the baseDeviceId is not
|
20 |
|
|
-- needed.
|
21 |
|
|
-- - Increase the priority of the response-packet when sent?
|
22 |
|
|
-- - Implement error indications if erronous packets are received.
|
23 |
|
|
-- - Implement error indications if err_i is received on the Wishbone bus.
|
24 |
|
|
-- - Add support for extended features to dynamically configure the status
|
25 |
|
|
-- from the port this block is connected to. Needed for the discovered- and
|
26 |
|
|
-- masterEnable-bits.
|
27 |
|
|
-- - Add support for outbound doorbells connected to interrupt input pins.
|
28 |
6 |
magro732 |
--
|
29 |
|
|
-- Author(s):
|
30 |
39 |
magro732 |
-- - Magnus Rosenius, magro732@opencores.org
|
31 |
6 |
magro732 |
--
|
32 |
|
|
-------------------------------------------------------------------------------
|
33 |
|
|
--
|
34 |
|
|
-- Copyright (C) 2013 Authors and OPENCORES.ORG
|
35 |
|
|
--
|
36 |
|
|
-- This source file may be used and distributed without
|
37 |
|
|
-- restriction provided that this copyright statement is not
|
38 |
|
|
-- removed from the file and that any derivative work contains
|
39 |
|
|
-- the original copyright notice and the associated disclaimer.
|
40 |
|
|
--
|
41 |
|
|
-- This source file is free software; you can redistribute it
|
42 |
|
|
-- and/or modify it under the terms of the GNU Lesser General
|
43 |
|
|
-- Public License as published by the Free Software Foundation;
|
44 |
|
|
-- either version 2.1 of the License, or (at your option) any
|
45 |
|
|
-- later version.
|
46 |
|
|
--
|
47 |
|
|
-- This source is distributed in the hope that it will be
|
48 |
|
|
-- useful, but WITHOUT ANY WARRANTY; without even the implied
|
49 |
|
|
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
50 |
|
|
-- PURPOSE. See the GNU Lesser General Public License for more
|
51 |
|
|
-- details.
|
52 |
|
|
--
|
53 |
|
|
-- You should have received a copy of the GNU Lesser General
|
54 |
|
|
-- Public License along with this source; if not, download it
|
55 |
|
|
-- from http://www.opencores.org/lgpl.shtml
|
56 |
|
|
--
|
57 |
|
|
-------------------------------------------------------------------------------
|
58 |
|
|
|
59 |
45 |
magro732 |
|
60 |
39 |
magro732 |
-------------------------------------------------------------------------------
|
61 |
|
|
-- RioWbBridge.
|
62 |
45 |
magro732 |
-- This block acts as an RapidIO endpoint and converts packets into Wishbone
|
63 |
48 |
magro732 |
-- accesses. The bridge is acting as a Wishbone-slave only.
|
64 |
39 |
magro732 |
-------------------------------------------------------------------------------
|
65 |
6 |
magro732 |
library ieee;
|
66 |
|
|
use ieee.std_logic_1164.all;
|
67 |
42 |
magro732 |
use ieee.numeric_std.all;
|
68 |
6 |
magro732 |
use work.rio_common.all;
|
69 |
|
|
|
70 |
|
|
-------------------------------------------------------------------------------
|
71 |
39 |
magro732 |
-- Entity for RioWbBridge.
|
72 |
6 |
magro732 |
-------------------------------------------------------------------------------
|
73 |
39 |
magro732 |
entity RioWbBridge is
|
74 |
6 |
magro732 |
generic(
|
75 |
39 |
magro732 |
EXTENDED_ADDRESS : natural range 0 to 2 := 0;
|
76 |
6 |
magro732 |
DEVICE_IDENTITY : std_logic_vector(15 downto 0);
|
77 |
|
|
DEVICE_VENDOR_IDENTITY : std_logic_vector(15 downto 0);
|
78 |
|
|
DEVICE_REV : std_logic_vector(31 downto 0);
|
79 |
|
|
ASSY_IDENTITY : std_logic_vector(15 downto 0);
|
80 |
|
|
ASSY_VENDOR_IDENTITY : std_logic_vector(15 downto 0);
|
81 |
39 |
magro732 |
ASSY_REV : std_logic_vector(15 downto 0));
|
82 |
6 |
magro732 |
port(
|
83 |
39 |
magro732 |
clk : in std_logic;
|
84 |
|
|
areset_n : in std_logic;
|
85 |
44 |
magro732 |
enable : in std_logic;
|
86 |
6 |
magro732 |
|
87 |
|
|
readFrameEmpty_i : in std_logic;
|
88 |
|
|
readFrame_o : out std_logic;
|
89 |
|
|
readContent_o : out std_logic;
|
90 |
|
|
readContentEnd_i : in std_logic;
|
91 |
|
|
readContentData_i : in std_logic_vector(31 downto 0);
|
92 |
|
|
writeFrameFull_i : in std_logic;
|
93 |
|
|
writeFrame_o : out std_logic;
|
94 |
|
|
writeFrameAbort_o : out std_logic;
|
95 |
|
|
writeContent_o : out std_logic;
|
96 |
|
|
writeContentData_o : out std_logic_vector(31 downto 0);
|
97 |
|
|
|
98 |
39 |
magro732 |
cyc_o : out std_logic;
|
99 |
|
|
stb_o : out std_logic;
|
100 |
|
|
we_o : out std_logic;
|
101 |
|
|
adr_o : out std_logic_vector(16*EXTENDED_ADDRESS+30 downto 0);
|
102 |
|
|
sel_o : out std_logic_vector(7 downto 0);
|
103 |
|
|
dat_o : out std_logic_vector(63 downto 0);
|
104 |
|
|
dat_i : in std_logic_vector(63 downto 0);
|
105 |
|
|
err_i : in std_logic;
|
106 |
|
|
ack_i : in std_logic);
|
107 |
|
|
end entity;
|
108 |
6 |
magro732 |
|
109 |
39 |
magro732 |
|
110 |
6 |
magro732 |
-------------------------------------------------------------------------------
|
111 |
|
|
-- Architecture for RioWbBridge.
|
112 |
|
|
-------------------------------------------------------------------------------
|
113 |
39 |
magro732 |
architecture RioWbBridgeImpl of RioWbBridge is
|
114 |
45 |
magro732 |
constant PORTS : natural := 2;
|
115 |
|
|
|
116 |
44 |
magro732 |
type StateType is (IDLE,
|
117 |
48 |
magro732 |
REQUEST_CLASS, REQUEST_CLASS_WAIT, REQUEST_CLASS_NEXT,
|
118 |
|
|
WRITE_CLASS, WRITE_CLASS_WAIT, WRITE_CLASS_NEXT,
|
119 |
|
|
RESPONSE_DONE_NO_PAYLOAD, RESPONSE_DONE_WITH_PAYLOAD,
|
120 |
|
|
RESPONSE_ERROR, RESPONSE_DONE);
|
121 |
44 |
magro732 |
signal state : StateType;
|
122 |
|
|
|
123 |
|
|
signal adr : std_logic_vector(16*EXTENDED_ADDRESS+30 downto 0);
|
124 |
|
|
|
125 |
|
|
signal requestReady : std_logic;
|
126 |
|
|
signal requestVc : std_logic;
|
127 |
|
|
signal requestCrf : std_logic;
|
128 |
|
|
signal requestPrio : std_logic_vector(1 downto 0);
|
129 |
|
|
signal requestTt : std_logic_vector(1 downto 0);
|
130 |
|
|
signal requestDstId : std_logic_vector(31 downto 0);
|
131 |
|
|
signal requestSrcId : std_logic_vector(31 downto 0);
|
132 |
|
|
signal requestTid : std_logic_vector(7 downto 0);
|
133 |
|
|
signal requestAddress : std_logic_vector(16*EXTENDED_ADDRESS+30 downto 0);
|
134 |
|
|
signal requestLength : std_logic_vector(4 downto 0);
|
135 |
|
|
signal requestSelect : std_logic_vector(7 downto 0);
|
136 |
|
|
signal requestDone : std_logic;
|
137 |
48 |
magro732 |
signal requestStall : std_logic;
|
138 |
44 |
magro732 |
|
139 |
48 |
magro732 |
signal writeNoResponseReady : std_logic;
|
140 |
|
|
signal writeWithResponseReady : std_logic;
|
141 |
44 |
magro732 |
signal writeVc : std_logic;
|
142 |
|
|
signal writeCrf : std_logic;
|
143 |
|
|
signal writePrio : std_logic_vector(1 downto 0);
|
144 |
|
|
signal writeTt : std_logic_vector(1 downto 0);
|
145 |
|
|
signal writeDstId : std_logic_vector(31 downto 0);
|
146 |
|
|
signal writeSrcId : std_logic_vector(31 downto 0);
|
147 |
|
|
signal writeTid : std_logic_vector(7 downto 0);
|
148 |
|
|
signal writeAddress : std_logic_vector(16*EXTENDED_ADDRESS+30 downto 0);
|
149 |
48 |
magro732 |
signal writePayloadLength : std_logic_vector(4 downto 0);
|
150 |
|
|
signal writePayloadIndex : std_logic_vector(4 downto 0);
|
151 |
44 |
magro732 |
signal writeSelect : std_logic_vector(7 downto 0);
|
152 |
|
|
signal writePayload : std_logic_vector(63 downto 0);
|
153 |
|
|
signal writeDone : std_logic;
|
154 |
48 |
magro732 |
signal writeStall : std_logic;
|
155 |
44 |
magro732 |
|
156 |
48 |
magro732 |
signal responseDoneNoPayloadReady : std_logic;
|
157 |
|
|
signal responseDoneWithPayloadReady : std_logic;
|
158 |
|
|
signal responseErrorReady : std_logic;
|
159 |
44 |
magro732 |
signal responseVc : std_logic;
|
160 |
|
|
signal responseCrf : std_logic;
|
161 |
|
|
signal responsePrio : std_logic_vector(1 downto 0);
|
162 |
|
|
signal responseTt : std_logic_vector(1 downto 0);
|
163 |
|
|
signal responseDstId : std_logic_vector(31 downto 0);
|
164 |
|
|
signal responseSrcId : std_logic_vector(31 downto 0);
|
165 |
|
|
signal responseTid : std_logic_vector(7 downto 0);
|
166 |
48 |
magro732 |
signal responsePayloadIndex : std_logic_vector(4 downto 0);
|
167 |
44 |
magro732 |
signal responsePayload : std_logic_vector(63 downto 0);
|
168 |
|
|
signal responseDone : std_logic;
|
169 |
|
|
|
170 |
48 |
magro732 |
signal maintReadRequestReady : std_logic;
|
171 |
|
|
signal maintWriteRequestReady : std_logic;
|
172 |
|
|
signal maintVcInbound : std_logic;
|
173 |
|
|
signal maintCrfInbound : std_logic;
|
174 |
|
|
signal maintPrioInbound : std_logic_vector(1 downto 0);
|
175 |
|
|
signal maintTtInbound : std_logic_vector(1 downto 0);
|
176 |
|
|
signal maintDstIdInbound : std_logic_vector(31 downto 0);
|
177 |
|
|
signal maintSrcIdInbound : std_logic_vector(31 downto 0);
|
178 |
|
|
signal maintSizeInbound : std_logic_vector(3 downto 0);
|
179 |
|
|
signal maintTidInbound : std_logic_vector(7 downto 0);
|
180 |
|
|
signal maintOffsetInbound : std_logic_vector(20 downto 0);
|
181 |
|
|
signal maintWdptrInbound : std_logic;
|
182 |
|
|
signal maintPayloadLengthInbound : std_logic_vector(2 downto 0);
|
183 |
|
|
signal maintPayloadIndexInbound : std_logic_vector(2 downto 0);
|
184 |
|
|
signal maintPayloadInbound : std_logic_vector(63 downto 0);
|
185 |
|
|
signal maintDoneInbound : std_logic;
|
186 |
|
|
signal maintStall : std_logic;
|
187 |
46 |
magro732 |
|
188 |
48 |
magro732 |
signal maintReadResponseReady : std_logic;
|
189 |
|
|
signal maintWriteResponseReady : std_logic;
|
190 |
|
|
signal maintStatusOutbound : std_logic_vector(3 downto 0);
|
191 |
|
|
signal maintPayloadLengthOutbound : std_logic_vector(2 downto 0);
|
192 |
|
|
signal maintPayloadIndexOutbound : std_logic_vector(2 downto 0);
|
193 |
|
|
signal maintPayloadOutbound : std_logic_vector(63 downto 0);
|
194 |
|
|
signal maintDoneOutbound : std_logic;
|
195 |
46 |
magro732 |
|
196 |
45 |
magro732 |
signal configStb : std_logic;
|
197 |
|
|
signal configWe : std_logic;
|
198 |
|
|
signal configAdr : std_logic_vector(21 downto 0);
|
199 |
|
|
signal configAdrByte : std_logic_vector(23 downto 0);
|
200 |
|
|
signal configDatWrite : std_logic_vector(31 downto 0);
|
201 |
|
|
signal configDatRead : std_logic_vector(31 downto 0);
|
202 |
|
|
signal configAck : std_logic;
|
203 |
|
|
|
204 |
44 |
magro732 |
signal inboundStb : std_logic;
|
205 |
48 |
magro732 |
signal inboundAdr : std_logic_vector(3 downto 0);
|
206 |
44 |
magro732 |
signal inboundDat : std_logic_vector(31 downto 0);
|
207 |
48 |
magro732 |
signal inboundStall : std_logic;
|
208 |
44 |
magro732 |
|
209 |
45 |
magro732 |
signal outboundStb : std_logic_vector(PORTS-1 downto 0);
|
210 |
48 |
magro732 |
signal outboundAdr : std_logic_vector(PORTS-1 downto 0);
|
211 |
45 |
magro732 |
signal outboundDat : std_logic_vector(32*PORTS-1 downto 0);
|
212 |
48 |
magro732 |
signal outboundStall : std_logic_vector(PORTS-1 downto 0);
|
213 |
39 |
magro732 |
|
214 |
48 |
magro732 |
signal memoryWrite : std_logic;
|
215 |
|
|
signal memoryAddress : std_logic_vector(4 downto 0);
|
216 |
|
|
signal memoryDataIn : std_logic_vector(63 downto 0);
|
217 |
|
|
|
218 |
39 |
magro732 |
begin
|
219 |
|
|
|
220 |
48 |
magro732 |
responseVc <= requestVc when (requestReady = '1') else writeVc;
|
221 |
|
|
responseCrf <= requestCrf when (requestReady = '1') else writeCrf;
|
222 |
|
|
responsePrio <= requestPrio when (requestReady = '1') else writePrio;
|
223 |
|
|
responseTt <= requestTt when (requestReady = '1') else writeTt;
|
224 |
|
|
responseDstId <= requestSrcId when (requestReady = '1') else writeSrcId;
|
225 |
|
|
responseSrcId <= requestDstId when (requestReady = '1') else writeDstId;
|
226 |
|
|
responseTid <= requestTid when (requestReady = '1') else writeTid;
|
227 |
44 |
magro732 |
|
228 |
6 |
magro732 |
-----------------------------------------------------------------------------
|
229 |
39 |
magro732 |
--
|
230 |
6 |
magro732 |
-----------------------------------------------------------------------------
|
231 |
39 |
magro732 |
adr_o <= adr;
|
232 |
|
|
|
233 |
|
|
Bridge: process(clk, areset_n)
|
234 |
6 |
magro732 |
begin
|
235 |
39 |
magro732 |
if (areset_n = '0') then
|
236 |
|
|
cyc_o <= '0';
|
237 |
|
|
stb_o <= '0';
|
238 |
|
|
we_o <= '0';
|
239 |
|
|
adr <= (others=>'0');
|
240 |
48 |
magro732 |
dat_o <= (others=>'0');
|
241 |
6 |
magro732 |
|
242 |
48 |
magro732 |
writePayloadIndex <= (others=>'0');
|
243 |
44 |
magro732 |
|
244 |
39 |
magro732 |
requestDone <= '0';
|
245 |
44 |
magro732 |
writeDone <= '0';
|
246 |
|
|
|
247 |
48 |
magro732 |
responseDoneNoPayloadReady <= '0';
|
248 |
|
|
responseDoneWithPayloadReady <= '0';
|
249 |
|
|
responseErrorReady <= '0';
|
250 |
|
|
|
251 |
|
|
memoryWrite <= '0';
|
252 |
|
|
memoryAddress <= (others=>'0');
|
253 |
|
|
memoryDataIn <= (others=>'0');
|
254 |
39 |
magro732 |
elsif (clk'event and clk = '1') then
|
255 |
44 |
magro732 |
if (enable = '1') then
|
256 |
|
|
case state is
|
257 |
|
|
when IDLE =>
|
258 |
|
|
---------------------------------------------------------------------
|
259 |
|
|
--
|
260 |
|
|
---------------------------------------------------------------------
|
261 |
48 |
magro732 |
requestDone <= '0';
|
262 |
|
|
writeDone <= '0';
|
263 |
|
|
responseDoneNoPayloadReady <= '0';
|
264 |
|
|
responseDoneWithPayloadReady <= '0';
|
265 |
|
|
responseErrorReady <= '0';
|
266 |
|
|
|
267 |
|
|
writePayloadIndex <= (others=>'0');
|
268 |
|
|
|
269 |
44 |
magro732 |
if (requestReady = '1') then
|
270 |
|
|
state <= REQUEST_CLASS;
|
271 |
48 |
magro732 |
elsif (writeNoResponseReady = '1') or (writeWithResponseReady = '1') then
|
272 |
44 |
magro732 |
state <= WRITE_CLASS;
|
273 |
|
|
end if;
|
274 |
39 |
magro732 |
|
275 |
44 |
magro732 |
when REQUEST_CLASS =>
|
276 |
|
|
---------------------------------------------------------------------
|
277 |
|
|
--
|
278 |
|
|
---------------------------------------------------------------------
|
279 |
48 |
magro732 |
cyc_o <= '1';
|
280 |
|
|
stb_o <= '1';
|
281 |
|
|
we_o <= '0';
|
282 |
|
|
adr <= requestAddress;
|
283 |
|
|
sel_o <= requestSelect;
|
284 |
|
|
|
285 |
|
|
memoryAddress <= writePayloadIndex;
|
286 |
|
|
writePayloadIndex <= std_logic_vector(unsigned(writePayloadIndex) + 1);
|
287 |
|
|
|
288 |
|
|
state <= REQUEST_CLASS_WAIT;
|
289 |
|
|
|
290 |
|
|
when REQUEST_CLASS_WAIT =>
|
291 |
|
|
---------------------------------------------------------------------
|
292 |
|
|
--
|
293 |
|
|
---------------------------------------------------------------------
|
294 |
44 |
magro732 |
if (ack_i = '1') then
|
295 |
48 |
magro732 |
if (writePayloadIndex = requestLength) then
|
296 |
44 |
magro732 |
cyc_o <= '0';
|
297 |
|
|
end if;
|
298 |
48 |
magro732 |
stb_o <= '0';
|
299 |
|
|
|
300 |
|
|
memoryWrite <= '1';
|
301 |
|
|
memoryDataIn <= dat_i;
|
302 |
|
|
|
303 |
|
|
state <= REQUEST_CLASS_NEXT;
|
304 |
|
|
elsif (err_i = '1') then
|
305 |
|
|
cyc_o <= '0';
|
306 |
|
|
stb_o <= '0';
|
307 |
|
|
state <= RESPONSE_ERROR;
|
308 |
44 |
magro732 |
end if;
|
309 |
39 |
magro732 |
|
310 |
48 |
magro732 |
when REQUEST_CLASS_NEXT =>
|
311 |
44 |
magro732 |
---------------------------------------------------------------------
|
312 |
|
|
--
|
313 |
|
|
---------------------------------------------------------------------
|
314 |
48 |
magro732 |
memoryWrite <= '0';
|
315 |
|
|
memoryAddress <= writePayloadIndex;
|
316 |
|
|
writePayloadIndex <= std_logic_vector(unsigned(writePayloadIndex) + 1);
|
317 |
|
|
|
318 |
|
|
adr <= std_logic_vector(unsigned(adr) + 1);
|
319 |
|
|
|
320 |
|
|
if (writePayloadIndex = requestLength) then
|
321 |
|
|
state <= RESPONSE_DONE_WITH_PAYLOAD;
|
322 |
44 |
magro732 |
else
|
323 |
48 |
magro732 |
stb_o <= '1';
|
324 |
|
|
state <= REQUEST_CLASS_WAIT;
|
325 |
44 |
magro732 |
end if;
|
326 |
6 |
magro732 |
|
327 |
44 |
magro732 |
when WRITE_CLASS =>
|
328 |
|
|
---------------------------------------------------------------------
|
329 |
|
|
--
|
330 |
|
|
---------------------------------------------------------------------
|
331 |
45 |
magro732 |
cyc_o <= '1';
|
332 |
|
|
stb_o <= '1';
|
333 |
|
|
we_o <= '1';
|
334 |
48 |
magro732 |
adr <= writeAddress;
|
335 |
45 |
magro732 |
sel_o <= writeSelect;
|
336 |
48 |
magro732 |
dat_o <= writePayload;
|
337 |
45 |
magro732 |
|
338 |
48 |
magro732 |
writePayloadIndex <= std_logic_vector(unsigned(writePayloadIndex) + 1);
|
339 |
|
|
|
340 |
|
|
state <= WRITE_CLASS_WAIT;
|
341 |
45 |
magro732 |
|
342 |
48 |
magro732 |
when WRITE_CLASS_WAIT =>
|
343 |
45 |
magro732 |
---------------------------------------------------------------------
|
344 |
|
|
--
|
345 |
|
|
---------------------------------------------------------------------
|
346 |
44 |
magro732 |
if (ack_i = '1') then
|
347 |
48 |
magro732 |
if (writePayloadIndex = writePayloadLength) then
|
348 |
|
|
cyc_o <= '0';
|
349 |
|
|
end if;
|
350 |
|
|
stb_o <= '0';
|
351 |
44 |
magro732 |
|
352 |
48 |
magro732 |
state <= WRITE_CLASS_NEXT;
|
353 |
|
|
elsif (err_i = '1') then
|
354 |
|
|
writeDone <= '1';
|
355 |
|
|
cyc_o <= '0';
|
356 |
|
|
stb_o <= '0';
|
357 |
|
|
state <= RESPONSE_ERROR;
|
358 |
|
|
end if;
|
359 |
|
|
|
360 |
|
|
when WRITE_CLASS_NEXT =>
|
361 |
|
|
---------------------------------------------------------------------
|
362 |
|
|
--
|
363 |
|
|
---------------------------------------------------------------------
|
364 |
|
|
adr <= std_logic_vector(unsigned(adr) + 1);
|
365 |
|
|
dat_o <= writePayload;
|
366 |
|
|
|
367 |
|
|
writePayloadIndex <= std_logic_vector(unsigned(writePayloadIndex) + 1);
|
368 |
|
|
if (writePayloadIndex = writePayloadLength) then
|
369 |
|
|
if (writeWithResponseReady = '1') then
|
370 |
|
|
state <= RESPONSE_DONE_NO_PAYLOAD;
|
371 |
44 |
magro732 |
else
|
372 |
|
|
writeDone <= '1';
|
373 |
48 |
magro732 |
state <= RESPONSE_DONE;
|
374 |
44 |
magro732 |
end if;
|
375 |
48 |
magro732 |
else
|
376 |
|
|
stb_o <= '1';
|
377 |
|
|
state <= WRITE_CLASS_WAIT;
|
378 |
|
|
end if;
|
379 |
|
|
|
380 |
|
|
when RESPONSE_DONE_NO_PAYLOAD =>
|
381 |
|
|
---------------------------------------------------------------------
|
382 |
|
|
--
|
383 |
|
|
---------------------------------------------------------------------
|
384 |
|
|
if (responseDone = '1') then
|
385 |
|
|
writeDone <= '1';
|
386 |
|
|
responseDoneNoPayloadReady <= '0';
|
387 |
|
|
state <= RESPONSE_DONE;
|
388 |
|
|
else
|
389 |
|
|
responseDoneNoPayloadReady <= '1';
|
390 |
44 |
magro732 |
end if;
|
391 |
|
|
|
392 |
48 |
magro732 |
when RESPONSE_DONE_WITH_PAYLOAD =>
|
393 |
44 |
magro732 |
---------------------------------------------------------------------
|
394 |
|
|
--
|
395 |
|
|
---------------------------------------------------------------------
|
396 |
48 |
magro732 |
if (responseDone = '1') then
|
397 |
|
|
requestDone <= '1';
|
398 |
|
|
responseDoneWithPayloadReady <= '0';
|
399 |
|
|
state <= RESPONSE_DONE;
|
400 |
39 |
magro732 |
else
|
401 |
48 |
magro732 |
responseDoneWithPayloadReady <= '1';
|
402 |
39 |
magro732 |
end if;
|
403 |
6 |
magro732 |
|
404 |
48 |
magro732 |
when RESPONSE_ERROR =>
|
405 |
|
|
---------------------------------------------------------------------
|
406 |
|
|
--
|
407 |
|
|
---------------------------------------------------------------------
|
408 |
|
|
-- REMARK: Must indicate that the previous frame is done also.
|
409 |
|
|
if (responseDone = '1') then
|
410 |
|
|
responseErrorReady <= '0';
|
411 |
|
|
state <= RESPONSE_DONE;
|
412 |
|
|
else
|
413 |
|
|
responseErrorReady <= '1';
|
414 |
|
|
end if;
|
415 |
|
|
|
416 |
|
|
when RESPONSE_DONE =>
|
417 |
|
|
-------------------------------------------------------------------
|
418 |
|
|
--
|
419 |
|
|
-------------------------------------------------------------------
|
420 |
|
|
state <= IDLE;
|
421 |
|
|
|
422 |
44 |
magro732 |
when others =>
|
423 |
6 |
magro732 |
|
424 |
44 |
magro732 |
end case;
|
425 |
|
|
end if;
|
426 |
39 |
magro732 |
end if;
|
427 |
|
|
end process;
|
428 |
|
|
|
429 |
48 |
magro732 |
PayloadMemory: MemorySimpleDualPort
|
430 |
|
|
generic map(ADDRESS_WIDTH=>5, DATA_WIDTH=>64)
|
431 |
|
|
port map(clkA_i=>clk,
|
432 |
|
|
enableA_i=>memoryWrite,
|
433 |
|
|
addressA_i=>memoryAddress,
|
434 |
|
|
dataA_i=>memoryDataIn,
|
435 |
|
|
clkB_i=>clk,
|
436 |
|
|
enableB_i=>responseDoneWithPayloadReady,
|
437 |
|
|
addressB_i=>responsePayloadIndex,
|
438 |
|
|
dataB_o=>responsePayload);
|
439 |
|
|
|
440 |
39 |
magro732 |
-----------------------------------------------------------------------------
|
441 |
48 |
magro732 |
-- Inbound packet processing.
|
442 |
39 |
magro732 |
-----------------------------------------------------------------------------
|
443 |
6 |
magro732 |
|
444 |
48 |
magro732 |
InboundMaintenance: MaintenanceInbound
|
445 |
|
|
generic map(
|
446 |
|
|
ENABLE_READ_RESPONSE=>false,
|
447 |
|
|
ENABLE_WRITE_RESPONSE=>false,
|
448 |
|
|
ENABLE_PORT_WRITE=>false)
|
449 |
|
|
port map(
|
450 |
|
|
clk=>clk, areset_n=>areset_n, enable=>enable,
|
451 |
|
|
readRequestReady_o=>maintReadRequestReady,
|
452 |
|
|
writeRequestReady_o=>maintWriteRequestReady,
|
453 |
|
|
readResponseReady_o=>open,
|
454 |
|
|
writeResponseReady_o=>open,
|
455 |
|
|
portWriteReady_o=>open,
|
456 |
|
|
vc_o=>maintVcInbound,
|
457 |
|
|
crf_o=>maintCrfInbound,
|
458 |
|
|
prio_o=>maintPrioInbound,
|
459 |
|
|
tt_o=>maintTtInbound,
|
460 |
|
|
dstid_o=>maintDstIdInbound,
|
461 |
|
|
srcid_o=>maintSrcIdInbound,
|
462 |
|
|
size_o=>maintSizeInbound,
|
463 |
|
|
status_o=>open,
|
464 |
|
|
tid_o=>maintTidInbound,
|
465 |
|
|
hop_o=>open,
|
466 |
|
|
offset_o=>maintOffsetInbound,
|
467 |
|
|
wdptr_o=>maintWdptrInbound,
|
468 |
|
|
payloadLength_o=>maintPayloadLengthInbound,
|
469 |
|
|
payloadIndex_i=>maintPayloadIndexInbound,
|
470 |
|
|
payload_o=>maintPayloadInbound,
|
471 |
|
|
done_i=>maintDoneInbound,
|
472 |
|
|
inboundStb_i=>inboundStb,
|
473 |
|
|
inboundAdr_i=>inboundAdr,
|
474 |
|
|
inboundDat_i=>inboundDat,
|
475 |
|
|
inboundStall_o=>maintStall);
|
476 |
|
|
|
477 |
39 |
magro732 |
RequestClassInboundInst: RequestClassInbound
|
478 |
|
|
generic map(
|
479 |
|
|
EXTENDED_ADDRESS=>EXTENDED_ADDRESS)
|
480 |
|
|
port map(
|
481 |
|
|
clk=>clk,
|
482 |
|
|
areset_n=>areset_n,
|
483 |
|
|
enable=>enable,
|
484 |
48 |
magro732 |
nreadReady_o=>requestReady,
|
485 |
39 |
magro732 |
vc_o=>requestVc,
|
486 |
|
|
crf_o=>requestCrf,
|
487 |
|
|
prio_o=>requestPrio,
|
488 |
|
|
tt_o=>requestTt,
|
489 |
|
|
dstId_o=>requestDstId,
|
490 |
|
|
srcId_o=>requestSrcId,
|
491 |
|
|
tid_o=>requestTid,
|
492 |
|
|
address_o=>requestAddress,
|
493 |
44 |
magro732 |
length_o=>requestLength,
|
494 |
39 |
magro732 |
select_o=>requestSelect,
|
495 |
|
|
done_i=>requestDone,
|
496 |
45 |
magro732 |
inboundStb_i=>inboundStb,
|
497 |
|
|
inboundAdr_i=>inboundAdr,
|
498 |
|
|
inboundDat_i=>inboundDat,
|
499 |
48 |
magro732 |
inboundStall_o=>requestStall);
|
500 |
6 |
magro732 |
|
501 |
39 |
magro732 |
WriteClassInboundInst: WriteClassInbound
|
502 |
|
|
generic map(
|
503 |
|
|
EXTENDED_ADDRESS=>EXTENDED_ADDRESS)
|
504 |
|
|
port map(
|
505 |
|
|
clk=>clk,
|
506 |
|
|
areset_n=>areset_n,
|
507 |
|
|
enable=>enable,
|
508 |
48 |
magro732 |
nwriteReady_o=>writeNoResponseReady,
|
509 |
|
|
nwriterReady_o=>writeWithResponseReady,
|
510 |
39 |
magro732 |
vc_o=>writeVc,
|
511 |
|
|
crf_o=>writeCrf,
|
512 |
|
|
prio_o=>writePrio,
|
513 |
|
|
tt_o=>writeTt,
|
514 |
|
|
dstId_o=>writeDstId,
|
515 |
|
|
srcId_o=>writeSrcId,
|
516 |
|
|
tid_o=>writeTid,
|
517 |
|
|
address_o=>writeAddress,
|
518 |
48 |
magro732 |
length_o=>writePayloadLength,
|
519 |
39 |
magro732 |
select_o=>writeSelect,
|
520 |
48 |
magro732 |
payloadIndex_i=>writePayloadIndex,
|
521 |
39 |
magro732 |
payload_o=>writePayload,
|
522 |
|
|
done_i=>writeDone,
|
523 |
45 |
magro732 |
inboundStb_i=>inboundStb,
|
524 |
|
|
inboundAdr_i=>inboundAdr,
|
525 |
|
|
inboundDat_i=>inboundDat,
|
526 |
48 |
magro732 |
inboundStall_o=>writeStall);
|
527 |
6 |
magro732 |
|
528 |
48 |
magro732 |
-----------------------------------------------------------------------------
|
529 |
|
|
-- Outbound packet processing.
|
530 |
|
|
-----------------------------------------------------------------------------
|
531 |
|
|
OutboundMaintenance: MaintenanceOutbound
|
532 |
|
|
port map(
|
533 |
|
|
clk=>clk, areset_n=>areset_n, enable=>enable,
|
534 |
|
|
readRequestReady_i=>'0',
|
535 |
|
|
writeRequestReady_i=>'0',
|
536 |
|
|
readResponseReady_i=>maintReadResponseReady,
|
537 |
|
|
writeResponseReady_i=>maintWriteResponseReady,
|
538 |
|
|
portWriteReady_i=>'0',
|
539 |
|
|
vc_i=>maintVcInbound,
|
540 |
|
|
crf_i=>maintCrfInbound,
|
541 |
|
|
prio_i=>maintPrioInbound,
|
542 |
|
|
tt_i=>maintTtInbound,
|
543 |
|
|
dstid_i=>maintSrcIdInbound,
|
544 |
|
|
srcid_i=>maintDstIdInbound,
|
545 |
|
|
size_i=>(others=>'0'),
|
546 |
|
|
status_i=>maintStatusOutbound,
|
547 |
|
|
tid_i=>maintTidInbound,
|
548 |
|
|
hop_i=>x"ff",
|
549 |
|
|
offset_i=>(others=>'0'),
|
550 |
|
|
wdptr_i=>'0',
|
551 |
|
|
payloadLength_i=>maintPayloadLengthOutbound,
|
552 |
|
|
payloadIndex_o=>maintPayloadIndexOutbound,
|
553 |
|
|
payload_i=>maintPayloadOutbound,
|
554 |
|
|
done_o=>maintDoneOutbound,
|
555 |
|
|
outboundStb_o=>outboundStb(1),
|
556 |
|
|
outboundAdr_o=>outboundAdr(1),
|
557 |
|
|
outboundDat_o=>outboundDat(63 downto 32),
|
558 |
|
|
outboundStall_i=>outboundStall(1));
|
559 |
|
|
|
560 |
39 |
magro732 |
ResponseClassOutboundInst: ResponseClassOutbound
|
561 |
|
|
port map(
|
562 |
|
|
clk=>clk,
|
563 |
|
|
areset_n=>areset_n,
|
564 |
|
|
enable=>enable,
|
565 |
48 |
magro732 |
doneNoPayloadReady_i=>responseDoneNoPayloadReady,
|
566 |
|
|
doneWithPayloadReady_i=>responseDoneWithPayloadReady,
|
567 |
|
|
errorReady_i=>responseErrorReady,
|
568 |
44 |
magro732 |
vc_i=>responseVc,
|
569 |
|
|
crf_i=>responseCrf,
|
570 |
|
|
prio_i=>responsePrio,
|
571 |
|
|
tt_i=>responseTt,
|
572 |
|
|
dstid_i=>responseDstId,
|
573 |
|
|
srcid_i=>responseSrcId,
|
574 |
|
|
tid_i=>responseTid,
|
575 |
|
|
payloadLength_i=>requestLength,
|
576 |
48 |
magro732 |
payloadIndex_o=>responsePayloadIndex,
|
577 |
39 |
magro732 |
payload_i=>responsePayload,
|
578 |
|
|
done_o=>responseDone,
|
579 |
45 |
magro732 |
outboundStb_o=>outboundStb(0),
|
580 |
48 |
magro732 |
outboundAdr_o=>outboundAdr(0),
|
581 |
45 |
magro732 |
outboundDat_o=>outboundDat(31 downto 0),
|
582 |
48 |
magro732 |
outboundStall_i=>outboundStall(0));
|
583 |
44 |
magro732 |
|
584 |
46 |
magro732 |
-----------------------------------------------------------------------------
|
585 |
45 |
magro732 |
-- Common interface toward the packet queues.
|
586 |
|
|
-----------------------------------------------------------------------------
|
587 |
|
|
|
588 |
48 |
magro732 |
inboundStall <= requestStall or writeStall or maintStall;
|
589 |
39 |
magro732 |
RioLogicalCommonInst: RioLogicalCommon
|
590 |
45 |
magro732 |
generic map(PORTS=>PORTS)
|
591 |
39 |
magro732 |
port map(
|
592 |
|
|
clk=>clk,
|
593 |
|
|
areset_n=>areset_n,
|
594 |
|
|
enable=>enable,
|
595 |
|
|
readFrameEmpty_i=>readFrameEmpty_i,
|
596 |
|
|
readFrame_o=>readFrame_o,
|
597 |
|
|
readContent_o=>readContent_o,
|
598 |
|
|
readContentEnd_i=>readContentEnd_i,
|
599 |
|
|
readContentData_i=>readContentData_i,
|
600 |
|
|
writeFrameFull_i=>writeFrameFull_i,
|
601 |
|
|
writeFrame_o=>writeFrame_o,
|
602 |
|
|
writeFrameAbort_o=>writeFrameAbort_o,
|
603 |
|
|
writeContent_o=>writeContent_o,
|
604 |
|
|
writeContentData_o=>writeContentData_o,
|
605 |
45 |
magro732 |
inboundStb_o=>inboundStb,
|
606 |
|
|
inboundAdr_o=>inboundAdr,
|
607 |
|
|
inboundDat_o=>inboundDat,
|
608 |
48 |
magro732 |
inboundStall_i=>inboundStall,
|
609 |
45 |
magro732 |
outboundStb_i=>outboundStb,
|
610 |
48 |
magro732 |
outboundAdr_i=>outboundAdr,
|
611 |
45 |
magro732 |
outboundDat_i=>outboundDat,
|
612 |
48 |
magro732 |
outboundStall_o=>outboundStall);
|
613 |
6 |
magro732 |
|
614 |
39 |
magro732 |
-----------------------------------------------------------------------------
|
615 |
|
|
-- Configuration memory.
|
616 |
|
|
-----------------------------------------------------------------------------
|
617 |
48 |
magro732 |
MaintenanceBridge: RioLogicalMaintenance
|
618 |
|
|
port map(
|
619 |
|
|
clk=>clk, areset_n=>areset_n, enable=>enable,
|
620 |
|
|
readRequestReady_i=>maintReadRequestReady,
|
621 |
|
|
writeRequestReady_i=>maintWriteRequestReady,
|
622 |
|
|
size_i=>maintSizeInbound,
|
623 |
|
|
offset_i=>maintOffsetInbound,
|
624 |
|
|
wdptr_i=>maintWdptrInbound,
|
625 |
|
|
payloadLength_i=>maintPayloadLengthInbound,
|
626 |
|
|
payloadIndex_o=>maintPayloadIndexInbound,
|
627 |
|
|
payload_i=>maintPayloadInbound,
|
628 |
|
|
done_o=>maintDoneInbound,
|
629 |
|
|
readResponseReady_o=>maintReadResponseReady,
|
630 |
|
|
writeResponseReady_o=>maintWriteResponseReady,
|
631 |
|
|
status_o=>maintStatusOutbound,
|
632 |
|
|
payloadLength_o=>maintPayloadLengthOutbound,
|
633 |
|
|
payloadIndex_i=>maintPayloadIndexOutbound,
|
634 |
|
|
payload_o=>maintPayloadOutbound,
|
635 |
|
|
done_i=>maintDoneOutbound,
|
636 |
|
|
configStb_o=>configStb,
|
637 |
|
|
configWe_o=>configWe,
|
638 |
|
|
configAdr_o=>configAdr,
|
639 |
|
|
configDat_o=>configDatWrite,
|
640 |
|
|
configDat_i=>configDatRead,
|
641 |
|
|
configAck_i=>configAck);
|
642 |
|
|
|
643 |
45 |
magro732 |
configAdrByte <= configAdr & "00";
|
644 |
48 |
magro732 |
|
645 |
45 |
magro732 |
memoryConfig : process(clk, areset_n)
|
646 |
|
|
variable componentTag : std_logic_vector(31 downto 0);
|
647 |
|
|
variable hostBaseDeviceIdLocked : std_logic;
|
648 |
|
|
variable hostBaseDeviceId : std_logic_vector(15 downto 0);
|
649 |
|
|
begin
|
650 |
|
|
if (areset_n = '0') then
|
651 |
|
|
componentTag := (others => '0');
|
652 |
|
|
hostBaseDeviceIdLocked := '0';
|
653 |
|
|
hostBaseDeviceId := (others => '1');
|
654 |
6 |
magro732 |
|
655 |
45 |
magro732 |
configDatRead <= (others => '0');
|
656 |
|
|
configAck <= '0';
|
657 |
|
|
elsif (clk'event and clk = '1') then
|
658 |
|
|
if (configAck = '0') then
|
659 |
|
|
if (configStb = '1') then
|
660 |
|
|
configAck <= '1';
|
661 |
|
|
configDatRead <= (others=>'0');
|
662 |
|
|
|
663 |
|
|
-- Check the address the access is for.
|
664 |
|
|
case (configAdrByte) is
|
665 |
|
|
when x"000000" =>
|
666 |
|
|
-----------------------------------------------------------------
|
667 |
|
|
-- Device Identity CAR. Read-only.
|
668 |
|
|
-----------------------------------------------------------------
|
669 |
|
|
configDatRead(31 downto 16) <= DEVICE_IDENTITY;
|
670 |
|
|
configDatRead(15 downto 0) <= DEVICE_VENDOR_IDENTITY;
|
671 |
|
|
|
672 |
|
|
when x"000004" =>
|
673 |
|
|
-----------------------------------------------------------------
|
674 |
|
|
-- Device Information CAR. Read-only.
|
675 |
|
|
-----------------------------------------------------------------
|
676 |
|
|
configDatRead(31 downto 0) <= DEVICE_REV;
|
677 |
|
|
|
678 |
|
|
when x"000008" =>
|
679 |
|
|
-----------------------------------------------------------------
|
680 |
|
|
-- Assembly Identity CAR. Read-only.
|
681 |
|
|
-----------------------------------------------------------------
|
682 |
|
|
configDatRead(31 downto 16) <= ASSY_IDENTITY;
|
683 |
|
|
configDatRead(15 downto 0) <= ASSY_VENDOR_IDENTITY;
|
684 |
|
|
|
685 |
|
|
when x"00000c" =>
|
686 |
|
|
-----------------------------------------------------------------
|
687 |
|
|
-- Assembly Information CAR. Read-only.
|
688 |
|
|
-----------------------------------------------------------------
|
689 |
|
|
configDatRead(31 downto 16) <= ASSY_REV;
|
690 |
|
|
|
691 |
|
|
when x"000010" =>
|
692 |
|
|
-----------------------------------------------------------------
|
693 |
|
|
-- Processing Element Features CAR. Read-only.
|
694 |
|
|
-----------------------------------------------------------------
|
695 |
|
|
-- Bridge.
|
696 |
|
|
configDatRead(31) <= '1';
|
697 |
|
|
-- Extended addressing support, 34-bit addresses.
|
698 |
|
|
configDatRead(2 downto 0) <= "001";
|
699 |
|
|
|
700 |
|
|
when x"000018" =>
|
701 |
|
|
-----------------------------------------------------------------
|
702 |
|
|
-- Source Operations CAR. Read-only.
|
703 |
|
|
-----------------------------------------------------------------
|
704 |
|
|
-- Cannot act as a source of any packets.
|
705 |
|
|
|
706 |
|
|
when x"00001c" =>
|
707 |
|
|
-----------------------------------------------------------------
|
708 |
|
|
-- Destination Operations CAR. Read-only.
|
709 |
|
|
-----------------------------------------------------------------
|
710 |
|
|
-- Read, supported.
|
711 |
|
|
configDatRead(15) <= '1';
|
712 |
|
|
-- Write, supported.
|
713 |
|
|
configDatRead(14) <= '1';
|
714 |
|
|
-- Write-with-response, supported.
|
715 |
|
|
configDatRead(12) <= '1';
|
716 |
|
|
|
717 |
|
|
when x"00004c" =>
|
718 |
|
|
-----------------------------------------------------------------
|
719 |
|
|
-- Processing Element Logical Layer Control CSR.
|
720 |
|
|
-----------------------------------------------------------------
|
721 |
|
|
-- Extended addressing control, PE supports 34 bits addresses.
|
722 |
|
|
configDatRead(2 downto 0) <= "001";
|
723 |
6 |
magro732 |
|
724 |
45 |
magro732 |
when x"000060" =>
|
725 |
|
|
-----------------------------------------------------------------
|
726 |
|
|
-- Base Device ID CSR.
|
727 |
|
|
-----------------------------------------------------------------
|
728 |
|
|
-- This is not used since this endpoint only replies to packets
|
729 |
|
|
-- and it can then use the destination deviceId as a source.
|
730 |
|
|
|
731 |
|
|
when x"000068" =>
|
732 |
|
|
-----------------------------------------------------------------
|
733 |
|
|
-- Host Base Device ID Lock CSR.
|
734 |
|
|
-----------------------------------------------------------------
|
735 |
6 |
magro732 |
|
736 |
45 |
magro732 |
-- Check if writing.
|
737 |
|
|
if (configWe = '1') then
|
738 |
|
|
-- Write access.
|
739 |
|
|
|
740 |
|
|
-- Check if this field has been written before.
|
741 |
|
|
if (hostBaseDeviceIdLocked = '0') then
|
742 |
|
|
-- The field has not been written.
|
743 |
|
|
-- Lock the field and set the host base device id.
|
744 |
|
|
hostBaseDeviceIdLocked := '1';
|
745 |
|
|
hostBaseDeviceId := configDatWrite(15 downto 0);
|
746 |
|
|
else
|
747 |
|
|
-- The field has been written.
|
748 |
|
|
-- Check if the written data is the same as the stored.
|
749 |
|
|
if (hostBaseDeviceId = configDatWrite(15 downto 0)) then
|
750 |
|
|
-- Same as stored, reset the value to its initial value.
|
751 |
|
|
hostBaseDeviceIdLocked := '0';
|
752 |
|
|
hostBaseDeviceId := (others => '1');
|
753 |
|
|
else
|
754 |
|
|
-- Not writing the same as the stored value.
|
755 |
|
|
-- Ignore the write.
|
756 |
|
|
end if;
|
757 |
|
|
end if;
|
758 |
|
|
end if;
|
759 |
|
|
|
760 |
|
|
configDatRead(15 downto 0) <= hostBaseDeviceId;
|
761 |
|
|
|
762 |
|
|
when x"00006C" =>
|
763 |
|
|
-----------------------------------------------------------------
|
764 |
|
|
-- Component TAG CSR.
|
765 |
|
|
-----------------------------------------------------------------
|
766 |
|
|
if (configWe = '1') then
|
767 |
|
|
componentTag := configDatWrite;
|
768 |
|
|
end if;
|
769 |
|
|
|
770 |
|
|
configDatRead <= componentTag;
|
771 |
|
|
|
772 |
|
|
when others =>
|
773 |
|
|
-----------------------------------------------------------------
|
774 |
|
|
-- Other access.
|
775 |
|
|
-----------------------------------------------------------------
|
776 |
|
|
-- Respond with all zeros.
|
777 |
|
|
configDatRead <= (others => '0');
|
778 |
|
|
end case;
|
779 |
|
|
end if;
|
780 |
|
|
else
|
781 |
|
|
configAck <= '0';
|
782 |
|
|
end if;
|
783 |
|
|
end if;
|
784 |
|
|
end process;
|
785 |
|
|
|
786 |
39 |
magro732 |
end architecture;
|