1 |
33 |
magro732 |
-------------------------------------------------------------------------------
|
2 |
|
|
-- RioLogicalCommon.
|
3 |
|
|
-------------------------------------------------------------------------------
|
4 |
|
|
-- Ingress:
|
5 |
35 |
magro732 |
-- * Removes in-the-middle and trailing CRC.
|
6 |
33 |
magro732 |
-- * Forwards packets to logical-layer handlers depending on ftype and
|
7 |
|
|
-- transaction (output as address).
|
8 |
|
|
-- * Outputs header and deviceIDs in seperate accesses to facilitate 8- and
|
9 |
|
|
-- 16-bit deviceAddress support. All fields are right-justified.
|
10 |
|
|
-- Egress:
|
11 |
35 |
magro732 |
-- * Adds in-the-middle and trailing CRC.
|
12 |
33 |
magro732 |
-- * Receives packets from logical-layer handlers.
|
13 |
35 |
magro732 |
-- * Receives header and deviceIDs in seperate accesses to facilitate 8- and
|
14 |
|
|
-- 16-bit deviceAddress support. All fields are right-justified.
|
15 |
33 |
magro732 |
-------------------------------------------------------------------------------
|
16 |
|
|
-- REMARK: Egress; Places packets in different queues depending on the packet priority?
|
17 |
|
|
-- REMARK: Use inputOutput/message/maintenance/gsm/...-strobes instead?
|
18 |
|
|
-- REMARK: If the deviceId:s are removed, it will work for both 8/16-bit deviceIds.
|
19 |
|
|
-- case (ftype) is
|
20 |
|
|
-- when x"1" =>
|
21 |
|
|
-- -- Intervention-request class.
|
22 |
|
|
-- gsmStb_o <= '1';
|
23 |
|
|
-- when x"2" =>
|
24 |
|
|
-- -- Request-class.
|
25 |
|
|
-- if ((transaction = "0100") or
|
26 |
|
|
-- (transaction = "1100") or (transaction = "1101") or
|
27 |
|
|
-- (transaction = "1110") or (transaction = "1111")) then
|
28 |
|
|
-- inputOutputStb_o <= '1';
|
29 |
|
|
-- else
|
30 |
|
|
-- gsmStb_o <= '1';
|
31 |
|
|
-- end if;
|
32 |
|
|
-- when x"5" =>
|
33 |
|
|
-- -- Write-class.
|
34 |
|
|
-- if ((transaction = "0100") or (transaction = "0101") or
|
35 |
|
|
-- (transaction = "1100") or (transaction = "1101") or
|
36 |
|
|
-- (transaction = "1110")) then
|
37 |
|
|
-- inputOutputStb_o <= '1';
|
38 |
|
|
-- elsif ((transaction = "0000") or (transaction = "0001")) then
|
39 |
|
|
-- gsmStb_o <= '1';
|
40 |
|
|
-- end if;
|
41 |
|
|
-- when x"6" =>
|
42 |
|
|
-- -- Streaming-Write class.
|
43 |
|
|
-- inputOutputStb_o <= '1';
|
44 |
|
|
-- when x"7" =>
|
45 |
|
|
-- -- Flow-control class.
|
46 |
|
|
-- flowControlStb_o <= '1';
|
47 |
|
|
-- when x"8" =>
|
48 |
|
|
-- -- Maintenance class.
|
49 |
|
|
-- maintenanceStb_o <= '1';
|
50 |
|
|
-- when x"9" =>
|
51 |
|
|
-- -- Data-Streaming class.
|
52 |
|
|
-- dataStreamingStb_o <= '1';
|
53 |
|
|
-- when x"a" =>
|
54 |
|
|
-- -- Doorbell class.
|
55 |
|
|
-- -- REMARK: Make this belong to input/output since the packets
|
56 |
|
|
-- -- and their responses look the same?
|
57 |
|
|
-- messagePassingStb_o <= '1';
|
58 |
|
|
-- when x"b" =>
|
59 |
|
|
-- -- Message class.
|
60 |
|
|
-- messagePassingStb_o <= '1';
|
61 |
|
|
-- when x"d" =>
|
62 |
|
|
-- -- Response class.
|
63 |
|
|
-- -- REMARK: Seperate strobe for this???
|
64 |
|
|
-- if ((transaction = "0000") or (transaction = "1000")) then
|
65 |
|
|
-- -- REMARK: Doorbell-response going in here as well... *sigh*
|
66 |
|
|
-- -- REMARK: GSM-responses going in here as well...
|
67 |
|
|
-- responseStb_o <= '1';
|
68 |
|
|
-- elsif (transaction = "0001") then
|
69 |
|
|
-- messagePassing <= '1';
|
70 |
|
|
-- end if;
|
71 |
|
|
-- when others =>
|
72 |
|
|
-- -- Unsupported ftype.
|
73 |
|
|
-- -- REMARK: Discard this packet.
|
74 |
|
|
-- end case;
|
75 |
|
|
|
76 |
|
|
-- tt=00
|
77 |
|
|
-- 0: header(15:0);dest(7:0);src(7:0);
|
78 |
|
|
-- 1: transaction(3:0)
|
79 |
|
|
-- shifter: 32 (32 empty)
|
80 |
|
|
-- tt=01
|
81 |
|
|
-- 0: header(15:0);dest(15:0);
|
82 |
|
|
-- 1: src(15:0);transaction(3:0)
|
83 |
|
|
-- shifter: 16 (48 empty)
|
84 |
|
|
|
85 |
34 |
magro732 |
-------------------------------------------------------------------------------
|
86 |
|
|
-- RioLogicalCommonIngress.
|
87 |
|
|
-------------------------------------------------------------------------------
|
88 |
35 |
magro732 |
-- REMARK: Check the destination address to see if it matches the one configured???
|
89 |
33 |
magro732 |
library ieee;
|
90 |
34 |
magro732 |
use ieee.std_logic_1164.all;
|
91 |
33 |
magro732 |
use ieee.numeric_std.all;
|
92 |
|
|
use work.rio_common.all;
|
93 |
|
|
|
94 |
|
|
-------------------------------------------------------------------------------
|
95 |
|
|
-- Entity for RioLogicalCommonIngress.
|
96 |
|
|
-------------------------------------------------------------------------------
|
97 |
|
|
entity RioLogicalCommonIngress is
|
98 |
|
|
port(
|
99 |
|
|
clk : in std_logic;
|
100 |
|
|
areset_n : in std_logic;
|
101 |
|
|
|
102 |
|
|
readFrameEmpty_i : in std_logic;
|
103 |
|
|
readFrame_o : out std_logic;
|
104 |
|
|
readContent_o : out std_logic;
|
105 |
|
|
readContentEnd_i : in std_logic;
|
106 |
|
|
readContentData_i : in std_logic_vector(31 downto 0);
|
107 |
|
|
|
108 |
|
|
masterCyc_o : out std_logic;
|
109 |
|
|
masterStb_o : out std_logic;
|
110 |
35 |
magro732 |
masterAdr_o : out std_logic_vector(7 downto 0);
|
111 |
|
|
masterSel_o : out std_logic_vector(3 downto 0);
|
112 |
|
|
masterDat_o : out std_logic_vector(31 downto 0);
|
113 |
33 |
magro732 |
masterAck_i : in std_logic);
|
114 |
|
|
end entity;
|
115 |
|
|
|
116 |
|
|
|
117 |
|
|
-------------------------------------------------------------------------------
|
118 |
|
|
--
|
119 |
|
|
-------------------------------------------------------------------------------
|
120 |
|
|
architecture RioLogicalCommonIngress of RioLogicalCommonIngress is
|
121 |
|
|
|
122 |
|
|
begin
|
123 |
|
|
|
124 |
|
|
process(clk, areset_n)
|
125 |
|
|
begin
|
126 |
|
|
if (areset_n = '0') then
|
127 |
|
|
|
128 |
|
|
elsif (clk'event and clk = '1') then
|
129 |
|
|
readContent_o <= '0';
|
130 |
|
|
|
131 |
|
|
case state is
|
132 |
|
|
when IDLE =>
|
133 |
|
|
---------------------------------------------------------------------
|
134 |
|
|
--
|
135 |
|
|
---------------------------------------------------------------------
|
136 |
|
|
packetPosition <= 0;
|
137 |
|
|
if (readFrameEmpty_i = '0') then
|
138 |
|
|
readContent_o <= '1';
|
139 |
|
|
state <= WAIT_HEADER_0;
|
140 |
|
|
end if;
|
141 |
|
|
|
142 |
|
|
when WAIT_HEADER_0 =>
|
143 |
|
|
---------------------------------------------------------------------
|
144 |
|
|
--
|
145 |
|
|
---------------------------------------------------------------------
|
146 |
|
|
readContent_o <= '1';
|
147 |
|
|
state <= HEADER_0;
|
148 |
|
|
|
149 |
|
|
when HEADER_0 =>
|
150 |
|
|
---------------------------------------------------------------------
|
151 |
|
|
--
|
152 |
|
|
---------------------------------------------------------------------
|
153 |
|
|
packetContent <= packetContent(31 downto 0) & readContentData_i;
|
154 |
|
|
packetPosition <= packetPosition + 1;
|
155 |
|
|
readContent_o <= '1';
|
156 |
|
|
|
157 |
|
|
tt <= readContentData_i(21 downto 20);
|
158 |
|
|
ftype <= readContentData_i(19 downto 16);
|
159 |
|
|
|
160 |
|
|
state <= HEADER_1;
|
161 |
|
|
|
162 |
|
|
when HEADER_1 =>
|
163 |
|
|
---------------------------------------------------------------------
|
164 |
|
|
--
|
165 |
|
|
---------------------------------------------------------------------
|
166 |
|
|
packetContent <= packetContent(31 downto 0) & readContentData_i;
|
167 |
|
|
packetPosition <= packetPosition + 1;
|
168 |
|
|
|
169 |
|
|
if (tt = "00") then
|
170 |
|
|
transaction <= readContentData_i(31 downto 28);
|
171 |
|
|
elsif (tt = "01") then
|
172 |
|
|
transaction <= readContentData_i(15 downto 12);
|
173 |
|
|
end if;
|
174 |
|
|
|
175 |
|
|
state <= SEND_HEADER;
|
176 |
|
|
|
177 |
|
|
when SEND_HEADER =>
|
178 |
|
|
---------------------------------------------------------------------
|
179 |
|
|
--
|
180 |
|
|
---------------------------------------------------------------------
|
181 |
|
|
masterStb_o <= '1';
|
182 |
35 |
magro732 |
masterAdr_o <= ftype & transaction;
|
183 |
|
|
masterSel_o <= x"0011";
|
184 |
|
|
masterDat_o <= x"0000" & packetContent(63 downto 48);
|
185 |
33 |
magro732 |
packetContent <= packetContent(47 downto 0) & x"0000";
|
186 |
|
|
|
187 |
|
|
state <= SEND_DESTINATION;
|
188 |
|
|
|
189 |
|
|
when SEND_DESTINATION =>
|
190 |
|
|
---------------------------------------------------------------------
|
191 |
|
|
--
|
192 |
|
|
---------------------------------------------------------------------
|
193 |
|
|
if (masterAck_i = '1') then
|
194 |
|
|
if (tt = "00") then
|
195 |
35 |
magro732 |
masterSel_o <= x"0001";
|
196 |
|
|
masterDat_o <= x"000000" & packetContent(63 downto 56);
|
197 |
33 |
magro732 |
packetContent <= packetContent(55 downto 0) & x"00";
|
198 |
|
|
elsif (tt = "01") then
|
199 |
35 |
magro732 |
masterSel_o <= x"0011";
|
200 |
|
|
masterDat_o <= x"0000" & packetContent(63 downto 48);
|
201 |
33 |
magro732 |
packetContent <= packetContent(31 downto 0) & readContentData_i;
|
202 |
|
|
readContent_o <= '1';
|
203 |
|
|
end if;
|
204 |
|
|
|
205 |
|
|
state <= SEND_SOURCE;
|
206 |
|
|
end if;
|
207 |
|
|
|
208 |
|
|
when SEND_SOURCE =>
|
209 |
|
|
---------------------------------------------------------------------
|
210 |
|
|
--
|
211 |
|
|
---------------------------------------------------------------------
|
212 |
|
|
if (masterAck_i = '1') then
|
213 |
|
|
if (tt = "00") then
|
214 |
35 |
magro732 |
masterSel_o <= x"0001";
|
215 |
|
|
masterDat_o <= x"000000" & packetContent(63 downto 56);
|
216 |
33 |
magro732 |
packetContent <= packetContent(55 downto 0) & x"00";
|
217 |
|
|
elsif (tt = "01") then
|
218 |
35 |
magro732 |
masterSel_o <= x"0011";
|
219 |
|
|
masterDat_o <= x"0000" & packetContent(63 downto 48);
|
220 |
33 |
magro732 |
packetContent <= packetContent(47 downto 0) & x"0000";
|
221 |
|
|
end if;
|
222 |
|
|
|
223 |
|
|
state <= FORWARD;
|
224 |
|
|
end if;
|
225 |
|
|
|
226 |
|
|
when FORWARD =>
|
227 |
|
|
---------------------------------------------------------------------
|
228 |
|
|
--
|
229 |
|
|
---------------------------------------------------------------------
|
230 |
|
|
if (masterAck_i = '1') then
|
231 |
35 |
magro732 |
masterSel_o <= x"1111";
|
232 |
|
|
masterDat_o <= packetContent(63 downto 32);
|
233 |
33 |
magro732 |
|
234 |
|
|
packetPosition <= packetPosition + 1;
|
235 |
|
|
|
236 |
|
|
-- REMARK: Rewrite depending on tt-field to compensate for
|
237 |
|
|
-- different number of valid bits in the shifter...
|
238 |
|
|
if (packetPosition < 20) then
|
239 |
|
|
packetContent <=
|
240 |
|
|
packetContent(31 downto 0) & readContentData_i;
|
241 |
|
|
elsif (packetPosition = 20) then
|
242 |
|
|
packetContent <=
|
243 |
|
|
packetContent(31 downto 0) & readContentData_i(15 downto 0) & x"0000";
|
244 |
|
|
else
|
245 |
|
|
packetContent <=
|
246 |
|
|
packetContent(15 downto 0) & readContentData_i & x"0000";
|
247 |
|
|
end if;
|
248 |
|
|
|
249 |
|
|
if (readContentEnd_i = '0') then
|
250 |
|
|
readContent_o <= '1';
|
251 |
|
|
else
|
252 |
|
|
readFrame_o <= '1';
|
253 |
|
|
state <= FORWARD_LAST;
|
254 |
|
|
end if;
|
255 |
|
|
end if;
|
256 |
|
|
|
257 |
|
|
when FORWARD_LAST =>
|
258 |
|
|
---------------------------------------------------------------------
|
259 |
|
|
--
|
260 |
|
|
---------------------------------------------------------------------
|
261 |
35 |
magro732 |
-- REMARK: The last always contain the CRC?
|
262 |
33 |
magro732 |
if (masterAck_i = '1') then
|
263 |
35 |
magro732 |
masterSel_o <= x"1111";
|
264 |
|
|
masterDat_o <= packetContent(63 downto 32);
|
265 |
33 |
magro732 |
state <= END_PACKET;
|
266 |
|
|
end if;
|
267 |
|
|
|
268 |
|
|
when END_PACKET =>
|
269 |
|
|
---------------------------------------------------------------------
|
270 |
|
|
--
|
271 |
|
|
---------------------------------------------------------------------
|
272 |
|
|
if (masterAck_i = '1') then
|
273 |
|
|
state <= IDLE;
|
274 |
|
|
end if;
|
275 |
|
|
|
276 |
|
|
when others =>
|
277 |
|
|
---------------------------------------------------------------------
|
278 |
|
|
--
|
279 |
|
|
---------------------------------------------------------------------
|
280 |
|
|
state <= IDLE;
|
281 |
|
|
end case;
|
282 |
|
|
end if;
|
283 |
|
|
end process;
|
284 |
|
|
|
285 |
|
|
end architecture;
|
286 |
|
|
|
287 |
|
|
|
288 |
34 |
magro732 |
-------------------------------------------------------------------------------
|
289 |
|
|
-- RioLogicalCommonEgress.
|
290 |
|
|
-- Only 8-bit and 16-bit deviceId are supported. The first write must contain
|
291 |
|
|
-- the 16-bit header, the second write must contain the destination address and
|
292 |
|
|
-- the third must contain the source address.
|
293 |
|
|
-- CRC is calculated during the transfer and inserted at byte 81 and 82 and
|
294 |
|
|
-- appended to the packet when it ends.
|
295 |
|
|
-- slaveSelect_i - four bits indicating valid bytes in slaveData_i.
|
296 |
|
|
-------------------------------------------------------------------------------
|
297 |
|
|
library ieee;
|
298 |
|
|
use ieee.std_logic_1164.all;
|
299 |
|
|
use ieee.numeric_std.all;
|
300 |
|
|
use work.rio_common.all;
|
301 |
33 |
magro732 |
|
302 |
34 |
magro732 |
-------------------------------------------------------------------------------
|
303 |
|
|
-- Entity for RioLogicalCommonEgress.
|
304 |
|
|
-------------------------------------------------------------------------------
|
305 |
|
|
entity RioLogicalCommonEgress is
|
306 |
|
|
port(
|
307 |
|
|
clk : in std_logic;
|
308 |
|
|
areset_n : in std_logic;
|
309 |
33 |
magro732 |
|
310 |
34 |
magro732 |
writeFrameFull_i : in std_logic;
|
311 |
|
|
writeFrame_o : out std_logic;
|
312 |
|
|
writeFrameAbort_o : out std_logic;
|
313 |
|
|
writeContent_o : out std_logic;
|
314 |
|
|
writeContentData_o : out std_logic_vector(31 downto 0);
|
315 |
|
|
|
316 |
|
|
slaveCyc_i : in std_logic;
|
317 |
|
|
slaveStb_i : in std_logic;
|
318 |
|
|
slaveSel_i : in std_logic_vector(3 downto 0);
|
319 |
|
|
slaveDat_i : in std_logic_vector(31 downto 0);
|
320 |
|
|
slaveAck_o : out std_logic);
|
321 |
|
|
end entity;
|
322 |
|
|
|
323 |
|
|
|
324 |
33 |
magro732 |
-------------------------------------------------------------------------------
|
325 |
34 |
magro732 |
-- Architecture for RioLogicalCommonEgress.
|
326 |
|
|
-------------------------------------------------------------------------------
|
327 |
|
|
architecture RioLogicalCommonEgress of RioLogicalCommonEgress is
|
328 |
|
|
|
329 |
|
|
component Crc16CITT is
|
330 |
|
|
port(
|
331 |
|
|
d_i : in std_logic_vector(15 downto 0);
|
332 |
|
|
crc_i : in std_logic_vector(15 downto 0);
|
333 |
|
|
crc_o : out std_logic_vector(15 downto 0));
|
334 |
|
|
end component;
|
335 |
|
|
|
336 |
|
|
signal crc16Current, crc16Temp, crc16Next: std_logic_vector(15 downto 0);
|
337 |
|
|
|
338 |
|
|
begin
|
339 |
|
|
|
340 |
|
|
process(clk, areset_n)
|
341 |
|
|
begin
|
342 |
|
|
if (areset_n = '0') then
|
343 |
|
|
crc16Current <= x"0000";
|
344 |
|
|
writeContentData <= (others=>'0');
|
345 |
|
|
elsif (clk'event and clk = '1') then
|
346 |
|
|
writeContent_o <= '0';
|
347 |
|
|
writeFrame_o <= '0';
|
348 |
|
|
|
349 |
|
|
case state is
|
350 |
|
|
when IDLE =>
|
351 |
|
|
---------------------------------------------------------------------
|
352 |
|
|
--
|
353 |
|
|
---------------------------------------------------------------------
|
354 |
35 |
magro732 |
packetPosition <= 0;
|
355 |
34 |
magro732 |
if (writeFrameFull_i = '0') then
|
356 |
|
|
state <= HEADER_GET;
|
357 |
|
|
crc16Current <= x"ffff";
|
358 |
|
|
end if;
|
359 |
|
|
|
360 |
|
|
when GET_HEADER =>
|
361 |
|
|
---------------------------------------------------------------------
|
362 |
|
|
--
|
363 |
|
|
---------------------------------------------------------------------
|
364 |
|
|
if ((slaveCyc_i = '1') and (slaveStb_i = '1')) then
|
365 |
|
|
-- REMARK: Only support the header in one position?
|
366 |
|
|
if (slaveSelect_i = "1100") then
|
367 |
|
|
header <= slaveData_i(31 downto 16);
|
368 |
|
|
tt <= slaveData_i(21 downto 20);
|
369 |
|
|
elsif (slaveSelect_i = "0110") then
|
370 |
|
|
header <= slaveData_i(23 downto 8);
|
371 |
|
|
tt <= slaveData_i(13 downto 12);
|
372 |
|
|
elsif (slaveSelect_i = "0011") then
|
373 |
|
|
header <= slaveData_i(15 downto 0);
|
374 |
|
|
tt <= slaveData_i(5 downto 4);
|
375 |
|
|
else
|
376 |
35 |
magro732 |
-- REMARK: Not supported.
|
377 |
34 |
magro732 |
end if;
|
378 |
|
|
|
379 |
|
|
slaveAck_o <= '1';
|
380 |
|
|
|
381 |
|
|
state <= HEADER_ACK;
|
382 |
|
|
else
|
383 |
|
|
state <= RESTART_FRAME;
|
384 |
|
|
end if;
|
385 |
|
|
|
386 |
|
|
when HEADER_ACK =>
|
387 |
|
|
---------------------------------------------------------------------
|
388 |
|
|
--
|
389 |
|
|
---------------------------------------------------------------------
|
390 |
|
|
slaveAck_o <= '0';
|
391 |
|
|
state <= DESTINATION_GET;
|
392 |
|
|
|
393 |
|
|
when DESTINATION_GET =>
|
394 |
|
|
---------------------------------------------------------------------
|
395 |
|
|
--
|
396 |
|
|
---------------------------------------------------------------------
|
397 |
|
|
|
398 |
|
|
if ((slaveCyc_i = '1') and (slaveStb_i = '1')) then
|
399 |
|
|
-- REMARK: Only support the destination in one position?
|
400 |
|
|
if (slaveSelect_i = "1000") and (tt = "00") then
|
401 |
|
|
dstAddr <= slaveData_i(31 downto 24);
|
402 |
|
|
elsif (slaveSelect_i = "0100") and (tt = "00") then
|
403 |
|
|
dstAddr <= slaveData_i(23 downto 16);
|
404 |
|
|
elsif (slaveSelect_i = "0010") and (tt = "00") then
|
405 |
|
|
dstAddr <= slaveData_i(15 downto 8);
|
406 |
|
|
elsif (slaveSelect_i = "0001") and (tt = "00") then
|
407 |
|
|
dstAddr <= slaveData_i(7 downto 0);
|
408 |
|
|
elsif (slaveSelect_i = "1100") and (tt = "01") then
|
409 |
|
|
writeContent_o <= '1';
|
410 |
|
|
writeContentData <= header & slaveData_i(31 downto 16);
|
411 |
|
|
packetPosition <= packetPosition + 1;
|
412 |
|
|
elsif (slaveSelect_i = "0110") and (tt = "01") then
|
413 |
|
|
writeContent_o <= '1';
|
414 |
|
|
writeContentData <= header & slaveData_i(24 downto 8);
|
415 |
|
|
packetPosition <= packetPosition + 1;
|
416 |
|
|
elsif (slaveSelect_i = "0011") and (tt = "01") then
|
417 |
|
|
writeContent_o <= '1';
|
418 |
|
|
writeContentData <= header & slaveData_i(15 downto 0);
|
419 |
|
|
packetPosition <= packetPosition + 1;
|
420 |
|
|
else
|
421 |
|
|
-- REMARK: Not supported.
|
422 |
|
|
end if;
|
423 |
|
|
|
424 |
|
|
slaveAck_o <= '1';
|
425 |
|
|
|
426 |
|
|
state <= DESTINATION_ACK;
|
427 |
|
|
else
|
428 |
|
|
state <= RESTART_FRAME;
|
429 |
|
|
end if;
|
430 |
|
|
|
431 |
|
|
when DESTINATION_ACK =>
|
432 |
|
|
---------------------------------------------------------------------
|
433 |
|
|
--
|
434 |
|
|
---------------------------------------------------------------------
|
435 |
|
|
slaveAck_o <= '0';
|
436 |
|
|
state <= SOURCE_GET;
|
437 |
|
|
|
438 |
|
|
when SOURCE_GET =>
|
439 |
|
|
---------------------------------------------------------------------
|
440 |
|
|
--
|
441 |
|
|
---------------------------------------------------------------------
|
442 |
|
|
|
443 |
|
|
if ((slaveCyc_i = '1') and (slaveStb_i = '1')) then
|
444 |
|
|
-- REMARK: Only support the source in one position?
|
445 |
|
|
if (slaveSelect_i = "1000") and (tt = "00") then
|
446 |
|
|
halfWordPending <= '0';
|
447 |
|
|
writeContent_o <= '1';
|
448 |
|
|
writeContentData <= header & dstAddr & slaveData_i(31 downto 24);
|
449 |
|
|
packetPosition <= packetPosition + 1;
|
450 |
|
|
elsif (slaveSelect_i = "0100") and (tt = "00") then
|
451 |
|
|
halfWordPending <= '0';
|
452 |
|
|
writeContent_o <= '1';
|
453 |
|
|
writeContentData <= header & dstAddr & slaveData_i(23 downto 16);
|
454 |
|
|
packetPosition <= packetPosition + 1;
|
455 |
|
|
elsif (slaveSelect_i = "0010") and (tt = "00") then
|
456 |
|
|
halfWordPending <= '0';
|
457 |
|
|
writeContent_o <= '1';
|
458 |
|
|
writeContentData <= header & dstAddr & slaveData_i(15 downto 8);
|
459 |
|
|
packetPosition <= packetPosition + 1;
|
460 |
|
|
elsif (slaveSelect_i = "0001") and (tt = "00") then
|
461 |
|
|
halfWordPending <= '0';
|
462 |
|
|
writeContent_o <= '1';
|
463 |
|
|
writeContentData <= header & dstAddr & slaveData_i(7 downto 0);
|
464 |
|
|
packetPosition <= packetPosition + 1;
|
465 |
|
|
elsif (slaveSelect_i = "1100") and (tt = "01") then
|
466 |
|
|
halfWordPending <= '1';
|
467 |
|
|
halfWord <= slaveData_i(31 downto 16);
|
468 |
|
|
elsif (slaveSelect_i = "0110") and (tt = "01") then
|
469 |
|
|
halfWordPending <= '1';
|
470 |
|
|
halfWord <= slaveData_i(24 downto 8);
|
471 |
|
|
elsif (slaveSelect_i = "0011") and (tt = "01") then
|
472 |
|
|
halfWordPending <= '1';
|
473 |
|
|
halfWord <= slaveData_i(15 downto 0);
|
474 |
|
|
else
|
475 |
|
|
-- REMARK: Not supported.
|
476 |
|
|
end if;
|
477 |
|
|
|
478 |
|
|
slaveAck_o <= '1';
|
479 |
|
|
|
480 |
|
|
state <= SOURCE_ACK;
|
481 |
|
|
else
|
482 |
|
|
state <= RESTART_FRAME;
|
483 |
|
|
end if;
|
484 |
|
|
|
485 |
|
|
when SOURCE_ACK =>
|
486 |
|
|
---------------------------------------------------------------------
|
487 |
|
|
--
|
488 |
|
|
---------------------------------------------------------------------
|
489 |
|
|
slaveAck_o <= '0';
|
490 |
|
|
|
491 |
|
|
if (tt = "00") then
|
492 |
|
|
crcCurrent <= crcNext;
|
493 |
|
|
end if;
|
494 |
|
|
|
495 |
|
|
state <= CONTENT_GET;
|
496 |
|
|
|
497 |
|
|
when CONTENT_GET =>
|
498 |
|
|
---------------------------------------------------------------------
|
499 |
|
|
--
|
500 |
|
|
---------------------------------------------------------------------
|
501 |
|
|
if ((slaveCyc_i = '1') and (slaveStb_i = '1')) then
|
502 |
|
|
-- REMARK: Only support full writes? Not possible with the last
|
503 |
|
|
-- access though.
|
504 |
|
|
if (slaveSelect_i = "1111") then
|
505 |
|
|
if (halfWordPending = '0') then
|
506 |
|
|
writeContent_o <= '1';
|
507 |
|
|
writeContentData <= slaveData_i;
|
508 |
|
|
packetPosition <= packetPosition + 1;
|
509 |
|
|
else
|
510 |
|
|
writeContent_o <= '1';
|
511 |
|
|
writeContentData <= halfWord & slaveData_i(31 downto 16);
|
512 |
|
|
packetPosition <= packetPosition + 1;
|
513 |
|
|
halfWord <= slaveData_i(15 downto 0);
|
514 |
|
|
end if;
|
515 |
|
|
elsif (slaveSelect_i = "1100") then
|
516 |
|
|
if (halfWordPending = '0') then
|
517 |
|
|
halfWordPending <= '1';
|
518 |
|
|
halfWord <= slaveData_i(31 downto 16);
|
519 |
|
|
else
|
520 |
|
|
writeContent_o <= '1';
|
521 |
|
|
writeContentData <= halfWord & slaveData_i(31 downto 16);
|
522 |
|
|
packetPosition <= packetPosition + 1;
|
523 |
|
|
halfWordPending <= '0';
|
524 |
|
|
end if;
|
525 |
|
|
elsif (slaveSelect_i = "0011") then
|
526 |
|
|
if (halfWordPending = '0') then
|
527 |
|
|
halfWordPending <= '1';
|
528 |
|
|
halfWord <= slaveData_i(15 downto 0);
|
529 |
|
|
else
|
530 |
|
|
writeContent_o <= '1';
|
531 |
|
|
writeContentData <= halfWord & slaveData_i(15 downto 0);
|
532 |
|
|
packetPosition <= packetPosition + 1;
|
533 |
|
|
halfWordPending <= '0';
|
534 |
|
|
end if;
|
535 |
|
|
end if;
|
536 |
|
|
|
537 |
|
|
slaveAck_o <= '1';
|
538 |
|
|
|
539 |
|
|
state <= CONTENT_ACK;
|
540 |
|
|
else
|
541 |
|
|
state <= CRC_APPEND;
|
542 |
|
|
end if;
|
543 |
|
|
|
544 |
|
|
when CONTENT_ACK =>
|
545 |
|
|
---------------------------------------------------------------------
|
546 |
|
|
--
|
547 |
|
|
---------------------------------------------------------------------
|
548 |
|
|
slaveAck_o <= '0';
|
549 |
|
|
|
550 |
|
|
crc16Current <= crc16Next;
|
551 |
|
|
|
552 |
|
|
if (packetPosition = 20) then
|
553 |
|
|
if (halfWordPending = '0') then
|
554 |
|
|
halfWordPending <= '1';
|
555 |
|
|
halfWord <= crc16Next;
|
556 |
|
|
else
|
557 |
|
|
-- REMARK: The current CRC has to be updated when this is written.
|
558 |
|
|
writeContent_o <= '1';
|
559 |
|
|
writeContentData <= halfWord & crc16Next;
|
560 |
|
|
packetPosition <= packetPosition + 1;
|
561 |
|
|
halfWordPending <= '0';
|
562 |
|
|
halfWord <= crc16Next;
|
563 |
|
|
end if;
|
564 |
|
|
end if;
|
565 |
|
|
|
566 |
|
|
state <= CONTENT_GET;
|
567 |
|
|
|
568 |
|
|
when CRC_APPEND =>
|
569 |
|
|
---------------------------------------------------------------------
|
570 |
|
|
--
|
571 |
|
|
---------------------------------------------------------------------
|
572 |
|
|
if (halfWordPending = '0') then
|
573 |
|
|
writeContent_o <= '1';
|
574 |
|
|
writeContentData <= crc16Current & x"0000";
|
575 |
|
|
packetPosition <= packetPosition + 1;
|
576 |
|
|
else
|
577 |
|
|
writeContent_o <= '1';
|
578 |
|
|
writeContentData <= halfWord & crc16Current;
|
579 |
|
|
packetPosition <= packetPosition + 1;
|
580 |
|
|
end if;
|
581 |
|
|
|
582 |
|
|
state <= SEND_FRAME;
|
583 |
|
|
|
584 |
|
|
when SEND_FRAME =>
|
585 |
|
|
---------------------------------------------------------------------
|
586 |
|
|
--
|
587 |
|
|
---------------------------------------------------------------------
|
588 |
|
|
writeFrame_o <= '1';
|
589 |
|
|
state <= WAIT_UPDATE;
|
590 |
|
|
|
591 |
|
|
when RESTART_FRAME =>
|
592 |
|
|
---------------------------------------------------------------------
|
593 |
|
|
--
|
594 |
|
|
---------------------------------------------------------------------
|
595 |
|
|
writeFrameAbort_o <= '1';
|
596 |
|
|
state <= WAIT_UPDATE;
|
597 |
|
|
|
598 |
|
|
when WAIT_UPDATE =>
|
599 |
|
|
---------------------------------------------------------------------
|
600 |
|
|
--
|
601 |
|
|
---------------------------------------------------------------------
|
602 |
|
|
state <= IDLE;
|
603 |
|
|
|
604 |
|
|
when others =>
|
605 |
|
|
---------------------------------------------------------------------
|
606 |
|
|
--
|
607 |
|
|
---------------------------------------------------------------------
|
608 |
|
|
end case;
|
609 |
|
|
end if;
|
610 |
|
|
end process;
|
611 |
|
|
|
612 |
|
|
-----------------------------------------------------------------------------
|
613 |
|
|
-- Packet CRC calculation.
|
614 |
|
|
-----------------------------------------------------------------------------
|
615 |
|
|
|
616 |
|
|
Crc16High: Crc16CITT
|
617 |
|
|
port map(
|
618 |
|
|
d_i=>writeContentData(31 downto 16), crc_i=>crc16Current, crc_o=>crc16Temp);
|
619 |
|
|
Crc16Low: Crc16CITT
|
620 |
|
|
port map(
|
621 |
|
|
d_i=>writeContentData(15 downto 0), crc_i=>crc16Temp, crc_o=>crc16Next);
|
622 |
|
|
|
623 |
|
|
end architecture;
|
624 |
|
|
|
625 |
|
|
|
626 |
|
|
|
627 |
|
|
|
628 |
|
|
|
629 |
|
|
-------------------------------------------------------------------------------
|
630 |
33 |
magro732 |
-- RioLogicalMaintenanceRequest
|
631 |
34 |
magro732 |
-- This logical layer module handles ingress maintenance requests.
|
632 |
33 |
magro732 |
-- Addresses: 0x80 (maint read request) and 0x81 (maint write request).
|
633 |
|
|
-------------------------------------------------------------------------------
|
634 |
|
|
library ieee;
|
635 |
|
|
use ieee.std_logic_1164.all;
|
636 |
34 |
magro732 |
use ieee.numeric_std.all;
|
637 |
33 |
magro732 |
use work.rio_common.all;
|
638 |
|
|
|
639 |
35 |
magro732 |
|
640 |
33 |
magro732 |
-------------------------------------------------------------------------------
|
641 |
|
|
-- Entity for RioLogicalMaintenanceRequest.
|
642 |
|
|
-------------------------------------------------------------------------------
|
643 |
|
|
entity RioLogicalMaintenanceRequest is
|
644 |
|
|
generic(
|
645 |
|
|
DEVICE_IDENTITY : std_logic_vector(15 downto 0);
|
646 |
|
|
DEVICE_VENDOR_IDENTITY : std_logic_vector(15 downto 0);
|
647 |
|
|
DEVICE_REV : std_logic_vector(31 downto 0);
|
648 |
|
|
ASSY_IDENTITY : std_logic_vector(15 downto 0);
|
649 |
|
|
ASSY_VENDOR_IDENTITY : std_logic_vector(15 downto 0);
|
650 |
|
|
ASSY_REV : std_logic_vector(15 downto 0);
|
651 |
|
|
DEFAULT_BASE_DEVICE_ID : std_logic_vector(15 downto 0) := x"ffff");
|
652 |
|
|
port(
|
653 |
|
|
clk : in std_logic;
|
654 |
|
|
areset_n : in std_logic;
|
655 |
|
|
|
656 |
35 |
magro732 |
configStb_o : out std_logic;
|
657 |
|
|
configWe_o : out std_logic;
|
658 |
|
|
configAdr_o : out std_logic_vector(23 downto 0);
|
659 |
|
|
configDat_o : out std_logic_vector(63 downto 0);
|
660 |
|
|
configSel_o : out std_logic_vector(7 downto 0);
|
661 |
|
|
configDat_i : in std_logic_vector(63 downto 0);
|
662 |
|
|
configAck_i : in std_logic;
|
663 |
|
|
|
664 |
33 |
magro732 |
slaveCyc_i : in std_logic;
|
665 |
|
|
slaveStb_i : in std_logic;
|
666 |
34 |
magro732 |
slaveAdr_i : in std_logic_vector(7 downto 0);
|
667 |
|
|
slaveDat_i : in std_logic_vector(31 downto 0);
|
668 |
|
|
slaveAck_o : out std_logic;
|
669 |
|
|
|
670 |
|
|
masterCyc_o : out std_logic;
|
671 |
|
|
masterStb_o : out std_logic;
|
672 |
|
|
masterDat_o : out std_logic_vector(31 downto 0);
|
673 |
|
|
masterAck_i : in std_logic);
|
674 |
33 |
magro732 |
end entity;
|
675 |
|
|
|
676 |
35 |
magro732 |
|
677 |
|
|
-------------------------------------------------------------------------------
|
678 |
|
|
--
|
679 |
|
|
-------------------------------------------------------------------------------
|
680 |
33 |
magro732 |
architecture RioLogicalMaintenanceRequest of RioLogicalMaintenanceRequest is
|
681 |
35 |
magro732 |
component MemorySinglePort is
|
682 |
|
|
generic(
|
683 |
|
|
ADDRESS_WIDTH : natural := 1;
|
684 |
|
|
DATA_WIDTH : natural := 1);
|
685 |
|
|
port(
|
686 |
|
|
clk_i : in std_logic;
|
687 |
|
|
enable_i : in std_logic;
|
688 |
|
|
writeEnable_i : in std_logic;
|
689 |
|
|
address_i : in std_logic_vector(ADDRESS_WIDTH-1 downto 0);
|
690 |
|
|
data_i : in std_logic_vector(DATA_WIDTH-1 downto 0);
|
691 |
|
|
data_o : out std_logic_vector(DATA_WIDTH-1 downto 0));
|
692 |
|
|
end component;
|
693 |
33 |
magro732 |
|
694 |
|
|
begin
|
695 |
|
|
|
696 |
|
|
slaveAck_o <= slaveAck;
|
697 |
|
|
MaintenanceRequest: process(clk, areset_n)
|
698 |
|
|
begin
|
699 |
|
|
if (areset_n = '0') then
|
700 |
|
|
|
701 |
|
|
elsif (clk'event and clk = '1') then
|
702 |
35 |
magro732 |
case state is
|
703 |
|
|
when WAIT_PACKET =>
|
704 |
|
|
---------------------------------------------------------------------
|
705 |
|
|
--
|
706 |
|
|
---------------------------------------------------------------------
|
707 |
|
|
if (slaveCyc_i = '1') then
|
708 |
|
|
if (slaveAck = '0') then
|
709 |
|
|
if (slaveStb_i = '1') then
|
710 |
|
|
if (slaveAddress_i = x"80") then
|
711 |
|
|
-- Maintenance read request.
|
712 |
|
|
case (packetIndex) is
|
713 |
|
|
when 0 =>
|
714 |
|
|
-- x"0000" & ackid & vc & crf & prio & tt & ftype
|
715 |
|
|
header <= slaveDat_i(15 downto 0);
|
716 |
|
|
when 1 =>
|
717 |
|
|
-- destId
|
718 |
|
|
destId <= slaveDat_i;
|
719 |
|
|
when 2 =>
|
720 |
|
|
-- srcId
|
721 |
|
|
srcId <= slaveDat_i;
|
722 |
|
|
when 3 =>
|
723 |
|
|
-- transaction & rdsize & srcTID & hop & config_offset(20:13)
|
724 |
|
|
size <= slaveDat_i(27 downto 24);
|
725 |
|
|
srcTid <= slaveDat_i(23 downto 16);
|
726 |
|
|
configOffset(20 downto 13) <= slaveDat_i(7 downto 0);
|
727 |
|
|
when 4 =>
|
728 |
|
|
-- config_offset(12:0) & wdptr & rsrv & crc(15:0)
|
729 |
|
|
configOffset(12 downto 0) <= slaveDat_i(31 downto 16);
|
730 |
|
|
wdptr <= slaveDat_i(18);
|
731 |
|
|
maintReadComplete <= '1';
|
732 |
|
|
when others =>
|
733 |
|
|
-- There should be no more content in a maintenance read request.
|
734 |
|
|
-- Discard.
|
735 |
|
|
end case;
|
736 |
|
|
elsif (slaveAddress_i = x"81") then
|
737 |
|
|
-- Maintenance write request.
|
738 |
|
|
case (packetIndex) is
|
739 |
|
|
when 0 =>
|
740 |
|
|
-- x"0000" & ackid & vc & crf & prio & tt & ftype
|
741 |
|
|
header <= slaveDat_i(15 downto 0);
|
742 |
|
|
when 1 =>
|
743 |
|
|
-- destId
|
744 |
|
|
destId <= slaveDat_i;
|
745 |
|
|
when 2 =>
|
746 |
|
|
-- srcId
|
747 |
|
|
srcId <= slaveDat_i;
|
748 |
|
|
when 3 =>
|
749 |
|
|
-- transaction & wrsize & srcTID & hop & config_offset(20:13)
|
750 |
|
|
size <= slaveDat_i(27 downto 24);
|
751 |
|
|
srcTid <= slaveDat_i(23 downto 16);
|
752 |
|
|
configOffset(20 downto 13) <= slaveDat_i(7 downto 0);
|
753 |
|
|
when 4 =>
|
754 |
|
|
-- config_offset(12:0) & wdptr & rsrv & double-word(63:48)
|
755 |
|
|
configOffset(12 downto 0) <= slaveDat_i(31 downto 16);
|
756 |
|
|
configData(63 downto 48) <= slaveData_i(15 downto 0);
|
757 |
|
|
wdptr <= slaveDat_i(18);
|
758 |
|
|
memoryEnable <= '1';
|
759 |
|
|
memoryAddress <= 0;
|
760 |
|
|
when 5 | 7 | 9 | 11 | 13 | 15 | 17 | 19 | 21 | 23 | 25 | 27 | 29 | 31 =>
|
761 |
|
|
-- double-word(47:16)
|
762 |
|
|
configData(47 downto 16) <= slaveData_i;
|
763 |
|
|
when 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 | 22 | 24 | 26 | 28 | 30 =>
|
764 |
|
|
-- double-word(15:0) & double-word(63:48)
|
765 |
|
|
memoryAddress <= memoryAddress + 1;
|
766 |
|
|
memoryWrite <= '1';
|
767 |
|
|
memoryDataIn <= configData(63 downto 16) & slaveData_i(31 downto 16);
|
768 |
|
|
configData(63 downto 48) <= slaveData_i(15 downto 0);
|
769 |
|
|
maintWriteComplete <= '1';
|
770 |
|
|
when others =>
|
771 |
|
|
-- There should be no more content in a maintenance read request.
|
772 |
|
|
-- Discard.
|
773 |
|
|
end case;
|
774 |
|
|
end if;
|
775 |
|
|
slaveAck <= '1';
|
776 |
|
|
end if;
|
777 |
|
|
else
|
778 |
|
|
packetIndex <= packetIndex + 1;
|
779 |
|
|
slaveAck <= '0';
|
780 |
|
|
end if;
|
781 |
|
|
else
|
782 |
|
|
if (maintReadComplete = '1') then
|
783 |
|
|
state <= CONFIG_READ;
|
784 |
|
|
configIterator <= bytes;
|
785 |
|
|
memoryEnable <= '1';
|
786 |
|
|
memoryAddress <= 0;
|
787 |
|
|
end if;
|
788 |
|
|
if (maintWriteComplete = '1') then
|
789 |
|
|
state <= CONFIG_WRITE;
|
790 |
|
|
end if;
|
791 |
|
|
packetIndex <= 0;
|
792 |
|
|
maintReadComplete <= '0';
|
793 |
|
|
maintWriteComplete <= '0';
|
794 |
|
|
end if;
|
795 |
|
|
|
796 |
|
|
when CONFIG_READ =>
|
797 |
|
|
---------------------------------------------------------------------
|
798 |
|
|
--
|
799 |
|
|
---------------------------------------------------------------------
|
800 |
|
|
configStb_o <= '1';
|
801 |
|
|
configWe_o <= '0';
|
802 |
|
|
configAdr_o <= configOffset;
|
803 |
|
|
configSel_o <= byteLanes;
|
804 |
|
|
configIterator <= configIterator - 1;
|
805 |
|
|
configSpaceState <= CONFIG_READ_ACK;
|
806 |
|
|
|
807 |
|
|
when CONFIG_READ_ACK =>
|
808 |
|
|
---------------------------------------------------------------------
|
809 |
|
|
--
|
810 |
|
|
---------------------------------------------------------------------
|
811 |
|
|
if (configAck_i = '1') then
|
812 |
|
|
memoryAddress <= memoryAddress + 1;
|
813 |
|
|
memoryWrite <= '1';
|
814 |
|
|
memoryDataIn <= configSpaceDat_i;
|
815 |
|
|
|
816 |
|
|
if (configIterator /= 0) then
|
817 |
|
|
configAdr_o <= configAdr_o + 1;
|
818 |
|
|
state <= CONFIG_READ;
|
819 |
|
|
else
|
820 |
|
|
configStb_o <= '0';
|
821 |
|
|
packetIndex <= 0;
|
822 |
|
|
state <= CONFIG_READ_RESPONSE;
|
823 |
|
|
end if;
|
824 |
|
|
end if;
|
825 |
|
|
|
826 |
|
|
when CONFIG_READ_RESPONSE =>
|
827 |
|
|
---------------------------------------------------------------------
|
828 |
|
|
--
|
829 |
|
|
---------------------------------------------------------------------
|
830 |
|
|
masterCyc_o <= '1';
|
831 |
|
|
masterStb_o <= '1';
|
832 |
|
|
masterDat_o <= header;
|
833 |
|
|
packetIndex <= packetIndex + 1;
|
834 |
|
|
state <= CONFIG_READ_RESPONSE_ACK;
|
835 |
|
|
|
836 |
|
|
when CONFIG_READ_RESPONSE_ACK =>
|
837 |
|
|
---------------------------------------------------------------------
|
838 |
|
|
--
|
839 |
|
|
---------------------------------------------------------------------
|
840 |
|
|
if (masterAck_i = '1') then
|
841 |
|
|
masterCyc_o <= '1';
|
842 |
|
|
masterStb_o <= '1';
|
843 |
33 |
magro732 |
case (packetIndex) is
|
844 |
|
|
when 0 =>
|
845 |
|
|
-- x"0000" & ackid & vc & crf & prio & tt & ftype
|
846 |
35 |
magro732 |
masterDat_o <= header;
|
847 |
33 |
magro732 |
when 1 =>
|
848 |
35 |
magro732 |
-- destination is the source.
|
849 |
|
|
masterDat_o <= srcId;
|
850 |
33 |
magro732 |
when 2 =>
|
851 |
35 |
magro732 |
-- source is the destination.
|
852 |
|
|
masterDat_o <= destId;
|
853 |
33 |
magro732 |
when 3 =>
|
854 |
35 |
magro732 |
-- transaction & status & targetTID & hop & reserved(7:0)
|
855 |
|
|
masterDat_o <= "0010" & "0000" & srcTid & x"ff" & x"00";
|
856 |
33 |
magro732 |
when 4 =>
|
857 |
35 |
magro732 |
-- reserved(15:0) & double-word0(63:32)
|
858 |
|
|
masterDat_o <= x"0000" & memoryDataOut(63 downto 32);
|
859 |
34 |
magro732 |
when 5 =>
|
860 |
35 |
magro732 |
masterDat_o <= memoryDataOut(31 downto 0) & x"0000";
|
861 |
|
|
-- REMARK: Add more here to send the full response...
|
862 |
33 |
magro732 |
when others =>
|
863 |
35 |
magro732 |
state <= WAIT_PACKET;
|
864 |
33 |
magro732 |
end case;
|
865 |
35 |
magro732 |
packetIndex <= packetIndex + 1;
|
866 |
33 |
magro732 |
end if;
|
867 |
35 |
magro732 |
|
868 |
|
|
when CONFIG_WRITE =>
|
869 |
|
|
---------------------------------------------------------------------
|
870 |
|
|
--
|
871 |
|
|
---------------------------------------------------------------------
|
872 |
|
|
|
873 |
|
|
when others =>
|
874 |
|
|
|
875 |
|
|
end case;
|
876 |
33 |
magro732 |
end if;
|
877 |
|
|
end process;
|
878 |
|
|
|
879 |
35 |
magro732 |
-----------------------------------------------------------------------------
|
880 |
|
|
--
|
881 |
|
|
-----------------------------------------------------------------------------
|
882 |
|
|
-- REMARK: Make this a common component?
|
883 |
|
|
-- REMARK: Change bytes to double-words?
|
884 |
|
|
process(wdptr, size)
|
885 |
|
|
begin
|
886 |
|
|
case (wdptr & size) is
|
887 |
|
|
when "00000" =>
|
888 |
|
|
bytes <= 1;
|
889 |
|
|
byteLanes <= "10000000";
|
890 |
|
|
when "00001" =>
|
891 |
|
|
bytes <= 1;
|
892 |
|
|
byteLanes <= "01000000";
|
893 |
|
|
|
894 |
|
|
when "00010" =>
|
895 |
|
|
bytes <= 1;
|
896 |
|
|
byteLanes <= "00100000";
|
897 |
|
|
when "00011" =>
|
898 |
|
|
bytes <= 1;
|
899 |
|
|
byteLanes <= "00010000";
|
900 |
|
|
|
901 |
|
|
when "10000" =>
|
902 |
|
|
bytes <= 1;
|
903 |
|
|
byteLanes <= "00001000";
|
904 |
|
|
when "10001" =>
|
905 |
|
|
bytes <= 1;
|
906 |
|
|
byteLanes <= "00000100";
|
907 |
|
|
|
908 |
|
|
when "10010" =>
|
909 |
|
|
bytes <= 1;
|
910 |
|
|
byteLanes <= "00000010";
|
911 |
|
|
when "10011" =>
|
912 |
|
|
bytes <= 1;
|
913 |
|
|
byteLanes <= "00000001";
|
914 |
|
|
|
915 |
|
|
when "00100" =>
|
916 |
|
|
bytes <= 2;
|
917 |
|
|
byteLanes <= "11000000";
|
918 |
|
|
when "00101" =>
|
919 |
|
|
bytes <= 3;
|
920 |
|
|
byteLanes <= "11100000";
|
921 |
|
|
|
922 |
|
|
when "00110" =>
|
923 |
|
|
bytes <= 2;
|
924 |
|
|
byteLanes <= "00110000";
|
925 |
|
|
when "00111" =>
|
926 |
|
|
bytes <= 5;
|
927 |
|
|
byteLanes <= "11111000";
|
928 |
|
|
|
929 |
|
|
when "10100" =>
|
930 |
|
|
bytes <= 2;
|
931 |
|
|
byteLanes <= "00001100";
|
932 |
|
|
when "10101" =>
|
933 |
|
|
bytes <= 3;
|
934 |
|
|
byteLanes <= "00000111";
|
935 |
|
|
|
936 |
|
|
when "10110" =>
|
937 |
|
|
bytes <= 2;
|
938 |
|
|
byteLanes <= "00000011";
|
939 |
|
|
when "10111" =>
|
940 |
|
|
bytes <= 5;
|
941 |
|
|
byteLanes <= "00011111";
|
942 |
|
|
|
943 |
|
|
when "01000" =>
|
944 |
|
|
bytes <= 4;
|
945 |
|
|
byteLanes <= "11110000";
|
946 |
|
|
when "11000" =>
|
947 |
|
|
bytes <= 4;
|
948 |
|
|
byteLanes <= "00001111";
|
949 |
|
|
|
950 |
|
|
when "01001" =>
|
951 |
|
|
bytes <= 6;
|
952 |
|
|
byteLanes <= "11111100";
|
953 |
|
|
when "11001" =>
|
954 |
|
|
bytes <= 6;
|
955 |
|
|
byteLanes <= "00111111";
|
956 |
|
|
|
957 |
|
|
when "01010" =>
|
958 |
|
|
bytes <= 7;
|
959 |
|
|
byteLanes <= "11111110";
|
960 |
|
|
when "11010" =>
|
961 |
|
|
bytes <= 7;
|
962 |
|
|
byteLanes <= "01111111";
|
963 |
|
|
|
964 |
|
|
when "01011" =>
|
965 |
|
|
bytes <= 8;
|
966 |
|
|
byteLanes <= "11111111";
|
967 |
|
|
when "11011" =>
|
968 |
|
|
bytes <= 16;
|
969 |
|
|
byteLanes <= "11111111";
|
970 |
|
|
|
971 |
|
|
when "01100" =>
|
972 |
|
|
bytes <= 32;
|
973 |
|
|
byteLanes <= "11111111";
|
974 |
|
|
when "11100" =>
|
975 |
|
|
bytes <= 64;
|
976 |
|
|
byteLanes <= "11111111";
|
977 |
|
|
|
978 |
|
|
when "01101" =>
|
979 |
|
|
bytes <= 96;
|
980 |
|
|
byteLanes <= "11111111";
|
981 |
|
|
when "11101" =>
|
982 |
|
|
bytes <= 128;
|
983 |
|
|
byteLanes <= "11111111";
|
984 |
|
|
|
985 |
|
|
when "01110" =>
|
986 |
|
|
bytes <= 160;
|
987 |
|
|
byteLanes <= "11111111";
|
988 |
|
|
when "11110" =>
|
989 |
|
|
bytes <= 192;
|
990 |
|
|
byteLanes <= "11111111";
|
991 |
|
|
|
992 |
|
|
when "01111" =>
|
993 |
|
|
bytes <= 224;
|
994 |
|
|
byteLanes <= "11111111";
|
995 |
|
|
when "11111" =>
|
996 |
|
|
bytes <= 256;
|
997 |
|
|
byteLanes <= "11111111";
|
998 |
33 |
magro732 |
|
999 |
35 |
magro732 |
end case;
|
1000 |
|
|
end process;
|
1001 |
|
|
|
1002 |
|
|
end architecture;
|
1003 |
|
|
|
1004 |
|
|
|
1005 |
|
|
entity MaintenanceReadRequestInbound is
|
1006 |
|
|
port(
|
1007 |
|
|
clk : in std_logic;
|
1008 |
|
|
areset_n : in std_logic;
|
1009 |
|
|
|
1010 |
|
|
slaveCyc_i : in std_logic;
|
1011 |
|
|
slaveStb_i : in std_logic;
|
1012 |
|
|
slaveAdr_i : in std_logic_vector(7 downto 0);
|
1013 |
|
|
slaveDat_i : in std_logic_vector(31 downto 0);
|
1014 |
|
|
slaveAck_o : out std_logic;
|
1015 |
|
|
|
1016 |
|
|
header_o : out std_logic_vector(15 downto 0);
|
1017 |
|
|
dstId_o : out std_logic_vector(31 downto 0);
|
1018 |
|
|
srcId_o : out std_logic_vector(31 downto 0);
|
1019 |
|
|
tid_o : out std_logic_vector(7 downto 0);
|
1020 |
|
|
configOffset_o : out std_logic_vector(21 downto 0);
|
1021 |
|
|
configLength_o : out std_logic_vector(3 downto 0);
|
1022 |
|
|
configSelect_o : out std_logic_vector(7 downto 0);
|
1023 |
|
|
ready_o : out std_logic;
|
1024 |
|
|
done_i : in std_logic);
|
1025 |
|
|
end entity;
|
1026 |
|
|
|
1027 |
|
|
|
1028 |
|
|
architecture MaintenanceReadRequestInbound of MaintenanceReadRequestInbound is
|
1029 |
|
|
|
1030 |
|
|
begin
|
1031 |
|
|
|
1032 |
|
|
ready_o <= maintReadComplete;
|
1033 |
|
|
slaveAck_o <= slaveAck;
|
1034 |
|
|
MaintenanceReadRequest: process(clk, areset_n)
|
1035 |
|
|
begin
|
1036 |
|
|
if (areset_n = '0') then
|
1037 |
|
|
|
1038 |
|
|
elsif (clk'event and clk = '1') then
|
1039 |
|
|
case state is
|
1040 |
|
|
when WAIT_PACKET =>
|
1041 |
|
|
---------------------------------------------------------------------
|
1042 |
|
|
--
|
1043 |
|
|
---------------------------------------------------------------------
|
1044 |
|
|
if (slaveCyc_i = '1') then
|
1045 |
|
|
if (slaveAck = '0') then
|
1046 |
|
|
if (slaveStb_i = '1') then
|
1047 |
|
|
if (slaveAddress_i = x"80") then
|
1048 |
|
|
case (packetIndex) is
|
1049 |
|
|
when 0 =>
|
1050 |
|
|
-- x"0000" & ackid & vc & crf & prio & tt & ftype
|
1051 |
|
|
header <= slaveDat_i(15 downto 0);
|
1052 |
|
|
packetIndex <= packetIndex + 1;
|
1053 |
|
|
when 1 =>
|
1054 |
|
|
-- destid
|
1055 |
|
|
destId <= slaveDat_i;
|
1056 |
|
|
packetIndex <= packetIndex + 1;
|
1057 |
|
|
when 2 =>
|
1058 |
|
|
-- srcid
|
1059 |
|
|
srcId <= slaveDat_i;
|
1060 |
|
|
packetIndex <= packetIndex + 1;
|
1061 |
|
|
when 3 =>
|
1062 |
|
|
-- transaction & rdsize & srcTID & hop & config_offset(20:13)
|
1063 |
|
|
size <= slaveDat_i(27 downto 24);
|
1064 |
|
|
srcTid <= slaveDat_i(23 downto 16);
|
1065 |
|
|
configOffset(20 downto 13) <= slaveDat_i(7 downto 0);
|
1066 |
|
|
packetIndex <= packetIndex + 1;
|
1067 |
|
|
when 4 =>
|
1068 |
|
|
-- config_offset(12:0) & wdptr & rsrv & crc(15:0)
|
1069 |
|
|
configOffset(12 downto 0) <= slaveDat_i(31 downto 16);
|
1070 |
|
|
wdptr <= slaveDat_i(18);
|
1071 |
|
|
packetIndex <= packetIndex + 1;
|
1072 |
|
|
maintReadComplete <= '1';
|
1073 |
|
|
when others =>
|
1074 |
|
|
-- There should be no more content in a maintenance read request.
|
1075 |
|
|
-- Discard.
|
1076 |
|
|
end case;
|
1077 |
|
|
end if;
|
1078 |
|
|
slaveAck <= '1';
|
1079 |
|
|
end if;
|
1080 |
|
|
else
|
1081 |
|
|
slaveAck <= '0';
|
1082 |
|
|
end if;
|
1083 |
|
|
else
|
1084 |
|
|
if (maintReadComplete = '1') then
|
1085 |
|
|
state <= READY;
|
1086 |
|
|
end if;
|
1087 |
|
|
packetIndex <= 0;
|
1088 |
|
|
end if;
|
1089 |
|
|
|
1090 |
|
|
when READY =>
|
1091 |
|
|
---------------------------------------------------------------------
|
1092 |
|
|
--
|
1093 |
|
|
---------------------------------------------------------------------
|
1094 |
|
|
if (done_i = '1') then
|
1095 |
|
|
maintReadComplete <= '0';
|
1096 |
|
|
state <= WAIT_PACKET;
|
1097 |
|
|
end if;
|
1098 |
|
|
|
1099 |
|
|
when others =>
|
1100 |
|
|
|
1101 |
|
|
end case;
|
1102 |
|
|
end if;
|
1103 |
|
|
end process;
|
1104 |
|
|
|
1105 |
33 |
magro732 |
-----------------------------------------------------------------------------
|
1106 |
35 |
magro732 |
--
|
1107 |
33 |
magro732 |
-----------------------------------------------------------------------------
|
1108 |
35 |
magro732 |
-- REMARK: Make this a common component?
|
1109 |
|
|
-- REMARK: Change bytes to double-words?
|
1110 |
|
|
process(wdptr, size)
|
1111 |
33 |
magro732 |
begin
|
1112 |
35 |
magro732 |
case (wdptr & size) is
|
1113 |
|
|
when "00000" =>
|
1114 |
|
|
bytes <= 1;
|
1115 |
|
|
byteLanes <= "10000000";
|
1116 |
|
|
when "00001" =>
|
1117 |
|
|
bytes <= 1;
|
1118 |
|
|
byteLanes <= "01000000";
|
1119 |
|
|
|
1120 |
|
|
when "00010" =>
|
1121 |
|
|
bytes <= 1;
|
1122 |
|
|
byteLanes <= "00100000";
|
1123 |
|
|
when "00011" =>
|
1124 |
|
|
bytes <= 1;
|
1125 |
|
|
byteLanes <= "00010000";
|
1126 |
|
|
|
1127 |
|
|
when "10000" =>
|
1128 |
|
|
bytes <= 1;
|
1129 |
|
|
byteLanes <= "00001000";
|
1130 |
|
|
when "10001" =>
|
1131 |
|
|
bytes <= 1;
|
1132 |
|
|
byteLanes <= "00000100";
|
1133 |
|
|
|
1134 |
|
|
when "10010" =>
|
1135 |
|
|
bytes <= 1;
|
1136 |
|
|
byteLanes <= "00000010";
|
1137 |
|
|
when "10011" =>
|
1138 |
|
|
bytes <= 1;
|
1139 |
|
|
byteLanes <= "00000001";
|
1140 |
|
|
|
1141 |
|
|
when "00100" =>
|
1142 |
|
|
bytes <= 2;
|
1143 |
|
|
byteLanes <= "11000000";
|
1144 |
|
|
when "00101" =>
|
1145 |
|
|
bytes <= 3;
|
1146 |
|
|
byteLanes <= "11100000";
|
1147 |
|
|
|
1148 |
|
|
when "00110" =>
|
1149 |
|
|
bytes <= 2;
|
1150 |
|
|
byteLanes <= "00110000";
|
1151 |
|
|
when "00111" =>
|
1152 |
|
|
bytes <= 5;
|
1153 |
|
|
byteLanes <= "11111000";
|
1154 |
|
|
|
1155 |
|
|
when "10100" =>
|
1156 |
|
|
bytes <= 2;
|
1157 |
|
|
byteLanes <= "00001100";
|
1158 |
|
|
when "10101" =>
|
1159 |
|
|
bytes <= 3;
|
1160 |
|
|
byteLanes <= "00000111";
|
1161 |
|
|
|
1162 |
|
|
when "10110" =>
|
1163 |
|
|
bytes <= 2;
|
1164 |
|
|
byteLanes <= "00000011";
|
1165 |
|
|
when "10111" =>
|
1166 |
|
|
bytes <= 5;
|
1167 |
|
|
byteLanes <= "00011111";
|
1168 |
|
|
|
1169 |
|
|
when "01000" =>
|
1170 |
|
|
bytes <= 4;
|
1171 |
|
|
byteLanes <= "11110000";
|
1172 |
|
|
when "11000" =>
|
1173 |
|
|
bytes <= 4;
|
1174 |
|
|
byteLanes <= "00001111";
|
1175 |
|
|
|
1176 |
|
|
when "01001" =>
|
1177 |
|
|
bytes <= 6;
|
1178 |
|
|
byteLanes <= "11111100";
|
1179 |
|
|
when "11001" =>
|
1180 |
|
|
bytes <= 6;
|
1181 |
|
|
byteLanes <= "00111111";
|
1182 |
|
|
|
1183 |
|
|
when "01010" =>
|
1184 |
|
|
bytes <= 7;
|
1185 |
|
|
byteLanes <= "11111110";
|
1186 |
|
|
when "11010" =>
|
1187 |
|
|
bytes <= 7;
|
1188 |
|
|
byteLanes <= "01111111";
|
1189 |
|
|
|
1190 |
|
|
when "01011" =>
|
1191 |
|
|
bytes <= 8;
|
1192 |
|
|
byteLanes <= "11111111";
|
1193 |
|
|
when "11011" =>
|
1194 |
|
|
bytes <= 16;
|
1195 |
|
|
byteLanes <= "11111111";
|
1196 |
|
|
|
1197 |
|
|
when "01100" =>
|
1198 |
|
|
bytes <= 32;
|
1199 |
|
|
byteLanes <= "11111111";
|
1200 |
|
|
when "11100" =>
|
1201 |
|
|
bytes <= 64;
|
1202 |
|
|
byteLanes <= "11111111";
|
1203 |
|
|
|
1204 |
|
|
when "01101" =>
|
1205 |
|
|
bytes <= 96;
|
1206 |
|
|
byteLanes <= "11111111";
|
1207 |
|
|
when "11101" =>
|
1208 |
|
|
bytes <= 128;
|
1209 |
|
|
byteLanes <= "11111111";
|
1210 |
|
|
|
1211 |
|
|
when "01110" =>
|
1212 |
|
|
bytes <= 160;
|
1213 |
|
|
byteLanes <= "11111111";
|
1214 |
|
|
when "11110" =>
|
1215 |
|
|
bytes <= 192;
|
1216 |
|
|
byteLanes <= "11111111";
|
1217 |
|
|
|
1218 |
|
|
when "01111" =>
|
1219 |
|
|
bytes <= 224;
|
1220 |
|
|
byteLanes <= "11111111";
|
1221 |
|
|
when "11111" =>
|
1222 |
|
|
bytes <= 256;
|
1223 |
|
|
byteLanes <= "11111111";
|
1224 |
|
|
|
1225 |
33 |
magro732 |
end case;
|
1226 |
|
|
end process;
|
1227 |
|
|
|
1228 |
|
|
end architecture;
|