1 |
46 |
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 parsers and generators.
|
10 |
|
|
--
|
11 |
|
|
-- To Do:
|
12 |
|
|
-- - Add support for maint-request and response in both directions.
|
13 |
|
|
-- - Add support for portWrite in both directions.
|
14 |
|
|
-- - Add generic to disable support for specified packets.
|
15 |
|
|
-- - Dont set complete before the packet is ready in inbound packet
|
16 |
|
|
-- handler.
|
17 |
|
|
-- - Add error indication if erronous sizes are received.
|
18 |
|
|
--
|
19 |
|
|
-- Author(s):
|
20 |
|
|
-- - Magnus Rosenius, magro732@opencores.org
|
21 |
|
|
--
|
22 |
|
|
-------------------------------------------------------------------------------
|
23 |
|
|
--
|
24 |
|
|
-- Copyright (C) 2014 Authors and OPENCORES.ORG
|
25 |
|
|
--
|
26 |
|
|
-- This source file may be used and distributed without
|
27 |
|
|
-- restriction provided that this copyright statement is not
|
28 |
|
|
-- removed from the file and that any derivative work contains
|
29 |
|
|
-- the original copyright notice and the associated disclaimer.
|
30 |
|
|
--
|
31 |
|
|
-- This source file is free software; you can redistribute it
|
32 |
|
|
-- and/or modify it under the terms of the GNU Lesser General
|
33 |
|
|
-- Public License as published by the Free Software Foundation;
|
34 |
|
|
-- either version 2.1 of the License, or (at your option) any
|
35 |
|
|
-- later version.
|
36 |
|
|
--
|
37 |
|
|
-- This source is distributed in the hope that it will be
|
38 |
|
|
-- useful, but WITHOUT ANY WARRANTY; without even the implied
|
39 |
|
|
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
40 |
|
|
-- PURPOSE. See the GNU Lesser General Public License for more
|
41 |
|
|
-- details.
|
42 |
|
|
--
|
43 |
|
|
-- You should have received a copy of the GNU Lesser General
|
44 |
|
|
-- Public License along with this source; if not, download it
|
45 |
|
|
-- from http://www.opencores.org/lgpl.shtml
|
46 |
|
|
--
|
47 |
|
|
-------------------------------------------------------------------------------
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
-------------------------------------------------------------------------------
|
51 |
|
|
-- MaintenanceInbound
|
52 |
|
|
-------------------------------------------------------------------------------
|
53 |
|
|
library ieee;
|
54 |
|
|
use ieee.std_logic_1164.all;
|
55 |
|
|
use ieee.numeric_std.all;
|
56 |
|
|
use work.rio_common.all;
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
-------------------------------------------------------------------------------
|
60 |
|
|
-- Entity for MaintenanceInbound.
|
61 |
|
|
-------------------------------------------------------------------------------
|
62 |
|
|
entity MaintenanceInbound is
|
63 |
|
|
port(
|
64 |
|
|
clk : in std_logic;
|
65 |
|
|
areset_n : in std_logic;
|
66 |
|
|
enable : in std_logic;
|
67 |
|
|
|
68 |
|
|
readRequestReady_o : out std_logic;
|
69 |
|
|
writeRequestReady_o : out std_logic;
|
70 |
|
|
readResponseReady_o : out std_logic;
|
71 |
|
|
writeResponseReady_o : out std_logic;
|
72 |
|
|
portWriteReady_o : out std_logic;
|
73 |
|
|
vc_o : out std_logic;
|
74 |
|
|
crf_o : out std_logic;
|
75 |
|
|
prio_o : out std_logic_vector(1 downto 0);
|
76 |
|
|
tt_o : out std_logic_vector(1 downto 0);
|
77 |
|
|
dstid_o : out std_logic_vector(31 downto 0);
|
78 |
|
|
srcid_o : out std_logic_vector(31 downto 0);
|
79 |
|
|
tid_o : out std_logic_vector(7 downto 0);
|
80 |
|
|
hop_o : out std_logic_vector(7 downto 0);
|
81 |
|
|
offset_o : out std_logic_vector(20 downto 0);
|
82 |
|
|
wdptr_o : out std_logic;
|
83 |
|
|
payloadLength_o : out std_logic_vector(3 downto 0);
|
84 |
|
|
payloadIndex_i : in std_logic_vector(3 downto 0);
|
85 |
|
|
payload_o : out std_logic_vector(31 downto 0);
|
86 |
|
|
done_i : in std_logic;
|
87 |
|
|
|
88 |
|
|
inboundCyc_i : in std_logic;
|
89 |
|
|
inboundStb_i : in std_logic;
|
90 |
|
|
inboundAdr_i : in std_logic_vector(7 downto 0);
|
91 |
|
|
inboundDat_i : in std_logic_vector(31 downto 0);
|
92 |
|
|
inboundAck_o : out std_logic);
|
93 |
|
|
end entity;
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
-------------------------------------------------------------------------------
|
97 |
|
|
-- Architecture for MaintenanceInbound.
|
98 |
|
|
-------------------------------------------------------------------------------
|
99 |
|
|
architecture MaintenanceInbound of MaintenanceInbound is
|
100 |
|
|
|
101 |
|
|
type StateType is (RECEIVE_PACKET, READY);
|
102 |
|
|
signal state : StateType;
|
103 |
|
|
|
104 |
|
|
signal wdptr : std_logic;
|
105 |
|
|
signal size : std_logic_vector(3 downto 0);
|
106 |
|
|
signal words : natural range 0 to 32;
|
107 |
|
|
|
108 |
|
|
signal inboundAck : std_logic;
|
109 |
|
|
signal maintReadComplete : std_logic;
|
110 |
|
|
signal maintWriteComplete : std_logic;
|
111 |
|
|
|
112 |
|
|
signal packetIndex : natural range 0 to 33;
|
113 |
|
|
signal packetData : std_logic_vector(31 downto 0);
|
114 |
|
|
|
115 |
|
|
signal memoryWrite : std_logic;
|
116 |
|
|
signal memoryAddress : std_logic_vector(3 downto 0);
|
117 |
|
|
signal memoryDataIn : std_logic_vector(31 downto 0);
|
118 |
|
|
|
119 |
|
|
begin
|
120 |
|
|
|
121 |
|
|
readRequestReady_o <= maintReadComplete when (state = READY) else '0';
|
122 |
|
|
writeRequestReady_o <= maintWriteComplete when (state = READY) else '0';
|
123 |
|
|
readResponseReady_o <= '0';
|
124 |
|
|
writeResponseReady_o <= '0';
|
125 |
|
|
portWriteReady_o <= '0';
|
126 |
|
|
|
127 |
|
|
inboundAck_o <= inboundAck;
|
128 |
|
|
MaintenanceRequest: process(clk, areset_n)
|
129 |
|
|
begin
|
130 |
|
|
if (areset_n = '0') then
|
131 |
|
|
inboundAck <= '0';
|
132 |
|
|
|
133 |
|
|
maintReadComplete <= '0';
|
134 |
|
|
maintWriteComplete <= '0';
|
135 |
|
|
|
136 |
|
|
vc_o <= '0';
|
137 |
|
|
crf_o <= '0';
|
138 |
|
|
prio_o <= "00";
|
139 |
|
|
tt_o <= "00";
|
140 |
|
|
dstid_o <= (others=>'0');
|
141 |
|
|
srcid_o <= (others=>'0');
|
142 |
|
|
tid_o <= (others=>'0');
|
143 |
|
|
hop_o <= (others=>'0');
|
144 |
|
|
offset_o <= (others=>'0');
|
145 |
|
|
|
146 |
|
|
wdptr <= '0';
|
147 |
|
|
size <= (others=>'0');
|
148 |
|
|
|
149 |
|
|
packetIndex <= 0;
|
150 |
|
|
memoryWrite <= '0';
|
151 |
|
|
memoryAddress <= (others=>'0');
|
152 |
|
|
memoryDataIn <= (others=>'0');
|
153 |
|
|
elsif (clk'event and clk = '1') then
|
154 |
|
|
case state is
|
155 |
|
|
when RECEIVE_PACKET =>
|
156 |
|
|
---------------------------------------------------------------------
|
157 |
|
|
-- This state waits for a new maintenance packet, receives it
|
158 |
|
|
-- and parses it.
|
159 |
|
|
---------------------------------------------------------------------
|
160 |
|
|
if (inboundCyc_i = '1') then
|
161 |
|
|
if (inboundAck = '0') then
|
162 |
|
|
if (inboundStb_i = '1') then
|
163 |
|
|
if (inboundAdr_i = x"80") then
|
164 |
|
|
-------------------------------------------------------------
|
165 |
|
|
-- Maintenance Read Request packet parser.
|
166 |
|
|
-------------------------------------------------------------
|
167 |
|
|
case (packetIndex) is
|
168 |
|
|
when 0 =>
|
169 |
|
|
-- x"0000" & ackid & vc & crf & prio & tt & ftype
|
170 |
|
|
vc_o <= inboundDat_i(9);
|
171 |
|
|
crf_o <= inboundDat_i(8);
|
172 |
|
|
prio_o <= inboundDat_i(7 downto 6);
|
173 |
|
|
tt_o <= inboundDat_i(5 downto 4);
|
174 |
|
|
packetIndex <= packetIndex + 1;
|
175 |
|
|
when 1 =>
|
176 |
|
|
-- dstid
|
177 |
|
|
dstid_o <= inboundDat_i;
|
178 |
|
|
packetIndex <= packetIndex + 1;
|
179 |
|
|
when 2 =>
|
180 |
|
|
-- srcid
|
181 |
|
|
srcid_o <= inboundDat_i;
|
182 |
|
|
packetIndex <= packetIndex + 1;
|
183 |
|
|
when 3 =>
|
184 |
|
|
-- transaction & rdsize & srcTID & hop & config_offset(20:13)
|
185 |
|
|
size <= inboundDat_i(27 downto 24);
|
186 |
|
|
tid_o <= inboundDat_i(23 downto 16);
|
187 |
|
|
hop_o <= inboundDat_i(15 downto 8);
|
188 |
|
|
offset_o(20 downto 13) <= inboundDat_i(7 downto 0);
|
189 |
|
|
packetIndex <= packetIndex + 1;
|
190 |
|
|
when 4 =>
|
191 |
|
|
-- config_offset(12:0) & wdptr & rsrv & crc(15:0)
|
192 |
|
|
offset_o(12 downto 0) <= inboundDat_i(31 downto 19);
|
193 |
|
|
wdptr <= inboundDat_i(18);
|
194 |
|
|
packetIndex <= packetIndex + 1;
|
195 |
|
|
maintReadComplete <= '1';
|
196 |
|
|
when others =>
|
197 |
|
|
-- There should be no more content in a maintenance read request.
|
198 |
|
|
-- Discard.
|
199 |
|
|
end case;
|
200 |
|
|
inboundAck <= '1';
|
201 |
|
|
elsif (inboundAdr_i = x"81") then
|
202 |
|
|
-------------------------------------------------------------
|
203 |
|
|
-- Maintenance Write Request packet parser.
|
204 |
|
|
-------------------------------------------------------------
|
205 |
|
|
case (packetIndex) is
|
206 |
|
|
when 0 =>
|
207 |
|
|
-- x"0000" & ackid & vc & crf & prio & tt & ftype
|
208 |
|
|
vc_o <= inboundDat_i(9);
|
209 |
|
|
crf_o <= inboundDat_i(8);
|
210 |
|
|
prio_o <= inboundDat_i(7 downto 6);
|
211 |
|
|
tt_o <= inboundDat_i(5 downto 4);
|
212 |
|
|
packetIndex <= packetIndex + 1;
|
213 |
|
|
when 1 =>
|
214 |
|
|
-- destId
|
215 |
|
|
dstid_o <= inboundDat_i;
|
216 |
|
|
packetIndex <= packetIndex + 1;
|
217 |
|
|
when 2 =>
|
218 |
|
|
-- srcId
|
219 |
|
|
srcid_o <= inboundDat_i;
|
220 |
|
|
packetIndex <= packetIndex + 1;
|
221 |
|
|
when 3 =>
|
222 |
|
|
-- transaction & wrsize & srcTID & hop & config_offset(20:13)
|
223 |
|
|
size <= inboundDat_i(27 downto 24);
|
224 |
|
|
tid_o <= inboundDat_i(23 downto 16);
|
225 |
|
|
hop_o <= inboundDat_i(15 downto 8);
|
226 |
|
|
offset_o(20 downto 13) <= inboundDat_i(7 downto 0);
|
227 |
|
|
packetIndex <= packetIndex + 1;
|
228 |
|
|
when 4 =>
|
229 |
|
|
-- config_offset(12:0) & wdptr & rsrv & double-word(63:48)
|
230 |
|
|
offset_o(12 downto 0) <= inboundDat_i(31 downto 19);
|
231 |
|
|
wdptr <= inboundDat_i(18);
|
232 |
|
|
packetData(31 downto 16) <= inboundDat_i(15 downto 0);
|
233 |
|
|
packetIndex <= packetIndex + 1;
|
234 |
|
|
when 5 | 7 | 9 | 11 | 13 | 15 | 17 | 19 | 21 | 23 | 25 | 27 | 29 | 31 =>
|
235 |
|
|
-- double-word(47:16)
|
236 |
|
|
packetData(31 downto 16) <= inboundDat_i(15 downto 0);
|
237 |
|
|
packetIndex <= packetIndex + 1;
|
238 |
|
|
|
239 |
|
|
if (not ((size = "1000") and (wdptr = '1'))) then
|
240 |
|
|
memoryWrite <= '1';
|
241 |
|
|
memoryDataIn <= packetData(31 downto 16) & inboundDat_i(31 downto 16);
|
242 |
|
|
end if;
|
243 |
|
|
when 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 | 22 | 24 | 26 | 28 | 30 | 32 =>
|
244 |
|
|
-- double-word(15:0) & double-word(63:48)
|
245 |
|
|
packetData(31 downto 16) <= inboundDat_i(15 downto 0);
|
246 |
|
|
packetIndex <= packetIndex + 1;
|
247 |
|
|
|
248 |
|
|
memoryWrite <= '1';
|
249 |
|
|
memoryDataIn <= packetData(31 downto 16) & inboundDat_i(31 downto 16);
|
250 |
|
|
-- REMARK: Dont set complete before the packet is ready...
|
251 |
|
|
maintWriteComplete <= '1';
|
252 |
|
|
when others =>
|
253 |
|
|
-- There should be no more content in a maintenance write request.
|
254 |
|
|
-- Discard.
|
255 |
|
|
end case;
|
256 |
|
|
inboundAck <= '1';
|
257 |
|
|
elsif (inboundAdr_i = x"82") then
|
258 |
|
|
-------------------------------------------------------------
|
259 |
|
|
-- Maintenance Read Response packet parser.
|
260 |
|
|
-------------------------------------------------------------
|
261 |
|
|
elsif (inboundAdr_i = x"83") then
|
262 |
|
|
-------------------------------------------------------------
|
263 |
|
|
-- Maintenance Write Response packet parser.
|
264 |
|
|
-------------------------------------------------------------
|
265 |
|
|
elsif (inboundAdr_i = x"84") then
|
266 |
|
|
-------------------------------------------------------------
|
267 |
|
|
-- Maintenance Port-Write Request packet parser.
|
268 |
|
|
-------------------------------------------------------------
|
269 |
|
|
else
|
270 |
|
|
-------------------------------------------------------------
|
271 |
|
|
-- Unsupported maintenance packet.
|
272 |
|
|
-------------------------------------------------------------
|
273 |
|
|
-- REMARK: Cannot handle these, dont answer. Or answer and
|
274 |
|
|
-- discard?
|
275 |
|
|
end if;
|
276 |
|
|
end if;
|
277 |
|
|
else
|
278 |
|
|
if (memoryWrite = '1') then
|
279 |
|
|
memoryAddress <= std_logic_vector(unsigned(memoryAddress) + 1);
|
280 |
|
|
end if;
|
281 |
|
|
|
282 |
|
|
memoryWrite <= '0';
|
283 |
|
|
inboundAck <= '0';
|
284 |
|
|
end if;
|
285 |
|
|
else
|
286 |
|
|
if (maintReadComplete = '1') or (maintWriteComplete = '1') then
|
287 |
|
|
state <= READY;
|
288 |
|
|
end if;
|
289 |
|
|
packetIndex <= 0;
|
290 |
|
|
memoryAddress <= (others=>'0');
|
291 |
|
|
end if;
|
292 |
|
|
|
293 |
|
|
when READY =>
|
294 |
|
|
---------------------------------------------------------------------
|
295 |
|
|
-- Wait for the handler of the packet to signal that it has been
|
296 |
|
|
-- processed.
|
297 |
|
|
---------------------------------------------------------------------
|
298 |
|
|
if (done_i = '1') then
|
299 |
|
|
maintReadComplete <= '0';
|
300 |
|
|
maintWriteComplete <= '0';
|
301 |
|
|
state <= RECEIVE_PACKET;
|
302 |
|
|
end if;
|
303 |
|
|
|
304 |
|
|
when others =>
|
305 |
|
|
---------------------------------------------------------------------
|
306 |
|
|
--
|
307 |
|
|
---------------------------------------------------------------------
|
308 |
|
|
|
309 |
|
|
end case;
|
310 |
|
|
end if;
|
311 |
|
|
end process;
|
312 |
|
|
|
313 |
|
|
-----------------------------------------------------------------------------
|
314 |
|
|
-- Transformation of rdsize/wrsize into length of access and byte lanes.
|
315 |
|
|
-----------------------------------------------------------------------------
|
316 |
|
|
|
317 |
|
|
process(clk, areset_n)
|
318 |
|
|
begin
|
319 |
|
|
if (areset_n = '0') then
|
320 |
|
|
payloadLength_o <= (others=>'0');
|
321 |
|
|
wdptr_o <= '0';
|
322 |
|
|
elsif (clk'event and clk = '1') then
|
323 |
|
|
if (maintReadComplete = '1') or (maintWriteComplete = '1') then
|
324 |
|
|
if (wdptr = '0') then
|
325 |
|
|
case size is
|
326 |
|
|
when "1000" =>
|
327 |
|
|
-- Read 1 word.
|
328 |
|
|
payloadLength_o <= "0000";
|
329 |
|
|
wdptr_o <= '0';
|
330 |
|
|
when "1011" =>
|
331 |
|
|
-- Read 2 words.
|
332 |
|
|
payloadLength_o <= "0001";
|
333 |
|
|
wdptr_o <= '0';
|
334 |
|
|
when "1100" =>
|
335 |
|
|
-- Read 8 words.
|
336 |
|
|
payloadLength_o <= "0111";
|
337 |
|
|
wdptr_o <= '0';
|
338 |
|
|
when others =>
|
339 |
|
|
-- REMARK: Not allowed for a maintenance packet.
|
340 |
|
|
payloadLength_o <= "0000";
|
341 |
|
|
wdptr_o <= '0';
|
342 |
|
|
end case;
|
343 |
|
|
else
|
344 |
|
|
case size is
|
345 |
|
|
when "1000" =>
|
346 |
|
|
-- Read 1 word.
|
347 |
|
|
payloadLength_o <= "0000";
|
348 |
|
|
wdptr_o <= '1';
|
349 |
|
|
when "1011" =>
|
350 |
|
|
-- Read 4 words.
|
351 |
|
|
payloadLength_o <= "0011";
|
352 |
|
|
wdptr_o <= '0';
|
353 |
|
|
when "1100" =>
|
354 |
|
|
-- Read 16 words.
|
355 |
|
|
payloadLength_o <= "1111";
|
356 |
|
|
wdptr_o <= '0';
|
357 |
|
|
when others =>
|
358 |
|
|
-- REMARK: Not allowed for a maintenance packet.
|
359 |
|
|
payloadLength_o <= "0000";
|
360 |
|
|
wdptr_o <= '0';
|
361 |
|
|
end case;
|
362 |
|
|
end if;
|
363 |
|
|
end if;
|
364 |
|
|
end if;
|
365 |
|
|
end process;
|
366 |
|
|
|
367 |
|
|
-----------------------------------------------------------------------------
|
368 |
|
|
-- Payload content memory.
|
369 |
|
|
-----------------------------------------------------------------------------
|
370 |
|
|
PayloadMemory: MemorySimpleDualPort
|
371 |
|
|
generic map(ADDRESS_WIDTH=>4, DATA_WIDTH=>32)
|
372 |
|
|
port map(clkA_i=>clk,
|
373 |
|
|
enableA_i=>memoryWrite,
|
374 |
|
|
addressA_i=>memoryAddress,
|
375 |
|
|
dataA_i=>memoryDataIn,
|
376 |
|
|
clkB_i=>clk,
|
377 |
|
|
enableB_i=>enable,
|
378 |
|
|
addressB_i=>payloadIndex_i,
|
379 |
|
|
dataB_o=>payload_o);
|
380 |
|
|
|
381 |
|
|
end architecture;
|
382 |
|
|
|
383 |
|
|
|
384 |
|
|
-------------------------------------------------------------------------------
|
385 |
|
|
-- MaintenanceOutbound.
|
386 |
|
|
-------------------------------------------------------------------------------
|
387 |
|
|
library ieee;
|
388 |
|
|
use ieee.std_logic_1164.all;
|
389 |
|
|
use ieee.numeric_std.all;
|
390 |
|
|
use work.rio_common.all;
|
391 |
|
|
|
392 |
|
|
-------------------------------------------------------------------------------
|
393 |
|
|
-- Entity for MaintenanceOutbound.
|
394 |
|
|
-------------------------------------------------------------------------------
|
395 |
|
|
entity MaintenanceOutbound is
|
396 |
|
|
port(
|
397 |
|
|
clk : in std_logic;
|
398 |
|
|
areset_n : in std_logic;
|
399 |
|
|
enable : in std_logic;
|
400 |
|
|
|
401 |
|
|
readRequestReady_i : in std_logic;
|
402 |
|
|
writeRequestReady_i : in std_logic;
|
403 |
|
|
readResponseReady_i : in std_logic;
|
404 |
|
|
writeResponseReady_i : in std_logic;
|
405 |
|
|
portWriteReady_i : in std_logic;
|
406 |
|
|
vc_i : in std_logic;
|
407 |
|
|
crf_i : in std_logic;
|
408 |
|
|
prio_i : in std_logic_vector(1 downto 0);
|
409 |
|
|
tt_i : in std_logic_vector(1 downto 0);
|
410 |
|
|
dstid_i : in std_logic_vector(31 downto 0);
|
411 |
|
|
srcid_i : in std_logic_vector(31 downto 0);
|
412 |
|
|
status_i : in std_logic_vector(3 downto 0);
|
413 |
|
|
tid_i : in std_logic_vector(7 downto 0);
|
414 |
|
|
hop_i : in std_logic_vector(7 downto 0);
|
415 |
|
|
wdptr_i : in std_logic;
|
416 |
|
|
offset_i : in std_logic_vector(20 downto 0);
|
417 |
|
|
payloadLength_i : in std_logic_vector(3 downto 0);
|
418 |
|
|
payloadIndex_o : out std_logic_vector(3 downto 0);
|
419 |
|
|
payload_i : in std_logic_vector(31 downto 0);
|
420 |
|
|
done_o : out std_logic;
|
421 |
|
|
|
422 |
|
|
outboundCyc_o : out std_logic;
|
423 |
|
|
outboundStb_o : out std_logic;
|
424 |
|
|
outboundDat_o : out std_logic_vector(31 downto 0);
|
425 |
|
|
outboundAck_i : in std_logic);
|
426 |
|
|
end entity;
|
427 |
|
|
|
428 |
|
|
|
429 |
|
|
-------------------------------------------------------------------------------
|
430 |
|
|
-- Architecture for MaintenanceOutbound.
|
431 |
|
|
-------------------------------------------------------------------------------
|
432 |
|
|
architecture MaintenanceOutbound of MaintenanceOutbound is
|
433 |
|
|
type StateType is (WAIT_PACKET,
|
434 |
|
|
READ_RESPONSE, WRITE_RESPONSE,
|
435 |
|
|
WAIT_COMPLETE, RESPONSE_DONE);
|
436 |
|
|
signal state : StateType;
|
437 |
|
|
|
438 |
|
|
signal packetIndex : natural range 0 to 33;
|
439 |
|
|
signal header : std_logic_vector(31 downto 0);
|
440 |
|
|
signal payload : std_logic_vector(15 downto 0);
|
441 |
|
|
signal payloadIndex : std_logic_vector(3 downto 0);
|
442 |
|
|
|
443 |
|
|
begin
|
444 |
|
|
|
445 |
|
|
-- unused(31:16) | ackId(15:10) | vc(9) | crf(8) | prio(7:6) | tt(5:4) | ftype(3:0).
|
446 |
|
|
header <= x"0000" & "000000" & vc_i & crf_i & prio_i & tt_i & x"8";
|
447 |
|
|
|
448 |
|
|
payloadIndex_o <= payloadIndex;
|
449 |
|
|
|
450 |
|
|
MaintenanceResponse: process(clk, areset_n)
|
451 |
|
|
begin
|
452 |
|
|
if (areset_n = '0') then
|
453 |
|
|
state <= WAIT_PACKET;
|
454 |
|
|
packetIndex <= 0;
|
455 |
|
|
|
456 |
|
|
payload <= (others=>'0');
|
457 |
|
|
payloadIndex <= (others=>'0');
|
458 |
|
|
|
459 |
|
|
outboundCyc_o <= '0';
|
460 |
|
|
outboundStb_o <= '0';
|
461 |
|
|
|
462 |
|
|
done_o <= '0';
|
463 |
|
|
elsif (clk'event and clk = '1') then
|
464 |
|
|
if (enable = '1') then
|
465 |
|
|
case state is
|
466 |
|
|
when WAIT_PACKET =>
|
467 |
|
|
-------------------------------------------------------------------
|
468 |
|
|
--
|
469 |
|
|
-------------------------------------------------------------------
|
470 |
|
|
if (readResponseReady_i = '1') then
|
471 |
|
|
outboundCyc_o <= '1';
|
472 |
|
|
outboundStb_o <= '1';
|
473 |
|
|
outboundDat_o <= header;
|
474 |
|
|
packetIndex <= 1;
|
475 |
|
|
payloadIndex <= (others=>'0');
|
476 |
|
|
state <= READ_RESPONSE;
|
477 |
|
|
elsif (writeResponseReady_i = '1') then
|
478 |
|
|
outboundCyc_o <= '1';
|
479 |
|
|
outboundStb_o <= '1';
|
480 |
|
|
outboundDat_o <= header;
|
481 |
|
|
packetIndex <= 1;
|
482 |
|
|
state <= WRITE_RESPONSE;
|
483 |
|
|
end if;
|
484 |
|
|
|
485 |
|
|
when READ_RESPONSE =>
|
486 |
|
|
---------------------------------------------------------------------
|
487 |
|
|
--
|
488 |
|
|
---------------------------------------------------------------------
|
489 |
|
|
if (outboundAck_i = '1') then
|
490 |
|
|
case (packetIndex) is
|
491 |
|
|
when 1 =>
|
492 |
|
|
-- destination
|
493 |
|
|
outboundDat_o <= dstid_i;
|
494 |
|
|
packetIndex <= packetIndex + 1;
|
495 |
|
|
when 2 =>
|
496 |
|
|
-- source
|
497 |
|
|
outboundDat_o <= srcid_i;
|
498 |
|
|
packetIndex <= packetIndex + 1;
|
499 |
|
|
when 3 =>
|
500 |
|
|
-- transaction & status & targetTID & hop & reserved(7:0)
|
501 |
|
|
outboundDat_o <= "0010" & status_i & tid_i & hop_i & x"00";
|
502 |
|
|
packetIndex <= packetIndex + 1;
|
503 |
|
|
when 4 =>
|
504 |
|
|
-- reserved(15:0) & double-wordN(63:48)
|
505 |
|
|
if (payloadLength_i = "0000") and (wdptr_i = '0') then
|
506 |
|
|
outboundDat_o <= x"0000" & payload_i(31 downto 16);
|
507 |
|
|
payload <= payload_i(15 downto 0);
|
508 |
|
|
payloadIndex <= std_logic_vector(unsigned(payloadIndex) + 1);
|
509 |
|
|
elsif (payloadLength_i = "0000") and (wdptr_i = '1') then
|
510 |
|
|
outboundDat_o <= x"0000" & x"0000";
|
511 |
|
|
else
|
512 |
|
|
outboundDat_o <= x"0000" & payload_i(31 downto 16);
|
513 |
|
|
payload <= payload_i(15 downto 0);
|
514 |
|
|
payloadIndex <= std_logic_vector(unsigned(payloadIndex) + 1);
|
515 |
|
|
end if;
|
516 |
|
|
packetIndex <= packetIndex + 1;
|
517 |
|
|
when 5 | 7 | 9 | 11 | 13 | 15 | 17 | 19 | 21 | 23 | 25 | 27 | 29 | 31 =>
|
518 |
|
|
-- double-wordN(47:16)
|
519 |
|
|
if (payloadLength_i = "0000") and (wdptr_i = '0') then
|
520 |
|
|
outboundDat_o <= payload & x"0000";
|
521 |
|
|
elsif (payloadLength_i = "0000") and (wdptr_i = '1') then
|
522 |
|
|
outboundDat_o <= x"0000" & payload_i(31 downto 16);
|
523 |
|
|
payload <= payload_i(15 downto 0);
|
524 |
|
|
payloadIndex <= std_logic_vector(unsigned(payloadIndex) + 1);
|
525 |
|
|
else
|
526 |
|
|
outboundDat_o <= payload & payload_i(31 downto 16);
|
527 |
|
|
payload <= payload_i(15 downto 0);
|
528 |
|
|
payloadIndex <= std_logic_vector(unsigned(payloadIndex) + 1);
|
529 |
|
|
end if;
|
530 |
|
|
packetIndex <= packetIndex + 1;
|
531 |
|
|
when 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 | 22 | 24 | 26 | 28 | 30 | 32 =>
|
532 |
|
|
-- double-wordN(15:0) & double-wordN(63:48)
|
533 |
|
|
if (payloadLength_i = "0000") and (wdptr_i = '0') then
|
534 |
|
|
outboundDat_o <= x"0000" & x"0000";
|
535 |
|
|
elsif (payloadLength_i = "0000") and (wdptr_i = '1') then
|
536 |
|
|
outboundDat_o <= payload & x"0000";
|
537 |
|
|
else
|
538 |
|
|
if (payloadIndex /= payloadLength_i) then
|
539 |
|
|
outboundDat_o <= payload & payload_i(31 downto 16);
|
540 |
|
|
payload <= payload_i(15 downto 0);
|
541 |
|
|
else
|
542 |
|
|
outboundDat_o <= payload & x"0000";
|
543 |
|
|
payload <= payload_i(15 downto 0);
|
544 |
|
|
end if;
|
545 |
|
|
end if;
|
546 |
|
|
|
547 |
|
|
payloadIndex <= std_logic_vector(unsigned(payloadIndex) + 1);
|
548 |
|
|
if (payloadIndex(3 downto 1) = payloadLength_i(3 downto 1)) then
|
549 |
|
|
state <= WAIT_COMPLETE;
|
550 |
|
|
else
|
551 |
|
|
packetIndex <= packetIndex + 1;
|
552 |
|
|
end if;
|
553 |
|
|
when others =>
|
554 |
|
|
-- Unallowed response length.
|
555 |
|
|
-- Dont do anything.
|
556 |
|
|
end case;
|
557 |
|
|
end if;
|
558 |
|
|
|
559 |
|
|
when WRITE_RESPONSE =>
|
560 |
|
|
---------------------------------------------------------------------
|
561 |
|
|
--
|
562 |
|
|
---------------------------------------------------------------------
|
563 |
|
|
if (outboundAck_i = '1') then
|
564 |
|
|
case (packetIndex) is
|
565 |
|
|
when 1 =>
|
566 |
|
|
-- destination
|
567 |
|
|
outboundDat_o <= dstid_i;
|
568 |
|
|
packetIndex <= packetIndex + 1;
|
569 |
|
|
when 2 =>
|
570 |
|
|
-- source
|
571 |
|
|
outboundDat_o <= srcid_i;
|
572 |
|
|
packetIndex <= packetIndex + 1;
|
573 |
|
|
when 3 =>
|
574 |
|
|
-- transaction & status & targetTID & hop & reserved(7:0)
|
575 |
|
|
outboundDat_o <= "0011" & status_i & tid_i & hop_i & x"00";
|
576 |
|
|
packetIndex <= packetIndex + 1;
|
577 |
|
|
when others =>
|
578 |
|
|
-- reserved(15:0) & crc(15:0)
|
579 |
|
|
outboundDat_o <= x"00000000";
|
580 |
|
|
packetIndex <= packetIndex + 1;
|
581 |
|
|
state <= WAIT_COMPLETE;
|
582 |
|
|
end case;
|
583 |
|
|
end if;
|
584 |
|
|
|
585 |
|
|
when WAIT_COMPLETE =>
|
586 |
|
|
-------------------------------------------------------------------
|
587 |
|
|
--
|
588 |
|
|
-------------------------------------------------------------------
|
589 |
|
|
if (outboundAck_i = '1') then
|
590 |
|
|
outboundCyc_o <= '0';
|
591 |
|
|
outboundStb_o <= '0';
|
592 |
|
|
state <= RESPONSE_DONE;
|
593 |
|
|
end if;
|
594 |
|
|
|
595 |
|
|
when RESPONSE_DONE =>
|
596 |
|
|
---------------------------------------------------------------------
|
597 |
|
|
--
|
598 |
|
|
---------------------------------------------------------------------
|
599 |
|
|
if (readResponseReady_i = '0') and (writeResponseReady_i = '0') then
|
600 |
|
|
state <= WAIT_PACKET;
|
601 |
|
|
done_o <= '0';
|
602 |
|
|
else
|
603 |
|
|
done_o <= '1';
|
604 |
|
|
end if;
|
605 |
|
|
|
606 |
|
|
when others =>
|
607 |
|
|
---------------------------------------------------------------------
|
608 |
|
|
--
|
609 |
|
|
---------------------------------------------------------------------
|
610 |
|
|
state <= WAIT_PACKET;
|
611 |
|
|
|
612 |
|
|
end case;
|
613 |
|
|
end if;
|
614 |
|
|
end if;
|
615 |
|
|
end process;
|
616 |
|
|
|
617 |
|
|
end architecture;
|