| 1 |
4 |
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 the transmission channel independent parts of the LP-Serial
|
| 10 |
|
|
-- Physical Layer Specification (RapidIO 2.2, part 6).
|
| 11 |
|
|
--
|
| 12 |
|
|
-- To Do:
|
| 13 |
|
|
-- -
|
| 14 |
|
|
--
|
| 15 |
|
|
-- Author(s):
|
| 16 |
|
|
-- - Magnus Rosenius, magro732@opencores.org
|
| 17 |
|
|
--
|
| 18 |
|
|
-------------------------------------------------------------------------------
|
| 19 |
|
|
--
|
| 20 |
|
|
-- Copyright (C) 2013 Authors and OPENCORES.ORG
|
| 21 |
|
|
--
|
| 22 |
|
|
-- This source file may be used and distributed without
|
| 23 |
|
|
-- restriction provided that this copyright statement is not
|
| 24 |
|
|
-- removed from the file and that any derivative work contains
|
| 25 |
|
|
-- the original copyright notice and the associated disclaimer.
|
| 26 |
|
|
--
|
| 27 |
|
|
-- This source file is free software; you can redistribute it
|
| 28 |
|
|
-- and/or modify it under the terms of the GNU Lesser General
|
| 29 |
|
|
-- Public License as published by the Free Software Foundation;
|
| 30 |
|
|
-- either version 2.1 of the License, or (at your option) any
|
| 31 |
|
|
-- later version.
|
| 32 |
|
|
--
|
| 33 |
|
|
-- This source is distributed in the hope that it will be
|
| 34 |
|
|
-- useful, but WITHOUT ANY WARRANTY; without even the implied
|
| 35 |
|
|
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
| 36 |
|
|
-- PURPOSE. See the GNU Lesser General Public License for more
|
| 37 |
|
|
-- details.
|
| 38 |
|
|
--
|
| 39 |
|
|
-- You should have received a copy of the GNU Lesser General
|
| 40 |
|
|
-- Public License along with this source; if not, download it
|
| 41 |
|
|
-- from http://www.opencores.org/lgpl.shtml
|
| 42 |
|
|
--
|
| 43 |
|
|
-------------------------------------------------------------------------------
|
| 44 |
|
|
|
| 45 |
|
|
|
| 46 |
|
|
-------------------------------------------------------------------------------
|
| 47 |
|
|
-- RioSerial
|
| 48 |
8 |
magro732 |
--
|
| 49 |
11 |
magro732 |
-- Generics
|
| 50 |
|
|
-- --------
|
| 51 |
|
|
-- TIMEOUT_WIDTH - The number of bits to be used in the portLinkTimeout signal.
|
| 52 |
|
|
-- NUMBER_WORDS - The number of parallell words that the data symbols can
|
| 53 |
|
|
-- contain. This sizes the data buses. It can be used to increase the bandwidth
|
| 54 |
|
|
-- of the core. Note that it cannot be larger than 4. This is since two
|
| 55 |
|
|
-- packets may be completed at the same tick and the interface to the
|
| 56 |
|
|
-- packetBuffer cannot handle more than one packets in one tick.
|
| 57 |
|
|
--
|
| 58 |
|
|
-- Signals
|
| 59 |
|
|
-- -------
|
| 60 |
|
|
-- System signals.
|
| 61 |
8 |
magro732 |
-- clk - System clock.
|
| 62 |
|
|
-- areset_n - System reset. Asynchronous, active low.
|
| 63 |
|
|
--
|
| 64 |
11 |
magro732 |
-- Configuration signals. These are used to change the runtime behaviour.
|
| 65 |
8 |
magro732 |
-- portLinkTimeout_i - The number of ticks to wait for a packet-accepted before
|
| 66 |
|
|
-- a timeout occurrs.
|
| 67 |
|
|
-- linkInitialized_o - Indicates if a link partner is answering with valid
|
| 68 |
|
|
-- status-control-symbols.
|
| 69 |
|
|
-- inputPortEnable_i - Activate the input port for non-maintenance packets. If
|
| 70 |
|
|
-- deasserted, only non-maintenance packets are allowed.
|
| 71 |
|
|
-- outputPortEnable_i - Activate the output port for non-maintenance packets.
|
| 72 |
|
|
-- If deasserted, only non-maintenance packets are allowed.
|
| 73 |
|
|
--
|
| 74 |
|
|
-- This interface makes it possible to read and write ackId in both outbound
|
| 75 |
|
|
-- and inbound directions. All input signals are validated by localAckIdWrite.
|
| 76 |
|
|
-- localAckIdWrite_i - Indicate if a localAckId write operation is ongoing.
|
| 77 |
|
|
-- Usually this signal is high one tick.
|
| 78 |
|
|
-- clrOutstandingAckId_i - Clear outstanding ackId, i.e. reset the transmission
|
| 79 |
|
|
-- window. The signal is only read if localAckIdWrite_i is high.
|
| 80 |
|
|
-- inboundAckId_i - The value to set the inbound ackId (the ackId that the
|
| 81 |
|
|
-- next inbound packet should have) to. This signal is only read if localAckIdWrite
|
| 82 |
|
|
-- is high.
|
| 83 |
|
|
-- outstandingAckId_i - The value to set the outstanding ackId (the ackId
|
| 84 |
|
|
-- transmitted but not acknowledged) to. This signal is only read if localAckIdWrite
|
| 85 |
|
|
-- is high.
|
| 86 |
|
|
-- outboundAckId_i - The value to set the outbound ackId (the ackId that the
|
| 87 |
|
|
-- next outbound packet will have) to. This signal is only read if localAckIdWrite
|
| 88 |
|
|
-- is high.
|
| 89 |
|
|
-- inboundAckId_o - The current inbound ackId.
|
| 90 |
|
|
-- outstandingAckId_o - The current outstanding ackId.
|
| 91 |
|
|
-- outboundAckId_o - The current outbound ackId.
|
| 92 |
|
|
--
|
| 93 |
|
|
-- This is the interface to the packet buffering sublayer.
|
| 94 |
|
|
-- The window signals are used to send packets without removing them from the
|
| 95 |
|
|
-- memory storage. This way, many packet can be sent without awaiting
|
| 96 |
|
|
-- packet-accepted symbols and if a packet-accepted gets lost, it is possible
|
| 97 |
|
|
-- to revert and resend a packet. This is achived by reading readWindowEmpty
|
| 98 |
|
|
-- for new packet and asserting readWindowNext when a packet has been sent.
|
| 99 |
|
|
-- When the packet-accepted is received, readFrame should be asserted to remove the
|
| 100 |
|
|
-- packet from the storage. If a packet-accepted is missing, readWindowReset is
|
| 101 |
|
|
-- asserted to set the current packet to read to the one that has not received
|
| 102 |
|
|
-- a packet-accepted.
|
| 103 |
|
|
-- readFrameEmpty_i - Indicate if a packet is ready in the outbound direction.
|
| 104 |
|
|
-- Once deasserted, it is possible to read the packet content using
|
| 105 |
|
|
-- readContent_o to update readContentData and readContentEnd.
|
| 106 |
|
|
-- readFrame_o - Assert this signal for one tick to discard the oldest packet.
|
| 107 |
|
|
-- It should be used when a packet has been fully read, a linkpartner has
|
| 108 |
|
|
-- accepted it and the resources occupied by it should be returned to be
|
| 109 |
|
|
-- used for new packets.
|
| 110 |
|
|
-- readFrameRestart_o - Assert this signal to restart the reading of the
|
| 111 |
|
|
-- current packet. readContentData and readContentEnd will be reset to the
|
| 112 |
|
|
-- first content of the packet.
|
| 113 |
|
|
-- readFrameAborted_i - This signal is asserted if the current packet was
|
| 114 |
|
|
-- aborted while it was written. It is used when a transmitter starts to send a
|
| 115 |
|
|
-- packet before it has been fully received and it is cancelled before it is
|
| 116 |
|
|
-- completed. A one tick asserted readFrameRestart signal resets this signal.
|
| 117 |
|
|
-- readWindowEmpty_i - Indicate if there are more packets to send.
|
| 118 |
|
|
-- readWindowReset_o - Reset the current packet to the oldest stored in the memory.
|
| 119 |
|
|
-- readWindowNext_o - Indicate that a new packet should be read. Must only be
|
| 120 |
|
|
-- asserted if readWindowEmpty is deasserted. It should be high for one tick.
|
| 121 |
|
|
-- readContentEmpty_i - Indicate if there are any packet content to be read.
|
| 122 |
|
|
-- This signal is updated directly when packet content is written making it
|
| 123 |
|
|
-- possible to read packet content before the full packet has been written to
|
| 124 |
|
|
-- the memory storage.
|
| 125 |
|
|
-- readContent_o - Update readContentData and readContentEnd.
|
| 126 |
|
|
-- readContentEnd_i - Indicate if the end of the current packet has been
|
| 127 |
|
|
-- reached. When asserted, readContentData is not valid.
|
| 128 |
|
|
-- readContentData_i - The content of the current packet.
|
| 129 |
|
|
-- writeFrameFull_i - Indicate if the inbound packet storage is ready to accept
|
| 130 |
|
|
-- a new packet.
|
| 131 |
|
|
-- writeFrame_o - Indicate that a new complete inbound packet has been written.
|
| 132 |
|
|
-- writeFrameAbort_o - Indicate that the current packet is aborted and that all
|
| 133 |
|
|
-- data written for this packet should be discarded.
|
| 134 |
|
|
-- writeContent_o - Indicate that writeContentData is valid and should be
|
| 135 |
|
|
-- written into the packet content storage.
|
| 136 |
|
|
-- writeContentData_o - The content to write to the packet content storage.
|
| 137 |
|
|
--
|
| 138 |
|
|
-- This is the interface to the PCS (Physical Control Sublayer). Four types of
|
| 139 |
|
|
-- symbols exist, idle, control, data and error.
|
| 140 |
|
|
-- Idle symbols are transmitted when nothing else can be transmitted. They are
|
| 141 |
|
|
-- mainly intended to enforce a timing on the transmitted symbols. This is
|
| 142 |
|
|
-- needed to be able to guarantee that a status-control-symbol is transmitted
|
| 143 |
|
|
-- at least once every 256 symbol.
|
| 144 |
|
|
-- Control symbols contain control-symbols as described by the standard.
|
| 145 |
|
|
-- Data symbols contains a 32-bit fragment of a RapidIO packet.
|
| 146 |
|
|
-- Error symbols indicate that a corrupted symbol was received. This could be
|
| 147 |
|
|
-- used by a PCS layer to indicate that a transmission error was detected and
|
| 148 |
|
|
-- that the above layers should send link-requests to ensure the synchronism
|
| 149 |
|
|
-- between the link-partners.
|
| 150 |
|
|
-- The signals in this interface are:
|
| 151 |
|
|
-- portInitialized_i - An asserted signal on this pin indicates that the PCS
|
| 152 |
|
|
-- layer has established synchronization with the link and is ready to accept
|
| 153 |
|
|
-- symbols.
|
| 154 |
|
|
-- outboundSymbolEmpty_o - An asserted signal indicates that there are no
|
| 155 |
|
|
-- outbound symbols to read. Once deasserted, outboundSymbol_o will be
|
| 156 |
|
|
-- already be valid. This signal will be updated one tick after
|
| 157 |
|
|
-- outboundSymbolRead_i has been asserted.
|
| 158 |
|
|
-- outboundSymbolRead_i - Indicate that outboundSymbol_o has been read and a
|
| 159 |
|
|
-- new value could be accepted. It should be active for one tick.
|
| 160 |
11 |
magro732 |
-- REMARK: Update this comment...
|
| 161 |
|
|
-- outboundSymbol_o - The outbound symbol. It is divided into two parts,
|
| 162 |
|
|
-- symbolType and symbolContent.
|
| 163 |
|
|
-- symbolType - The two MSB bits are the type of the symbol according to
|
| 164 |
|
|
-- table below:
|
| 165 |
|
|
-- 00=IDLE, the rest of the bits are not used.
|
| 166 |
|
|
-- 01=CONTROL, the control symbols payload (24 bits) are placed in the MSB
|
| 167 |
|
|
-- part of the symbolContent.
|
| 168 |
|
|
-- 10=ERROR, the rest of the bits are not used.
|
| 169 |
|
|
-- 11=DATA, all the remaining bits contain the number of valid words and
|
| 170 |
|
|
-- the payload of the symbol.
|
| 171 |
|
|
-- symbolContent - The rest of the bits are symbol content. If there are
|
| 172 |
|
|
-- multiple words in the symbols they must be set to zero. The first
|
| 173 |
|
|
-- received word is placed in the MSB part of this field.
|
| 174 |
8 |
magro732 |
-- inboundSymbolFull_o - An asserted signal indicates that no more inbound
|
| 175 |
|
|
-- symbols can be accepted.
|
| 176 |
|
|
-- inboundSymbolWrite_i - Indicate that inboundSymbol_i contains valid
|
| 177 |
11 |
magro732 |
-- information that should be forwarded. Should be active for one tick.
|
| 178 |
8 |
magro732 |
-- inboundSymbol_i - The inbound symbol. See outboundSymbol_o for formating.
|
| 179 |
4 |
magro732 |
-------------------------------------------------------------------------------
|
| 180 |
|
|
library ieee;
|
| 181 |
|
|
use ieee.std_logic_1164.all;
|
| 182 |
|
|
use ieee.numeric_std.all;
|
| 183 |
|
|
use work.rio_common.all;
|
| 184 |
|
|
|
| 185 |
|
|
|
| 186 |
|
|
-------------------------------------------------------------------------------
|
| 187 |
|
|
-- Entity for RioSerial.
|
| 188 |
|
|
-------------------------------------------------------------------------------
|
| 189 |
|
|
entity RioSerial is
|
| 190 |
|
|
generic(
|
| 191 |
13 |
magro732 |
TIMEOUT_WIDTH : natural := 20;
|
| 192 |
11 |
magro732 |
NUMBER_WORDS : natural range 1 to 4 := 1);
|
| 193 |
4 |
magro732 |
port(
|
| 194 |
|
|
-- System signals.
|
| 195 |
|
|
clk : in std_logic;
|
| 196 |
|
|
areset_n : in std_logic;
|
| 197 |
|
|
|
| 198 |
|
|
-- Status signals for maintenance operations.
|
| 199 |
|
|
portLinkTimeout_i : in std_logic_vector(TIMEOUT_WIDTH-1 downto 0);
|
| 200 |
|
|
linkInitialized_o : out std_logic;
|
| 201 |
|
|
inputPortEnable_i : in std_logic;
|
| 202 |
|
|
outputPortEnable_i : in std_logic;
|
| 203 |
|
|
|
| 204 |
|
|
-- Support for portLocalAckIdCSR.
|
| 205 |
|
|
localAckIdWrite_i : in std_logic;
|
| 206 |
|
|
clrOutstandingAckId_i : in std_logic;
|
| 207 |
|
|
inboundAckId_i : in std_logic_vector(4 downto 0);
|
| 208 |
|
|
outstandingAckId_i : in std_logic_vector(4 downto 0);
|
| 209 |
|
|
outboundAckId_i : in std_logic_vector(4 downto 0);
|
| 210 |
|
|
inboundAckId_o : out std_logic_vector(4 downto 0);
|
| 211 |
|
|
outstandingAckId_o : out std_logic_vector(4 downto 0);
|
| 212 |
|
|
outboundAckId_o : out std_logic_vector(4 downto 0);
|
| 213 |
|
|
|
| 214 |
|
|
-- Outbound frame interface.
|
| 215 |
|
|
readFrameEmpty_i : in std_logic;
|
| 216 |
|
|
readFrame_o : out std_logic;
|
| 217 |
|
|
readFrameRestart_o : out std_logic;
|
| 218 |
|
|
readFrameAborted_i : in std_logic;
|
| 219 |
|
|
readWindowEmpty_i : in std_logic;
|
| 220 |
|
|
readWindowReset_o : out std_logic;
|
| 221 |
|
|
readWindowNext_o : out std_logic;
|
| 222 |
|
|
readContentEmpty_i : in std_logic;
|
| 223 |
|
|
readContent_o : out std_logic;
|
| 224 |
|
|
readContentEnd_i : in std_logic;
|
| 225 |
11 |
magro732 |
readContentData_i : in std_logic_vector(2+(32*NUMBER_WORDS-1) downto 0);
|
| 226 |
4 |
magro732 |
|
| 227 |
|
|
-- Inbound frame interface.
|
| 228 |
|
|
writeFrameFull_i : in std_logic;
|
| 229 |
|
|
writeFrame_o : out std_logic;
|
| 230 |
|
|
writeFrameAbort_o : out std_logic;
|
| 231 |
|
|
writeContent_o : out std_logic;
|
| 232 |
11 |
magro732 |
writeContentData_o : out std_logic_vector(2+(32*NUMBER_WORDS-1) downto 0);
|
| 233 |
4 |
magro732 |
|
| 234 |
|
|
-- PCS layer signals.
|
| 235 |
|
|
portInitialized_i : in std_logic;
|
| 236 |
|
|
outboundSymbolEmpty_o : out std_logic;
|
| 237 |
|
|
outboundSymbolRead_i : in std_logic;
|
| 238 |
11 |
magro732 |
outboundSymbol_o : out std_logic_vector(((2+32)*NUMBER_WORDS-1) downto 0);
|
| 239 |
4 |
magro732 |
inboundSymbolFull_o : out std_logic;
|
| 240 |
|
|
inboundSymbolWrite_i : in std_logic;
|
| 241 |
11 |
magro732 |
inboundSymbol_i : in std_logic_vector(((2+32)*NUMBER_WORDS-1) downto 0));
|
| 242 |
4 |
magro732 |
end entity;
|
| 243 |
|
|
|
| 244 |
|
|
|
| 245 |
|
|
-------------------------------------------------------------------------------
|
| 246 |
|
|
-- Architecture for RioSerial.
|
| 247 |
|
|
-------------------------------------------------------------------------------
|
| 248 |
|
|
architecture RioSerialImpl of RioSerial is
|
| 249 |
|
|
|
| 250 |
|
|
component RioFifo1 is
|
| 251 |
|
|
generic(
|
| 252 |
|
|
WIDTH : natural);
|
| 253 |
|
|
port(
|
| 254 |
|
|
clk : in std_logic;
|
| 255 |
|
|
areset_n : in std_logic;
|
| 256 |
|
|
|
| 257 |
|
|
empty_o : out std_logic;
|
| 258 |
|
|
read_i : in std_logic;
|
| 259 |
|
|
data_o : out std_logic_vector(WIDTH-1 downto 0);
|
| 260 |
|
|
|
| 261 |
|
|
full_o : out std_logic;
|
| 262 |
|
|
write_i : in std_logic;
|
| 263 |
|
|
data_i : in std_logic_vector(WIDTH-1 downto 0));
|
| 264 |
|
|
end component;
|
| 265 |
|
|
|
| 266 |
|
|
component RioTransmitter is
|
| 267 |
|
|
generic(
|
| 268 |
11 |
magro732 |
TIMEOUT_WIDTH : natural;
|
| 269 |
|
|
NUMBER_WORDS : natural range 1 to 4 := 1);
|
| 270 |
4 |
magro732 |
port(
|
| 271 |
|
|
clk : in std_logic;
|
| 272 |
|
|
areset_n : in std_logic;
|
| 273 |
|
|
|
| 274 |
|
|
portLinkTimeout_i : in std_logic_vector(TIMEOUT_WIDTH-1 downto 0);
|
| 275 |
|
|
portEnable_i : in std_logic;
|
| 276 |
|
|
|
| 277 |
|
|
localAckIdWrite_i : in std_logic;
|
| 278 |
|
|
clrOutstandingAckId_i : in std_logic;
|
| 279 |
|
|
outstandingAckId_i : in std_logic_vector(4 downto 0);
|
| 280 |
|
|
outboundAckId_i : in std_logic_vector(4 downto 0);
|
| 281 |
|
|
outstandingAckId_o : out std_logic_vector(4 downto 0);
|
| 282 |
|
|
outboundAckId_o : out std_logic_vector(4 downto 0);
|
| 283 |
|
|
|
| 284 |
|
|
portInitialized_i : in std_logic;
|
| 285 |
|
|
txFull_i : in std_logic;
|
| 286 |
|
|
txWrite_o : out std_logic;
|
| 287 |
11 |
magro732 |
txType_o : out std_logic_vector(1 downto 0);
|
| 288 |
4 |
magro732 |
txData_o : out std_logic_vector(31 downto 0);
|
| 289 |
|
|
|
| 290 |
|
|
txControlEmpty_i : in std_logic;
|
| 291 |
|
|
txControlSymbol_i : in std_logic_vector(12 downto 0);
|
| 292 |
|
|
txControlUpdate_o : out std_logic;
|
| 293 |
|
|
rxControlEmpty_i : in std_logic;
|
| 294 |
|
|
rxControlSymbol_i : in std_logic_vector(12 downto 0);
|
| 295 |
|
|
rxControlUpdate_o : out std_logic;
|
| 296 |
|
|
|
| 297 |
|
|
linkInitialized_i : in std_logic;
|
| 298 |
|
|
linkInitialized_o : out std_logic;
|
| 299 |
|
|
ackIdStatus_i : in std_logic_vector(4 downto 0);
|
| 300 |
|
|
|
| 301 |
|
|
readFrameEmpty_i : in std_logic;
|
| 302 |
|
|
readFrame_o : out std_logic;
|
| 303 |
|
|
readFrameRestart_o : out std_logic;
|
| 304 |
|
|
readFrameAborted_i : in std_logic;
|
| 305 |
|
|
readWindowEmpty_i : in std_logic;
|
| 306 |
|
|
readWindowReset_o : out std_logic;
|
| 307 |
|
|
readWindowNext_o : out std_logic;
|
| 308 |
|
|
readContentEmpty_i : in std_logic;
|
| 309 |
|
|
readContent_o : out std_logic;
|
| 310 |
|
|
readContentEnd_i : in std_logic;
|
| 311 |
11 |
magro732 |
readContentWords_i : in std_logic_vector(1 downto 0);
|
| 312 |
|
|
readContentData_i : in std_logic_vector(32*NUMBER_WORDS-1 downto 0));
|
| 313 |
4 |
magro732 |
end component;
|
| 314 |
|
|
|
| 315 |
|
|
component RioReceiver is
|
| 316 |
11 |
magro732 |
generic(
|
| 317 |
|
|
NUMBER_WORDS : natural range 1 to 4 := 1);
|
| 318 |
4 |
magro732 |
port(
|
| 319 |
|
|
clk : in std_logic;
|
| 320 |
|
|
areset_n : in std_logic;
|
| 321 |
|
|
|
| 322 |
|
|
portEnable_i : in std_logic;
|
| 323 |
|
|
|
| 324 |
|
|
localAckIdWrite_i : in std_logic;
|
| 325 |
|
|
inboundAckId_i : in std_logic_vector(4 downto 0);
|
| 326 |
|
|
inboundAckId_o : out std_logic_vector(4 downto 0);
|
| 327 |
|
|
|
| 328 |
|
|
portInitialized_i : in std_logic;
|
| 329 |
|
|
rxEmpty_i : in std_logic;
|
| 330 |
|
|
rxRead_o : out std_logic;
|
| 331 |
11 |
magro732 |
rxType_i : in std_logic_vector(2*NUMBER_WORDS-1 downto 0);
|
| 332 |
|
|
rxData_i : in std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
| 333 |
4 |
magro732 |
|
| 334 |
11 |
magro732 |
txControlWrite_o : out std_logic_vector(NUMBER_WORDS-1 downto 0);
|
| 335 |
|
|
txControlSymbol_o : out std_logic_vector(12*NUMBER_WORDS downto 0);
|
| 336 |
|
|
rxControlWrite_o : out std_logic_vector(NUMBER_WORDS-1 downto 0);
|
| 337 |
|
|
rxControlSymbol_o : out std_logic_vector(12*NUMBER_WORDS downto 0);
|
| 338 |
4 |
magro732 |
|
| 339 |
|
|
ackIdStatus_o : out std_logic_vector(4 downto 0);
|
| 340 |
|
|
linkInitialized_o : out std_logic;
|
| 341 |
|
|
|
| 342 |
|
|
writeFrameFull_i : in std_logic;
|
| 343 |
|
|
writeFrame_o : out std_logic;
|
| 344 |
|
|
writeFrameAbort_o : out std_logic;
|
| 345 |
|
|
writeContent_o : out std_logic;
|
| 346 |
11 |
magro732 |
writeContentWords_o : out std_logic_vector(1 downto 0);
|
| 347 |
|
|
writeContentData_o : out std_logic_vector(32*NUMBER_WORDS-1 downto 0));
|
| 348 |
4 |
magro732 |
end component;
|
| 349 |
|
|
|
| 350 |
|
|
signal linkInitializedRx : std_logic;
|
| 351 |
|
|
signal linkInitializedTx : std_logic;
|
| 352 |
|
|
signal ackIdStatus : std_logic_vector(4 downto 0);
|
| 353 |
|
|
|
| 354 |
11 |
magro732 |
signal txControlWrite : std_logic_vector(NUMBER_WORDS-1 downto 0);
|
| 355 |
|
|
signal txControlWriteSymbol : std_logic_vector(12*NUMBER_WORDS downto 0);
|
| 356 |
|
|
signal txControlReadEmpty : std_logic_vector(NUMBER_WORDS-1 downto 0);
|
| 357 |
|
|
signal txControlRead : std_logic_vector(NUMBER_WORDS-1 downto 0);
|
| 358 |
|
|
signal txControlReadSymbol : std_logic_vector(12*NUMBER_WORDS downto 0);
|
| 359 |
4 |
magro732 |
|
| 360 |
11 |
magro732 |
signal rxControlWrite : std_logic_vector(NUMBER_WORDS-1 downto 0);
|
| 361 |
|
|
signal rxControlWriteSymbol : std_logic_vector(12*NUMBER_WORDS downto 0);
|
| 362 |
|
|
signal rxControlReadEmpty : std_logic_vector(NUMBER_WORDS-1 downto 0);
|
| 363 |
|
|
signal rxControlRead : std_logic_vector(NUMBER_WORDS-1 downto 0);
|
| 364 |
|
|
signal rxControlReadSymbol : std_logic_vector(12*NUMBER_WORDS downto 0);
|
| 365 |
4 |
magro732 |
|
| 366 |
|
|
signal outboundFull : std_logic;
|
| 367 |
|
|
signal outboundWrite : std_logic;
|
| 368 |
11 |
magro732 |
signal outboundType : std_logic_vector(1 downto 0);
|
| 369 |
|
|
signal outboundData : std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
| 370 |
|
|
signal outboundSymbol : std_logic_vector(2+(32*NUMBER_WORDS-1) downto 0);
|
| 371 |
4 |
magro732 |
|
| 372 |
|
|
signal inboundEmpty : std_logic;
|
| 373 |
|
|
signal inboundRead : std_logic;
|
| 374 |
11 |
magro732 |
signal inboundType : std_logic_vector(1 downto 0);
|
| 375 |
|
|
signal inboundData : std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
| 376 |
|
|
signal inboundSymbol : std_logic_vector(((2+32)*NUMBER_WORDS-1) downto 0);
|
| 377 |
4 |
magro732 |
|
| 378 |
|
|
begin
|
| 379 |
|
|
|
| 380 |
|
|
linkInitialized_o <=
|
| 381 |
|
|
'1' when ((linkInitializedRx = '1') and (linkInitializedTx = '1')) else '0';
|
| 382 |
|
|
|
| 383 |
|
|
-----------------------------------------------------------------------------
|
| 384 |
|
|
-- Serial layer modules.
|
| 385 |
|
|
-----------------------------------------------------------------------------
|
| 386 |
|
|
|
| 387 |
|
|
Transmitter: RioTransmitter
|
| 388 |
|
|
generic map(
|
| 389 |
11 |
magro732 |
TIMEOUT_WIDTH=>TIMEOUT_WIDTH,
|
| 390 |
|
|
NUMBER_WORDS=>NUMBER_WORDS)
|
| 391 |
4 |
magro732 |
port map(
|
| 392 |
|
|
clk=>clk, areset_n=>areset_n,
|
| 393 |
|
|
portLinkTimeout_i=>portLinkTimeout_i,
|
| 394 |
|
|
portEnable_i=>outputPortEnable_i,
|
| 395 |
|
|
localAckIdWrite_i=>localAckIdWrite_i,
|
| 396 |
|
|
clrOutstandingAckId_i=>clrOutstandingAckId_i,
|
| 397 |
|
|
outstandingAckId_i=>outstandingAckId_i,
|
| 398 |
|
|
outboundAckId_i=>outboundAckId_i,
|
| 399 |
|
|
outstandingAckId_o=>outstandingAckId_o,
|
| 400 |
|
|
outboundAckId_o=>outboundAckId_o,
|
| 401 |
|
|
portInitialized_i=>portInitialized_i,
|
| 402 |
|
|
txFull_i=>outboundFull, txWrite_o=>outboundWrite,
|
| 403 |
11 |
magro732 |
txType_o=>outboundType, txData_o=>outboundData,
|
| 404 |
|
|
txControlEmpty_i=>txControlReadEmpty(0), txControlSymbol_i=>txControlReadSymbol,
|
| 405 |
|
|
txControlUpdate_o=>txControlRead(0),
|
| 406 |
|
|
rxControlEmpty_i=>rxControlReadEmpty(0), rxControlSymbol_i=>rxControlReadSymbol,
|
| 407 |
|
|
rxControlUpdate_o=>rxControlRead(0),
|
| 408 |
4 |
magro732 |
linkInitialized_o=>linkInitializedTx,
|
| 409 |
|
|
linkInitialized_i=>linkInitializedRx, ackIdStatus_i=>ackIdStatus,
|
| 410 |
|
|
readFrameEmpty_i=>readFrameEmpty_i, readFrame_o=>readFrame_o,
|
| 411 |
|
|
readFrameRestart_o=>readFrameRestart_o, readFrameAborted_i=>readFrameAborted_i,
|
| 412 |
|
|
readWindowEmpty_i=>readWindowEmpty_i,
|
| 413 |
|
|
readWindowReset_o=>readWindowReset_o, readWindowNext_o=>readWindowNext_o,
|
| 414 |
|
|
readContentEmpty_i=>readContentEmpty_i, readContent_o=>readContent_o,
|
| 415 |
11 |
magro732 |
readContentEnd_i=>readContentEnd_i,
|
| 416 |
|
|
readContentWords_i=>readContentData_i(2+(32*NUMBER_WORDS-1) downto 1+(32*NUMBER_WORDS-1)),
|
| 417 |
|
|
readContentData_i=>readContentData_i(32*NUMBER_WORDS-1 downto 0));
|
| 418 |
4 |
magro732 |
|
| 419 |
11 |
magro732 |
SymbolFifo: for i in 0 to NUMBER_WORDS-1 generate
|
| 420 |
|
|
TxSymbolFifo: RioFifo1
|
| 421 |
|
|
generic map(WIDTH=>13)
|
| 422 |
|
|
port map(
|
| 423 |
|
|
clk=>clk, areset_n=>areset_n,
|
| 424 |
|
|
empty_o=>txControlReadEmpty(i),
|
| 425 |
|
|
read_i=>txControlRead(i),
|
| 426 |
|
|
data_o=>txControlReadSymbol(12*(i+1) downto 12*i),
|
| 427 |
|
|
full_o=>open,
|
| 428 |
|
|
write_i=>txControlWrite(i),
|
| 429 |
|
|
data_i=>txControlWriteSymbol(12*(i+1) downto 12*i));
|
| 430 |
4 |
magro732 |
|
| 431 |
11 |
magro732 |
RxSymbolFifo: RioFifo1
|
| 432 |
|
|
generic map(WIDTH=>13)
|
| 433 |
|
|
port map(
|
| 434 |
|
|
clk=>clk, areset_n=>areset_n,
|
| 435 |
|
|
empty_o=>rxControlReadEmpty(i),
|
| 436 |
|
|
read_i=>rxControlRead(i),
|
| 437 |
|
|
data_o=>rxControlReadSymbol(12*(i+1) downto 12*i),
|
| 438 |
|
|
full_o=>open,
|
| 439 |
|
|
write_i=>rxControlWrite(i),
|
| 440 |
|
|
data_i=>rxControlWriteSymbol(12*(i+1) downto 12*i));
|
| 441 |
|
|
end generate;
|
| 442 |
|
|
|
| 443 |
4 |
magro732 |
Receiver: RioReceiver
|
| 444 |
11 |
magro732 |
generic map(NUMBER_WORDS=>NUMBER_WORDS)
|
| 445 |
4 |
magro732 |
port map(
|
| 446 |
|
|
clk=>clk, areset_n=>areset_n,
|
| 447 |
|
|
portEnable_i=>inputPortEnable_i,
|
| 448 |
|
|
localAckIdWrite_i=>localAckIdWrite_i,
|
| 449 |
|
|
inboundAckId_i=>inboundAckId_i,
|
| 450 |
|
|
inboundAckId_o=>inboundAckId_o,
|
| 451 |
|
|
portInitialized_i=>portInitialized_i,
|
| 452 |
|
|
rxEmpty_i=>inboundEmpty, rxRead_o=>inboundRead,
|
| 453 |
11 |
magro732 |
rxType_i=>inboundType, rxData_i=>inboundData,
|
| 454 |
4 |
magro732 |
txControlWrite_o=>txControlWrite, txControlSymbol_o=>txControlWriteSymbol,
|
| 455 |
|
|
rxControlWrite_o=>rxControlWrite, rxControlSymbol_o=>rxControlWriteSymbol,
|
| 456 |
|
|
ackIdStatus_o=>ackIdStatus,
|
| 457 |
|
|
linkInitialized_o=>linkInitializedRx,
|
| 458 |
|
|
writeFrameFull_i=>writeFrameFull_i,
|
| 459 |
|
|
writeFrame_o=>writeFrame_o, writeFrameAbort_o=>writeFrameAbort_o,
|
| 460 |
11 |
magro732 |
writeContent_o=>writeContent_o,
|
| 461 |
|
|
writeContentWords_o=>writeContentData_o(2+(32*NUMBER_WORDS-1) downto 1+(32*NUMBER_WORDS-1)),
|
| 462 |
|
|
writeContentData_o=>writeContentData_o(32*NUMBER_WORDS-1 downto 0));
|
| 463 |
4 |
magro732 |
|
| 464 |
|
|
-----------------------------------------------------------------------------
|
| 465 |
|
|
-- PCS layer FIFO interface.
|
| 466 |
|
|
-----------------------------------------------------------------------------
|
| 467 |
|
|
|
| 468 |
11 |
magro732 |
outboundSymbol <= outboundType & outboundData;
|
| 469 |
4 |
magro732 |
OutboundSymbolFifo: RioFifo1
|
| 470 |
11 |
magro732 |
generic map(WIDTH=>2+32*NUMBER_WORDS)
|
| 471 |
4 |
magro732 |
port map(
|
| 472 |
|
|
clk=>clk, areset_n=>areset_n,
|
| 473 |
|
|
empty_o=>outboundSymbolEmpty_o, read_i=>outboundSymbolRead_i, data_o=>outboundSymbol_o,
|
| 474 |
|
|
full_o=>outboundFull, write_i=>outboundWrite, data_i=>outboundSymbol);
|
| 475 |
|
|
|
| 476 |
11 |
magro732 |
inboundType <= inboundSymbol(2+(32*NUMBER_WORDS-1) downto 1+(32*NUMBER_WORDS-1));
|
| 477 |
|
|
inboundData <= inboundSymbol(32*NUMBER_WORDS-1 downto 0);
|
| 478 |
4 |
magro732 |
InboundSymbolFifo: RioFifo1
|
| 479 |
11 |
magro732 |
generic map(WIDTH=>2+32*NUMBER_WORDS)
|
| 480 |
4 |
magro732 |
port map(
|
| 481 |
|
|
clk=>clk, areset_n=>areset_n,
|
| 482 |
|
|
empty_o=>inboundEmpty, read_i=>inboundRead, data_o=>inboundSymbol,
|
| 483 |
|
|
full_o=>inboundSymbolFull_o, write_i=>inboundSymbolWrite_i, data_i=>inboundSymbol_i);
|
| 484 |
|
|
|
| 485 |
|
|
end architecture;
|
| 486 |
|
|
|
| 487 |
|
|
|
| 488 |
|
|
|
| 489 |
|
|
-------------------------------------------------------------------------------
|
| 490 |
|
|
-- RioTransmitter
|
| 491 |
|
|
-------------------------------------------------------------------------------
|
| 492 |
|
|
library ieee;
|
| 493 |
|
|
use ieee.std_logic_1164.all;
|
| 494 |
|
|
use ieee.numeric_std.all;
|
| 495 |
|
|
use work.rio_common.all;
|
| 496 |
|
|
|
| 497 |
|
|
|
| 498 |
|
|
-------------------------------------------------------------------------------
|
| 499 |
|
|
-- Entity for RioTransmitter.
|
| 500 |
|
|
-------------------------------------------------------------------------------
|
| 501 |
|
|
entity RioTransmitter is
|
| 502 |
|
|
generic(
|
| 503 |
11 |
magro732 |
TIMEOUT_WIDTH : natural;
|
| 504 |
|
|
NUMBER_WORDS : natural range 1 to 4 := 1);
|
| 505 |
4 |
magro732 |
port(
|
| 506 |
|
|
-- System signals.
|
| 507 |
|
|
clk : in std_logic;
|
| 508 |
|
|
areset_n : in std_logic;
|
| 509 |
|
|
|
| 510 |
|
|
-- Status signals used for maintenance.
|
| 511 |
|
|
portLinkTimeout_i : in std_logic_vector(TIMEOUT_WIDTH-1 downto 0);
|
| 512 |
|
|
portEnable_i : in std_logic;
|
| 513 |
|
|
|
| 514 |
|
|
-- Support for localAckIdCSR.
|
| 515 |
|
|
localAckIdWrite_i : in std_logic;
|
| 516 |
|
|
clrOutstandingAckId_i : in std_logic;
|
| 517 |
|
|
outstandingAckId_i : in std_logic_vector(4 downto 0);
|
| 518 |
|
|
outboundAckId_i : in std_logic_vector(4 downto 0);
|
| 519 |
|
|
outstandingAckId_o : out std_logic_vector(4 downto 0);
|
| 520 |
|
|
outboundAckId_o : out std_logic_vector(4 downto 0);
|
| 521 |
|
|
|
| 522 |
|
|
-- Port output interface.
|
| 523 |
|
|
portInitialized_i : in std_logic;
|
| 524 |
|
|
txFull_i : in std_logic;
|
| 525 |
|
|
txWrite_o : out std_logic;
|
| 526 |
11 |
magro732 |
txType_o : out std_logic_vector(2*NUMBER_WORDS-1 downto 0);
|
| 527 |
|
|
txData_o : out std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
| 528 |
4 |
magro732 |
|
| 529 |
|
|
-- Control symbols aimed to the transmitter.
|
| 530 |
|
|
txControlEmpty_i : in std_logic;
|
| 531 |
|
|
txControlSymbol_i : in std_logic_vector(12 downto 0);
|
| 532 |
|
|
txControlUpdate_o : out std_logic;
|
| 533 |
|
|
|
| 534 |
|
|
-- Control symbols from the receiver to send.
|
| 535 |
|
|
rxControlEmpty_i : in std_logic;
|
| 536 |
|
|
rxControlSymbol_i : in std_logic_vector(12 downto 0);
|
| 537 |
|
|
rxControlUpdate_o : out std_logic;
|
| 538 |
|
|
|
| 539 |
|
|
-- Internal signalling from the receiver part.
|
| 540 |
|
|
linkInitialized_o : out std_logic;
|
| 541 |
|
|
linkInitialized_i : in std_logic;
|
| 542 |
|
|
ackIdStatus_i : in std_logic_vector(4 downto 0);
|
| 543 |
|
|
|
| 544 |
|
|
-- Frame buffer interface.
|
| 545 |
|
|
readFrameEmpty_i : in std_logic;
|
| 546 |
|
|
readFrame_o : out std_logic;
|
| 547 |
|
|
readFrameRestart_o : out std_logic;
|
| 548 |
|
|
readFrameAborted_i : in std_logic;
|
| 549 |
|
|
readWindowEmpty_i : in std_logic;
|
| 550 |
|
|
readWindowReset_o : out std_logic;
|
| 551 |
|
|
readWindowNext_o : out std_logic;
|
| 552 |
|
|
readContentEmpty_i : in std_logic;
|
| 553 |
|
|
readContent_o : out std_logic;
|
| 554 |
|
|
readContentEnd_i : in std_logic;
|
| 555 |
11 |
magro732 |
readContentWords_i : in std_logic_vector(1 downto 0);
|
| 556 |
|
|
readContentData_i : in std_logic_vector(32*NUMBER_WORDS-1 downto 0));
|
| 557 |
4 |
magro732 |
end entity;
|
| 558 |
|
|
|
| 559 |
|
|
|
| 560 |
|
|
-------------------------------------------------------------------------------
|
| 561 |
|
|
-- Architecture for RioTransmitter.
|
| 562 |
|
|
-------------------------------------------------------------------------------
|
| 563 |
|
|
architecture RioTransmitterImpl of RioTransmitter is
|
| 564 |
|
|
|
| 565 |
|
|
constant NUMBER_STATUS_TRANSMIT : natural := 15;
|
| 566 |
|
|
constant NUMBER_LINK_RESPONSE_RETRIES : natural := 2;
|
| 567 |
11 |
magro732 |
|
| 568 |
|
|
component RioTransmitterCore is
|
| 569 |
|
|
generic(
|
| 570 |
|
|
NUMBER_WORDS : natural range 1 to 4 := 1);
|
| 571 |
|
|
port(
|
| 572 |
|
|
-- System signals.
|
| 573 |
|
|
clk : in std_logic;
|
| 574 |
|
|
areset_n : in std_logic;
|
| 575 |
|
|
|
| 576 |
|
|
-- Status signals used for maintenance.
|
| 577 |
|
|
portEnable_i : in std_logic;
|
| 578 |
|
|
|
| 579 |
|
|
-- Port output interface.
|
| 580 |
|
|
portInitialized_i : in std_logic;
|
| 581 |
|
|
txFull_i : in std_logic;
|
| 582 |
|
|
txWrite_o : out std_logic;
|
| 583 |
|
|
txType_o : out std_logic_vector(2*NUMBER_WORDS-1 downto 0);
|
| 584 |
|
|
txData_o : out std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
| 585 |
|
|
|
| 586 |
|
|
-- Control symbols aimed to the transmitter.
|
| 587 |
|
|
txControlEmpty_i : in std_logic;
|
| 588 |
|
|
txControlSymbol_i : in std_logic_vector(13*NUMBER_WORDS-1 downto 0);
|
| 589 |
|
|
txControlUpdate_o : out std_logic;
|
| 590 |
|
|
|
| 591 |
|
|
-- Control symbols from the receiver to send.
|
| 592 |
|
|
rxControlEmpty_i : in std_logic;
|
| 593 |
|
|
rxControlSymbol_i : in std_logic_vector(13*NUMBER_WORDS-1 downto 0);
|
| 594 |
|
|
rxControlUpdate_o : out std_logic;
|
| 595 |
|
|
|
| 596 |
|
|
-- Internal signalling from the receiver part.
|
| 597 |
|
|
linkInitialized_o : out std_logic;
|
| 598 |
|
|
linkInitialized_i : in std_logic;
|
| 599 |
|
|
ackIdStatus_i : in std_logic_vector(4 downto 0);
|
| 600 |
|
|
|
| 601 |
|
|
-- Internal core variables for cascading.
|
| 602 |
13 |
magro732 |
timeSentSet_o : out std_logic;
|
| 603 |
|
|
timeSentReset_o : out std_logic;
|
| 604 |
|
|
timeSentExpired_i : in std_logic;
|
| 605 |
11 |
magro732 |
operational_i : in std_logic;
|
| 606 |
|
|
operational_o : out std_logic;
|
| 607 |
|
|
ackId_i : in std_logic_vector(4 downto 0);
|
| 608 |
|
|
ackId_o : out std_logic_vector(4 downto 0);
|
| 609 |
|
|
bufferStatus_i : in std_logic_vector(4 downto 0);
|
| 610 |
|
|
bufferStatus_o : out std_logic_vector(4 downto 0);
|
| 611 |
|
|
statusReceived_i : in std_logic;
|
| 612 |
|
|
statusReceived_o : out std_logic;
|
| 613 |
|
|
numberSentLinkRequests_i : in std_logic_vector(1 downto 0);
|
| 614 |
|
|
numberSentLinkRequests_o : out std_logic_vector(1 downto 0);
|
| 615 |
|
|
outputErrorStopped_i : in std_logic;
|
| 616 |
|
|
outputErrorStopped_o : out std_logic;
|
| 617 |
|
|
recoverActive_i : in std_logic;
|
| 618 |
|
|
recoverActive_o : out std_logic;
|
| 619 |
|
|
recoverCounter_i : in std_logic_vector(4 downto 0);
|
| 620 |
|
|
recoverCounter_o : out std_logic_vector(4 downto 0);
|
| 621 |
|
|
ackIdWindow_i : in std_logic_vector(4 downto 0);
|
| 622 |
|
|
ackIdWindow_o : out std_logic_vector(4 downto 0);
|
| 623 |
|
|
frameState_i : in std_logic_vector(4 downto 0);
|
| 624 |
|
|
frameState_o : out std_logic_vector(4 downto 0);
|
| 625 |
|
|
frameWordCounter_i : in std_logic_vector(1 downto 0);
|
| 626 |
|
|
frameWordCounter_o : out std_logic_vector(1 downto 0);
|
| 627 |
|
|
frameContent_i : in std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
| 628 |
|
|
frameContent_o : out std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
| 629 |
|
|
counter_i : in std_logic_vector(3 downto 0);
|
| 630 |
|
|
counter_o : out std_logic_vector(3 downto 0);
|
| 631 |
|
|
symbolsTransmitted_i : in std_logic_vector(7 downto 0);
|
| 632 |
|
|
symbolsTransmitted_o : out std_logic_vector(7 downto 0);
|
| 633 |
|
|
|
| 634 |
|
|
-- Frame buffer interface.
|
| 635 |
|
|
readFrameEmpty_i : in std_logic;
|
| 636 |
|
|
readFrame_o : out std_logic;
|
| 637 |
|
|
readFrameRestart_o : out std_logic;
|
| 638 |
|
|
readFrameAborted_i : in std_logic;
|
| 639 |
|
|
readWindowEmpty_i : in std_logic;
|
| 640 |
|
|
readWindowReset_o : out std_logic;
|
| 641 |
|
|
readWindowNext_o : out std_logic;
|
| 642 |
|
|
readContentEmpty_i : in std_logic;
|
| 643 |
|
|
readContent_o : out std_logic;
|
| 644 |
|
|
readContentEnd_i : in std_logic;
|
| 645 |
|
|
readContentWords_i : in std_logic_vector(1 downto 0);
|
| 646 |
|
|
readContentData_i : in std_logic_vector(32*NUMBER_WORDS-1 downto 0));
|
| 647 |
|
|
end component;
|
| 648 |
4 |
magro732 |
|
| 649 |
|
|
component MemorySimpleDualPortAsync is
|
| 650 |
|
|
generic(
|
| 651 |
|
|
ADDRESS_WIDTH : natural := 1;
|
| 652 |
|
|
DATA_WIDTH : natural := 1;
|
| 653 |
|
|
INIT_VALUE : std_logic := 'U');
|
| 654 |
|
|
port(
|
| 655 |
|
|
clkA_i : in std_logic;
|
| 656 |
|
|
enableA_i : in std_logic;
|
| 657 |
|
|
addressA_i : in std_logic_vector(ADDRESS_WIDTH-1 downto 0);
|
| 658 |
|
|
dataA_i : in std_logic_vector(DATA_WIDTH-1 downto 0);
|
| 659 |
|
|
|
| 660 |
|
|
addressB_i : in std_logic_vector(ADDRESS_WIDTH-1 downto 0);
|
| 661 |
|
|
dataB_o : out std_logic_vector(DATA_WIDTH-1 downto 0));
|
| 662 |
|
|
end component;
|
| 663 |
|
|
|
| 664 |
11 |
magro732 |
signal timeCurrent : std_logic_vector(TIMEOUT_WIDTH downto 0);
|
| 665 |
13 |
magro732 |
signal timeSentElapsed : unsigned(TIMEOUT_WIDTH downto 0);
|
| 666 |
|
|
signal timeSentDelta : unsigned(TIMEOUT_WIDTH downto 0);
|
| 667 |
|
|
signal timeSentExpired : std_logic;
|
| 668 |
|
|
signal timeSentSet : std_logic;
|
| 669 |
|
|
signal timeSentReset : std_logic;
|
| 670 |
|
|
|
| 671 |
|
|
signal timeSentEnable : std_logic;
|
| 672 |
11 |
magro732 |
signal timeSentWriteAddress : std_logic_vector(4 downto 0);
|
| 673 |
|
|
signal timeSentReadAddress : std_logic_vector(4 downto 0);
|
| 674 |
|
|
signal timeSentReadData : std_logic_vector(TIMEOUT_WIDTH downto 0);
|
| 675 |
4 |
magro732 |
|
| 676 |
11 |
magro732 |
signal operationalCurrent, operationalNext : std_logic;
|
| 677 |
|
|
signal ackIdCurrent, ackIdNext : std_logic_vector(4 downto 0);
|
| 678 |
4 |
magro732 |
signal bufferStatusCurrent, bufferStatusNext : std_logic_vector(4 downto 0);
|
| 679 |
11 |
magro732 |
signal statusReceivedCurrent, statusReceivedNext : std_logic;
|
| 680 |
|
|
signal numberSentLinkRequestsCurrent, numberSentLinkRequestsNext : std_logic_vector(1 downto 0);
|
| 681 |
|
|
signal outputErrorStoppedCurrent, outputErrorStoppedNext : std_logic;
|
| 682 |
|
|
signal recoverActiveCurrent, recoverActiveNext : std_logic;
|
| 683 |
|
|
signal recoverCounterCurrent, recoverCounterNext : std_logic_vector(4 downto 0);
|
| 684 |
|
|
signal ackIdWindowCurrent, ackIdWindowNext : std_logic_vector(4 downto 0);
|
| 685 |
|
|
signal frameStateCurrent, frameStateNext : std_logic_vector(4 downto 0);
|
| 686 |
|
|
signal frameWordCounterCurrent, frameWordCounterNext : std_logic_vector(1 downto 0);
|
| 687 |
|
|
signal frameContentCurrent, frameContentNext : std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
| 688 |
|
|
signal counterCurrent, counterNext : std_logic_vector(3 downto 0);
|
| 689 |
|
|
signal symbolsTransmittedCurrent, symbolsTransmittedNext : std_logic_vector(7 downto 0);
|
| 690 |
4 |
magro732 |
|
| 691 |
|
|
begin
|
| 692 |
|
|
|
| 693 |
|
|
process(areset_n, clk)
|
| 694 |
|
|
begin
|
| 695 |
|
|
if (areset_n = '0') then
|
| 696 |
11 |
magro732 |
timeCurrent <= (others=>'0');
|
| 697 |
4 |
magro732 |
elsif (clk'event and clk = '1') then
|
| 698 |
11 |
magro732 |
timeCurrent <= std_logic_vector(unsigned(timeCurrent) + 1);
|
| 699 |
4 |
magro732 |
end if;
|
| 700 |
|
|
end process;
|
| 701 |
|
|
|
| 702 |
13 |
magro732 |
timeSentElapsed <= unsigned(timeCurrent) - unsigned(timeSentReadData);
|
| 703 |
|
|
timeSentDelta <= unsigned('0' & portLinkTimeout_i) - timeSentElapsed;
|
| 704 |
|
|
timeSentExpired <= timeSentDelta(TIMEOUT_WIDTH);
|
| 705 |
|
|
|
| 706 |
|
|
timeSentEnable <= (not txFull_i) and (timeSentSet or timeSentReset);
|
| 707 |
|
|
timeSentWriteAddress <= ackIdWindowCurrent when timeSentSet = '1' else
|
| 708 |
|
|
ackIdCurrent;
|
| 709 |
|
|
timeSentReadAddress <= ackIdCurrent;
|
| 710 |
|
|
|
| 711 |
4 |
magro732 |
TimeoutMemory: MemorySimpleDualPortAsync
|
| 712 |
|
|
generic map(ADDRESS_WIDTH=>5, DATA_WIDTH=>TIMEOUT_WIDTH+1, INIT_VALUE=>'0')
|
| 713 |
|
|
port map(
|
| 714 |
13 |
magro732 |
clkA_i=>clk, enableA_i=>timeSentEnable,
|
| 715 |
|
|
addressA_i=>timeSentWriteAddress, dataA_i=>timeCurrent,
|
| 716 |
11 |
magro732 |
addressB_i=>timeSentReadAddress, dataB_o=>timeSentReadData);
|
| 717 |
4 |
magro732 |
|
| 718 |
|
|
process(areset_n, clk)
|
| 719 |
|
|
begin
|
| 720 |
|
|
if (areset_n = '0') then
|
| 721 |
11 |
magro732 |
operationalCurrent <= '0';
|
| 722 |
|
|
ackIdCurrent <= (others=>'0');
|
| 723 |
|
|
bufferStatusCurrent <= (others=>'0');
|
| 724 |
4 |
magro732 |
statusReceivedCurrent <= '0';
|
| 725 |
11 |
magro732 |
numberSentLinkRequestsCurrent <= (others=>'0');
|
| 726 |
|
|
outputErrorStoppedCurrent <= '0';
|
| 727 |
|
|
recoverActiveCurrent <= '0';
|
| 728 |
|
|
recoverCounterCurrent <= (others=>'0');
|
| 729 |
|
|
ackIdWindowCurrent <= (others=>'0');
|
| 730 |
|
|
frameStateCurrent <= (others=>'0');
|
| 731 |
|
|
frameWordCounterCurrent <= (others=>'0');
|
| 732 |
|
|
frameContentCurrent <= (others=>'0');
|
| 733 |
|
|
counterCurrent <= (others=>'0');
|
| 734 |
|
|
symbolsTransmittedCurrent <= (others=>'0');
|
| 735 |
4 |
magro732 |
elsif (clk'event and clk = '1') then
|
| 736 |
13 |
magro732 |
if (txFull_i = '0') then
|
| 737 |
|
|
operationalCurrent <= operationalNext;
|
| 738 |
|
|
ackIdCurrent <= ackIdNext;
|
| 739 |
|
|
bufferStatusCurrent <= bufferStatusNext;
|
| 740 |
|
|
statusReceivedCurrent <= statusReceivedNext;
|
| 741 |
|
|
numberSentLinkRequestsCurrent <= numberSentLinkRequestsNext;
|
| 742 |
|
|
outputErrorStoppedCurrent <= outputErrorStoppedNext;
|
| 743 |
|
|
recoverActiveCurrent <= recoverActiveNext;
|
| 744 |
|
|
recoverCounterCurrent <= recoverCounterNext;
|
| 745 |
|
|
ackIdWindowCurrent <= ackIdWindowNext;
|
| 746 |
|
|
frameStateCurrent <= frameStateNext;
|
| 747 |
|
|
frameWordCounterCurrent <= frameWordCounterNext;
|
| 748 |
|
|
frameContentCurrent <= frameContentNext;
|
| 749 |
|
|
counterCurrent <= counterNext;
|
| 750 |
|
|
symbolsTransmittedCurrent <= symbolsTransmittedNext;
|
| 751 |
|
|
end if;
|
| 752 |
4 |
magro732 |
end if;
|
| 753 |
|
|
end process;
|
| 754 |
11 |
magro732 |
|
| 755 |
|
|
TxCore: RioTransmitterCore
|
| 756 |
13 |
magro732 |
generic map(NUMBER_WORDS=>NUMBER_WORDS)
|
| 757 |
11 |
magro732 |
port map(
|
| 758 |
|
|
clk=>clk, areset_n=>areset_n,
|
| 759 |
13 |
magro732 |
portEnable_i=>portEnable_i,
|
| 760 |
11 |
magro732 |
portInitialized_i=>portInitialized_i,
|
| 761 |
|
|
txFull_i=>txFull_i, txWrite_o=>txWrite_o, txType_o=>txType_o, txData_o=>txData_o,
|
| 762 |
|
|
txControlEmpty_i=>txControlEmpty_i,
|
| 763 |
|
|
txControlSymbol_i=>txControlSymbol_i,
|
| 764 |
|
|
txControlUpdate_o=>txControlUpdate_o,
|
| 765 |
|
|
rxControlEmpty_i=>rxControlEmpty_i,
|
| 766 |
|
|
rxControlSymbol_i=>rxControlSymbol_i,
|
| 767 |
|
|
rxControlUpdate_o=>rxControlUpdate_o,
|
| 768 |
|
|
linkInitialized_o=>linkInitialized_o,
|
| 769 |
|
|
linkInitialized_i=>linkInitialized_i,
|
| 770 |
|
|
ackIdStatus_i=>ackIdStatus_i,
|
| 771 |
4 |
magro732 |
|
| 772 |
13 |
magro732 |
timeSentSet_o=>timeSentSet,
|
| 773 |
|
|
timeSentReset_o=>timeSentReset,
|
| 774 |
|
|
timeSentExpired_i=>timeSentExpired,
|
| 775 |
11 |
magro732 |
|
| 776 |
|
|
operational_i=>operationalCurrent, operational_o=>operationalNext,
|
| 777 |
|
|
ackId_i=>ackIdCurrent, ackId_o=>ackIdNext,
|
| 778 |
|
|
bufferStatus_i=>bufferStatusCurrent, bufferStatus_o=>bufferStatusNext,
|
| 779 |
|
|
statusReceived_i=>statusReceivedCurrent, statusReceived_o=>statusReceivedNext,
|
| 780 |
|
|
numberSentLinkRequests_i=>numberSentLinkRequestsCurrent, numberSentLinkRequests_o=>numberSentLinkRequestsNext,
|
| 781 |
|
|
outputErrorStopped_i=>outputErrorStoppedCurrent, outputErrorStopped_o=>outputErrorStoppedNext,
|
| 782 |
|
|
recoverActive_i=>recoverActiveCurrent, recoverActive_o=>recoverActiveNext,
|
| 783 |
|
|
recoverCounter_i=>recoverCounterCurrent, recoverCounter_o=>recoverCounterNext,
|
| 784 |
|
|
ackIdWindow_i=>ackIdWindowCurrent, ackIdWindow_o=>ackIdWindowNext,
|
| 785 |
|
|
frameState_i=>frameStateCurrent, frameState_o=>frameStateNext,
|
| 786 |
|
|
frameWordCounter_i=>frameWordCounterCurrent, frameWordCounter_o=>frameWordCounterNext,
|
| 787 |
|
|
frameContent_i=>frameContentCurrent, frameContent_o=>frameContentNext,
|
| 788 |
|
|
counter_i=>counterCurrent, counter_o=>counterNext,
|
| 789 |
|
|
symbolsTransmitted_i=>symbolsTransmittedCurrent, symbolsTransmitted_o=>symbolsTransmittedNext,
|
| 790 |
4 |
magro732 |
|
| 791 |
11 |
magro732 |
readFrameEmpty_i=>readFrameEmpty_i,
|
| 792 |
|
|
readFrame_o=>readFrame_o,
|
| 793 |
|
|
readFrameRestart_o=>readFrameRestart_o,
|
| 794 |
|
|
readFrameAborted_i=>readFrameAborted_i,
|
| 795 |
|
|
readWindowEmpty_i=>readWindowEmpty_i,
|
| 796 |
|
|
readWindowReset_o=>readWindowReset_o,
|
| 797 |
|
|
readWindowNext_o=>readWindowNext_o,
|
| 798 |
|
|
readContentEmpty_i=>readContentEmpty_i,
|
| 799 |
|
|
readContent_o=>readContent_o,
|
| 800 |
|
|
readContentEnd_i=>readContentEnd_i,
|
| 801 |
|
|
readContentWords_i=>readContentWords_i,
|
| 802 |
|
|
readContentData_i=>readContentData_i);
|
| 803 |
4 |
magro732 |
|
| 804 |
11 |
magro732 |
end architecture;
|
| 805 |
|
|
|
| 806 |
|
|
|
| 807 |
|
|
|
| 808 |
|
|
-------------------------------------------------------------------------------
|
| 809 |
|
|
-- RioTransmitterCore
|
| 810 |
|
|
-------------------------------------------------------------------------------
|
| 811 |
|
|
library ieee;
|
| 812 |
|
|
use ieee.std_logic_1164.all;
|
| 813 |
|
|
use ieee.numeric_std.all;
|
| 814 |
|
|
use work.rio_common.all;
|
| 815 |
|
|
|
| 816 |
|
|
-------------------------------------------------------------------------------
|
| 817 |
|
|
-- Entity for RioTransmitterCore.
|
| 818 |
|
|
-------------------------------------------------------------------------------
|
| 819 |
|
|
entity RioTransmitterCore is
|
| 820 |
|
|
generic(
|
| 821 |
|
|
NUMBER_WORDS : natural range 1 to 4 := 1);
|
| 822 |
|
|
port(
|
| 823 |
|
|
-- System signals.
|
| 824 |
|
|
clk : in std_logic;
|
| 825 |
|
|
areset_n : in std_logic;
|
| 826 |
|
|
|
| 827 |
|
|
-- Status signals used for maintenance.
|
| 828 |
|
|
portEnable_i : in std_logic;
|
| 829 |
|
|
|
| 830 |
|
|
-- Port output interface.
|
| 831 |
|
|
portInitialized_i : in std_logic;
|
| 832 |
|
|
txFull_i : in std_logic;
|
| 833 |
|
|
txWrite_o : out std_logic;
|
| 834 |
|
|
txType_o : out std_logic_vector(2*NUMBER_WORDS-1 downto 0);
|
| 835 |
|
|
txData_o : out std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
| 836 |
|
|
|
| 837 |
|
|
-- Control symbols aimed to the transmitter.
|
| 838 |
|
|
txControlEmpty_i : in std_logic;
|
| 839 |
|
|
txControlSymbol_i : in std_logic_vector(13*NUMBER_WORDS-1 downto 0);
|
| 840 |
|
|
txControlUpdate_o : out std_logic;
|
| 841 |
|
|
|
| 842 |
|
|
-- Control symbols from the receiver to send.
|
| 843 |
|
|
rxControlEmpty_i : in std_logic;
|
| 844 |
|
|
rxControlSymbol_i : in std_logic_vector(13*NUMBER_WORDS-1 downto 0);
|
| 845 |
|
|
rxControlUpdate_o : out std_logic;
|
| 846 |
|
|
|
| 847 |
|
|
-- Internal signalling from the receiver part.
|
| 848 |
|
|
linkInitialized_o : out std_logic;
|
| 849 |
|
|
linkInitialized_i : in std_logic;
|
| 850 |
|
|
ackIdStatus_i : in std_logic_vector(4 downto 0);
|
| 851 |
|
|
|
| 852 |
|
|
-- Internal core variables for cascading.
|
| 853 |
13 |
magro732 |
timeSentSet_o : out std_logic;
|
| 854 |
|
|
timeSentReset_o : out std_logic;
|
| 855 |
|
|
timeSentExpired_i : in std_logic;
|
| 856 |
11 |
magro732 |
|
| 857 |
|
|
operational_i : in std_logic;
|
| 858 |
|
|
operational_o : out std_logic;
|
| 859 |
|
|
ackId_i : in std_logic_vector(4 downto 0);
|
| 860 |
|
|
ackId_o : out std_logic_vector(4 downto 0);
|
| 861 |
|
|
bufferStatus_i : in std_logic_vector(4 downto 0);
|
| 862 |
|
|
bufferStatus_o : out std_logic_vector(4 downto 0);
|
| 863 |
|
|
statusReceived_i : in std_logic;
|
| 864 |
|
|
statusReceived_o : out std_logic;
|
| 865 |
|
|
numberSentLinkRequests_i : in std_logic_vector(1 downto 0);
|
| 866 |
|
|
numberSentLinkRequests_o : out std_logic_vector(1 downto 0);
|
| 867 |
|
|
outputErrorStopped_i : in std_logic;
|
| 868 |
|
|
outputErrorStopped_o : out std_logic;
|
| 869 |
|
|
recoverActive_i : in std_logic;
|
| 870 |
|
|
recoverActive_o : out std_logic;
|
| 871 |
|
|
recoverCounter_i : in std_logic_vector(4 downto 0);
|
| 872 |
|
|
recoverCounter_o : out std_logic_vector(4 downto 0);
|
| 873 |
|
|
ackIdWindow_i : in std_logic_vector(4 downto 0);
|
| 874 |
|
|
ackIdWindow_o : out std_logic_vector(4 downto 0);
|
| 875 |
|
|
frameState_i : in std_logic_vector(4 downto 0);
|
| 876 |
|
|
frameState_o : out std_logic_vector(4 downto 0);
|
| 877 |
|
|
frameWordCounter_i : in std_logic_vector(1 downto 0);
|
| 878 |
|
|
frameWordCounter_o : out std_logic_vector(1 downto 0);
|
| 879 |
|
|
frameContent_i : in std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
| 880 |
|
|
frameContent_o : out std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
| 881 |
|
|
counter_i : in std_logic_vector(3 downto 0);
|
| 882 |
|
|
counter_o : out std_logic_vector(3 downto 0);
|
| 883 |
|
|
symbolsTransmitted_i : in std_logic_vector(7 downto 0);
|
| 884 |
|
|
symbolsTransmitted_o : out std_logic_vector(7 downto 0);
|
| 885 |
|
|
|
| 886 |
|
|
-- Frame buffer interface.
|
| 887 |
|
|
readFrameEmpty_i : in std_logic;
|
| 888 |
|
|
readFrame_o : out std_logic;
|
| 889 |
|
|
readFrameRestart_o : out std_logic;
|
| 890 |
|
|
readFrameAborted_i : in std_logic;
|
| 891 |
|
|
readWindowEmpty_i : in std_logic;
|
| 892 |
|
|
readWindowReset_o : out std_logic;
|
| 893 |
|
|
readWindowNext_o : out std_logic;
|
| 894 |
|
|
readContentEmpty_i : in std_logic;
|
| 895 |
|
|
readContent_o : out std_logic;
|
| 896 |
|
|
readContentEnd_i : in std_logic;
|
| 897 |
|
|
readContentWords_i : in std_logic_vector(1 downto 0);
|
| 898 |
|
|
readContentData_i : in std_logic_vector(32*NUMBER_WORDS-1 downto 0));
|
| 899 |
|
|
end entity;
|
| 900 |
4 |
magro732 |
|
| 901 |
|
|
|
| 902 |
11 |
magro732 |
-------------------------------------------------------------------------------
|
| 903 |
|
|
-- Architecture for RioTransmitterCore.
|
| 904 |
|
|
-------------------------------------------------------------------------------
|
| 905 |
13 |
magro732 |
-- REMARK: Check that all _o except channel variables are registered...
|
| 906 |
11 |
magro732 |
architecture RioTransmitterCoreImpl of RioTransmitterCore is
|
| 907 |
4 |
magro732 |
|
| 908 |
11 |
magro732 |
constant NUMBER_STATUS_TRANSMIT : std_logic_vector := "1111";
|
| 909 |
|
|
constant NUMBER_LINK_RESPONSE_RETRIES : std_logic_vector := "10";
|
| 910 |
4 |
magro732 |
|
| 911 |
11 |
magro732 |
-- REMARK: Binary coding???
|
| 912 |
|
|
constant FRAME_START : std_logic_vector(4 downto 0) := "00001";
|
| 913 |
|
|
constant FRAME_CHECK : std_logic_vector(4 downto 0) := "00010";
|
| 914 |
|
|
constant FRAME_ACKID : std_logic_vector(4 downto 0) := "00100";
|
| 915 |
|
|
constant FRAME_BODY : std_logic_vector(4 downto 0) := "01000";
|
| 916 |
|
|
constant FRAME_END : std_logic_vector(4 downto 0) := "10000";
|
| 917 |
|
|
|
| 918 |
|
|
component Crc5ITU is
|
| 919 |
|
|
port(
|
| 920 |
|
|
d_i : in std_logic_vector(18 downto 0);
|
| 921 |
|
|
crc_o : out std_logic_vector(4 downto 0));
|
| 922 |
|
|
end component;
|
| 923 |
4 |
magro732 |
|
| 924 |
13 |
magro732 |
signal txControlUpdateOut : std_logic;
|
| 925 |
11 |
magro732 |
signal sendRestartFromRetry, sendRestartFromRetryOut : std_logic;
|
| 926 |
|
|
signal sendLinkRequest, sendLinkRequestOut : std_logic;
|
| 927 |
4 |
magro732 |
|
| 928 |
13 |
magro732 |
signal readFrameOut : std_logic;
|
| 929 |
|
|
signal readFrameRestartOut : std_logic;
|
| 930 |
|
|
signal readWindowResetOut : std_logic;
|
| 931 |
|
|
signal readWindowNextOut : std_logic;
|
| 932 |
|
|
signal readContentOut : std_logic;
|
| 933 |
11 |
magro732 |
signal symbolControlRestartOut, symbolControlRestart : std_logic;
|
| 934 |
|
|
signal symbolControlLinkRequestOut, symbolControlLinkRequest : std_logic;
|
| 935 |
|
|
signal symbolControlStartOut, symbolControlStart : std_logic;
|
| 936 |
|
|
signal symbolControlEndOut, symbolControlEnd : std_logic;
|
| 937 |
|
|
signal symbolDataOut, symbolData : std_logic;
|
| 938 |
|
|
signal symbolDataContentOut, symbolDataContent : std_logic_vector(31 downto 0);
|
| 939 |
4 |
magro732 |
|
| 940 |
13 |
magro732 |
signal rxControlUpdateOut : std_logic;
|
| 941 |
11 |
magro732 |
signal symbolControlStype1 : std_logic;
|
| 942 |
|
|
signal controlValidOut, controlValid : std_logic;
|
| 943 |
|
|
signal stype0Out, stype0 : std_logic_vector(2 downto 0);
|
| 944 |
|
|
signal parameter0Out, parameter0 : std_logic_vector(4 downto 0);
|
| 945 |
|
|
signal parameter1Out, parameter1 : std_logic_vector(4 downto 0);
|
| 946 |
|
|
signal stype1 : std_logic_vector(2 downto 0);
|
| 947 |
|
|
signal cmd : std_logic_vector(2 downto 0);
|
| 948 |
|
|
signal dataValid : std_logic;
|
| 949 |
|
|
signal dataContent : std_logic_vector(31 downto 0);
|
| 950 |
|
|
|
| 951 |
|
|
signal controlContent : std_logic_vector(31 downto 0);
|
| 952 |
|
|
signal crc5 : std_logic_vector(4 downto 0);
|
| 953 |
|
|
|
| 954 |
|
|
signal txControlStype0 : std_logic_vector(2 downto 0);
|
| 955 |
|
|
signal txControlParameter0 : std_logic_vector(4 downto 0);
|
| 956 |
|
|
signal txControlParameter1 : std_logic_vector(4 downto 0);
|
| 957 |
4 |
magro732 |
|
| 958 |
11 |
magro732 |
signal rxControlStype0 : std_logic_vector(2 downto 0);
|
| 959 |
|
|
signal rxControlParameter0 : std_logic_vector(4 downto 0);
|
| 960 |
|
|
signal rxControlParameter1 : std_logic_vector(4 downto 0);
|
| 961 |
4 |
magro732 |
|
| 962 |
11 |
magro732 |
begin
|
| 963 |
4 |
magro732 |
|
| 964 |
11 |
magro732 |
linkInitialized_o <= operational_i;
|
| 965 |
|
|
|
| 966 |
|
|
-----------------------------------------------------------------------------
|
| 967 |
12 |
magro732 |
-- Assign control symbol from fifo signals.
|
| 968 |
|
|
-----------------------------------------------------------------------------
|
| 969 |
|
|
|
| 970 |
|
|
txControlStype0 <= txControlSymbol_i(12 downto 10);
|
| 971 |
|
|
txControlParameter0 <= txControlSymbol_i(9 downto 5);
|
| 972 |
|
|
txControlParameter1 <= txControlSymbol_i(4 downto 0);
|
| 973 |
|
|
|
| 974 |
|
|
rxControlStype0 <= rxControlSymbol_i(12 downto 10);
|
| 975 |
|
|
rxControlParameter0 <= rxControlSymbol_i(9 downto 5);
|
| 976 |
|
|
rxControlParameter1 <= rxControlSymbol_i(4 downto 0);
|
| 977 |
|
|
|
| 978 |
|
|
-----------------------------------------------------------------------------
|
| 979 |
11 |
magro732 |
-- N-3
|
| 980 |
|
|
-- Receive stuff from link-partner and timeout supervision.
|
| 981 |
|
|
-- Input: ackId, ackIdWindow, timeoutExpired
|
| 982 |
|
|
-- Output: sendLinkRequest, sendRestartFromRetry, ackId,
|
| 983 |
|
|
-----------------------------------------------------------------------------
|
| 984 |
4 |
magro732 |
|
| 985 |
11 |
magro732 |
process(clk, areset_n)
|
| 986 |
|
|
begin
|
| 987 |
|
|
if (areset_n = '0') then
|
| 988 |
13 |
magro732 |
txControlUpdate_o <= '0';
|
| 989 |
|
|
readFrame_o <= '0';
|
| 990 |
|
|
|
| 991 |
11 |
magro732 |
sendRestartFromRetry <= '0';
|
| 992 |
|
|
sendLinkRequest <= '0';
|
| 993 |
|
|
elsif (clk'event and clk = '1') then
|
| 994 |
13 |
magro732 |
txControlUpdate_o <= '0';
|
| 995 |
|
|
readFrame_o <= '0';
|
| 996 |
|
|
|
| 997 |
|
|
if (txFull_i = '0') then
|
| 998 |
|
|
txControlUpdate_o <= txControlUpdateOut;
|
| 999 |
|
|
readFrame_o <= readFrameOut;
|
| 1000 |
|
|
|
| 1001 |
|
|
sendRestartFromRetry <= sendRestartFromRetryOut;
|
| 1002 |
|
|
sendLinkRequest <= sendLinkRequestOut;
|
| 1003 |
|
|
end if;
|
| 1004 |
11 |
magro732 |
end if;
|
| 1005 |
|
|
end process;
|
| 1006 |
|
|
|
| 1007 |
12 |
magro732 |
process(outputErrorStopped_i, recoverActive_i, recoverCounter_i,
|
| 1008 |
13 |
magro732 |
ackId_i, ackIdWindow_i, bufferStatus_i, statusReceived_i,
|
| 1009 |
12 |
magro732 |
numberSentLinkRequests_i,
|
| 1010 |
13 |
magro732 |
operational_i,
|
| 1011 |
12 |
magro732 |
txControlEmpty_i, txControlStype0,
|
| 1012 |
13 |
magro732 |
txControlParameter0, txControlParameter1,
|
| 1013 |
|
|
timeSentExpired_i)
|
| 1014 |
11 |
magro732 |
begin
|
| 1015 |
|
|
outputErrorStopped_o <= outputErrorStopped_i;
|
| 1016 |
|
|
recoverActive_o <= recoverActive_i;
|
| 1017 |
|
|
recoverCounter_o <= recoverCounter_i;
|
| 1018 |
|
|
ackId_o <= ackId_i;
|
| 1019 |
|
|
bufferStatus_o <= bufferStatus_i;
|
| 1020 |
|
|
statusReceived_o <= statusReceived_i;
|
| 1021 |
|
|
numberSentLinkRequests_o <= numberSentLinkRequests_i;
|
| 1022 |
4 |
magro732 |
|
| 1023 |
13 |
magro732 |
timeSentReset_o <= '0';
|
| 1024 |
|
|
txControlUpdateOut <= '0';
|
| 1025 |
|
|
readFrameOut <= '0';
|
| 1026 |
12 |
magro732 |
|
| 1027 |
11 |
magro732 |
sendRestartFromRetryOut <= '0';
|
| 1028 |
|
|
sendLinkRequestOut <= '0';
|
| 1029 |
4 |
magro732 |
|
| 1030 |
11 |
magro732 |
if (recoverActive_i = '1') then
|
| 1031 |
|
|
if (ackId_i /= recoverCounter_i) then
|
| 1032 |
|
|
ackId_o <= std_logic_vector(unsigned(ackId_i) + 1);
|
| 1033 |
13 |
magro732 |
readFrameOut <= '1';
|
| 1034 |
11 |
magro732 |
else
|
| 1035 |
|
|
recoverActive_o <= '0';
|
| 1036 |
|
|
outputErrorStopped_o <= '0';
|
| 1037 |
|
|
end if;
|
| 1038 |
|
|
else
|
| 1039 |
13 |
magro732 |
if (operational_i = '0') then
|
| 1040 |
|
|
if (txControlEmpty_i = '0') then
|
| 1041 |
|
|
if (txControlStype0 = STYPE0_STATUS) then
|
| 1042 |
|
|
-- A status-control symbol has been received.
|
| 1043 |
|
|
ackId_o <= txControlParameter0;
|
| 1044 |
|
|
bufferStatus_o <= txControlParameter1;
|
| 1045 |
|
|
statusReceived_o <= '1';
|
| 1046 |
|
|
else
|
| 1047 |
|
|
-- Discard all other received symbols in this state.
|
| 1048 |
|
|
end if;
|
| 1049 |
|
|
txControlUpdateOut <= '1';
|
| 1050 |
|
|
end if;
|
| 1051 |
|
|
else
|
| 1052 |
|
|
-- Operational mode.
|
| 1053 |
|
|
|
| 1054 |
|
|
-- Make sure to reset the status received flag.
|
| 1055 |
|
|
statusReceived_o <= '0';
|
| 1056 |
|
|
|
| 1057 |
|
|
-- Check if the oldest frame timeout has expired.
|
| 1058 |
|
|
-- REMARK: Two link-requests are transmitted when a timeout occurrs...
|
| 1059 |
|
|
if ((ackId_i /= ackIdWindow_i) and
|
| 1060 |
|
|
(timeSentExpired_i = '1')) then
|
| 1061 |
|
|
-- There has been a timeout on a transmitted frame.
|
| 1062 |
|
|
|
| 1063 |
|
|
-- Reset the timeout to expire when the transmitted link-request has
|
| 1064 |
|
|
-- timed out instead.
|
| 1065 |
|
|
timeSentReset_o <= '1';
|
| 1066 |
|
|
|
| 1067 |
|
|
if (outputErrorStopped_i = '1') then
|
| 1068 |
|
|
-- Count the number of retransmissions and abort if
|
| 1069 |
|
|
-- no reply has been received for too many times.
|
| 1070 |
|
|
if (unsigned(numberSentLinkRequests_i) /= 0) then
|
| 1071 |
|
|
-- Not sent link-request too many times.
|
| 1072 |
|
|
|
| 1073 |
|
|
-- Send another link-request.
|
| 1074 |
|
|
sendLinkRequestOut <= '1';
|
| 1075 |
|
|
numberSentLinkRequests_o <= std_logic_vector(unsigned(numberSentLinkRequests_i) - 1);
|
| 1076 |
4 |
magro732 |
else
|
| 1077 |
13 |
magro732 |
-- No response for too many times.
|
| 1078 |
|
|
-- REMARK: What to do here???
|
| 1079 |
|
|
--readWindowReset_o <= '1';
|
| 1080 |
|
|
--stateNext <= STATE_UNINITIALIZED;
|
| 1081 |
4 |
magro732 |
end if;
|
| 1082 |
13 |
magro732 |
else
|
| 1083 |
|
|
sendLinkRequestOut <= '1';
|
| 1084 |
|
|
numberSentLinkRequests_o <= NUMBER_LINK_RESPONSE_RETRIES;
|
| 1085 |
|
|
outputErrorStopped_o <= '1';
|
| 1086 |
11 |
magro732 |
end if;
|
| 1087 |
|
|
else
|
| 1088 |
13 |
magro732 |
-- There has been no timeout.
|
| 1089 |
|
|
|
| 1090 |
|
|
-- Check if any control symbol has been received from the link
|
| 1091 |
|
|
-- partner.
|
| 1092 |
|
|
if (txControlEmpty_i = '0') then
|
| 1093 |
|
|
-- A control symbol has been received.
|
| 1094 |
4 |
magro732 |
|
| 1095 |
13 |
magro732 |
-- Check the received control symbol.
|
| 1096 |
|
|
case txControlStype0 is
|
| 1097 |
|
|
|
| 1098 |
|
|
when STYPE0_STATUS =>
|
| 1099 |
|
|
if (outputErrorStopped_i = '0') then
|
| 1100 |
|
|
-- Save the number of buffers in the link partner.
|
| 1101 |
|
|
bufferStatus_o <= txControlParameter1;
|
| 1102 |
|
|
end if;
|
| 1103 |
4 |
magro732 |
|
| 1104 |
13 |
magro732 |
when STYPE0_PACKET_ACCEPTED =>
|
| 1105 |
|
|
-- The link partner is accepting a frame.
|
| 1106 |
4 |
magro732 |
|
| 1107 |
13 |
magro732 |
if (outputErrorStopped_i = '0') then
|
| 1108 |
|
|
-- Save the number of buffers in the link partner.
|
| 1109 |
|
|
bufferStatus_o <= txControlParameter1;
|
| 1110 |
4 |
magro732 |
|
| 1111 |
13 |
magro732 |
-- Check if expecting this type of reply and that the ackId is
|
| 1112 |
|
|
-- expected.
|
| 1113 |
|
|
if ((ackId_i /= ackIdWindow_i) and
|
| 1114 |
|
|
(ackId_i = txControlParameter0)) then
|
| 1115 |
|
|
-- The packet-accepted is expected and the ackId is the expected.
|
| 1116 |
|
|
-- The frame has been accepted by the link partner.
|
| 1117 |
11 |
magro732 |
|
| 1118 |
13 |
magro732 |
-- Update to a new buffer and increment the ackId.
|
| 1119 |
|
|
readFrameOut <= '1';
|
| 1120 |
|
|
ackId_o <= std_logic_vector(unsigned(ackId_i) + 1);
|
| 1121 |
|
|
else
|
| 1122 |
|
|
-- Unexpected packet-accepted or packet-accepted for
|
| 1123 |
|
|
-- unexpected ackId.
|
| 1124 |
|
|
sendLinkRequestOut <= '1';
|
| 1125 |
|
|
numberSentLinkRequests_o <= NUMBER_LINK_RESPONSE_RETRIES;
|
| 1126 |
|
|
outputErrorStopped_o <= '1';
|
| 1127 |
4 |
magro732 |
end if;
|
| 1128 |
13 |
magro732 |
end if;
|
| 1129 |
|
|
|
| 1130 |
|
|
when STYPE0_PACKET_RETRY =>
|
| 1131 |
|
|
-- The link partner has asked for a frame retransmission.
|
| 1132 |
4 |
magro732 |
|
| 1133 |
13 |
magro732 |
if (outputErrorStopped_i = '0') then
|
| 1134 |
|
|
-- Save the number of buffers in the link partner.
|
| 1135 |
|
|
bufferStatus_o <= txControlParameter1;
|
| 1136 |
4 |
magro732 |
|
| 1137 |
13 |
magro732 |
-- Check if the ackId is the one expected.
|
| 1138 |
|
|
if (ackId_i = txControlParameter0) then
|
| 1139 |
|
|
-- The ackId to retry is expected.
|
| 1140 |
|
|
-- Go to the output-retry-stopped state.
|
| 1141 |
|
|
-- REMARK: The output-retry-stopped state is equivalent
|
| 1142 |
|
|
-- to sending a restart-from-retry.
|
| 1143 |
|
|
sendRestartFromRetryOut <= '1';
|
| 1144 |
|
|
else
|
| 1145 |
|
|
-- Unexpected ackId to retry.
|
| 1146 |
11 |
magro732 |
sendLinkRequestOut <= '1';
|
| 1147 |
|
|
numberSentLinkRequests_o <= NUMBER_LINK_RESPONSE_RETRIES;
|
| 1148 |
|
|
outputErrorStopped_o <= '1';
|
| 1149 |
|
|
end if;
|
| 1150 |
13 |
magro732 |
end if;
|
| 1151 |
|
|
|
| 1152 |
|
|
when STYPE0_PACKET_NOT_ACCEPTED =>
|
| 1153 |
|
|
if (outputErrorStopped_i = '0') then
|
| 1154 |
|
|
-- Packet was rejected by the link-partner.
|
| 1155 |
|
|
sendLinkRequestOut <= '1';
|
| 1156 |
|
|
numberSentLinkRequests_o <= NUMBER_LINK_RESPONSE_RETRIES;
|
| 1157 |
|
|
outputErrorStopped_o <= '1';
|
| 1158 |
|
|
end if;
|
| 1159 |
|
|
|
| 1160 |
|
|
when STYPE0_LINK_RESPONSE =>
|
| 1161 |
|
|
if (outputErrorStopped_i = '1') then
|
| 1162 |
|
|
-- Check if the link partner return value is acceptable.
|
| 1163 |
|
|
if ((unsigned(txControlParameter0) - unsigned(ackId_i)) <=
|
| 1164 |
|
|
(unsigned(ackIdWindow_i) - unsigned(ackId_i))) then
|
| 1165 |
|
|
-- Recoverable error.
|
| 1166 |
|
|
-- Use the received ackId and recover by removing packets
|
| 1167 |
|
|
-- that has been received by the link-partner.
|
| 1168 |
|
|
recoverCounter_o <= txControlParameter0;
|
| 1169 |
|
|
recoverActive_o <= '1';
|
| 1170 |
11 |
magro732 |
else
|
| 1171 |
13 |
magro732 |
-- Totally out of sync.
|
| 1172 |
|
|
-- REMARK: What to do here???
|
| 1173 |
|
|
--readWindowReset_o <= '1';
|
| 1174 |
|
|
--stateNext <= STATE_UNINITIALIZED;
|
| 1175 |
11 |
magro732 |
end if;
|
| 1176 |
13 |
magro732 |
else
|
| 1177 |
|
|
-- Dont expect or need a link-response in this state.
|
| 1178 |
4 |
magro732 |
-- Discard it.
|
| 1179 |
13 |
magro732 |
end if;
|
| 1180 |
|
|
|
| 1181 |
|
|
when STYPE0_VC_STATUS =>
|
| 1182 |
|
|
-- Not supported.
|
| 1183 |
|
|
-- Discard it.
|
| 1184 |
|
|
|
| 1185 |
|
|
when STYPE0_RESERVED =>
|
| 1186 |
|
|
-- Not supported.
|
| 1187 |
|
|
-- Discard it.
|
| 1188 |
4 |
magro732 |
|
| 1189 |
13 |
magro732 |
when STYPE0_IMPLEMENTATION_DEFINED =>
|
| 1190 |
|
|
-- Not supported.
|
| 1191 |
|
|
-- Discard it.
|
| 1192 |
|
|
|
| 1193 |
|
|
when others =>
|
| 1194 |
|
|
null;
|
| 1195 |
|
|
end case;
|
| 1196 |
4 |
magro732 |
|
| 1197 |
13 |
magro732 |
-- Indicate the control symbol has been processed.
|
| 1198 |
|
|
txControlUpdateOut <= '1';
|
| 1199 |
11 |
magro732 |
end if;
|
| 1200 |
|
|
end if;
|
| 1201 |
|
|
end if;
|
| 1202 |
|
|
end if;
|
| 1203 |
|
|
end process;
|
| 1204 |
|
|
|
| 1205 |
|
|
-----------------------------------------------------------------------------
|
| 1206 |
|
|
-- N-2 pipeline stage.
|
| 1207 |
|
|
-- Create stype1-part of symbols and data symbols. Save the time when a
|
| 1208 |
|
|
-- packet was fully sent.
|
| 1209 |
|
|
-- Input: sendRestartFromRetry, sendLinkRequest
|
| 1210 |
|
|
-- Output: ackIdWindow, frameState, timeout(0 to 31),
|
| 1211 |
|
|
-- symbolControlStart, symbolControlEnd, symbolControlRestart,
|
| 1212 |
|
|
-- symbolControlLinkRequest, symbolData2, symbolData2Content.
|
| 1213 |
|
|
-----------------------------------------------------------------------------
|
| 1214 |
4 |
magro732 |
|
| 1215 |
11 |
magro732 |
process(clk, areset_n)
|
| 1216 |
|
|
begin
|
| 1217 |
|
|
if (areset_n = '0') then
|
| 1218 |
13 |
magro732 |
readFrameRestart_o <= '0';
|
| 1219 |
|
|
readWindowReset_o <= '0';
|
| 1220 |
|
|
readWindowNext_o <= '0';
|
| 1221 |
|
|
readContent_o <= '0';
|
| 1222 |
|
|
|
| 1223 |
11 |
magro732 |
symbolControlRestart <= '0';
|
| 1224 |
|
|
symbolControlLinkRequest <= '0';
|
| 1225 |
|
|
symbolControlStart <= '0';
|
| 1226 |
|
|
symbolControlEnd <= '0';
|
| 1227 |
|
|
symbolData <= '0';
|
| 1228 |
|
|
symbolDataContent <= (others => '0');
|
| 1229 |
|
|
elsif (clk'event and clk = '1') then
|
| 1230 |
13 |
magro732 |
readFrameRestart_o <= '0';
|
| 1231 |
|
|
readWindowReset_o <= '0';
|
| 1232 |
|
|
readWindowNext_o <= '0';
|
| 1233 |
|
|
readContent_o <= '0';
|
| 1234 |
|
|
|
| 1235 |
|
|
if (txFull_i = '0') then
|
| 1236 |
|
|
readFrameRestart_o <= readFrameRestartOut;
|
| 1237 |
|
|
readWindowReset_o <= readWindowResetOut;
|
| 1238 |
|
|
readWindowNext_o <= readWindowNextOut;
|
| 1239 |
|
|
readContent_o <= readContentOut;
|
| 1240 |
|
|
|
| 1241 |
|
|
symbolControlRestart <= symbolControlRestartOut;
|
| 1242 |
|
|
symbolControlLinkRequest <= symbolControlLinkRequestOut;
|
| 1243 |
|
|
symbolControlStart <= symbolControlStartOut;
|
| 1244 |
|
|
symbolControlEnd <= symbolControlEndOut;
|
| 1245 |
|
|
symbolData <= symbolDataOut;
|
| 1246 |
|
|
symbolDataContent <= symbolDataContentOut;
|
| 1247 |
|
|
end if;
|
| 1248 |
11 |
magro732 |
end if;
|
| 1249 |
|
|
end process;
|
| 1250 |
|
|
|
| 1251 |
|
|
-- This process decide which stype1-part of a control symbols to send as well
|
| 1252 |
|
|
-- as all data symbols.
|
| 1253 |
13 |
magro732 |
process(readWindowEmpty_i, bufferStatus_i,
|
| 1254 |
|
|
recoverActive_i, recoverCounter_i, ackId_i, operational_i, outputErrorStopped_i, portEnable_i, readContentData_i, readContentWords_i, readContentEnd_i,
|
| 1255 |
|
|
frameState_i, frameWordCounter_i, frameContent_i,
|
| 1256 |
|
|
ackIdWindow_i,
|
| 1257 |
12 |
magro732 |
sendRestartFromRetry, sendLinkRequest)
|
| 1258 |
11 |
magro732 |
begin
|
| 1259 |
13 |
magro732 |
readFrameRestartOut <= '0';
|
| 1260 |
|
|
readWindowResetOut <= '0';
|
| 1261 |
|
|
readWindowNextOut <= '0';
|
| 1262 |
|
|
readContentOut <= '0';
|
| 1263 |
4 |
magro732 |
|
| 1264 |
11 |
magro732 |
frameState_o <= frameState_i;
|
| 1265 |
12 |
magro732 |
frameWordCounter_o <= frameWordCounter_i;
|
| 1266 |
|
|
frameContent_o <= frameContent_i;
|
| 1267 |
11 |
magro732 |
ackIdWindow_o <= ackIdWindow_i;
|
| 1268 |
|
|
|
| 1269 |
13 |
magro732 |
timeSentSet_o <= '0';
|
| 1270 |
4 |
magro732 |
|
| 1271 |
11 |
magro732 |
symbolControlRestartOut <= '0';
|
| 1272 |
|
|
symbolControlLinkRequestOut <= '0';
|
| 1273 |
|
|
symbolControlStartOut <= '0';
|
| 1274 |
|
|
symbolControlEndOut <= '0';
|
| 1275 |
|
|
symbolDataOut <= '0';
|
| 1276 |
|
|
symbolDataContentOut <= (others => '0');
|
| 1277 |
4 |
magro732 |
|
| 1278 |
11 |
magro732 |
if (recoverActive_i = '1') then
|
| 1279 |
|
|
-- REMARK: Make sure idle is generated when this state is active...
|
| 1280 |
|
|
ackIdWindow_o <= recoverCounter_i;
|
| 1281 |
|
|
frameState_o <= FRAME_START;
|
| 1282 |
4 |
magro732 |
|
| 1283 |
11 |
magro732 |
if (ackId_i /= recoverCounter_i) then
|
| 1284 |
13 |
magro732 |
-- REMARK: Discard packets; readFrameOut <= '1';
|
| 1285 |
11 |
magro732 |
else
|
| 1286 |
13 |
magro732 |
readWindowResetOut <= '1';
|
| 1287 |
11 |
magro732 |
end if;
|
| 1288 |
|
|
else
|
| 1289 |
13 |
magro732 |
if (operational_i = '0') then
|
| 1290 |
|
|
-----------------------------------------------------------------------
|
| 1291 |
|
|
-- This state is entered at startup. A port that is not initialized
|
| 1292 |
|
|
-- should only transmit idle sequences.
|
| 1293 |
|
|
-----------------------------------------------------------------------
|
| 1294 |
|
|
|
| 1295 |
|
|
-- Initialize framing before entering the operational state.
|
| 1296 |
|
|
-- REMARK: Only do this when the portInitialized becomes asserted???
|
| 1297 |
|
|
frameState_o <= FRAME_START;
|
| 1298 |
|
|
ackIdWindow_o <= ackId_i;
|
| 1299 |
|
|
readWindowResetOut <= '1';
|
| 1300 |
|
|
else
|
| 1301 |
|
|
-------------------------------------------------------------------
|
| 1302 |
|
|
-- This state is the operational state. It relays frames and handle
|
| 1303 |
|
|
-- flow control.
|
| 1304 |
|
|
-------------------------------------------------------------------
|
| 1305 |
|
|
|
| 1306 |
|
|
if (sendRestartFromRetry = '1') then
|
| 1307 |
|
|
-- Send a restart-from-retry control symbol to acknowledge the restart
|
| 1308 |
|
|
-- of the frame.
|
| 1309 |
|
|
symbolControlRestartOut <= '1';
|
| 1310 |
|
|
|
| 1311 |
|
|
-- Make sure there wont be any timeout before the frame is
|
| 1312 |
|
|
-- starting to be retransmitted.
|
| 1313 |
|
|
timeSentSet_o <= '1';
|
| 1314 |
|
|
|
| 1315 |
|
|
-- Restart the frame transmission.
|
| 1316 |
|
|
ackIdWindow_o <= ackId_i;
|
| 1317 |
11 |
magro732 |
frameState_o <= FRAME_START;
|
| 1318 |
13 |
magro732 |
readWindowResetOut <= '1';
|
| 1319 |
|
|
end if;
|
| 1320 |
4 |
magro732 |
|
| 1321 |
13 |
magro732 |
if (sendLinkRequest = '1') then
|
| 1322 |
|
|
-- Dont restart the packet transmission since we do not yet know which
|
| 1323 |
|
|
-- packets that was successfully received by our link partner.
|
| 1324 |
4 |
magro732 |
|
| 1325 |
13 |
magro732 |
-- Send a link-request symbol.
|
| 1326 |
|
|
symbolControlLinkRequestOut <= '1';
|
| 1327 |
4 |
magro732 |
|
| 1328 |
13 |
magro732 |
-- Write the current timer value.
|
| 1329 |
|
|
timeSentSet_o <= '1';
|
| 1330 |
|
|
end if;
|
| 1331 |
|
|
|
| 1332 |
|
|
if ((sendRestartFromRetry = '0') and (sendLinkRequest = '0') and
|
| 1333 |
|
|
(outputErrorStopped_i = '0')) then
|
| 1334 |
|
|
-- Check if a frame transfer is in progress.
|
| 1335 |
|
|
-- REMARK: Hold any data symbol if there is a pending symbol from the
|
| 1336 |
|
|
-- receiver side...
|
| 1337 |
4 |
magro732 |
|
| 1338 |
13 |
magro732 |
case frameState_i is
|
| 1339 |
|
|
|
| 1340 |
|
|
when FRAME_START =>
|
| 1341 |
|
|
---------------------------------------------------------------
|
| 1342 |
|
|
-- No frame has been started.
|
| 1343 |
|
|
---------------------------------------------------------------
|
| 1344 |
4 |
magro732 |
|
| 1345 |
13 |
magro732 |
-- Wait for a new frame to arrive from the frame buffer,
|
| 1346 |
|
|
-- for new buffers to be available at the link-partner
|
| 1347 |
|
|
-- and also check that a maximum 31 frames are outstanding.
|
| 1348 |
|
|
-- REMARK: Only update readContent_o in the last instance
|
| 1349 |
|
|
-- if cascaded...
|
| 1350 |
|
|
if ((readWindowEmpty_i = '0') and
|
| 1351 |
|
|
(bufferStatus_i /= "00000") and
|
| 1352 |
|
|
((unsigned(ackIdWindow_i) - unsigned(ackId_i)) /= 31)) then
|
| 1353 |
|
|
-- New data is available for transmission and there
|
| 1354 |
|
|
-- is room to receive it at the other side.
|
| 1355 |
|
|
|
| 1356 |
|
|
-- Indicate that a control symbol has been sent to start the
|
| 1357 |
|
|
-- transmission of the frame.
|
| 1358 |
|
|
frameState_o <= FRAME_CHECK;
|
| 1359 |
4 |
magro732 |
|
| 1360 |
13 |
magro732 |
-- Update the output from the frame buffer to contain the
|
| 1361 |
|
|
-- data when it is read later.
|
| 1362 |
|
|
readContentOut <= '1';
|
| 1363 |
|
|
end if;
|
| 1364 |
|
|
|
| 1365 |
|
|
when FRAME_CHECK =>
|
| 1366 |
|
|
-------------------------------------------------------
|
| 1367 |
|
|
-- Check if we are allowed to transmit this packet.
|
| 1368 |
|
|
-------------------------------------------------------
|
| 1369 |
|
|
-- REMARK: Merge this state with the one above or it will be
|
| 1370 |
|
|
-- impossible to send packet back-to-back...
|
| 1371 |
11 |
magro732 |
|
| 1372 |
13 |
magro732 |
-- Check if this packet is allowed to be transmitted.
|
| 1373 |
|
|
if ((portEnable_i = '1') or
|
| 1374 |
|
|
(readContentData_i(19 downto 16) = FTYPE_MAINTENANCE_CLASS)) then
|
| 1375 |
|
|
-- The packet may be transmitted.
|
| 1376 |
|
|
|
| 1377 |
|
|
-- Indicate that a control symbol has been sent to start the
|
| 1378 |
|
|
-- transmission of the frame.
|
| 1379 |
|
|
frameState_o <= FRAME_ACKID;
|
| 1380 |
|
|
frameWordCounter_o <= readContentWords_i;
|
| 1381 |
|
|
frameContent_o <= readContentData_i;
|
| 1382 |
|
|
readContentOut <= '1';
|
| 1383 |
|
|
|
| 1384 |
|
|
-- Send a control symbol to start the packet and a status to
|
| 1385 |
|
|
-- complete the symbol.
|
| 1386 |
|
|
symbolControlStartOut <= '1';
|
| 1387 |
|
|
else
|
| 1388 |
|
|
-- The packet should be discarded.
|
| 1389 |
|
|
-- Send idle-sequence.
|
| 1390 |
4 |
magro732 |
|
| 1391 |
13 |
magro732 |
-- Check that there are no outstanding packets that
|
| 1392 |
|
|
-- has not been acknowledged.
|
| 1393 |
|
|
if(unsigned(ackIdWindow_i) = unsigned(ackId_i)) then
|
| 1394 |
|
|
-- No unacknowledged packets.
|
| 1395 |
|
|
-- It is now safe to remove the unallowed frame.
|
| 1396 |
|
|
-- REMARK: Discard packets; readFrameOut <= '1';
|
| 1397 |
4 |
magro732 |
|
| 1398 |
13 |
magro732 |
-- Go back and send a new frame.
|
| 1399 |
|
|
frameState_o <= FRAME_START;
|
| 1400 |
11 |
magro732 |
end if;
|
| 1401 |
13 |
magro732 |
end if;
|
| 1402 |
|
|
|
| 1403 |
|
|
when FRAME_ACKID =>
|
| 1404 |
|
|
---------------------------------------------------------------
|
| 1405 |
|
|
-- Send the first packet content containing our current
|
| 1406 |
|
|
-- ackId.
|
| 1407 |
|
|
---------------------------------------------------------------
|
| 1408 |
11 |
magro732 |
|
| 1409 |
13 |
magro732 |
-- Write a new data symbol and fill in our ackId on the
|
| 1410 |
|
|
-- packet.
|
| 1411 |
|
|
symbolDataOut <= '1';
|
| 1412 |
|
|
symbolDataContentOut <=
|
| 1413 |
|
|
std_logic_vector(ackIdWindow_i) & "0" &
|
| 1414 |
|
|
frameContent_i((32*NUMBER_WORDS)-7 downto (32*(NUMBER_WORDS-1)));
|
| 1415 |
4 |
magro732 |
|
| 1416 |
13 |
magro732 |
-- REMARK: Code frameWordCounter as 0=1 or 1=1???
|
| 1417 |
|
|
if (unsigned(frameWordCounter_i) /= 0) then
|
| 1418 |
|
|
frameWordCounter_o <=
|
| 1419 |
|
|
std_logic_vector(unsigned(frameWordCounter_i) - 1);
|
| 1420 |
|
|
frameContent_o <=
|
| 1421 |
|
|
frameContent_i((32*(NUMBER_WORDS-1))-1 downto 0) & x"00000000";
|
| 1422 |
|
|
else
|
| 1423 |
|
|
frameWordCounter_o <= readContentWords_i;
|
| 1424 |
|
|
frameContent_o <= readContentData_i;
|
| 1425 |
|
|
readContentOut <= '1';
|
| 1426 |
|
|
end if;
|
| 1427 |
|
|
|
| 1428 |
|
|
-- Continue to send the rest of the body of the packet.
|
| 1429 |
|
|
frameState_o <= FRAME_BODY;
|
| 1430 |
|
|
|
| 1431 |
|
|
when FRAME_BODY =>
|
| 1432 |
|
|
---------------------------------------------------------------
|
| 1433 |
|
|
-- The frame has not been fully sent.
|
| 1434 |
|
|
-- Send a data symbol.
|
| 1435 |
|
|
---------------------------------------------------------------
|
| 1436 |
|
|
-- REMARK: There will be idle symbols generated here if the
|
| 1437 |
|
|
-- end-of-packet cannot be generated directly following the last
|
| 1438 |
|
|
-- data symbol... need to rewrite PacketBufferWindow to indicate
|
| 1439 |
|
|
-- the end at the last word.
|
| 1440 |
|
|
-- REMARK: Dont send anything if there is a pending symbol in the
|
| 1441 |
|
|
-- rx-control fifo to let it be transmitted in the middle of the
|
| 1442 |
|
|
-- packet...
|
| 1443 |
|
|
|
| 1444 |
|
|
-- Write a new data symbol.
|
| 1445 |
|
|
symbolDataOut <= '1';
|
| 1446 |
|
|
symbolDataContentOut <=
|
| 1447 |
|
|
frameContent_i((32*NUMBER_WORDS)-1 downto (32*(NUMBER_WORDS-1)));
|
| 1448 |
4 |
magro732 |
|
| 1449 |
13 |
magro732 |
if (unsigned(frameWordCounter_i) /= 0) then
|
| 1450 |
|
|
frameWordCounter_o <=
|
| 1451 |
|
|
std_logic_vector(unsigned(frameWordCounter_i) - 1);
|
| 1452 |
|
|
frameContent_o <=
|
| 1453 |
|
|
frameContent_i((32*(NUMBER_WORDS-1))-1 downto 0) & x"00000000";
|
| 1454 |
|
|
else
|
| 1455 |
|
|
-- Check if the frame is ending.
|
| 1456 |
|
|
if (readContentEnd_i = '1') then
|
| 1457 |
|
|
-- The frame is ending.
|
| 1458 |
11 |
magro732 |
|
| 1459 |
13 |
magro732 |
-- Update the window to the next frame.
|
| 1460 |
|
|
-- It takes one tick for the output from the frame
|
| 1461 |
|
|
-- buffer to get updated.
|
| 1462 |
|
|
readWindowNextOut <= '1';
|
| 1463 |
11 |
magro732 |
|
| 1464 |
13 |
magro732 |
-- Proceed to check if there is another frame to start
|
| 1465 |
|
|
-- with directly.
|
| 1466 |
|
|
frameState_o <= FRAME_END;
|
| 1467 |
4 |
magro732 |
else
|
| 1468 |
11 |
magro732 |
frameWordCounter_o <= readContentWords_i;
|
| 1469 |
13 |
magro732 |
frameContent_o <= readContentData_i;
|
| 1470 |
|
|
readContentOut <= '1';
|
| 1471 |
4 |
magro732 |
end if;
|
| 1472 |
13 |
magro732 |
end if;
|
| 1473 |
|
|
|
| 1474 |
|
|
when FRAME_END =>
|
| 1475 |
|
|
---------------------------------------------------------------
|
| 1476 |
|
|
-- A frame has ended and the window has been updated.
|
| 1477 |
|
|
-- Check if the next symbol should end the frame or if a
|
| 1478 |
|
|
-- new one should be started.
|
| 1479 |
|
|
---------------------------------------------------------------
|
| 1480 |
4 |
magro732 |
|
| 1481 |
13 |
magro732 |
-- Check if there is a new frame pending.
|
| 1482 |
|
|
if (readWindowEmpty_i = '1') then
|
| 1483 |
|
|
-- No new frame is pending.
|
| 1484 |
11 |
magro732 |
|
| 1485 |
13 |
magro732 |
-- Send a control symbol to end the packet.
|
| 1486 |
|
|
symbolControlEndOut <= '1';
|
| 1487 |
|
|
end if;
|
| 1488 |
11 |
magro732 |
|
| 1489 |
13 |
magro732 |
-- Update the window ackId.
|
| 1490 |
|
|
ackIdWindow_o <= std_logic_vector(unsigned(ackIdWindow_i) + 1);
|
| 1491 |
11 |
magro732 |
|
| 1492 |
13 |
magro732 |
-- Start timeout supervision for transmitted frame.
|
| 1493 |
|
|
timeSentSet_o <= '1';
|
| 1494 |
11 |
magro732 |
|
| 1495 |
13 |
magro732 |
-- Start a new frame the next time.
|
| 1496 |
|
|
frameState_o <= FRAME_START;
|
| 1497 |
|
|
|
| 1498 |
|
|
when others =>
|
| 1499 |
|
|
---------------------------------------------------------------
|
| 1500 |
|
|
--
|
| 1501 |
|
|
---------------------------------------------------------------
|
| 1502 |
|
|
null;
|
| 1503 |
|
|
|
| 1504 |
|
|
end case;
|
| 1505 |
11 |
magro732 |
end if;
|
| 1506 |
|
|
end if;
|
| 1507 |
|
|
end if;
|
| 1508 |
|
|
end process;
|
| 1509 |
|
|
|
| 1510 |
|
|
-----------------------------------------------------------------------------
|
| 1511 |
|
|
-- N-1
|
| 1512 |
|
|
-- Create the stype0 and stype1 part of a control symbol.
|
| 1513 |
|
|
-- This process makes sure that the buffer status are transmitted at least
|
| 1514 |
|
|
-- every 255 symbol.
|
| 1515 |
|
|
-- At startup it makes sure that at least 16 status symbols are transmitted
|
| 1516 |
|
|
-- before the operational-state is entered.
|
| 1517 |
|
|
-- Input: symbolControlStart, symbolControlEnd, symbolControlRestart,
|
| 1518 |
|
|
-- symbolControlLinkRequest, symbolData, symbolDataContent
|
| 1519 |
|
|
-- Output: symbolsTransmitted_o, operational_o,
|
| 1520 |
|
|
-- symbolControl, stype0, parameter0, parameter1, stype1, cmd,
|
| 1521 |
|
|
-- symbolData1, symbolData1Content
|
| 1522 |
|
|
-----------------------------------------------------------------------------
|
| 1523 |
|
|
|
| 1524 |
|
|
process(clk, areset_n)
|
| 1525 |
|
|
begin
|
| 1526 |
|
|
if (areset_n = '0') then
|
| 1527 |
13 |
magro732 |
rxControlUpdate_o <= '0';
|
| 1528 |
|
|
|
| 1529 |
11 |
magro732 |
controlValid <= '0';
|
| 1530 |
|
|
stype0 <= (others=>'0');
|
| 1531 |
|
|
parameter0 <= (others=>'0');
|
| 1532 |
|
|
parameter1 <= (others=>'0');
|
| 1533 |
|
|
stype1 <= STYPE1_NOP;
|
| 1534 |
|
|
cmd <= (others=>'0');
|
| 1535 |
|
|
dataValid <= '0';
|
| 1536 |
|
|
dataContent <= (others=>'0');
|
| 1537 |
|
|
elsif (clk'event and clk = '1') then
|
| 1538 |
|
|
if (txFull_i = '0') then
|
| 1539 |
13 |
magro732 |
rxControlUpdate_o <= rxControlUpdateOut;
|
| 1540 |
|
|
|
| 1541 |
11 |
magro732 |
controlValid <= controlValidOut;
|
| 1542 |
|
|
stype0 <= stype0Out;
|
| 1543 |
|
|
parameter0 <= parameter0Out;
|
| 1544 |
|
|
parameter1 <= parameter1Out;
|
| 1545 |
|
|
stype1 <= STYPE1_NOP;
|
| 1546 |
|
|
cmd <= "000";
|
| 1547 |
|
|
dataValid <= symbolData;
|
| 1548 |
|
|
dataContent <= symbolDataContent;
|
| 1549 |
|
|
|
| 1550 |
|
|
if (symbolControlStart = '1') then
|
| 1551 |
|
|
stype1 <= STYPE1_START_OF_PACKET;
|
| 1552 |
|
|
end if;
|
| 1553 |
|
|
if (symbolControlEnd = '1') then
|
| 1554 |
|
|
stype1 <= STYPE1_END_OF_PACKET;
|
| 1555 |
|
|
end if;
|
| 1556 |
|
|
if (symbolControlRestart = '1') then
|
| 1557 |
|
|
stype1 <= STYPE1_RESTART_FROM_RETRY;
|
| 1558 |
|
|
end if;
|
| 1559 |
|
|
if (symbolControlLinkRequest = '1') then
|
| 1560 |
|
|
stype1 <= STYPE1_LINK_REQUEST;
|
| 1561 |
|
|
cmd <= LINK_REQUEST_CMD_INPUT_STATUS;
|
| 1562 |
|
|
end if;
|
| 1563 |
|
|
end if;
|
| 1564 |
|
|
end if;
|
| 1565 |
|
|
end process;
|
| 1566 |
|
|
|
| 1567 |
|
|
symbolControlStype1 <=
|
| 1568 |
|
|
symbolControlRestart or symbolControlLinkRequest or
|
| 1569 |
|
|
symbolControlStart or symbolControlEnd;
|
| 1570 |
|
|
|
| 1571 |
13 |
magro732 |
process(linkInitialized_i, ackIdStatus_i, portInitialized_i,
|
| 1572 |
|
|
operational_i, counter_i, statusReceived_i, symbolsTransmitted_i,
|
| 1573 |
|
|
rxControlEmpty_i,
|
| 1574 |
|
|
symbolControlStype1, symbolData,
|
| 1575 |
|
|
rxControlStype0, rxControlParameter0, rxControlParameter1)
|
| 1576 |
11 |
magro732 |
begin
|
| 1577 |
|
|
operational_o <= operational_i;
|
| 1578 |
|
|
counter_o <= counter_i;
|
| 1579 |
12 |
magro732 |
symbolsTransmitted_o <= symbolsTransmitted_i;
|
| 1580 |
13 |
magro732 |
rxControlUpdateOut <= '0';
|
| 1581 |
11 |
magro732 |
|
| 1582 |
|
|
controlValidOut <= '0';
|
| 1583 |
|
|
stype0Out <= STYPE0_STATUS;
|
| 1584 |
|
|
parameter0Out <= ackIdStatus_i;
|
| 1585 |
|
|
parameter1Out <= "11111";
|
| 1586 |
|
|
|
| 1587 |
13 |
magro732 |
-- Check the operational state.
|
| 1588 |
|
|
if (operational_i = '0') then
|
| 1589 |
|
|
-----------------------------------------------------------------------
|
| 1590 |
|
|
-- This state is entered at startup. A port that is not initialized
|
| 1591 |
|
|
-- should only transmit idle sequences.
|
| 1592 |
|
|
-----------------------------------------------------------------------
|
| 1593 |
|
|
|
| 1594 |
|
|
-- Check if the port is initialized.
|
| 1595 |
|
|
if (portInitialized_i = '1') then
|
| 1596 |
|
|
---------------------------------------------------------------------
|
| 1597 |
|
|
-- The specification requires a status control symbol being sent at
|
| 1598 |
|
|
-- least every 1024 code word until an error-free status has been
|
| 1599 |
|
|
-- received. This implies that at most 256 idle sequences should be
|
| 1600 |
|
|
-- sent in between status control symbols. Once an error-free status
|
| 1601 |
|
|
-- has been received, status symbols may be sent more rapidly. At
|
| 1602 |
|
|
-- least 15 statuses has to be transmitted once an error-free status
|
| 1603 |
|
|
-- has been received.
|
| 1604 |
|
|
---------------------------------------------------------------------
|
| 1605 |
11 |
magro732 |
|
| 1606 |
13 |
magro732 |
-- Check if we are ready to change state to operational.
|
| 1607 |
|
|
if ((linkInitialized_i = '1') and
|
| 1608 |
|
|
(unsigned(counter_i) = 0)) then
|
| 1609 |
|
|
-- Receiver has received enough error free status symbols and we
|
| 1610 |
|
|
-- have transmitted enough.
|
| 1611 |
|
|
|
| 1612 |
|
|
-- Considder ourselfs operational.
|
| 1613 |
|
|
operational_o <= '1';
|
| 1614 |
|
|
else
|
| 1615 |
|
|
-- Not ready to change state to operational.
|
| 1616 |
|
|
-- Dont do anything.
|
| 1617 |
|
|
end if;
|
| 1618 |
11 |
magro732 |
|
| 1619 |
13 |
magro732 |
-- Check if idle sequence or a status symbol should be transmitted.
|
| 1620 |
|
|
if (((statusReceived_i = '0') and (symbolsTransmitted_i = x"ff")) or
|
| 1621 |
|
|
((statusReceived_i = '1') and (symbolsTransmitted_i > x"0f"))) then
|
| 1622 |
|
|
-- A status symbol should be transmitted.
|
| 1623 |
11 |
magro732 |
|
| 1624 |
13 |
magro732 |
-- Send a status control symbol to the link partner.
|
| 1625 |
|
|
controlValidOut <= '1';
|
| 1626 |
11 |
magro732 |
|
| 1627 |
13 |
magro732 |
-- Reset idle sequence transmission counter.
|
| 1628 |
|
|
symbolsTransmitted_o <= (others=>'0');
|
| 1629 |
11 |
magro732 |
|
| 1630 |
13 |
magro732 |
-- Check if the number of transmitted statuses should be updated.
|
| 1631 |
|
|
if (statusReceived_i = '1') and (unsigned(counter_i) /= 0) then
|
| 1632 |
|
|
counter_o <= std_logic_vector(unsigned(counter_i) - 1);
|
| 1633 |
4 |
magro732 |
end if;
|
| 1634 |
11 |
magro732 |
else
|
| 1635 |
13 |
magro732 |
-- Increment the idle sequence transmission counter.
|
| 1636 |
|
|
symbolsTransmitted_o <= std_logic_vector(unsigned(symbolsTransmitted_i) + 1);
|
| 1637 |
11 |
magro732 |
end if;
|
| 1638 |
|
|
else
|
| 1639 |
13 |
magro732 |
-- The port is not initialized.
|
| 1640 |
|
|
-- Reset initialization variables.
|
| 1641 |
|
|
counter_o <= NUMBER_STATUS_TRANSMIT;
|
| 1642 |
|
|
end if;
|
| 1643 |
|
|
else
|
| 1644 |
|
|
---------------------------------------------------------------------
|
| 1645 |
|
|
-- This is the operational state.
|
| 1646 |
|
|
-- It is entered once the link has been considdered up and running.
|
| 1647 |
|
|
---------------------------------------------------------------------
|
| 1648 |
4 |
magro732 |
|
| 1649 |
13 |
magro732 |
-- Check if the port is still initialized.
|
| 1650 |
|
|
if (portInitialized_i = '1') then
|
| 1651 |
|
|
-- The port is still initialized.
|
| 1652 |
|
|
|
| 1653 |
|
|
-- Check if a status must be sent.
|
| 1654 |
|
|
-- A status must be sent when there are not other stype0 value to
|
| 1655 |
|
|
-- send or if too many symbols without buffer-status has been sent.
|
| 1656 |
|
|
-- REMARK: Is there a risk of a race when a generated status-symbol
|
| 1657 |
|
|
-- is sent before another symbol stored in the rx-control fifo???
|
| 1658 |
|
|
if (((symbolControlStype1 = '1') and (rxControlEmpty_i = '1')) or
|
| 1659 |
|
|
((symbolControlStype1 = '0') and (symbolData = '0') and
|
| 1660 |
|
|
(symbolsTransmitted_i = x"ff"))) then
|
| 1661 |
|
|
-- A control symbol is about to be sent without pending symbol from
|
| 1662 |
|
|
-- receiver or too many idle symbols has been sent.
|
| 1663 |
|
|
|
| 1664 |
|
|
-- Force the sending of a status containing the bufferStatus.
|
| 1665 |
|
|
controlValidOut <= '1';
|
| 1666 |
|
|
symbolsTransmitted_o <= (others=>'0');
|
| 1667 |
|
|
elsif ((symbolData = '0') and (rxControlEmpty_i = '0')) then
|
| 1668 |
|
|
-- A control symbol is about to be sent and there is a pending
|
| 1669 |
|
|
-- symbol from the receiver.
|
| 1670 |
11 |
magro732 |
|
| 1671 |
13 |
magro732 |
-- Remove the symbol from the fifo.
|
| 1672 |
|
|
rxControlUpdateOut <= '1';
|
| 1673 |
|
|
|
| 1674 |
|
|
-- Send the receiver symbol.
|
| 1675 |
|
|
controlValidOut <= '1';
|
| 1676 |
|
|
stype0Out <= rxControlStype0;
|
| 1677 |
|
|
parameter0Out <= rxControlParameter0;
|
| 1678 |
|
|
parameter1Out <= rxControlParameter1;
|
| 1679 |
|
|
|
| 1680 |
|
|
-- Check if the transmitted symbol contains status about
|
| 1681 |
|
|
-- available buffers.
|
| 1682 |
|
|
if ((rxControlStype0 = STYPE0_PACKET_ACCEPTED) or
|
| 1683 |
|
|
(rxControlStype0 = STYPE0_PACKET_RETRY)) then
|
| 1684 |
|
|
-- A symbol containing the bufferStatus has been sent.
|
| 1685 |
11 |
magro732 |
symbolsTransmitted_o <= (others=>'0');
|
| 1686 |
4 |
magro732 |
else
|
| 1687 |
11 |
magro732 |
-- A symbol not containing the bufferStatus has been sent.
|
| 1688 |
|
|
symbolsTransmitted_o <= std_logic_vector(unsigned(symbolsTransmitted_i) + 1);
|
| 1689 |
4 |
magro732 |
end if;
|
| 1690 |
11 |
magro732 |
else
|
| 1691 |
13 |
magro732 |
-- A symbol not containing the bufferStatus has been sent.
|
| 1692 |
|
|
controlValidOut <= '0';
|
| 1693 |
|
|
symbolsTransmitted_o <= std_logic_vector(unsigned(symbolsTransmitted_i) + 1);
|
| 1694 |
|
|
end if;
|
| 1695 |
|
|
else
|
| 1696 |
|
|
-- The port is not initialized anymore.
|
| 1697 |
|
|
-- Change the operational state.
|
| 1698 |
|
|
operational_o <= '0';
|
| 1699 |
|
|
end if;
|
| 1700 |
11 |
magro732 |
end if;
|
| 1701 |
|
|
end process;
|
| 1702 |
|
|
|
| 1703 |
|
|
-----------------------------------------------------------------------------
|
| 1704 |
|
|
-- N pipeline stage.
|
| 1705 |
|
|
-- Make all symbols ready for transmission, i.e. calculate the CRC5 on
|
| 1706 |
|
|
-- control symbols.
|
| 1707 |
|
|
-- Inputs: controlValid, stype0, parameter0, parameter1, stype1, cmd,
|
| 1708 |
|
|
-- symbolData1, symbolData1Content
|
| 1709 |
|
|
-----------------------------------------------------------------------------
|
| 1710 |
4 |
magro732 |
|
| 1711 |
11 |
magro732 |
controlContent(31 downto 29) <= stype0;
|
| 1712 |
|
|
controlContent(28 downto 24) <= parameter0;
|
| 1713 |
|
|
controlContent(23 downto 19) <= parameter1;
|
| 1714 |
|
|
controlContent(18 downto 16) <= stype1;
|
| 1715 |
|
|
controlContent(15 downto 13) <= cmd;
|
| 1716 |
|
|
controlContent(12 downto 8) <= crc5;
|
| 1717 |
|
|
controlContent(7 downto 0) <= x"00";
|
| 1718 |
4 |
magro732 |
|
| 1719 |
11 |
magro732 |
Crc5Calculator: Crc5ITU
|
| 1720 |
|
|
port map(
|
| 1721 |
|
|
d_i=>controlContent(31 downto 13), crc_o=>crc5);
|
| 1722 |
|
|
|
| 1723 |
|
|
txWrite_o <= not txFull_i;
|
| 1724 |
|
|
process(clk, areset_n)
|
| 1725 |
|
|
begin
|
| 1726 |
|
|
if (areset_n = '0') then
|
| 1727 |
|
|
txType_o <= SYMBOL_IDLE;
|
| 1728 |
|
|
txData_o <= (others=>'0');
|
| 1729 |
|
|
elsif (clk'event and clk = '1') then
|
| 1730 |
|
|
if (txFull_i = '0') then
|
| 1731 |
|
|
txType_o <= SYMBOL_IDLE;
|
| 1732 |
|
|
if (controlValid = '1') then
|
| 1733 |
|
|
txType_o <= SYMBOL_CONTROL;
|
| 1734 |
|
|
txData_o <= controlContent;
|
| 1735 |
|
|
end if;
|
| 1736 |
|
|
if (dataValid = '1') then
|
| 1737 |
|
|
txType_o <= SYMBOL_DATA;
|
| 1738 |
|
|
txData_o <= dataContent;
|
| 1739 |
|
|
end if;
|
| 1740 |
|
|
end if;
|
| 1741 |
4 |
magro732 |
end if;
|
| 1742 |
11 |
magro732 |
end process;
|
| 1743 |
|
|
|
| 1744 |
4 |
magro732 |
end architecture;
|
| 1745 |
|
|
|
| 1746 |
|
|
|
| 1747 |
|
|
|
| 1748 |
|
|
-------------------------------------------------------------------------------
|
| 1749 |
|
|
--
|
| 1750 |
|
|
-------------------------------------------------------------------------------
|
| 1751 |
|
|
library ieee;
|
| 1752 |
|
|
use ieee.std_logic_1164.all;
|
| 1753 |
|
|
use ieee.numeric_std.all;
|
| 1754 |
|
|
use work.rio_common.all;
|
| 1755 |
|
|
|
| 1756 |
|
|
|
| 1757 |
11 |
magro732 |
entity RioReceiver is
|
| 1758 |
|
|
generic(
|
| 1759 |
|
|
NUMBER_WORDS : natural range 1 to 4 := 1);
|
| 1760 |
|
|
port(
|
| 1761 |
|
|
clk : in std_logic;
|
| 1762 |
|
|
areset_n : in std_logic;
|
| 1763 |
|
|
|
| 1764 |
|
|
portEnable_i : in std_logic;
|
| 1765 |
|
|
|
| 1766 |
|
|
localAckIdWrite_i : in std_logic;
|
| 1767 |
|
|
inboundAckId_i : in std_logic_vector(4 downto 0);
|
| 1768 |
|
|
inboundAckId_o : out std_logic_vector(4 downto 0);
|
| 1769 |
|
|
|
| 1770 |
|
|
portInitialized_i : in std_logic;
|
| 1771 |
|
|
rxEmpty_i : in std_logic;
|
| 1772 |
|
|
rxRead_o : out std_logic;
|
| 1773 |
|
|
rxType_i : in std_logic_vector(2*NUMBER_WORDS-1 downto 0);
|
| 1774 |
|
|
rxData_i : in std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
| 1775 |
|
|
|
| 1776 |
|
|
txControlWrite_o : out std_logic_vector(NUMBER_WORDS-1 downto 0);
|
| 1777 |
|
|
txControlSymbol_o : out std_logic_vector(12*NUMBER_WORDS downto 0);
|
| 1778 |
|
|
rxControlWrite_o : out std_logic_vector(NUMBER_WORDS-1 downto 0);
|
| 1779 |
|
|
rxControlSymbol_o : out std_logic_vector(12*NUMBER_WORDS downto 0);
|
| 1780 |
|
|
|
| 1781 |
|
|
ackIdStatus_o : out std_logic_vector(4 downto 0);
|
| 1782 |
|
|
linkInitialized_o : out std_logic;
|
| 1783 |
|
|
|
| 1784 |
|
|
writeFrameFull_i : in std_logic;
|
| 1785 |
|
|
writeFrame_o : out std_logic;
|
| 1786 |
|
|
writeFrameAbort_o : out std_logic;
|
| 1787 |
|
|
writeContent_o : out std_logic;
|
| 1788 |
|
|
writeContentWords_o : out std_logic_vector(1 downto 0);
|
| 1789 |
|
|
writeContentData_o : out std_logic_vector(32*NUMBER_WORDS-1 downto 0));
|
| 1790 |
|
|
end entity;
|
| 1791 |
|
|
|
| 1792 |
4 |
magro732 |
-------------------------------------------------------------------------------
|
| 1793 |
|
|
--
|
| 1794 |
|
|
-------------------------------------------------------------------------------
|
| 1795 |
11 |
magro732 |
architecture RioReceiverImpl of RioReceiver is
|
| 1796 |
|
|
|
| 1797 |
|
|
component RioReceiverCore is
|
| 1798 |
|
|
generic(
|
| 1799 |
|
|
NUMBER_WORDS : natural range 1 to 4 := 1);
|
| 1800 |
|
|
port(
|
| 1801 |
|
|
clk : in std_logic;
|
| 1802 |
|
|
areset_n : in std_logic;
|
| 1803 |
|
|
|
| 1804 |
|
|
-- Status signals used for maintenance.
|
| 1805 |
|
|
portEnable_i : in std_logic;
|
| 1806 |
|
|
|
| 1807 |
|
|
-- Support for localAckIdCSR.
|
| 1808 |
|
|
-- REMARK: Add support for this???
|
| 1809 |
|
|
localAckIdWrite_i : in std_logic;
|
| 1810 |
|
|
inboundAckId_i : in std_logic_vector(4 downto 0);
|
| 1811 |
|
|
inboundAckId_o : out std_logic_vector(4 downto 0);
|
| 1812 |
|
|
|
| 1813 |
|
|
-- Port input interface.
|
| 1814 |
|
|
portInitialized_i : in std_logic;
|
| 1815 |
|
|
rxEmpty_i : in std_logic;
|
| 1816 |
|
|
rxRead_o : out std_logic;
|
| 1817 |
|
|
rxType_i : in std_logic_vector(1 downto 0);
|
| 1818 |
|
|
rxData_i : in std_logic_vector(31 downto 0);
|
| 1819 |
|
|
|
| 1820 |
|
|
-- Receiver has received a control symbol containing:
|
| 1821 |
|
|
-- packet-accepted, packet-retry, packet-not-accepted,
|
| 1822 |
|
|
-- status, VC_status, link-response
|
| 1823 |
|
|
txControlWrite_o : out std_logic;
|
| 1824 |
|
|
txControlSymbol_o : out std_logic_vector(12 downto 0);
|
| 1825 |
|
|
|
| 1826 |
|
|
-- Reciever wants to signal the link partner:
|
| 1827 |
|
|
-- a new frame has been accepted => packet-accepted(rxAckId, bufferStatus)
|
| 1828 |
|
|
-- a frame needs to be retransmitted due to buffering =>
|
| 1829 |
|
|
-- packet-retry(rxAckId, bufferStatus)
|
| 1830 |
|
|
-- a frame is rejected due to errors => packet-not-accepted
|
| 1831 |
|
|
-- a link-request should be answered => link-response
|
| 1832 |
|
|
rxControlWrite_o : out std_logic;
|
| 1833 |
|
|
rxControlSymbol_o : out std_logic_vector(12 downto 0);
|
| 1834 |
|
|
|
| 1835 |
|
|
-- Status signals used internally.
|
| 1836 |
|
|
ackIdStatus_o : out std_logic_vector(4 downto 0);
|
| 1837 |
|
|
linkInitialized_o : out std_logic;
|
| 1838 |
|
|
|
| 1839 |
|
|
-- Core->Core cascading signals.
|
| 1840 |
|
|
enable_o : out std_logic;
|
| 1841 |
|
|
operational_i : in std_logic;
|
| 1842 |
|
|
operational_o : out std_logic;
|
| 1843 |
|
|
inputRetryStopped_i : in std_logic;
|
| 1844 |
|
|
inputRetryStopped_o : out std_logic;
|
| 1845 |
|
|
inputErrorStopped_i : in std_logic;
|
| 1846 |
|
|
inputErrorStopped_o : out std_logic;
|
| 1847 |
|
|
ackId_i : in unsigned(4 downto 0);
|
| 1848 |
|
|
ackId_o : out unsigned(4 downto 0);
|
| 1849 |
|
|
frameIndex_i : in std_logic_vector(6 downto 0);
|
| 1850 |
|
|
frameIndex_o : out std_logic_vector(6 downto 0);
|
| 1851 |
|
|
frameWordCounter_i : in std_logic_vector(1 downto 0);
|
| 1852 |
|
|
frameWordCounter_o : out std_logic_vector(1 downto 0);
|
| 1853 |
|
|
frameContent_i : in std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
| 1854 |
|
|
frameContent_o : out std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
| 1855 |
|
|
crc_i : in std_logic_vector(15 downto 0);
|
| 1856 |
|
|
crc_o : out std_logic_vector(15 downto 0);
|
| 1857 |
|
|
|
| 1858 |
|
|
-- Frame buffering interface.
|
| 1859 |
|
|
writeFrameFull_i : in std_logic;
|
| 1860 |
|
|
writeFrame_o : out std_logic;
|
| 1861 |
|
|
writeFrameAbort_o : out std_logic;
|
| 1862 |
|
|
writeContent_o : out std_logic;
|
| 1863 |
|
|
writeContentWords_o : out std_logic_vector(1 downto 0);
|
| 1864 |
|
|
writeContentData_o : out std_logic_vector(32*NUMBER_WORDS-1 downto 0));
|
| 1865 |
|
|
end component;
|
| 1866 |
|
|
|
| 1867 |
|
|
signal enable : std_logic_vector(NUMBER_WORDS-1 downto 0);
|
| 1868 |
|
|
signal operationalCurrent, operationalNext : std_logic_vector(NUMBER_WORDS-1 downto 0);
|
| 1869 |
|
|
signal inputRetryStoppedCurrent, inputRetryStoppedNext : std_logic_vector(NUMBER_WORDS-1 downto 0);
|
| 1870 |
|
|
signal inputErrorStoppedCurrent, inputErrorStoppedNext : std_logic_vector(NUMBER_WORDS-1 downto 0);
|
| 1871 |
|
|
signal ackIdCurrent, ackIdNext : unsigned(5*NUMBER_WORDS-1 downto 0);
|
| 1872 |
|
|
signal frameIndexCurrent, frameIndexNext : std_logic_vector(7*NUMBER_WORDS-1 downto 0);
|
| 1873 |
|
|
signal frameWordCounterCurrent, frameWordCounterNext : std_logic_vector(2*NUMBER_WORDS-1 downto 0);
|
| 1874 |
|
|
signal frameContentCurrent, frameContentNext : std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
| 1875 |
|
|
signal crcCurrent, crcNext : std_logic_vector(16*NUMBER_WORDS-1 downto 0);
|
| 1876 |
|
|
|
| 1877 |
|
|
signal txControlWrite : std_logic_vector(NUMBER_WORDS-1 downto 0);
|
| 1878 |
|
|
signal rxControlWrite : std_logic_vector(NUMBER_WORDS-1 downto 0);
|
| 1879 |
|
|
|
| 1880 |
|
|
signal writeFrame : std_logic_vector(NUMBER_WORDS-1 downto 0);
|
| 1881 |
|
|
signal writeFrameAbort : std_logic_vector(NUMBER_WORDS-1 downto 0);
|
| 1882 |
|
|
signal writeContent : std_logic_vector(NUMBER_WORDS-1 downto 0);
|
| 1883 |
|
|
signal writeContentWords : std_logic_vector(2*NUMBER_WORDS-1 downto 0);
|
| 1884 |
|
|
signal writeContentData : std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
| 1885 |
|
|
|
| 1886 |
|
|
begin
|
| 1887 |
|
|
|
| 1888 |
|
|
-----------------------------------------------------------------------------
|
| 1889 |
|
|
-- Output generation to packet buffer.
|
| 1890 |
|
|
-----------------------------------------------------------------------------
|
| 1891 |
|
|
process(enable, writeFrame, writeFrameAbort,
|
| 1892 |
|
|
writeContent, writeContentWords, writeContentData)
|
| 1893 |
|
|
begin
|
| 1894 |
|
|
writeFrame_o <= '0';
|
| 1895 |
|
|
writeFrameAbort_o <= '0';
|
| 1896 |
|
|
writeContent_o <= '0';
|
| 1897 |
|
|
writeContentWords_o <= (others=>'0');
|
| 1898 |
|
|
writeContentData_o <= (others=>'0');
|
| 1899 |
|
|
for i in 0 to NUMBER_WORDS-1 loop
|
| 1900 |
|
|
if ((writeFrame(i) = '1') and (enable(i) = '1')) then
|
| 1901 |
|
|
writeFrame_o <= '1';
|
| 1902 |
|
|
end if;
|
| 1903 |
|
|
|
| 1904 |
|
|
if ((writeFrameAbort(i) = '1') and (enable(i) = '1')) then
|
| 1905 |
|
|
writeFrameAbort_o <= '1';
|
| 1906 |
|
|
end if;
|
| 1907 |
|
|
|
| 1908 |
|
|
if ((writeContent(i) = '1') and (enable(i) = '1')) then
|
| 1909 |
|
|
writeContent_o <= '1';
|
| 1910 |
|
|
writeContentWords_o <= writeContentWords(2*(i+1)-1 downto 2*i);
|
| 1911 |
|
|
writeContentData_o <= writeContentData(32*(i+1)-1 downto 32*i);
|
| 1912 |
|
|
end if;
|
| 1913 |
|
|
end loop;
|
| 1914 |
|
|
end process;
|
| 1915 |
|
|
|
| 1916 |
|
|
-----------------------------------------------------------------------------
|
| 1917 |
|
|
-- Protocol core and synchronization.
|
| 1918 |
|
|
-----------------------------------------------------------------------------
|
| 1919 |
|
|
process(clk, areset_n)
|
| 1920 |
|
|
begin
|
| 1921 |
|
|
if (areset_n = '0') then
|
| 1922 |
|
|
operationalCurrent <= (others=>'0');
|
| 1923 |
|
|
inputRetryStoppedCurrent <= (others=>'0');
|
| 1924 |
|
|
inputErrorStoppedCurrent <= (others=>'0');
|
| 1925 |
|
|
ackIdCurrent <= (others=>'0');
|
| 1926 |
|
|
frameIndexCurrent <= (others => '0');
|
| 1927 |
|
|
frameWordCounterCurrent <= (others=>'0');
|
| 1928 |
|
|
frameContentCurrent <= (others=>'0');
|
| 1929 |
|
|
crcCurrent <= (others=>'0');
|
| 1930 |
|
|
elsif (clk'event and clk = '1') then
|
| 1931 |
|
|
if (enable(0) = '1') then
|
| 1932 |
|
|
operationalCurrent <= operationalNext;
|
| 1933 |
|
|
inputRetryStoppedCurrent <= inputRetryStoppedNext;
|
| 1934 |
|
|
inputErrorStoppedCurrent <= inputErrorStoppedNext;
|
| 1935 |
|
|
ackIdCurrent <= ackIdNext;
|
| 1936 |
|
|
frameIndexCurrent <= frameIndexNext;
|
| 1937 |
|
|
frameWordCounterCurrent <= frameWordCounterNext;
|
| 1938 |
|
|
frameContentCurrent <= frameContentNext;
|
| 1939 |
|
|
crcCurrent <= crcNext;
|
| 1940 |
|
|
end if;
|
| 1941 |
|
|
end if;
|
| 1942 |
|
|
end process;
|
| 1943 |
|
|
|
| 1944 |
|
|
CoreGeneration: for i in 0 to NUMBER_WORDS-1 generate
|
| 1945 |
|
|
txControlWrite_o(i) <= txControlWrite(i) and enable(i);
|
| 1946 |
|
|
rxControlWrite_o(i) <= rxControlWrite(i);
|
| 1947 |
|
|
|
| 1948 |
|
|
ReceiverCore: RioReceiverCore
|
| 1949 |
|
|
generic map(NUMBER_WORDS=>NUMBER_WORDS)
|
| 1950 |
|
|
port map(
|
| 1951 |
|
|
clk=>clk,
|
| 1952 |
|
|
areset_n=>areset_n,
|
| 1953 |
|
|
portEnable_i=>portEnable_i,
|
| 1954 |
|
|
localAckIdWrite_i=>localAckIdWrite_i,
|
| 1955 |
|
|
inboundAckId_i=>inboundAckId_i,
|
| 1956 |
|
|
inboundAckId_o=>inboundAckId_o,
|
| 1957 |
|
|
portInitialized_i=>portInitialized_i,
|
| 1958 |
|
|
rxEmpty_i=>rxEmpty_i,
|
| 1959 |
|
|
rxRead_o=>rxRead_o,
|
| 1960 |
|
|
rxType_i=>rxType_i,
|
| 1961 |
|
|
rxData_i=>rxData_i,
|
| 1962 |
|
|
txControlWrite_o=>txControlWrite(i),
|
| 1963 |
|
|
txControlSymbol_o=>txControlSymbol_o(13*(i+1)-1 downto 13*i),
|
| 1964 |
|
|
rxControlWrite_o=>rxControlWrite(i),
|
| 1965 |
|
|
rxControlSymbol_o=>rxControlSymbol_o(13*(i+1)-1 downto 13*i),
|
| 1966 |
|
|
ackIdStatus_o=>ackIdStatus_o,
|
| 1967 |
|
|
linkInitialized_o=>linkInitialized_o,
|
| 1968 |
|
|
enable_o=>enable(i),
|
| 1969 |
|
|
operational_i=>operationalCurrent(i),
|
| 1970 |
|
|
operational_o=>operationalNext(i),
|
| 1971 |
|
|
inputRetryStopped_i=>inputRetryStoppedCurrent(i),
|
| 1972 |
|
|
inputRetryStopped_o=>inputRetryStoppedNext(i),
|
| 1973 |
|
|
inputErrorStopped_i=>inputErrorStoppedCurrent(i),
|
| 1974 |
|
|
inputErrorStopped_o=>inputErrorStoppedNext(i),
|
| 1975 |
|
|
ackId_i=>ackIdCurrent(5*(i+1)-1 downto 5*i),
|
| 1976 |
|
|
ackId_o=>ackIdNext(5*(i+1)-1 downto 5*i),
|
| 1977 |
|
|
frameIndex_i=>frameIndexCurrent(7*(i+1)-1 downto 7*i),
|
| 1978 |
|
|
frameIndex_o=>frameIndexNext(7*(i+1)-1 downto 7*i),
|
| 1979 |
|
|
frameWordCounter_i=>frameWordCounterCurrent(2*(i+1)-1 downto 2*i),
|
| 1980 |
|
|
frameWordCounter_o=>frameWordCounterNext(2*(i+1)-1 downto 2*i),
|
| 1981 |
|
|
frameContent_i=>frameContentCurrent(32*(i+1)-1 downto 32*i),
|
| 1982 |
|
|
frameContent_o=>frameContentNext(32*(i+1)-1 downto 32*i),
|
| 1983 |
|
|
crc_i=>crcCurrent(16*(i+1)-1 downto 16*i),
|
| 1984 |
|
|
crc_o=>crcNext(16*(i+1)-1 downto 16*i),
|
| 1985 |
|
|
writeFrameFull_i=>writeFrameFull_i,
|
| 1986 |
|
|
writeFrame_o=>writeFrame(i),
|
| 1987 |
|
|
writeFrameAbort_o=>writeFrameAbort(i),
|
| 1988 |
|
|
writeContent_o=>writeContent(i),
|
| 1989 |
|
|
writeContentWords_o=>writeContentWords(2*(i+1)-1 downto 2*i),
|
| 1990 |
|
|
writeContentData_o=>writeContentData(32*(i+1)-1 downto 32*i));
|
| 1991 |
|
|
end generate;
|
| 1992 |
|
|
|
| 1993 |
|
|
end architecture;
|
| 1994 |
|
|
|
| 1995 |
|
|
-------------------------------------------------------------------------------
|
| 1996 |
|
|
-- RioReceiverCore
|
| 1997 |
|
|
-------------------------------------------------------------------------------
|
| 1998 |
|
|
library ieee;
|
| 1999 |
|
|
use ieee.std_logic_1164.all;
|
| 2000 |
|
|
use ieee.numeric_std.all;
|
| 2001 |
|
|
use work.rio_common.all;
|
| 2002 |
|
|
|
| 2003 |
|
|
|
| 2004 |
|
|
-------------------------------------------------------------------------------
|
| 2005 |
|
|
--
|
| 2006 |
|
|
-------------------------------------------------------------------------------
|
| 2007 |
|
|
entity RioReceiverCore is
|
| 2008 |
|
|
generic(
|
| 2009 |
|
|
NUMBER_WORDS : natural range 1 to 4 := 1);
|
| 2010 |
4 |
magro732 |
port(
|
| 2011 |
|
|
clk : in std_logic;
|
| 2012 |
|
|
areset_n : in std_logic;
|
| 2013 |
|
|
|
| 2014 |
|
|
-- Status signals used for maintenance.
|
| 2015 |
|
|
portEnable_i : in std_logic;
|
| 2016 |
|
|
|
| 2017 |
|
|
-- Support for localAckIdCSR.
|
| 2018 |
11 |
magro732 |
-- REMARK: Add support for this???
|
| 2019 |
4 |
magro732 |
localAckIdWrite_i : in std_logic;
|
| 2020 |
|
|
inboundAckId_i : in std_logic_vector(4 downto 0);
|
| 2021 |
|
|
inboundAckId_o : out std_logic_vector(4 downto 0);
|
| 2022 |
|
|
|
| 2023 |
|
|
-- Port input interface.
|
| 2024 |
|
|
portInitialized_i : in std_logic;
|
| 2025 |
|
|
rxEmpty_i : in std_logic;
|
| 2026 |
|
|
rxRead_o : out std_logic;
|
| 2027 |
11 |
magro732 |
rxType_i : in std_logic_vector(1 downto 0);
|
| 2028 |
4 |
magro732 |
rxData_i : in std_logic_vector(31 downto 0);
|
| 2029 |
|
|
|
| 2030 |
|
|
-- Receiver has received a control symbol containing:
|
| 2031 |
|
|
-- packet-accepted, packet-retry, packet-not-accepted,
|
| 2032 |
|
|
-- status, VC_status, link-response
|
| 2033 |
|
|
txControlWrite_o : out std_logic;
|
| 2034 |
|
|
txControlSymbol_o : out std_logic_vector(12 downto 0);
|
| 2035 |
|
|
|
| 2036 |
|
|
-- Reciever wants to signal the link partner:
|
| 2037 |
|
|
-- a new frame has been accepted => packet-accepted(rxAckId, bufferStatus)
|
| 2038 |
|
|
-- a frame needs to be retransmitted due to buffering =>
|
| 2039 |
|
|
-- packet-retry(rxAckId, bufferStatus)
|
| 2040 |
|
|
-- a frame is rejected due to errors => packet-not-accepted
|
| 2041 |
|
|
-- a link-request should be answered => link-response
|
| 2042 |
|
|
rxControlWrite_o : out std_logic;
|
| 2043 |
|
|
rxControlSymbol_o : out std_logic_vector(12 downto 0);
|
| 2044 |
|
|
|
| 2045 |
|
|
-- Status signals used internally.
|
| 2046 |
|
|
ackIdStatus_o : out std_logic_vector(4 downto 0);
|
| 2047 |
|
|
linkInitialized_o : out std_logic;
|
| 2048 |
|
|
|
| 2049 |
11 |
magro732 |
-- Core->Core cascading signals.
|
| 2050 |
|
|
enable_o : out std_logic;
|
| 2051 |
|
|
operational_i : in std_logic;
|
| 2052 |
|
|
operational_o : out std_logic;
|
| 2053 |
|
|
inputRetryStopped_i : in std_logic;
|
| 2054 |
|
|
inputRetryStopped_o : out std_logic;
|
| 2055 |
|
|
inputErrorStopped_i : in std_logic;
|
| 2056 |
|
|
inputErrorStopped_o : out std_logic;
|
| 2057 |
|
|
ackId_i : in unsigned(4 downto 0);
|
| 2058 |
|
|
ackId_o : out unsigned(4 downto 0);
|
| 2059 |
|
|
frameIndex_i : in std_logic_vector(6 downto 0);
|
| 2060 |
|
|
frameIndex_o : out std_logic_vector(6 downto 0);
|
| 2061 |
|
|
frameWordCounter_i : in std_logic_vector(1 downto 0);
|
| 2062 |
|
|
frameWordCounter_o : out std_logic_vector(1 downto 0);
|
| 2063 |
|
|
frameContent_i : in std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
| 2064 |
|
|
frameContent_o : out std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
| 2065 |
|
|
crc_i : in std_logic_vector(15 downto 0);
|
| 2066 |
|
|
crc_o : out std_logic_vector(15 downto 0);
|
| 2067 |
|
|
|
| 2068 |
4 |
magro732 |
-- Frame buffering interface.
|
| 2069 |
|
|
writeFrameFull_i : in std_logic;
|
| 2070 |
|
|
writeFrame_o : out std_logic;
|
| 2071 |
|
|
writeFrameAbort_o : out std_logic;
|
| 2072 |
|
|
writeContent_o : out std_logic;
|
| 2073 |
11 |
magro732 |
writeContentWords_o : out std_logic_vector(1 downto 0);
|
| 2074 |
|
|
writeContentData_o : out std_logic_vector(32*NUMBER_WORDS-1 downto 0));
|
| 2075 |
4 |
magro732 |
end entity;
|
| 2076 |
|
|
|
| 2077 |
|
|
|
| 2078 |
|
|
-------------------------------------------------------------------------------
|
| 2079 |
|
|
--
|
| 2080 |
|
|
-------------------------------------------------------------------------------
|
| 2081 |
11 |
magro732 |
architecture RioReceiverCoreImpl of RioReceiverCore is
|
| 2082 |
4 |
magro732 |
|
| 2083 |
|
|
component Crc5ITU is
|
| 2084 |
|
|
port(
|
| 2085 |
|
|
d_i : in std_logic_vector(18 downto 0);
|
| 2086 |
|
|
crc_o : out std_logic_vector(4 downto 0));
|
| 2087 |
|
|
end component;
|
| 2088 |
|
|
|
| 2089 |
|
|
component Crc16CITT is
|
| 2090 |
|
|
port(
|
| 2091 |
|
|
d_i : in std_logic_vector(15 downto 0);
|
| 2092 |
|
|
crc_i : in std_logic_vector(15 downto 0);
|
| 2093 |
|
|
crc_o : out std_logic_vector(15 downto 0));
|
| 2094 |
|
|
end component;
|
| 2095 |
|
|
|
| 2096 |
11 |
magro732 |
signal symbolEnable0, symbolEnable1 : std_logic;
|
| 2097 |
|
|
signal symbolType0 : std_logic_vector(1 downto 0);
|
| 2098 |
|
|
signal symbolContent0, symbolContent1 : std_logic_vector(31 downto 0);
|
| 2099 |
|
|
signal crc5Valid : std_logic;
|
| 2100 |
4 |
magro732 |
signal crc5 : std_logic_vector(4 downto 0);
|
| 2101 |
|
|
|
| 2102 |
11 |
magro732 |
signal symbolValid : std_logic;
|
| 2103 |
|
|
signal stype0Status : std_logic;
|
| 2104 |
|
|
signal stype1Start : std_logic;
|
| 2105 |
|
|
signal stype1End : std_logic;
|
| 2106 |
|
|
signal stype1Stomp : std_logic;
|
| 2107 |
|
|
signal stype1Restart : std_logic;
|
| 2108 |
|
|
signal stype1LinkRequest : std_logic;
|
| 2109 |
|
|
signal symbolData : std_logic;
|
| 2110 |
|
|
|
| 2111 |
4 |
magro732 |
signal crc16Data : std_logic_vector(31 downto 0);
|
| 2112 |
|
|
signal crc16Current : std_logic_vector(15 downto 0);
|
| 2113 |
|
|
signal crc16Temp : std_logic_vector(15 downto 0);
|
| 2114 |
|
|
signal crc16Next : std_logic_vector(15 downto 0);
|
| 2115 |
11 |
magro732 |
signal crc16Valid : std_logic;
|
| 2116 |
|
|
|
| 2117 |
|
|
signal frameContent : std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
| 2118 |
|
|
|
| 2119 |
|
|
signal rxControlWrite : std_logic;
|
| 2120 |
|
|
signal rxControlSymbol : std_logic_vector(12 downto 0);
|
| 2121 |
4 |
magro732 |
|
| 2122 |
|
|
begin
|
| 2123 |
|
|
|
| 2124 |
11 |
magro732 |
linkInitialized_o <= operational_i;
|
| 2125 |
|
|
ackIdStatus_o <= std_logic_vector(ackId_i);
|
| 2126 |
|
|
inboundAckId_o <= std_logic_vector(ackId_i);
|
| 2127 |
|
|
|
| 2128 |
4 |
magro732 |
-----------------------------------------------------------------------------
|
| 2129 |
11 |
magro732 |
-- First pipeline stage.
|
| 2130 |
|
|
-- Check the validity of the symbol, CRC5 on control symbols, and save the
|
| 2131 |
|
|
-- symbol content for the next stage.
|
| 2132 |
4 |
magro732 |
-----------------------------------------------------------------------------
|
| 2133 |
|
|
|
| 2134 |
11 |
magro732 |
-- Read the fifo immediatly.
|
| 2135 |
|
|
rxRead_o <= not rxEmpty_i;
|
| 2136 |
4 |
magro732 |
|
| 2137 |
11 |
magro732 |
Crc5Calculator: Crc5ITU
|
| 2138 |
|
|
port map(
|
| 2139 |
|
|
d_i=>rxData_i(31 downto 13), crc_o=>crc5);
|
| 2140 |
|
|
|
| 2141 |
|
|
process(clk, areset_n)
|
| 2142 |
|
|
begin
|
| 2143 |
|
|
if (areset_n = '0') then
|
| 2144 |
|
|
crc5Valid <= '0';
|
| 2145 |
|
|
symbolType0 <= (others => '0');
|
| 2146 |
|
|
symbolContent0 <= (others => '0');
|
| 2147 |
|
|
elsif (clk'event and clk = '1') then
|
| 2148 |
|
|
if (rxEmpty_i = '0') then
|
| 2149 |
|
|
if (crc5 = rxData_i(12 downto 8)) then
|
| 2150 |
|
|
crc5Valid <= '1';
|
| 2151 |
|
|
else
|
| 2152 |
|
|
crc5Valid <= '0';
|
| 2153 |
|
|
end if;
|
| 2154 |
|
|
symbolEnable0 <= '1';
|
| 2155 |
|
|
symbolType0 <= rxType_i;
|
| 2156 |
|
|
symbolContent0 <= rxData_i;
|
| 2157 |
|
|
else
|
| 2158 |
|
|
symbolEnable0 <= '0';
|
| 2159 |
|
|
end if;
|
| 2160 |
|
|
end if;
|
| 2161 |
|
|
end process;
|
| 2162 |
|
|
|
| 2163 |
4 |
magro732 |
-----------------------------------------------------------------------------
|
| 2164 |
11 |
magro732 |
-- Second pipeline stage.
|
| 2165 |
|
|
-- Separate the part of the control symbol that are going to the transmitter
|
| 2166 |
|
|
-- side and check the type of symbol for this side.
|
| 2167 |
4 |
magro732 |
-----------------------------------------------------------------------------
|
| 2168 |
|
|
|
| 2169 |
11 |
magro732 |
process(clk, areset_n)
|
| 2170 |
|
|
begin
|
| 2171 |
|
|
if (areset_n = '0') then
|
| 2172 |
|
|
txControlWrite_o <= '0';
|
| 2173 |
|
|
txControlSymbol_o <= (others => '0');
|
| 2174 |
4 |
magro732 |
|
| 2175 |
11 |
magro732 |
symbolValid <= '0';
|
| 2176 |
|
|
stype0Status <= '0';
|
| 2177 |
|
|
stype1Start <= '0';
|
| 2178 |
|
|
stype1End <= '0';
|
| 2179 |
|
|
stype1Stomp <= '0';
|
| 2180 |
|
|
stype1Restart <= '0';
|
| 2181 |
|
|
stype1LinkRequest <= '0';
|
| 2182 |
|
|
symbolData <= '0';
|
| 2183 |
|
|
|
| 2184 |
|
|
symbolContent1 <= (others => '0');
|
| 2185 |
|
|
elsif (clk'event and clk = '1') then
|
| 2186 |
|
|
if (symbolEnable0 = '1') then
|
| 2187 |
|
|
symbolEnable1 <= '1';
|
| 2188 |
|
|
symbolContent1 <= symbolContent0;
|
| 2189 |
|
|
|
| 2190 |
|
|
if (symbolType0 = SYMBOL_CONTROL) then
|
| 2191 |
|
|
if (crc5Valid = '1') then
|
| 2192 |
|
|
-- REMARK: Check if stype0 is nop and dont forward it???
|
| 2193 |
|
|
symbolValid <= '1';
|
| 2194 |
|
|
txControlWrite_o <= '1';
|
| 2195 |
|
|
txControlSymbol_o <= symbolContent0(31 downto 19);
|
| 2196 |
|
|
else
|
| 2197 |
|
|
symbolValid <= '0';
|
| 2198 |
|
|
txControlWrite_o <= '0';
|
| 2199 |
|
|
txControlSymbol_o <= (others => '0');
|
| 2200 |
|
|
end if;
|
| 2201 |
|
|
else
|
| 2202 |
|
|
symbolValid <= '1';
|
| 2203 |
|
|
end if;
|
| 2204 |
|
|
|
| 2205 |
|
|
if ((symbolType0 = SYMBOL_CONTROL) and
|
| 2206 |
|
|
(symbolContent0(31 downto 29) = STYPE0_STATUS)) then
|
| 2207 |
|
|
stype0Status <= '1';
|
| 2208 |
|
|
else
|
| 2209 |
|
|
stype0Status <= '0';
|
| 2210 |
|
|
end if;
|
| 2211 |
|
|
if ((symbolType0 = SYMBOL_CONTROL) and
|
| 2212 |
|
|
(symbolContent0(18 downto 16) = STYPE1_START_OF_PACKET)) then
|
| 2213 |
|
|
stype1Start <= '1';
|
| 2214 |
|
|
else
|
| 2215 |
|
|
stype1Start <= '0';
|
| 2216 |
|
|
end if;
|
| 2217 |
|
|
if ((symbolType0 = SYMBOL_CONTROL) and
|
| 2218 |
|
|
(symbolContent0(18 downto 16) = STYPE1_END_OF_PACKET)) then
|
| 2219 |
|
|
stype1End <= '1';
|
| 2220 |
|
|
else
|
| 2221 |
|
|
stype1End <= '0';
|
| 2222 |
|
|
end if;
|
| 2223 |
|
|
if ((symbolType0 = SYMBOL_CONTROL) and
|
| 2224 |
|
|
(symbolContent0(18 downto 16) = STYPE1_STOMP)) then
|
| 2225 |
|
|
stype1Stomp <= '1';
|
| 2226 |
|
|
else
|
| 2227 |
|
|
stype1Stomp <= '0';
|
| 2228 |
|
|
end if;
|
| 2229 |
|
|
if ((symbolType0 = SYMBOL_CONTROL) and
|
| 2230 |
|
|
(symbolContent0(18 downto 16) = STYPE1_RESTART_FROM_RETRY)) then
|
| 2231 |
|
|
stype1Restart <= '1';
|
| 2232 |
|
|
else
|
| 2233 |
|
|
stype1Restart <= '0';
|
| 2234 |
|
|
end if;
|
| 2235 |
|
|
if ((symbolType0 = SYMBOL_CONTROL) and
|
| 2236 |
|
|
(symbolContent0(18 downto 16) = STYPE1_LINK_REQUEST)) then
|
| 2237 |
|
|
stype1LinkRequest <= '1';
|
| 2238 |
|
|
else
|
| 2239 |
|
|
stype1LinkRequest <= '0';
|
| 2240 |
|
|
end if;
|
| 2241 |
|
|
if (symbolType0 = SYMBOL_DATA) then
|
| 2242 |
|
|
symbolData <= '1';
|
| 2243 |
|
|
else
|
| 2244 |
|
|
symbolData <= '0';
|
| 2245 |
|
|
end if;
|
| 2246 |
|
|
else
|
| 2247 |
|
|
symbolEnable1 <= '0';
|
| 2248 |
|
|
end if;
|
| 2249 |
|
|
end if;
|
| 2250 |
|
|
end process;
|
| 2251 |
|
|
|
| 2252 |
4 |
magro732 |
-----------------------------------------------------------------------------
|
| 2253 |
11 |
magro732 |
-- Third pipeline stage.
|
| 2254 |
|
|
-- Update the CRC16 for the packet.
|
| 2255 |
|
|
-- Update the buffered data and write it to the packet buffer if needed.
|
| 2256 |
|
|
-- Update the main receiver state machine.
|
| 2257 |
|
|
-- Generate reply symbols to the link-partner.
|
| 2258 |
|
|
-- Note that this stage cannot contain any registers as it could be cascaded
|
| 2259 |
|
|
-- to other cores.
|
| 2260 |
4 |
magro732 |
-----------------------------------------------------------------------------
|
| 2261 |
11 |
magro732 |
|
| 2262 |
|
|
-----------------------------------------------------------------------------
|
| 2263 |
|
|
-- CRC-calculation.
|
| 2264 |
|
|
-- Add a data symbol to the calculated CRC for the packet.
|
| 2265 |
|
|
-- controlSymbol->just forward old crc16.
|
| 2266 |
|
|
-- first data-symbol in packet->crc_o is product of 11111 and the
|
| 2267 |
|
|
-- symbolContent1 without ackid.
|
| 2268 |
|
|
-- not first data-symbol->crc_o is product of crc_i and symbolContent1.
|
| 2269 |
|
|
-----------------------------------------------------------------------------
|
| 2270 |
4 |
magro732 |
|
| 2271 |
11 |
magro732 |
crc16Data(31 downto 26) <= "000000" when (unsigned(frameIndex_i) = 1) else
|
| 2272 |
|
|
symbolContent1(31 downto 26);
|
| 2273 |
|
|
crc16Data(25 downto 0) <= symbolContent1(25 downto 0);
|
| 2274 |
4 |
magro732 |
|
| 2275 |
11 |
magro732 |
crc16Current <= crc_i when (unsigned(frameIndex_i) /= 1) else
|
| 2276 |
|
|
(others => '1');
|
| 2277 |
|
|
|
| 2278 |
|
|
Crc16Msb: Crc16CITT
|
| 2279 |
4 |
magro732 |
port map(
|
| 2280 |
|
|
d_i=>crc16Data(31 downto 16), crc_i=>crc16Current, crc_o=>crc16Temp);
|
| 2281 |
11 |
magro732 |
Crc16Lsb: Crc16CITT
|
| 2282 |
4 |
magro732 |
port map(
|
| 2283 |
|
|
d_i=>crc16Data(15 downto 0), crc_i=>crc16Temp, crc_o=>crc16Next);
|
| 2284 |
|
|
|
| 2285 |
11 |
magro732 |
crc_o <= crc_i when (symbolData = '0') else
|
| 2286 |
|
|
crc16Next;
|
| 2287 |
|
|
|
| 2288 |
|
|
crc16Valid <= '1' when (crc_i = x"0000") else '0';
|
| 2289 |
|
|
|
| 2290 |
4 |
magro732 |
-----------------------------------------------------------------------------
|
| 2291 |
11 |
magro732 |
-- Update buffered data.
|
| 2292 |
4 |
magro732 |
-----------------------------------------------------------------------------
|
| 2293 |
|
|
|
| 2294 |
11 |
magro732 |
-- Append the new symbol content to the end of the
|
| 2295 |
|
|
-- current frame content if the symbol is a data symbol.
|
| 2296 |
|
|
frameContentSingle:
|
| 2297 |
|
|
if (NUMBER_WORDS = 1) generate
|
| 2298 |
|
|
frameContent <= symbolContent1;
|
| 2299 |
|
|
end generate;
|
| 2300 |
|
|
frameContentMulti:
|
| 2301 |
|
|
if (NUMBER_WORDS > 1) generate
|
| 2302 |
|
|
frameContent <=
|
| 2303 |
|
|
(frameContent_i((32*(NUMBER_WORDS-1))-1 downto 0) & symbolContent1) when (symbolData = '1') else
|
| 2304 |
|
|
frameContent_i;
|
| 2305 |
|
|
end generate;
|
| 2306 |
4 |
magro732 |
|
| 2307 |
11 |
magro732 |
-- Update outputs.
|
| 2308 |
|
|
enable_o <= symbolEnable1;
|
| 2309 |
|
|
frameContent_o <= frameContent;
|
| 2310 |
|
|
writeContentData_o <= frameContent;
|
| 2311 |
4 |
magro732 |
|
| 2312 |
11 |
magro732 |
-----------------------------------------------------------------------------
|
| 2313 |
|
|
-- Main inbound symbol handler.
|
| 2314 |
|
|
-----------------------------------------------------------------------------
|
| 2315 |
|
|
process(portInitialized_i, portEnable_i, writeFrameFull_i,
|
| 2316 |
|
|
operational_i, ackId_i, frameIndex_i, frameWordCounter_i,
|
| 2317 |
|
|
inputRetryStopped_i, inputErrorStopped_i,
|
| 2318 |
|
|
symbolValid,
|
| 2319 |
|
|
stype0Status,
|
| 2320 |
|
|
stype1Start, stype1End, stype1Stomp, stype1Restart, stype1LinkRequest,
|
| 2321 |
|
|
symbolData,
|
| 2322 |
|
|
symbolContent1,
|
| 2323 |
|
|
frameContent,
|
| 2324 |
|
|
crc16Valid)
|
| 2325 |
|
|
begin
|
| 2326 |
|
|
operational_o <= operational_i;
|
| 2327 |
|
|
ackId_o <= ackId_i;
|
| 2328 |
|
|
frameIndex_o <= frameIndex_i;
|
| 2329 |
|
|
frameWordCounter_o <= frameWordCounter_i;
|
| 2330 |
|
|
inputRetryStopped_o <= inputRetryStopped_i;
|
| 2331 |
|
|
inputErrorStopped_o <= inputErrorStopped_i;
|
| 2332 |
|
|
|
| 2333 |
|
|
rxControlWrite <= '0';
|
| 2334 |
|
|
rxControlSymbol <= (others => '0');
|
| 2335 |
|
|
|
| 2336 |
|
|
writeFrame_o <= '0';
|
| 2337 |
|
|
writeFrameAbort_o <= '0';
|
| 2338 |
|
|
writeContent_o <= '0';
|
| 2339 |
|
|
writeContentWords_o <= (others => '0');
|
| 2340 |
4 |
magro732 |
|
| 2341 |
11 |
magro732 |
-- Act on the current state.
|
| 2342 |
|
|
if (operational_i = '0') then
|
| 2343 |
|
|
---------------------------------------------------------------------
|
| 2344 |
|
|
-- The port is not operational and is waiting for status control
|
| 2345 |
|
|
-- symbols to be received on the link. Count the number
|
| 2346 |
|
|
-- of error-free status symbols and considder the link operational
|
| 2347 |
|
|
-- when enough of them has been received. Frames are not allowed
|
| 2348 |
|
|
-- here.
|
| 2349 |
|
|
---------------------------------------------------------------------
|
| 2350 |
|
|
|
| 2351 |
|
|
-- Check if the port is initialized.
|
| 2352 |
|
|
if (portInitialized_i = '1') then
|
| 2353 |
|
|
-- Port is initialized.
|
| 2354 |
|
|
|
| 2355 |
|
|
-- Check if the control symbol has a valid checksum.
|
| 2356 |
|
|
if (symbolValid = '1') then
|
| 2357 |
|
|
-- The control symbol has a valid checksum.
|
| 2358 |
4 |
magro732 |
|
| 2359 |
11 |
magro732 |
-- Check the stype0 part if we should count the number of
|
| 2360 |
|
|
-- error-free status symbols.
|
| 2361 |
|
|
if (stype0Status = '1') then
|
| 2362 |
|
|
-- The symbol is a status.
|
| 2363 |
4 |
magro732 |
|
| 2364 |
11 |
magro732 |
-- Check if enough status symbols have been received.
|
| 2365 |
|
|
if (unsigned(frameIndex_i) = 7) then
|
| 2366 |
|
|
-- Enough status symbols have been received.
|
| 2367 |
4 |
magro732 |
|
| 2368 |
11 |
magro732 |
-- Reset all packets.
|
| 2369 |
|
|
frameIndex_o <= (others => '0');
|
| 2370 |
|
|
writeFrameAbort_o <= '1';
|
| 2371 |
|
|
|
| 2372 |
|
|
-- Set the link as initialized.
|
| 2373 |
|
|
operational_o <= '1';
|
| 2374 |
4 |
magro732 |
else
|
| 2375 |
11 |
magro732 |
-- Increase the number of error-free status symbols that
|
| 2376 |
|
|
-- has been received.
|
| 2377 |
|
|
frameIndex_o <= std_logic_vector(unsigned(frameIndex_i) + 1);
|
| 2378 |
4 |
magro732 |
end if;
|
| 2379 |
11 |
magro732 |
else
|
| 2380 |
|
|
-- The symbol is not a status.
|
| 2381 |
|
|
-- Dont do anything.
|
| 2382 |
|
|
end if;
|
| 2383 |
|
|
else
|
| 2384 |
|
|
-- A control symbol with CRC5 error was recevied.
|
| 2385 |
|
|
frameIndex_o <= (others => '0');
|
| 2386 |
|
|
end if;
|
| 2387 |
|
|
else
|
| 2388 |
|
|
-- The port has become uninitialized.
|
| 2389 |
|
|
frameIndex_o <= (others => '0');
|
| 2390 |
|
|
end if;
|
| 2391 |
|
|
else
|
| 2392 |
|
|
---------------------------------------------------------------------
|
| 2393 |
|
|
-- The port has been initialized and enough error free status symbols
|
| 2394 |
|
|
-- have been received. Forward data frames to the frame buffer
|
| 2395 |
|
|
-- interface. This is the normal operational state.
|
| 2396 |
|
|
---------------------------------------------------------------------
|
| 2397 |
|
|
|
| 2398 |
|
|
-- Check that the port is initialized.
|
| 2399 |
|
|
if (portInitialized_i = '1') then
|
| 2400 |
|
|
-- The port and link is initialized.
|
| 2401 |
|
|
|
| 2402 |
|
|
-- Check if the control symbol has a valid CRC-5.
|
| 2403 |
|
|
if (symbolValid = '1') then
|
| 2404 |
|
|
-- The symbol is correct.
|
| 2405 |
4 |
magro732 |
|
| 2406 |
11 |
magro732 |
if ((stype1Start = '1') and
|
| 2407 |
|
|
(inputRetryStopped_i = '0') and (inputErrorStopped_i = '0')) then
|
| 2408 |
|
|
-------------------------------------------------------------
|
| 2409 |
|
|
-- Start the reception of a new frame or end a currently
|
| 2410 |
|
|
-- ongoing frame and start a new one.
|
| 2411 |
|
|
-------------------------------------------------------------
|
| 2412 |
4 |
magro732 |
|
| 2413 |
11 |
magro732 |
-- Check if a frame has already been started.
|
| 2414 |
|
|
if (unsigned(frameIndex_i) /= 0) then
|
| 2415 |
|
|
-- A frame is already started.
|
| 2416 |
|
|
-- Complete the last frame and start to ackumulate a new one
|
| 2417 |
|
|
-- and update the ackId.
|
| 2418 |
4 |
magro732 |
|
| 2419 |
11 |
magro732 |
if (unsigned(frameIndex_i) > 3) then
|
| 2420 |
4 |
magro732 |
|
| 2421 |
11 |
magro732 |
-- Reset the frame index to indicate the frame is started.
|
| 2422 |
|
|
frameIndex_o <= "0000001";
|
| 2423 |
|
|
frameWordCounter_o <= (others=>'0');
|
| 2424 |
|
|
|
| 2425 |
|
|
-- Check the CRC-16 and the length of the received frame.
|
| 2426 |
|
|
if (crc16Valid = '1') then
|
| 2427 |
|
|
-- The CRC-16 is ok.
|
| 2428 |
|
|
|
| 2429 |
|
|
-- Check if there are any unwritten buffered packet content
|
| 2430 |
|
|
-- and write it if there is.
|
| 2431 |
|
|
-- REMARK: Multi-symbol support...
|
| 2432 |
|
|
if (unsigned(frameWordCounter_i) /= 0) then
|
| 2433 |
|
|
writeContent_o <= '1';
|
| 2434 |
|
|
end if;
|
| 2435 |
4 |
magro732 |
|
| 2436 |
11 |
magro732 |
-- Update the frame buffer to indicate that the frame has
|
| 2437 |
|
|
-- been completly received.
|
| 2438 |
|
|
writeFrame_o <= '1';
|
| 2439 |
4 |
magro732 |
|
| 2440 |
11 |
magro732 |
-- Update ackId.
|
| 2441 |
|
|
ackId_o <= ackId_i + 1;
|
| 2442 |
4 |
magro732 |
|
| 2443 |
11 |
magro732 |
-- Send packet-accepted.
|
| 2444 |
|
|
-- The buffer status is appended by the transmitter
|
| 2445 |
|
|
-- when sent to get the latest number.
|
| 2446 |
|
|
rxControlWrite <= '1';
|
| 2447 |
|
|
rxControlSymbol <= STYPE0_PACKET_ACCEPTED &
|
| 2448 |
|
|
std_logic_vector(ackId_i) &
|
| 2449 |
|
|
"11111";
|
| 2450 |
|
|
else
|
| 2451 |
|
|
-- The CRC-16 is not ok.
|
| 2452 |
4 |
magro732 |
|
| 2453 |
11 |
magro732 |
-- Make the transmitter send a packet-not-accepted to indicate
|
| 2454 |
|
|
-- that the received packet contained a CRC error.
|
| 2455 |
|
|
rxControlWrite <= '1';
|
| 2456 |
|
|
rxControlSymbol <= STYPE0_PACKET_NOT_ACCEPTED &
|
| 2457 |
|
|
"00000" &
|
| 2458 |
|
|
PACKET_NOT_ACCEPTED_CAUSE_PACKET_CRC;
|
| 2459 |
|
|
inputErrorStopped_o <= '1';
|
| 2460 |
4 |
magro732 |
end if;
|
| 2461 |
|
|
else
|
| 2462 |
11 |
magro732 |
-- This packet is too small.
|
| 2463 |
|
|
-- Make the transmitter send a packet-not-accepted to indicated
|
| 2464 |
|
|
-- that the received packet was too small.
|
| 2465 |
|
|
rxControlWrite <= '1';
|
| 2466 |
|
|
rxControlSymbol <= STYPE0_PACKET_NOT_ACCEPTED &
|
| 2467 |
|
|
"00000" &
|
| 2468 |
|
|
PACKET_NOT_ACCEPTED_CAUSE_GENERAL_ERROR;
|
| 2469 |
|
|
inputErrorStopped_o <= '1';
|
| 2470 |
4 |
magro732 |
end if;
|
| 2471 |
|
|
else
|
| 2472 |
11 |
magro732 |
-- No frame has been started.
|
| 2473 |
|
|
|
| 2474 |
|
|
-- Reset the frame index to indicate the frame is started.
|
| 2475 |
|
|
frameIndex_o <= "0000001";
|
| 2476 |
|
|
frameWordCounter_o <= (others=>'0');
|
| 2477 |
4 |
magro732 |
end if;
|
| 2478 |
11 |
magro732 |
end if;
|
| 2479 |
|
|
|
| 2480 |
|
|
if ((stype1End = '1') and
|
| 2481 |
|
|
(inputRetryStopped_i = '0') and (inputErrorStopped_i = '0')) then
|
| 2482 |
|
|
-------------------------------------------------------------
|
| 2483 |
|
|
-- End the reception of an old frame.
|
| 2484 |
|
|
-------------------------------------------------------------
|
| 2485 |
4 |
magro732 |
|
| 2486 |
11 |
magro732 |
-- Check if a frame has already been started.
|
| 2487 |
|
|
if (unsigned(frameIndex_i) > 3) then
|
| 2488 |
|
|
-- A frame has been started and it is large enough.
|
| 2489 |
4 |
magro732 |
|
| 2490 |
11 |
magro732 |
-- Reset frame reception to indicate that no frame is ongoing.
|
| 2491 |
|
|
frameIndex_o <= (others => '0');
|
| 2492 |
|
|
|
| 2493 |
|
|
-- Check the CRC-16 and the length of the received frame.
|
| 2494 |
|
|
if (crc16Valid = '1') then
|
| 2495 |
|
|
-- The CRC-16 is ok.
|
| 2496 |
4 |
magro732 |
|
| 2497 |
11 |
magro732 |
-- Check if there are any unwritten buffered packet content
|
| 2498 |
|
|
-- and write it if there is.
|
| 2499 |
|
|
-- REMARK: Multi-symbol support...
|
| 2500 |
|
|
if (unsigned(frameWordCounter_i) /= 0) then
|
| 2501 |
|
|
writeContent_o <= '1';
|
| 2502 |
|
|
end if;
|
| 2503 |
4 |
magro732 |
|
| 2504 |
11 |
magro732 |
-- Update the frame buffer to indicate that the frame has
|
| 2505 |
|
|
-- been completly received.
|
| 2506 |
|
|
writeFrame_o <= '1';
|
| 2507 |
4 |
magro732 |
|
| 2508 |
11 |
magro732 |
-- Update ackId.
|
| 2509 |
|
|
ackId_o <= ackId_i + 1;
|
| 2510 |
4 |
magro732 |
|
| 2511 |
11 |
magro732 |
-- Send packet-accepted.
|
| 2512 |
|
|
-- The buffer status is appended by the transmitter
|
| 2513 |
|
|
-- when sent to get the latest number.
|
| 2514 |
|
|
rxControlWrite <= '1';
|
| 2515 |
|
|
rxControlSymbol <= STYPE0_PACKET_ACCEPTED &
|
| 2516 |
|
|
std_logic_vector(ackId_i) &
|
| 2517 |
|
|
"11111";
|
| 2518 |
|
|
else
|
| 2519 |
|
|
-- The CRC-16 is not ok.
|
| 2520 |
4 |
magro732 |
|
| 2521 |
11 |
magro732 |
-- Make the transmitter send a packet-not-accepted to indicate
|
| 2522 |
|
|
-- that the received packet contained a CRC error.
|
| 2523 |
|
|
rxControlWrite <= '1';
|
| 2524 |
|
|
rxControlSymbol <= STYPE0_PACKET_NOT_ACCEPTED &
|
| 2525 |
|
|
"00000" &
|
| 2526 |
|
|
PACKET_NOT_ACCEPTED_CAUSE_PACKET_CRC;
|
| 2527 |
|
|
inputErrorStopped_o <= '1';
|
| 2528 |
4 |
magro732 |
end if;
|
| 2529 |
|
|
else
|
| 2530 |
11 |
magro732 |
-- This packet is too small.
|
| 2531 |
|
|
-- Make the transmitter send a packet-not-accepted to indicate
|
| 2532 |
|
|
-- that the received packet was too small.
|
| 2533 |
|
|
rxControlWrite <= '1';
|
| 2534 |
|
|
rxControlSymbol <= STYPE0_PACKET_NOT_ACCEPTED &
|
| 2535 |
|
|
"00000" &
|
| 2536 |
|
|
PACKET_NOT_ACCEPTED_CAUSE_GENERAL_ERROR;
|
| 2537 |
|
|
inputErrorStopped_o <= '1';
|
| 2538 |
4 |
magro732 |
end if;
|
| 2539 |
11 |
magro732 |
end if;
|
| 2540 |
4 |
magro732 |
|
| 2541 |
11 |
magro732 |
if ((stype1Stomp = '1') and
|
| 2542 |
|
|
(inputRetryStopped_i = '0') and (inputErrorStopped_i = '0')) then
|
| 2543 |
|
|
-------------------------------------------------------------
|
| 2544 |
|
|
-- Restart the reception of an old frame.
|
| 2545 |
|
|
-------------------------------------------------------------
|
| 2546 |
|
|
-- See 5.10 in the standard.
|
| 2547 |
4 |
magro732 |
|
| 2548 |
11 |
magro732 |
-- Make the transmitter send a packet-retry to indicate
|
| 2549 |
|
|
-- that the packet cannot be accepted.
|
| 2550 |
|
|
rxControlWrite <= '1';
|
| 2551 |
|
|
rxControlSymbol <= STYPE0_PACKET_RETRY &
|
| 2552 |
|
|
std_logic_vector(ackId_i) &
|
| 2553 |
|
|
"11111";
|
| 2554 |
|
|
|
| 2555 |
|
|
-- Enter the input retry-stopped state.
|
| 2556 |
|
|
inputRetryStopped_o <= '1';
|
| 2557 |
|
|
end if;
|
| 2558 |
4 |
magro732 |
|
| 2559 |
11 |
magro732 |
if (stype1Restart = '1') then
|
| 2560 |
|
|
if (inputRetryStopped_i = '1') then
|
| 2561 |
|
|
-------------------------------------------------------------
|
| 2562 |
|
|
-- The receiver indicates a restart from a retry sent
|
| 2563 |
|
|
-- from us.
|
| 2564 |
|
|
-------------------------------------------------------------
|
| 2565 |
4 |
magro732 |
|
| 2566 |
11 |
magro732 |
-- Abort the frame and reset frame reception.
|
| 2567 |
|
|
frameIndex_o <= (others => '0');
|
| 2568 |
|
|
writeFrameAbort_o <= '1';
|
| 2569 |
|
|
|
| 2570 |
|
|
-- Go back to the normal operational state.
|
| 2571 |
|
|
inputRetryStopped_o <= '0';
|
| 2572 |
|
|
else
|
| 2573 |
|
|
-------------------------------------------------------------
|
| 2574 |
|
|
-- The receiver indicates a restart from a retry sent
|
| 2575 |
|
|
-- from us.
|
| 2576 |
|
|
-------------------------------------------------------------
|
| 2577 |
|
|
-- See 5.10 in the standard.
|
| 2578 |
|
|
-- Protocol error, this symbol should not be received here since
|
| 2579 |
|
|
-- we should have been in input-retry-stopped.
|
| 2580 |
|
|
|
| 2581 |
|
|
-- Send a packet-not-accepted to indicate that a protocol
|
| 2582 |
|
|
-- error has occurred.
|
| 2583 |
|
|
rxControlWrite <= '1';
|
| 2584 |
|
|
rxControlSymbol <= STYPE0_PACKET_NOT_ACCEPTED &
|
| 2585 |
|
|
"00000" &
|
| 2586 |
|
|
PACKET_NOT_ACCEPTED_CAUSE_GENERAL_ERROR;
|
| 2587 |
|
|
inputErrorStopped_o <= '1';
|
| 2588 |
|
|
end if;
|
| 2589 |
|
|
end if;
|
| 2590 |
4 |
magro732 |
|
| 2591 |
11 |
magro732 |
if (stype1LinkRequest = '1') then
|
| 2592 |
|
|
-------------------------------------------------------------
|
| 2593 |
|
|
-- Reply to a LINK-REQUEST.
|
| 2594 |
|
|
-------------------------------------------------------------
|
| 2595 |
|
|
|
| 2596 |
|
|
-- Check the command part.
|
| 2597 |
|
|
if (symbolContent1(15 downto 13) = "100") then
|
| 2598 |
|
|
-- Return input port status command.
|
| 2599 |
|
|
-- This functions as a link-request(restart-from-error)
|
| 2600 |
|
|
-- control symbol under error situations.
|
| 2601 |
4 |
magro732 |
|
| 2602 |
11 |
magro732 |
if (inputErrorStopped_i = '1') then
|
| 2603 |
|
|
rxControlWrite <= '1';
|
| 2604 |
|
|
rxControlSymbol <= STYPE0_LINK_RESPONSE &
|
| 2605 |
|
|
std_logic_vector(ackId_i) &
|
| 2606 |
|
|
"00101";
|
| 2607 |
|
|
elsif (inputRetryStopped_i = '1') then
|
| 2608 |
|
|
rxControlWrite <= '1';
|
| 2609 |
|
|
rxControlSymbol <= STYPE0_LINK_RESPONSE &
|
| 2610 |
|
|
std_logic_vector(ackId_i) &
|
| 2611 |
|
|
"00100";
|
| 2612 |
4 |
magro732 |
else
|
| 2613 |
11 |
magro732 |
-- Send a link response containing an ok reply.
|
| 2614 |
|
|
rxControlWrite <= '1';
|
| 2615 |
|
|
rxControlSymbol <= STYPE0_LINK_RESPONSE &
|
| 2616 |
|
|
std_logic_vector(ackId_i) &
|
| 2617 |
|
|
"10000";
|
| 2618 |
4 |
magro732 |
end if;
|
| 2619 |
|
|
else
|
| 2620 |
11 |
magro732 |
-- Reset device command or other unsupported command.
|
| 2621 |
|
|
-- Discard this.
|
| 2622 |
4 |
magro732 |
end if;
|
| 2623 |
|
|
|
| 2624 |
11 |
magro732 |
-- Abort the frame and reset frame reception.
|
| 2625 |
|
|
inputRetryStopped_o <= '0';
|
| 2626 |
|
|
inputErrorStopped_o <= '0';
|
| 2627 |
|
|
frameIndex_o <= (others=>'0');
|
| 2628 |
|
|
writeFrameAbort_o <= '1';
|
| 2629 |
|
|
end if;
|
| 2630 |
4 |
magro732 |
|
| 2631 |
11 |
magro732 |
if ((symbolData = '1') and
|
| 2632 |
|
|
(inputRetryStopped_i = '0') and (inputErrorStopped_i = '0')) then
|
| 2633 |
|
|
-------------------------------------------------------------
|
| 2634 |
|
|
-- This is a data symbol.
|
| 2635 |
|
|
-------------------------------------------------------------
|
| 2636 |
|
|
-- REMARK: Add check for in-the-middle-crc here...
|
| 2637 |
4 |
magro732 |
|
| 2638 |
11 |
magro732 |
case frameIndex_i is
|
| 2639 |
|
|
when "0000000" | "1000110" =>
|
| 2640 |
|
|
-- A frame has not been started or is too long.
|
| 2641 |
|
|
-- Send packet-not-accepted.
|
| 2642 |
|
|
rxControlWrite <= '1';
|
| 2643 |
|
|
rxControlSymbol <= STYPE0_PACKET_NOT_ACCEPTED &
|
| 2644 |
|
|
"00000" &
|
| 2645 |
|
|
PACKET_NOT_ACCEPTED_CAUSE_GENERAL_ERROR;
|
| 2646 |
|
|
inputErrorStopped_o <= '1';
|
| 2647 |
|
|
when "0000001" =>
|
| 2648 |
|
|
if (unsigned(symbolContent1(31 downto 27)) = ackId_i) then
|
| 2649 |
|
|
if ((portEnable_i = '1') or
|
| 2650 |
|
|
(symbolContent1(19 downto 16) = FTYPE_MAINTENANCE_CLASS)) then
|
| 2651 |
|
|
|
| 2652 |
|
|
-- Check if there are buffers available to store the new
|
| 2653 |
|
|
-- packet.
|
| 2654 |
|
|
if (writeFrameFull_i = '0') then
|
| 2655 |
|
|
-- There are buffering space available to store the new
|
| 2656 |
|
|
-- data.
|
| 2657 |
|
|
|
| 2658 |
|
|
-- Check if the buffer entry is ready to be written
|
| 2659 |
|
|
-- into the packet buffer.
|
| 2660 |
|
|
-- REMARK: Multi-symbol support...
|
| 2661 |
|
|
if (unsigned(frameWordCounter_i) = (NUMBER_WORDS-1)) then
|
| 2662 |
|
|
-- Write the data to the frame FIFO.
|
| 2663 |
|
|
frameWordCounter_o <= (others=>'0');
|
| 2664 |
|
|
writeContent_o <= '1';
|
| 2665 |
|
|
writeContentWords_o <= frameWordCounter_i;
|
| 2666 |
|
|
else
|
| 2667 |
|
|
frameWordCounter_o <= std_logic_vector(unsigned(frameWordCounter_i) + 1);
|
| 2668 |
|
|
end if;
|
| 2669 |
4 |
magro732 |
|
| 2670 |
11 |
magro732 |
-- Increment the number of received data symbols.
|
| 2671 |
|
|
frameIndex_o <= std_logic_vector(unsigned(frameIndex_i) + 1);
|
| 2672 |
|
|
else
|
| 2673 |
|
|
-- The packet buffer is full.
|
| 2674 |
|
|
-- Let the link-partner resend the packet.
|
| 2675 |
|
|
rxControlWrite <= '1';
|
| 2676 |
|
|
rxControlSymbol <= STYPE0_PACKET_RETRY &
|
| 2677 |
|
|
std_logic_vector(ackId_i) &
|
| 2678 |
|
|
"11111";
|
| 2679 |
|
|
inputRetryStopped_o <= '1';
|
| 2680 |
|
|
end if;
|
| 2681 |
4 |
magro732 |
else
|
| 2682 |
11 |
magro732 |
-- A non-maintenance packets are not allowed.
|
| 2683 |
|
|
-- Send packet-not-accepted.
|
| 2684 |
|
|
rxControlWrite <= '1';
|
| 2685 |
|
|
rxControlSymbol <= STYPE0_PACKET_NOT_ACCEPTED &
|
| 2686 |
|
|
"00000" &
|
| 2687 |
|
|
PACKET_NOT_ACCEPTED_CAUSE_NON_MAINTENANCE_STOPPED;
|
| 2688 |
|
|
inputErrorStopped_o <= '1';
|
| 2689 |
4 |
magro732 |
end if;
|
| 2690 |
|
|
else
|
| 2691 |
11 |
magro732 |
-- The ackId is unexpected.
|
| 2692 |
|
|
-- Send packet-not-accepted.
|
| 2693 |
|
|
rxControlWrite <= '1';
|
| 2694 |
|
|
rxControlSymbol <= STYPE0_PACKET_NOT_ACCEPTED &
|
| 2695 |
|
|
"00000" &
|
| 2696 |
|
|
PACKET_NOT_ACCEPTED_CAUSE_UNEXPECTED_ACKID;
|
| 2697 |
|
|
inputErrorStopped_o <= '1';
|
| 2698 |
4 |
magro732 |
end if;
|
| 2699 |
11 |
magro732 |
when others =>
|
| 2700 |
|
|
-- A frame has been started and is not too long.
|
| 2701 |
|
|
-- Check if the buffer entry is ready to be written
|
| 2702 |
|
|
-- into the packet buffer.
|
| 2703 |
|
|
-- REMARK: Multi-symbol support...
|
| 2704 |
|
|
if (unsigned(frameWordCounter_i) = (NUMBER_WORDS-1)) then
|
| 2705 |
|
|
-- Write the data to the frame FIFO.
|
| 2706 |
|
|
frameWordCounter_o <= (others=>'0');
|
| 2707 |
|
|
writeContent_o <= '1';
|
| 2708 |
|
|
writeContentWords_o <= frameWordCounter_i;
|
| 2709 |
|
|
else
|
| 2710 |
|
|
frameWordCounter_o <= std_logic_vector(unsigned(frameWordCounter_i) + 1);
|
| 2711 |
|
|
end if;
|
| 2712 |
4 |
magro732 |
|
| 2713 |
11 |
magro732 |
-- Increment the number of received data symbols.
|
| 2714 |
|
|
frameIndex_o <= std_logic_vector(unsigned(frameIndex_i) + 1);
|
| 2715 |
|
|
end case;
|
| 2716 |
|
|
end if;
|
| 2717 |
|
|
else
|
| 2718 |
|
|
-- A control symbol contains a crc error.
|
| 2719 |
4 |
magro732 |
|
| 2720 |
11 |
magro732 |
-- Send a packet-not-accepted to indicate that a corrupted
|
| 2721 |
|
|
-- control-symbol has been received and change state.
|
| 2722 |
|
|
rxControlWrite <= '1';
|
| 2723 |
|
|
rxControlSymbol <= STYPE0_PACKET_NOT_ACCEPTED &
|
| 2724 |
|
|
"00000" &
|
| 2725 |
|
|
PACKET_NOT_ACCEPTED_CAUSE_CONTROL_CRC;
|
| 2726 |
|
|
inputErrorStopped_o <= '1';
|
| 2727 |
|
|
end if;
|
| 2728 |
|
|
else
|
| 2729 |
|
|
-- The port has become uninitialized.
|
| 2730 |
|
|
-- Go back to the uninitialized state.
|
| 2731 |
|
|
operational_o <= '0';
|
| 2732 |
4 |
magro732 |
end if;
|
| 2733 |
|
|
end if;
|
| 2734 |
|
|
end process;
|
| 2735 |
|
|
|
| 2736 |
11 |
magro732 |
-----------------------------------------------------------------------------
|
| 2737 |
|
|
-- Fourth pipeline stage.
|
| 2738 |
|
|
-----------------------------------------------------------------------------
|
| 2739 |
|
|
-- REMARK: Do more stuff in this stage, convert a one-hot to the symbol to
|
| 2740 |
|
|
-- send...
|
| 2741 |
|
|
-- REMARK: Register other outputs here like writeContent_o...
|
| 2742 |
|
|
|
| 2743 |
|
|
process(clk, areset_n)
|
| 2744 |
|
|
begin
|
| 2745 |
|
|
if (areset_n = '0') then
|
| 2746 |
|
|
rxControlWrite_o <= '0';
|
| 2747 |
|
|
rxControlSymbol_o <= (others=>'0');
|
| 2748 |
|
|
elsif (clk'event and clk = '1') then
|
| 2749 |
|
|
rxControlWrite_o <= rxControlWrite and symbolEnable1;
|
| 2750 |
|
|
rxControlSymbol_o <= rxControlSymbol;
|
| 2751 |
|
|
end if;
|
| 2752 |
|
|
end process;
|
| 2753 |
|
|
|
| 2754 |
4 |
magro732 |
end architecture;
|
| 2755 |
|
|
|
| 2756 |
|
|
|
| 2757 |
|
|
|
| 2758 |
|
|
-------------------------------------------------------------------------------
|
| 2759 |
|
|
--
|
| 2760 |
|
|
---------------------------------------------------------------------------------
|
| 2761 |
|
|
library ieee;
|
| 2762 |
|
|
use ieee.std_logic_1164.all;
|
| 2763 |
|
|
|
| 2764 |
|
|
|
| 2765 |
|
|
-------------------------------------------------------------------------------
|
| 2766 |
|
|
--
|
| 2767 |
|
|
-------------------------------------------------------------------------------
|
| 2768 |
|
|
entity RioFifo1 is
|
| 2769 |
|
|
generic(
|
| 2770 |
|
|
WIDTH : natural);
|
| 2771 |
|
|
port(
|
| 2772 |
|
|
clk : in std_logic;
|
| 2773 |
|
|
areset_n : in std_logic;
|
| 2774 |
|
|
|
| 2775 |
|
|
empty_o : out std_logic;
|
| 2776 |
|
|
read_i : in std_logic;
|
| 2777 |
|
|
data_o : out std_logic_vector(WIDTH-1 downto 0);
|
| 2778 |
|
|
|
| 2779 |
|
|
full_o : out std_logic;
|
| 2780 |
|
|
write_i : in std_logic;
|
| 2781 |
|
|
data_i : in std_logic_vector(WIDTH-1 downto 0));
|
| 2782 |
|
|
end entity;
|
| 2783 |
|
|
|
| 2784 |
|
|
|
| 2785 |
|
|
-------------------------------------------------------------------------------
|
| 2786 |
|
|
--
|
| 2787 |
|
|
-------------------------------------------------------------------------------
|
| 2788 |
|
|
architecture RioFifo1Impl of RioFifo1 is
|
| 2789 |
|
|
signal empty : std_logic;
|
| 2790 |
|
|
signal full : std_logic;
|
| 2791 |
|
|
begin
|
| 2792 |
|
|
|
| 2793 |
|
|
empty_o <= empty;
|
| 2794 |
|
|
full_o <= full;
|
| 2795 |
|
|
|
| 2796 |
|
|
process(areset_n, clk)
|
| 2797 |
|
|
begin
|
| 2798 |
|
|
if (areset_n = '0') then
|
| 2799 |
|
|
empty <= '1';
|
| 2800 |
|
|
full <= '0';
|
| 2801 |
|
|
data_o <= (others => '0');
|
| 2802 |
|
|
elsif (clk'event and clk = '1') then
|
| 2803 |
|
|
if (empty = '1') then
|
| 2804 |
|
|
if (write_i = '1') then
|
| 2805 |
|
|
empty <= '0';
|
| 2806 |
|
|
full <= '1';
|
| 2807 |
|
|
data_o <= data_i;
|
| 2808 |
|
|
end if;
|
| 2809 |
|
|
else
|
| 2810 |
|
|
if (read_i = '1') then
|
| 2811 |
|
|
empty <= '1';
|
| 2812 |
|
|
full <= '0';
|
| 2813 |
|
|
end if;
|
| 2814 |
|
|
end if;
|
| 2815 |
|
|
end if;
|
| 2816 |
|
|
end process;
|
| 2817 |
|
|
|
| 2818 |
|
|
end architecture;
|
| 2819 |
|
|
|
| 2820 |
|
|
|
| 2821 |
|
|
|
| 2822 |
|
|
-------------------------------------------------------------------------------
|
| 2823 |
|
|
-- A CRC-5 calculator following the implementation proposed in the 2.2
|
| 2824 |
|
|
-- standard.
|
| 2825 |
|
|
-------------------------------------------------------------------------------
|
| 2826 |
|
|
library ieee;
|
| 2827 |
|
|
use ieee.std_logic_1164.all;
|
| 2828 |
|
|
|
| 2829 |
|
|
|
| 2830 |
|
|
-------------------------------------------------------------------------------
|
| 2831 |
|
|
--
|
| 2832 |
|
|
-------------------------------------------------------------------------------
|
| 2833 |
|
|
entity Crc5ITU is
|
| 2834 |
|
|
port(
|
| 2835 |
|
|
d_i : in std_logic_vector(18 downto 0);
|
| 2836 |
|
|
crc_o : out std_logic_vector(4 downto 0));
|
| 2837 |
|
|
end entity;
|
| 2838 |
|
|
|
| 2839 |
|
|
|
| 2840 |
|
|
-------------------------------------------------------------------------------
|
| 2841 |
|
|
--
|
| 2842 |
|
|
-------------------------------------------------------------------------------
|
| 2843 |
|
|
architecture Crc5Impl of Crc5ITU is
|
| 2844 |
|
|
signal d : std_logic_vector(0 to 18);
|
| 2845 |
|
|
signal c : std_logic_vector(0 to 4);
|
| 2846 |
|
|
|
| 2847 |
|
|
begin
|
| 2848 |
|
|
-- Reverse the bit vector indexes to make them the same as in the standard.
|
| 2849 |
|
|
d(18) <= d_i(0); d(17) <= d_i(1); d(16) <= d_i(2); d(15) <= d_i(3);
|
| 2850 |
|
|
d(14) <= d_i(4); d(13) <= d_i(5); d(12) <= d_i(6); d(11) <= d_i(7);
|
| 2851 |
|
|
d(10) <= d_i(8); d(9) <= d_i(9); d(8) <= d_i(10); d(7) <= d_i(11);
|
| 2852 |
|
|
d(6) <= d_i(12); d(5) <= d_i(13); d(4) <= d_i(14); d(3) <= d_i(15);
|
| 2853 |
|
|
d(2) <= d_i(16); d(1) <= d_i(17); d(0) <= d_i(18);
|
| 2854 |
|
|
|
| 2855 |
|
|
-- Calculate the resulting crc.
|
| 2856 |
|
|
c(0) <= d(18) xor d(16) xor d(15) xor d(12) xor
|
| 2857 |
|
|
d(10) xor d(5) xor d(4) xor d(3) xor
|
| 2858 |
|
|
d(1) xor d(0);
|
| 2859 |
|
|
c(1) <= (not d(18)) xor d(17) xor d(15) xor d(13) xor
|
| 2860 |
|
|
d(12) xor d(11) xor d(10) xor d(6) xor
|
| 2861 |
|
|
d(3) xor d(2) xor d(0);
|
| 2862 |
|
|
c(2) <= (not d(18)) xor d(16) xor d(14) xor d(13) xor
|
| 2863 |
|
|
d(12) xor d(11) xor d(7) xor d(4) xor
|
| 2864 |
|
|
d(3) xor d(1);
|
| 2865 |
|
|
c(3) <= (not d(18)) xor d(17) xor d(16) xor d(14) xor
|
| 2866 |
|
|
d(13) xor d(10) xor d(8) xor d(3) xor
|
| 2867 |
|
|
d(2) xor d(1);
|
| 2868 |
|
|
c(4) <= d(18) xor d(17) xor d(15) xor d(14) xor
|
| 2869 |
|
|
d(11) xor d(9) xor d(4) xor d(3) xor
|
| 2870 |
|
|
d(2) xor d(0);
|
| 2871 |
|
|
|
| 2872 |
|
|
-- Reverse the bit vector indexes to make them the same as in the standard.
|
| 2873 |
|
|
crc_o(4) <= c(0); crc_o(3) <= c(1); crc_o(2) <= c(2); crc_o(1) <= c(3);
|
| 2874 |
|
|
crc_o(0) <= c(4);
|
| 2875 |
|
|
end architecture;
|
| 2876 |
11 |
magro732 |
|
| 2877 |
|
|
|
| 2878 |
|
|
-------------------------------------------------------------------------------
|
| 2879 |
|
|
--
|
| 2880 |
|
|
-------------------------------------------------------------------------------
|
| 2881 |
|
|
library ieee;
|
| 2882 |
|
|
use ieee.std_logic_1164.all;
|
| 2883 |
|
|
use ieee.numeric_std.all;
|
| 2884 |
|
|
use work.rio_common.all;
|
| 2885 |
|
|
|
| 2886 |
|
|
-------------------------------------------------------------------------------
|
| 2887 |
|
|
--
|
| 2888 |
|
|
-------------------------------------------------------------------------------
|
| 2889 |
|
|
entity Crc16Calculator is
|
| 2890 |
|
|
|
| 2891 |
|
|
generic (
|
| 2892 |
|
|
NUMBER_WORDS : natural range 1 to 8 := 1);
|
| 2893 |
|
|
|
| 2894 |
|
|
port (
|
| 2895 |
|
|
clk : in std_logic;
|
| 2896 |
|
|
areset_n : in std_logic;
|
| 2897 |
|
|
|
| 2898 |
|
|
write_i : in std_logic;
|
| 2899 |
|
|
crc_i : in std_logic_vector(15 downto 0);
|
| 2900 |
|
|
data_i : in std_logic_vector((32*NUMBER_WORDS)-1 downto 0);
|
| 2901 |
|
|
|
| 2902 |
|
|
crc_o : out std_logic_vector(15 downto 0);
|
| 2903 |
|
|
done_o : out std_logic);
|
| 2904 |
|
|
|
| 2905 |
|
|
end Crc16Calculator;
|
| 2906 |
|
|
|
| 2907 |
|
|
-------------------------------------------------------------------------------
|
| 2908 |
|
|
--
|
| 2909 |
|
|
-------------------------------------------------------------------------------
|
| 2910 |
|
|
architecture Crc16CalculatorImpl of Crc16Calculator is
|
| 2911 |
|
|
|
| 2912 |
|
|
component Crc16CITT is
|
| 2913 |
|
|
port(
|
| 2914 |
|
|
d_i : in std_logic_vector(15 downto 0);
|
| 2915 |
|
|
crc_i : in std_logic_vector(15 downto 0);
|
| 2916 |
|
|
crc_o : out std_logic_vector(15 downto 0));
|
| 2917 |
|
|
end component;
|
| 2918 |
|
|
|
| 2919 |
|
|
signal iterator : natural range 0 to 2*NUMBER_WORDS;
|
| 2920 |
|
|
signal crcData : std_logic_vector((32*NUMBER_WORDS)-1 downto 0);
|
| 2921 |
|
|
signal crcCurrent : std_logic_vector(15 downto 0);
|
| 2922 |
|
|
signal crcNext : std_logic_vector(15 downto 0);
|
| 2923 |
|
|
|
| 2924 |
|
|
begin
|
| 2925 |
|
|
|
| 2926 |
|
|
process(areset_n, clk)
|
| 2927 |
|
|
begin
|
| 2928 |
|
|
if (areset_n = '0') then
|
| 2929 |
|
|
iterator <= 0;
|
| 2930 |
|
|
done_o <= '0';
|
| 2931 |
|
|
crc_o <= (others => '0');
|
| 2932 |
|
|
elsif (clk'event and clk = '1') then
|
| 2933 |
|
|
if (write_i = '1') then
|
| 2934 |
|
|
iterator <= 2*NUMBER_WORDS-1;
|
| 2935 |
|
|
crcData <= data_i;
|
| 2936 |
|
|
crcCurrent <= crc_i;
|
| 2937 |
|
|
done_o <= '0';
|
| 2938 |
|
|
else
|
| 2939 |
|
|
if (iterator /= 0) then
|
| 2940 |
|
|
iterator <= iterator - 1;
|
| 2941 |
|
|
crcData <= crcData(((32*NUMBER_WORDS)-1)-16 downto 0) & x"0000";
|
| 2942 |
|
|
crcCurrent <= crcNext;
|
| 2943 |
|
|
else
|
| 2944 |
|
|
crc_o <= crcNext;
|
| 2945 |
|
|
done_o <= '1';
|
| 2946 |
|
|
end if;
|
| 2947 |
|
|
end if;
|
| 2948 |
|
|
end if;
|
| 2949 |
|
|
end process;
|
| 2950 |
|
|
|
| 2951 |
|
|
Crc16Inst: Crc16CITT
|
| 2952 |
|
|
port map(
|
| 2953 |
|
|
d_i=>crcData((32*NUMBER_WORDS)-1 downto (32*NUMBER_WORDS)-16),
|
| 2954 |
|
|
crc_i=>crcCurrent, crc_o=>crcNext);
|
| 2955 |
|
|
|
| 2956 |
|
|
end architecture;
|
| 2957 |
|
|
|