Line 175... |
Line 175... |
-- symbols can be accepted.
|
-- symbols can be accepted.
|
-- inboundSymbolWrite_i - Indicate that inboundSymbol_i contains valid
|
-- inboundSymbolWrite_i - Indicate that inboundSymbol_i contains valid
|
-- information that should be forwarded. Should be active for one tick.
|
-- information that should be forwarded. Should be active for one tick.
|
-- inboundSymbol_i - The inbound symbol. See outboundSymbol_o for formating.
|
-- inboundSymbol_i - The inbound symbol. See outboundSymbol_o for formating.
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
|
-- REMARK: Multi-symbol support is not fully supported yet...
|
|
-- REMARK: Optimize the piggy-backing of symbols from the receiver, use the
|
|
-- number of words that remain to determine when to insert a control-symbol
|
|
-- into a stream of data-symbols...
|
|
-- REMARK: Optimize the transmitter better, too low performance...
|
|
|
library ieee;
|
library ieee;
|
use ieee.std_logic_1164.all;
|
use ieee.std_logic_1164.all;
|
use ieee.numeric_std.all;
|
use ieee.numeric_std.all;
|
use work.rio_common.all;
|
use work.rio_common.all;
|
|
|
Line 231... |
Line 237... |
writeContent_o : out std_logic;
|
writeContent_o : out std_logic;
|
writeContentData_o : out std_logic_vector(2+(32*NUMBER_WORDS-1) downto 0);
|
writeContentData_o : out std_logic_vector(2+(32*NUMBER_WORDS-1) downto 0);
|
|
|
-- PCS layer signals.
|
-- PCS layer signals.
|
portInitialized_i : in std_logic;
|
portInitialized_i : in std_logic;
|
outboundSymbolEmpty_o : out std_logic;
|
outboundSymbolFull_i : in std_logic;
|
outboundSymbolRead_i : in std_logic;
|
outboundSymbolWrite_o : out std_logic;
|
outboundSymbol_o : out std_logic_vector(((2+32)*NUMBER_WORDS-1) downto 0);
|
outboundSymbol_o : out std_logic_vector(((2+32)*NUMBER_WORDS-1) downto 0);
|
inboundSymbolFull_o : out std_logic;
|
inboundSymbolEmpty_i : in std_logic;
|
inboundSymbolWrite_i : in std_logic;
|
inboundSymbolRead_o : out std_logic;
|
inboundSymbol_i : in std_logic_vector(((2+32)*NUMBER_WORDS-1) downto 0));
|
inboundSymbol_i : in std_logic_vector(((2+32)*NUMBER_WORDS-1) downto 0));
|
end entity;
|
end entity;
|
|
|
|
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- Architecture for RioSerial.
|
-- Architecture for RioSerial.
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
architecture RioSerialImpl of RioSerial is
|
architecture RioSerialImpl of RioSerial is
|
|
|
component RioFifo1 is
|
component RioFifo is
|
generic(
|
generic(
|
WIDTH : natural);
|
DEPTH_WIDTH : natural;
|
|
DATA_WIDTH : natural);
|
port(
|
port(
|
clk : in std_logic;
|
clk : in std_logic;
|
areset_n : in std_logic;
|
areset_n : in std_logic;
|
|
|
empty_o : out std_logic;
|
empty_o : out std_logic;
|
read_i : in std_logic;
|
read_i : in std_logic;
|
data_o : out std_logic_vector(WIDTH-1 downto 0);
|
data_o : out std_logic_vector(DATA_WIDTH-1 downto 0);
|
|
|
full_o : out std_logic;
|
full_o : out std_logic;
|
write_i : in std_logic;
|
write_i : in std_logic;
|
data_i : in std_logic_vector(WIDTH-1 downto 0));
|
data_i : in std_logic_vector(DATA_WIDTH-1 downto 0));
|
end component;
|
end component;
|
|
|
component RioTransmitter is
|
component RioTransmitter is
|
generic(
|
generic(
|
TIMEOUT_WIDTH : natural;
|
TIMEOUT_WIDTH : natural;
|
Line 282... |
Line 289... |
outboundAckId_o : out std_logic_vector(4 downto 0);
|
outboundAckId_o : out std_logic_vector(4 downto 0);
|
|
|
portInitialized_i : in std_logic;
|
portInitialized_i : in std_logic;
|
txFull_i : in std_logic;
|
txFull_i : in std_logic;
|
txWrite_o : out std_logic;
|
txWrite_o : out std_logic;
|
txType_o : out std_logic_vector(1 downto 0);
|
txType_o : out std_logic_vector(2*NUMBER_WORDS-1 downto 0);
|
txData_o : out std_logic_vector(31 downto 0);
|
txData_o : out std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
|
|
txControlEmpty_i : in std_logic;
|
txControlEmpty_i : in std_logic_vector(NUMBER_WORDS-1 downto 0);
|
txControlSymbol_i : in std_logic_vector(12 downto 0);
|
txControlSymbol_i : in std_logic_vector(12*NUMBER_WORDS downto 0);
|
txControlUpdate_o : out std_logic;
|
txControlUpdate_o : out std_logic_vector(NUMBER_WORDS-1 downto 0);
|
rxControlEmpty_i : in std_logic;
|
rxControlEmpty_i : in std_logic_vector(NUMBER_WORDS-1 downto 0);
|
rxControlSymbol_i : in std_logic_vector(12 downto 0);
|
rxControlSymbol_i : in std_logic_vector(12*NUMBER_WORDS downto 0);
|
rxControlUpdate_o : out std_logic;
|
rxControlUpdate_o : out std_logic_vector(NUMBER_WORDS-1 downto 0);
|
|
|
linkInitialized_i : in std_logic;
|
linkInitialized_i : in std_logic;
|
linkInitialized_o : out std_logic;
|
linkInitialized_o : out std_logic;
|
ackIdStatus_i : in std_logic_vector(4 downto 0);
|
ackIdStatus_i : in std_logic_vector(4 downto 0);
|
|
|
Line 361... |
Line 368... |
signal rxControlWriteSymbol : std_logic_vector(12*NUMBER_WORDS downto 0);
|
signal rxControlWriteSymbol : std_logic_vector(12*NUMBER_WORDS downto 0);
|
signal rxControlReadEmpty : std_logic_vector(NUMBER_WORDS-1 downto 0);
|
signal rxControlReadEmpty : std_logic_vector(NUMBER_WORDS-1 downto 0);
|
signal rxControlRead : std_logic_vector(NUMBER_WORDS-1 downto 0);
|
signal rxControlRead : std_logic_vector(NUMBER_WORDS-1 downto 0);
|
signal rxControlReadSymbol : std_logic_vector(12*NUMBER_WORDS downto 0);
|
signal rxControlReadSymbol : std_logic_vector(12*NUMBER_WORDS downto 0);
|
|
|
signal outboundFull : std_logic;
|
|
signal outboundWrite : std_logic;
|
|
signal outboundType : std_logic_vector(1 downto 0);
|
signal outboundType : std_logic_vector(1 downto 0);
|
signal outboundData : std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
signal outboundData : std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
signal outboundSymbol : std_logic_vector(2+(32*NUMBER_WORDS-1) downto 0);
|
|
|
|
signal inboundEmpty : std_logic;
|
|
signal inboundRead : std_logic;
|
|
signal inboundType : std_logic_vector(1 downto 0);
|
signal inboundType : std_logic_vector(1 downto 0);
|
signal inboundData : std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
signal inboundData : std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
signal inboundSymbol : std_logic_vector(((2+32)*NUMBER_WORDS-1) downto 0);
|
|
|
|
begin
|
begin
|
|
|
linkInitialized_o <=
|
linkInitialized_o <=
|
'1' when ((linkInitializedRx = '1') and (linkInitializedTx = '1')) else '0';
|
'1' when ((linkInitializedRx = '1') and (linkInitializedTx = '1')) else '0';
|
|
|
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
-- Serial layer modules.
|
-- Serial layer modules.
|
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
|
|
|
outboundSymbol_o <= outboundType & outboundData;
|
Transmitter: RioTransmitter
|
Transmitter: RioTransmitter
|
generic map(
|
generic map(
|
TIMEOUT_WIDTH=>TIMEOUT_WIDTH,
|
TIMEOUT_WIDTH=>TIMEOUT_WIDTH,
|
NUMBER_WORDS=>NUMBER_WORDS)
|
NUMBER_WORDS=>NUMBER_WORDS)
|
port map(
|
port map(
|
Line 397... |
Line 399... |
outstandingAckId_i=>outstandingAckId_i,
|
outstandingAckId_i=>outstandingAckId_i,
|
outboundAckId_i=>outboundAckId_i,
|
outboundAckId_i=>outboundAckId_i,
|
outstandingAckId_o=>outstandingAckId_o,
|
outstandingAckId_o=>outstandingAckId_o,
|
outboundAckId_o=>outboundAckId_o,
|
outboundAckId_o=>outboundAckId_o,
|
portInitialized_i=>portInitialized_i,
|
portInitialized_i=>portInitialized_i,
|
txFull_i=>outboundFull, txWrite_o=>outboundWrite,
|
txFull_i=>outboundSymbolFull_i,
|
txType_o=>outboundType, txData_o=>outboundData,
|
txWrite_o=>outboundsymbolWrite_o,
|
txControlEmpty_i=>txControlReadEmpty(0), txControlSymbol_i=>txControlReadSymbol,
|
txType_o=>outboundType,
|
txControlUpdate_o=>txControlRead(0),
|
txData_o=>outboundData,
|
rxControlEmpty_i=>rxControlReadEmpty(0), rxControlSymbol_i=>rxControlReadSymbol,
|
txControlEmpty_i=>txControlReadEmpty,
|
rxControlUpdate_o=>rxControlRead(0),
|
txControlSymbol_i=>txControlReadSymbol,
|
|
txControlUpdate_o=>txControlRead,
|
|
rxControlEmpty_i=>rxControlReadEmpty,
|
|
rxControlSymbol_i=>rxControlReadSymbol,
|
|
rxControlUpdate_o=>rxControlRead,
|
linkInitialized_o=>linkInitializedTx,
|
linkInitialized_o=>linkInitializedTx,
|
linkInitialized_i=>linkInitializedRx, ackIdStatus_i=>ackIdStatus,
|
linkInitialized_i=>linkInitializedRx,
|
readFrameEmpty_i=>readFrameEmpty_i, readFrame_o=>readFrame_o,
|
ackIdStatus_i=>ackIdStatus,
|
readFrameRestart_o=>readFrameRestart_o, readFrameAborted_i=>readFrameAborted_i,
|
readFrameEmpty_i=>readFrameEmpty_i,
|
|
readFrame_o=>readFrame_o,
|
|
readFrameRestart_o=>readFrameRestart_o,
|
|
readFrameAborted_i=>readFrameAborted_i,
|
readWindowEmpty_i=>readWindowEmpty_i,
|
readWindowEmpty_i=>readWindowEmpty_i,
|
readWindowReset_o=>readWindowReset_o, readWindowNext_o=>readWindowNext_o,
|
readWindowReset_o=>readWindowReset_o,
|
readContentEmpty_i=>readContentEmpty_i, readContent_o=>readContent_o,
|
readWindowNext_o=>readWindowNext_o,
|
|
readContentEmpty_i=>readContentEmpty_i,
|
|
readContent_o=>readContent_o,
|
readContentEnd_i=>readContentEnd_i,
|
readContentEnd_i=>readContentEnd_i,
|
readContentWords_i=>readContentData_i(2+(32*NUMBER_WORDS-1) downto 1+(32*NUMBER_WORDS-1)),
|
readContentWords_i=>readContentData_i(2+(32*NUMBER_WORDS-1) downto 1+(32*NUMBER_WORDS-1)),
|
readContentData_i=>readContentData_i(32*NUMBER_WORDS-1 downto 0));
|
readContentData_i=>readContentData_i(32*NUMBER_WORDS-1 downto 0));
|
|
|
SymbolFifo: for i in 0 to NUMBER_WORDS-1 generate
|
SymbolFifo: for i in 0 to NUMBER_WORDS-1 generate
|
TxSymbolFifo: RioFifo1
|
TxSymbolFifo: RioFifo
|
generic map(WIDTH=>13)
|
generic map(DEPTH_WIDTH=>5, DATA_WIDTH=>13)
|
port map(
|
port map(
|
clk=>clk, areset_n=>areset_n,
|
clk=>clk, areset_n=>areset_n,
|
empty_o=>txControlReadEmpty(i),
|
empty_o=>txControlReadEmpty(i),
|
read_i=>txControlRead(i),
|
read_i=>txControlRead(i),
|
data_o=>txControlReadSymbol(12*(i+1) downto 12*i),
|
data_o=>txControlReadSymbol(12*(i+1) downto 12*i),
|
full_o=>open,
|
full_o=>open,
|
write_i=>txControlWrite(i),
|
write_i=>txControlWrite(i),
|
data_i=>txControlWriteSymbol(12*(i+1) downto 12*i));
|
data_i=>txControlWriteSymbol(12*(i+1) downto 12*i));
|
|
|
RxSymbolFifo: RioFifo1
|
RxSymbolFifo: RioFifo
|
generic map(WIDTH=>13)
|
generic map(DEPTH_WIDTH=>5, DATA_WIDTH=>13)
|
port map(
|
port map(
|
clk=>clk, areset_n=>areset_n,
|
clk=>clk, areset_n=>areset_n,
|
empty_o=>rxControlReadEmpty(i),
|
empty_o=>rxControlReadEmpty(i),
|
read_i=>rxControlRead(i),
|
read_i=>rxControlRead(i),
|
data_o=>rxControlReadSymbol(12*(i+1) downto 12*i),
|
data_o=>rxControlReadSymbol(12*(i+1) downto 12*i),
|
full_o=>open,
|
full_o=>open,
|
write_i=>rxControlWrite(i),
|
write_i=>rxControlWrite(i),
|
data_i=>rxControlWriteSymbol(12*(i+1) downto 12*i));
|
data_i=>rxControlWriteSymbol(12*(i+1) downto 12*i));
|
end generate;
|
end generate;
|
|
|
|
inboundType <= inboundSymbol_i(2+(32*NUMBER_WORDS-1) downto 1+(32*NUMBER_WORDS-1));
|
|
inboundData <= inboundSymbol_i(32*NUMBER_WORDS-1 downto 0);
|
Receiver: RioReceiver
|
Receiver: RioReceiver
|
generic map(NUMBER_WORDS=>NUMBER_WORDS)
|
generic map(NUMBER_WORDS=>NUMBER_WORDS)
|
port map(
|
port map(
|
clk=>clk, areset_n=>areset_n,
|
clk=>clk, areset_n=>areset_n,
|
portEnable_i=>inputPortEnable_i,
|
portEnable_i=>inputPortEnable_i,
|
localAckIdWrite_i=>localAckIdWrite_i,
|
localAckIdWrite_i=>localAckIdWrite_i,
|
inboundAckId_i=>inboundAckId_i,
|
inboundAckId_i=>inboundAckId_i,
|
inboundAckId_o=>inboundAckId_o,
|
inboundAckId_o=>inboundAckId_o,
|
portInitialized_i=>portInitialized_i,
|
portInitialized_i=>portInitialized_i,
|
rxEmpty_i=>inboundEmpty, rxRead_o=>inboundRead,
|
rxEmpty_i=>inboundSymbolEmpty_i,
|
rxType_i=>inboundType, rxData_i=>inboundData,
|
rxRead_o=>inboundSymbolRead_o,
|
txControlWrite_o=>txControlWrite, txControlSymbol_o=>txControlWriteSymbol,
|
rxType_i=>inboundType,
|
rxControlWrite_o=>rxControlWrite, rxControlSymbol_o=>rxControlWriteSymbol,
|
rxData_i=>inboundData,
|
|
txControlWrite_o=>txControlWrite,
|
|
txControlSymbol_o=>txControlWriteSymbol,
|
|
rxControlWrite_o=>rxControlWrite,
|
|
rxControlSymbol_o=>rxControlWriteSymbol,
|
ackIdStatus_o=>ackIdStatus,
|
ackIdStatus_o=>ackIdStatus,
|
linkInitialized_o=>linkInitializedRx,
|
linkInitialized_o=>linkInitializedRx,
|
writeFrameFull_i=>writeFrameFull_i,
|
writeFrameFull_i=>writeFrameFull_i,
|
writeFrame_o=>writeFrame_o, writeFrameAbort_o=>writeFrameAbort_o,
|
writeFrame_o=>writeFrame_o,
|
|
writeFrameAbort_o=>writeFrameAbort_o,
|
writeContent_o=>writeContent_o,
|
writeContent_o=>writeContent_o,
|
writeContentWords_o=>writeContentData_o(2+(32*NUMBER_WORDS-1) downto 1+(32*NUMBER_WORDS-1)),
|
writeContentWords_o=>writeContentData_o(2+(32*NUMBER_WORDS-1) downto 1+(32*NUMBER_WORDS-1)),
|
writeContentData_o=>writeContentData_o(32*NUMBER_WORDS-1 downto 0));
|
writeContentData_o=>writeContentData_o(32*NUMBER_WORDS-1 downto 0));
|
|
|
-----------------------------------------------------------------------------
|
|
-- PCS layer FIFO interface.
|
|
-----------------------------------------------------------------------------
|
|
|
|
outboundSymbol <= outboundType & outboundData;
|
|
OutboundSymbolFifo: RioFifo1
|
|
generic map(WIDTH=>2+32*NUMBER_WORDS)
|
|
port map(
|
|
clk=>clk, areset_n=>areset_n,
|
|
empty_o=>outboundSymbolEmpty_o, read_i=>outboundSymbolRead_i, data_o=>outboundSymbol_o,
|
|
full_o=>outboundFull, write_i=>outboundWrite, data_i=>outboundSymbol);
|
|
|
|
inboundType <= inboundSymbol(2+(32*NUMBER_WORDS-1) downto 1+(32*NUMBER_WORDS-1));
|
|
inboundData <= inboundSymbol(32*NUMBER_WORDS-1 downto 0);
|
|
InboundSymbolFifo: RioFifo1
|
|
generic map(WIDTH=>2+32*NUMBER_WORDS)
|
|
port map(
|
|
clk=>clk, areset_n=>areset_n,
|
|
empty_o=>inboundEmpty, read_i=>inboundRead, data_o=>inboundSymbol,
|
|
full_o=>inboundSymbolFull_o, write_i=>inboundSymbolWrite_i, data_i=>inboundSymbol_i);
|
|
|
|
end architecture;
|
end architecture;
|
|
|
|
|
|
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
Line 525... |
Line 522... |
txWrite_o : out std_logic;
|
txWrite_o : out std_logic;
|
txType_o : out std_logic_vector(2*NUMBER_WORDS-1 downto 0);
|
txType_o : out std_logic_vector(2*NUMBER_WORDS-1 downto 0);
|
txData_o : out std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
txData_o : out std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
|
|
-- Control symbols aimed to the transmitter.
|
-- Control symbols aimed to the transmitter.
|
txControlEmpty_i : in std_logic;
|
txControlEmpty_i : in std_logic_vector(NUMBER_WORDS-1 downto 0);
|
txControlSymbol_i : in std_logic_vector(12 downto 0);
|
txControlSymbol_i : in std_logic_vector(12*NUMBER_WORDS downto 0);
|
txControlUpdate_o : out std_logic;
|
txControlUpdate_o : out std_logic_vector(NUMBER_WORDS-1 downto 0);
|
|
|
-- Control symbols from the receiver to send.
|
-- Control symbols from the receiver to send.
|
rxControlEmpty_i : in std_logic;
|
rxControlEmpty_i : in std_logic_vector(NUMBER_WORDS-1 downto 0);
|
rxControlSymbol_i : in std_logic_vector(12 downto 0);
|
rxControlSymbol_i : in std_logic_vector(12*NUMBER_WORDS downto 0);
|
rxControlUpdate_o : out std_logic;
|
rxControlUpdate_o : out std_logic_vector(NUMBER_WORDS-1 downto 0);
|
|
|
-- Internal signalling from the receiver part.
|
-- Internal signalling from the receiver part.
|
linkInitialized_o : out std_logic;
|
linkInitialized_o : out std_logic;
|
linkInitialized_i : in std_logic;
|
linkInitialized_i : in std_logic;
|
ackIdStatus_i : in std_logic_vector(4 downto 0);
|
ackIdStatus_i : in std_logic_vector(4 downto 0);
|
Line 620... |
Line 617... |
recoverActive_o : out std_logic;
|
recoverActive_o : out std_logic;
|
recoverCounter_i : in std_logic_vector(4 downto 0);
|
recoverCounter_i : in std_logic_vector(4 downto 0);
|
recoverCounter_o : out std_logic_vector(4 downto 0);
|
recoverCounter_o : out std_logic_vector(4 downto 0);
|
ackIdWindow_i : in std_logic_vector(4 downto 0);
|
ackIdWindow_i : in std_logic_vector(4 downto 0);
|
ackIdWindow_o : out std_logic_vector(4 downto 0);
|
ackIdWindow_o : out std_logic_vector(4 downto 0);
|
frameState_i : in std_logic_vector(6 downto 0);
|
frameState_i : in std_logic_vector(3 downto 0);
|
frameState_o : out std_logic_vector(6 downto 0);
|
frameState_o : out std_logic_vector(3 downto 0);
|
frameWordCounter_i : in std_logic_vector(1 downto 0);
|
frameWordCounter_i : in std_logic_vector(1 downto 0);
|
frameWordCounter_o : out std_logic_vector(1 downto 0);
|
frameWordCounter_o : out std_logic_vector(1 downto 0);
|
frameContent_i : in std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
frameContent_i : in std_logic_vector(63 downto 0);
|
frameContent_o : out std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
frameContent_o : out std_logic_vector(63 downto 0);
|
counter_i : in std_logic_vector(3 downto 0);
|
counter_i : in std_logic_vector(3 downto 0);
|
counter_o : out std_logic_vector(3 downto 0);
|
counter_o : out std_logic_vector(3 downto 0);
|
symbolsTransmitted_i : in std_logic_vector(7 downto 0);
|
symbolsTransmitted_i : in std_logic_vector(7 downto 0);
|
symbolsTransmitted_o : out std_logic_vector(7 downto 0);
|
symbolsTransmitted_o : out std_logic_vector(7 downto 0);
|
|
maintenanceClass_i : in std_logic;
|
|
maintenanceClass_o : out std_logic;
|
|
|
-- Frame buffer interface.
|
-- Frame buffer interface.
|
readFrameEmpty_i : in std_logic;
|
readFrameEmpty_i : in std_logic;
|
readFrame_o : out std_logic;
|
readFrame_o : out std_logic;
|
readFrameRestart_o : out std_logic;
|
readFrameRestart_o : out std_logic;
|
Line 673... |
Line 672... |
signal timeSentEnable : std_logic;
|
signal timeSentEnable : std_logic;
|
signal timeSentWriteAddress : std_logic_vector(4 downto 0);
|
signal timeSentWriteAddress : std_logic_vector(4 downto 0);
|
signal timeSentReadAddress : std_logic_vector(4 downto 0);
|
signal timeSentReadAddress : std_logic_vector(4 downto 0);
|
signal timeSentReadData : std_logic_vector(TIMEOUT_WIDTH downto 0);
|
signal timeSentReadData : std_logic_vector(TIMEOUT_WIDTH downto 0);
|
|
|
signal operationalCurrent, operationalNext : std_logic;
|
signal operationalCurrent, operationalNext : std_logic_vector(NUMBER_WORDS-1 downto 0);
|
signal ackIdCurrent, ackIdNext : std_logic_vector(4 downto 0);
|
signal ackIdCurrent, ackIdNext : std_logic_vector(5*NUMBER_WORDS-1 downto 0);
|
signal bufferStatusCurrent, bufferStatusNext : std_logic_vector(4 downto 0);
|
signal bufferStatusCurrent, bufferStatusNext : std_logic_vector(5*NUMBER_WORDS-1 downto 0);
|
signal statusReceivedCurrent, statusReceivedNext : std_logic;
|
signal statusReceivedCurrent, statusReceivedNext : std_logic_vector(NUMBER_WORDS-1 downto 0);
|
signal numberSentLinkRequestsCurrent, numberSentLinkRequestsNext : std_logic_vector(1 downto 0);
|
signal numberSentLinkRequestsCurrent, numberSentLinkRequestsNext : std_logic_vector(2*NUMBER_WORDS-1 downto 0);
|
signal outputErrorStoppedCurrent, outputErrorStoppedNext : std_logic;
|
signal outputErrorStoppedCurrent, outputErrorStoppedNext : std_logic_vector(NUMBER_WORDS-1 downto 0);
|
signal fatalErrorCurrent, fatalErrorNext : std_logic;
|
signal fatalErrorCurrent, fatalErrorNext : std_logic_vector(NUMBER_WORDS-1 downto 0);
|
signal recoverActiveCurrent, recoverActiveNext : std_logic;
|
signal recoverActiveCurrent, recoverActiveNext : std_logic_vector(NUMBER_WORDS-1 downto 0);
|
signal recoverCounterCurrent, recoverCounterNext : std_logic_vector(4 downto 0);
|
signal recoverCounterCurrent, recoverCounterNext : std_logic_vector(5*NUMBER_WORDS-1 downto 0);
|
signal ackIdWindowCurrent, ackIdWindowNext : std_logic_vector(4 downto 0);
|
signal ackIdWindowCurrent, ackIdWindowNext : std_logic_vector(5*NUMBER_WORDS-1 downto 0);
|
signal frameStateCurrent, frameStateNext : std_logic_vector(6 downto 0);
|
signal frameStateCurrent, frameStateNext : std_logic_vector(4*NUMBER_WORDS-1 downto 0);
|
signal frameWordCounterCurrent, frameWordCounterNext : std_logic_vector(1 downto 0);
|
signal frameWordCounterCurrent, frameWordCounterNext : std_logic_vector(2*NUMBER_WORDS-1 downto 0);
|
signal frameContentCurrent, frameContentNext : std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
signal frameContentCurrent, frameContentNext : std_logic_vector(64*NUMBER_WORDS-1 downto 0);
|
signal counterCurrent, counterNext : std_logic_vector(3 downto 0);
|
signal counterCurrent, counterNext : std_logic_vector(4*NUMBER_WORDS-1 downto 0);
|
signal symbolsTransmittedCurrent, symbolsTransmittedNext : std_logic_vector(7 downto 0);
|
signal symbolsTransmittedCurrent, symbolsTransmittedNext : std_logic_vector(8*NUMBER_WORDS-1 downto 0);
|
|
signal maintenanceClassCurrent, maintenanceClassNext : std_logic_vector(NUMBER_WORDS-1 downto 0);
|
|
|
|
signal readFrame : std_logic_vector(NUMBER_WORDS-1 downto 0);
|
|
signal readFrameRestart : std_logic_vector(NUMBER_WORDS-1 downto 0);
|
|
signal readWindowReset : std_logic_vector(NUMBER_WORDS-1 downto 0);
|
|
signal readWindowNext : std_logic_vector(NUMBER_WORDS-1 downto 0);
|
|
signal readContent : std_logic_vector(NUMBER_WORDS-1 downto 0);
|
|
begin
|
|
|
|
-----------------------------------------------------------------------------
|
|
-- Output generation to packet buffer.
|
|
-----------------------------------------------------------------------------
|
|
process(readFrame, readFrameRestart,
|
|
readWindowReset, readWindowNext, readContent)
|
begin
|
begin
|
|
readFrame_o <= '0';
|
|
readFrameRestart_o <= '0';
|
|
readWindowReset_o <= '0';
|
|
readWindowNext_o <= '0';
|
|
readContent_o <= '0';
|
|
for i in 0 to NUMBER_WORDS-1 loop
|
|
if (readFrame(i) = '1') then
|
|
readFrame_o <= '1';
|
|
end if;
|
|
|
|
if (readFrameRestart(i) = '1') then
|
|
readFrameRestart_o <= '1';
|
|
end if;
|
|
|
|
if (readWindowReset(i) = '1') then
|
|
readWindowReset_o <= '1';
|
|
end if;
|
|
|
|
if (readWindowNext(i) = '1') then
|
|
readWindowNext_o <= '1';
|
|
end if;
|
|
|
|
if (readContent(i) = '1') then
|
|
readContent_o <= '1';
|
|
end if;
|
|
end loop;
|
|
end process;
|
|
|
|
-----------------------------------------------------------------------------
|
|
-- Timeout logic.
|
|
-----------------------------------------------------------------------------
|
process(areset_n, clk)
|
process(areset_n, clk)
|
begin
|
begin
|
if (areset_n = '0') then
|
if (areset_n = '0') then
|
timeCurrent <= (others=>'0');
|
timeCurrent <= (others=>'0');
|
elsif (clk'event and clk = '1') then
|
elsif (clk'event and clk = '1') then
|
Line 716... |
Line 758... |
port map(
|
port map(
|
clkA_i=>clk, enableA_i=>timeSentEnable,
|
clkA_i=>clk, enableA_i=>timeSentEnable,
|
addressA_i=>timeSentWriteAddress, dataA_i=>timeCurrent,
|
addressA_i=>timeSentWriteAddress, dataA_i=>timeCurrent,
|
addressB_i=>timeSentReadAddress, dataB_o=>timeSentReadData);
|
addressB_i=>timeSentReadAddress, dataB_o=>timeSentReadData);
|
|
|
|
-----------------------------------------------------------------------------
|
|
-- Protocol core and synchronization.
|
|
-----------------------------------------------------------------------------
|
process(areset_n, clk)
|
process(areset_n, clk)
|
begin
|
begin
|
if (areset_n = '0') then
|
if (areset_n = '0') then
|
operationalCurrent <= '0';
|
operationalCurrent <= (others=>'0');
|
ackIdCurrent <= (others=>'0');
|
ackIdCurrent <= (others=>'0');
|
bufferStatusCurrent <= (others=>'0');
|
bufferStatusCurrent <= (others=>'0');
|
statusReceivedCurrent <= '0';
|
statusReceivedCurrent <= (others=>'0');
|
numberSentLinkRequestsCurrent <= (others=>'0');
|
numberSentLinkRequestsCurrent <= (others=>'0');
|
outputErrorStoppedCurrent <= '0';
|
outputErrorStoppedCurrent <= (others=>'0');
|
fatalErrorCurrent <= '0';
|
fatalErrorCurrent <= (others=>'0');
|
recoverActiveCurrent <= '0';
|
recoverActiveCurrent <= (others=>'0');
|
recoverCounterCurrent <= (others=>'0');
|
recoverCounterCurrent <= (others=>'0');
|
ackIdWindowCurrent <= (others=>'0');
|
ackIdWindowCurrent <= (others=>'0');
|
frameStateCurrent <= (others=>'0');
|
frameStateCurrent <= (others=>'0');
|
frameWordCounterCurrent <= (others=>'0');
|
frameWordCounterCurrent <= (others=>'0');
|
frameContentCurrent <= (others=>'0');
|
frameContentCurrent <= (others=>'0');
|
counterCurrent <= (others=>'0');
|
counterCurrent <= (others=>'0');
|
symbolsTransmittedCurrent <= (others=>'0');
|
symbolsTransmittedCurrent <= (others=>'0');
|
|
maintenanceClassCurrent <= (others=>'0');
|
elsif (clk'event and clk = '1') then
|
elsif (clk'event and clk = '1') then
|
if (txFull_i = '0') then
|
if (txFull_i = '0') then
|
operationalCurrent <= operationalNext;
|
operationalCurrent <= operationalNext;
|
ackIdCurrent <= ackIdNext;
|
ackIdCurrent <= ackIdNext;
|
bufferStatusCurrent <= bufferStatusNext;
|
bufferStatusCurrent <= bufferStatusNext;
|
Line 751... |
Line 797... |
frameStateCurrent <= frameStateNext;
|
frameStateCurrent <= frameStateNext;
|
frameWordCounterCurrent <= frameWordCounterNext;
|
frameWordCounterCurrent <= frameWordCounterNext;
|
frameContentCurrent <= frameContentNext;
|
frameContentCurrent <= frameContentNext;
|
counterCurrent <= counterNext;
|
counterCurrent <= counterNext;
|
symbolsTransmittedCurrent <= symbolsTransmittedNext;
|
symbolsTransmittedCurrent <= symbolsTransmittedNext;
|
|
maintenanceClassCurrent <= maintenanceClassNext;
|
end if;
|
end if;
|
end if;
|
end if;
|
end process;
|
end process;
|
|
|
|
CoreGeneration: for i in 0 to NUMBER_WORDS-1 generate
|
TxCore: RioTransmitterCore
|
TxCore: RioTransmitterCore
|
generic map(NUMBER_WORDS=>NUMBER_WORDS)
|
generic map(NUMBER_WORDS=>NUMBER_WORDS)
|
port map(
|
port map(
|
clk=>clk, areset_n=>areset_n,
|
clk=>clk, areset_n=>areset_n,
|
portEnable_i=>portEnable_i,
|
portEnable_i=>portEnable_i,
|
portInitialized_i=>portInitialized_i,
|
portInitialized_i=>portInitialized_i,
|
txFull_i=>txFull_i, txWrite_o=>txWrite_o, txType_o=>txType_o, txData_o=>txData_o,
|
txFull_i=>txFull_i,
|
txControlEmpty_i=>txControlEmpty_i,
|
txWrite_o=>txWrite_o,
|
txControlSymbol_i=>txControlSymbol_i,
|
txType_o=>txType_o,
|
txControlUpdate_o=>txControlUpdate_o,
|
txData_o=>txData_o,
|
rxControlEmpty_i=>rxControlEmpty_i,
|
txControlEmpty_i=>txControlEmpty_i(i),
|
rxControlSymbol_i=>rxControlSymbol_i,
|
txControlSymbol_i=>txControlSymbol_i(13*(i+1)-1 downto 13*i),
|
rxControlUpdate_o=>rxControlUpdate_o,
|
txControlUpdate_o=>txControlUpdate_o(i),
|
|
rxControlEmpty_i=>rxControlEmpty_i(i),
|
|
rxControlSymbol_i=>rxControlSymbol_i(13*(i+1)-1 downto 13*i),
|
|
rxControlUpdate_o=>rxControlUpdate_o(i),
|
linkInitialized_o=>linkInitialized_o,
|
linkInitialized_o=>linkInitialized_o,
|
linkInitialized_i=>linkInitialized_i,
|
linkInitialized_i=>linkInitialized_i,
|
ackIdStatus_i=>ackIdStatus_i,
|
ackIdStatus_i=>ackIdStatus_i,
|
|
|
timeSentSet_o=>timeSentSet,
|
timeSentSet_o=>timeSentSet,
|
timeSentReset_o=>timeSentReset,
|
timeSentReset_o=>timeSentReset,
|
timeSentExpired_i=>timeSentExpired,
|
timeSentExpired_i=>timeSentExpired,
|
|
operational_i=>operationalCurrent(i),
|
operational_i=>operationalCurrent, operational_o=>operationalNext,
|
operational_o=>operationalNext(i),
|
ackId_i=>ackIdCurrent, ackId_o=>ackIdNext,
|
ackId_i=>ackIdCurrent(5*(i+1)-1 downto 5*i),
|
bufferStatus_i=>bufferStatusCurrent, bufferStatus_o=>bufferStatusNext,
|
ackId_o=>ackIdNext(5*(i+1)-1 downto 5*i),
|
statusReceived_i=>statusReceivedCurrent, statusReceived_o=>statusReceivedNext,
|
bufferStatus_i=>bufferStatusCurrent(5*(i+1)-1 downto 5*i),
|
numberSentLinkRequests_i=>numberSentLinkRequestsCurrent, numberSentLinkRequests_o=>numberSentLinkRequestsNext,
|
bufferStatus_o=>bufferStatusNext(5*(i+1)-1 downto 5*i),
|
outputErrorStopped_i=>outputErrorStoppedCurrent, outputErrorStopped_o=>outputErrorStoppedNext,
|
statusReceived_i=>statusReceivedCurrent(i),
|
fatalError_i=>fatalErrorCurrent, fatalError_o=>fatalErrorNext,
|
statusReceived_o=>statusReceivedNext(i),
|
recoverActive_i=>recoverActiveCurrent, recoverActive_o=>recoverActiveNext,
|
numberSentLinkRequests_i=>numberSentLinkRequestsCurrent(2*(i+1)-1 downto 2*i),
|
recoverCounter_i=>recoverCounterCurrent, recoverCounter_o=>recoverCounterNext,
|
numberSentLinkRequests_o=>numberSentLinkRequestsNext(2*(i+1)-1 downto 2*i),
|
ackIdWindow_i=>ackIdWindowCurrent, ackIdWindow_o=>ackIdWindowNext,
|
outputErrorStopped_i=>outputErrorStoppedCurrent(i),
|
frameState_i=>frameStateCurrent, frameState_o=>frameStateNext,
|
outputErrorStopped_o=>outputErrorStoppedNext(i),
|
frameWordCounter_i=>frameWordCounterCurrent, frameWordCounter_o=>frameWordCounterNext,
|
fatalError_i=>fatalErrorCurrent(i),
|
frameContent_i=>frameContentCurrent, frameContent_o=>frameContentNext,
|
fatalError_o=>fatalErrorNext(i),
|
counter_i=>counterCurrent, counter_o=>counterNext,
|
recoverActive_i=>recoverActiveCurrent(i),
|
symbolsTransmitted_i=>symbolsTransmittedCurrent, symbolsTransmitted_o=>symbolsTransmittedNext,
|
recoverActive_o=>recoverActiveNext(i),
|
|
recoverCounter_i=>recoverCounterCurrent(5*(i+1)-1 downto 5*i),
|
|
recoverCounter_o=>recoverCounterNext(5*(i+1)-1 downto 5*i),
|
|
ackIdWindow_i=>ackIdWindowCurrent(5*(i+1)-1 downto 5*i),
|
|
ackIdWindow_o=>ackIdWindowNext(5*(i+1)-1 downto 5*i),
|
|
frameState_i=>frameStateCurrent(4*(i+1)-1 downto 4*i),
|
|
frameState_o=>frameStateNext(4*(i+1)-1 downto 4*i),
|
|
frameWordCounter_i=>frameWordCounterCurrent(2*(i+1)-1 downto 2*i),
|
|
frameWordCounter_o=>frameWordCounterNext(2*(i+1)-1 downto 2*i),
|
|
frameContent_i=>frameContentCurrent(64*(i+1)-1 downto 64*i),
|
|
frameContent_o=>frameContentNext(64*(i+1)-1 downto 64*i),
|
|
counter_i=>counterCurrent(4*(i+1)-1 downto 4*i),
|
|
counter_o=>counterNext(4*(i+1)-1 downto 4*i),
|
|
symbolsTransmitted_i=>symbolsTransmittedCurrent(8*(i+1)-1 downto 8*i),
|
|
symbolsTransmitted_o=>symbolsTransmittedNext(8*(i+1)-1 downto 8*i),
|
|
maintenanceClass_i=>maintenanceClassCurrent(i),
|
|
maintenanceClass_o=>maintenanceClassNext(i),
|
readFrameEmpty_i=>readFrameEmpty_i,
|
readFrameEmpty_i=>readFrameEmpty_i,
|
readFrame_o=>readFrame_o,
|
readFrame_o=>readFrame(i),
|
readFrameRestart_o=>readFrameRestart_o,
|
readFrameRestart_o=>readFrameRestart(i),
|
readFrameAborted_i=>readFrameAborted_i,
|
readFrameAborted_i=>readFrameAborted_i,
|
readWindowEmpty_i=>readWindowEmpty_i,
|
readWindowEmpty_i=>readWindowEmpty_i,
|
readWindowReset_o=>readWindowReset_o,
|
readWindowReset_o=>readWindowReset(i),
|
readWindowNext_o=>readWindowNext_o,
|
readWindowNext_o=>readWindowNext(i),
|
readContentEmpty_i=>readContentEmpty_i,
|
readContentEmpty_i=>readContentEmpty_i,
|
readContent_o=>readContent_o,
|
readContent_o=>readContent(i),
|
readContentEnd_i=>readContentEnd_i,
|
readContentEnd_i=>readContentEnd_i,
|
readContentWords_i=>readContentWords_i,
|
readContentWords_i=>readContentWords_i,
|
readContentData_i=>readContentData_i);
|
readContentData_i=>readContentData_i);
|
|
end generate;
|
|
|
end architecture;
|
end architecture;
|
|
|
|
|
|
|
Line 853... |
Line 919... |
-- Internal signalling from the receiver part.
|
-- Internal signalling from the receiver part.
|
linkInitialized_o : out std_logic;
|
linkInitialized_o : out std_logic;
|
linkInitialized_i : in std_logic;
|
linkInitialized_i : in std_logic;
|
ackIdStatus_i : in std_logic_vector(4 downto 0);
|
ackIdStatus_i : in std_logic_vector(4 downto 0);
|
|
|
-- Internal core variables for cascading.
|
-- Timeout signals.
|
timeSentSet_o : out std_logic;
|
timeSentSet_o : out std_logic;
|
timeSentReset_o : out std_logic;
|
timeSentReset_o : out std_logic;
|
timeSentExpired_i : in std_logic;
|
timeSentExpired_i : in std_logic;
|
|
|
|
-- Internal core variables for cascading.
|
operational_i : in std_logic;
|
operational_i : in std_logic;
|
operational_o : out std_logic;
|
operational_o : out std_logic;
|
ackId_i : in std_logic_vector(4 downto 0);
|
ackId_i : in std_logic_vector(4 downto 0);
|
ackId_o : out std_logic_vector(4 downto 0);
|
ackId_o : out std_logic_vector(4 downto 0);
|
bufferStatus_i : in std_logic_vector(4 downto 0);
|
bufferStatus_i : in std_logic_vector(4 downto 0);
|
Line 878... |
Line 945... |
recoverActive_o : out std_logic;
|
recoverActive_o : out std_logic;
|
recoverCounter_i : in std_logic_vector(4 downto 0);
|
recoverCounter_i : in std_logic_vector(4 downto 0);
|
recoverCounter_o : out std_logic_vector(4 downto 0);
|
recoverCounter_o : out std_logic_vector(4 downto 0);
|
ackIdWindow_i : in std_logic_vector(4 downto 0);
|
ackIdWindow_i : in std_logic_vector(4 downto 0);
|
ackIdWindow_o : out std_logic_vector(4 downto 0);
|
ackIdWindow_o : out std_logic_vector(4 downto 0);
|
frameState_i : in std_logic_vector(6 downto 0);
|
frameState_i : in std_logic_vector(3 downto 0);
|
frameState_o : out std_logic_vector(6 downto 0);
|
frameState_o : out std_logic_vector(3 downto 0);
|
frameWordCounter_i : in std_logic_vector(1 downto 0);
|
frameWordCounter_i : in std_logic_vector(1 downto 0);
|
frameWordCounter_o : out std_logic_vector(1 downto 0);
|
frameWordCounter_o : out std_logic_vector(1 downto 0);
|
frameContent_i : in std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
frameContent_i : in std_logic_vector(63 downto 0);
|
frameContent_o : out std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
frameContent_o : out std_logic_vector(63 downto 0);
|
counter_i : in std_logic_vector(3 downto 0);
|
counter_i : in std_logic_vector(3 downto 0);
|
counter_o : out std_logic_vector(3 downto 0);
|
counter_o : out std_logic_vector(3 downto 0);
|
symbolsTransmitted_i : in std_logic_vector(7 downto 0);
|
symbolsTransmitted_i : in std_logic_vector(7 downto 0);
|
symbolsTransmitted_o : out std_logic_vector(7 downto 0);
|
symbolsTransmitted_o : out std_logic_vector(7 downto 0);
|
|
maintenanceClass_i : in std_logic;
|
|
maintenanceClass_o : out std_logic;
|
|
|
-- Frame buffer interface.
|
-- Frame buffer interface.
|
readFrameEmpty_i : in std_logic;
|
readFrameEmpty_i : in std_logic;
|
readFrame_o : out std_logic;
|
readFrame_o : out std_logic;
|
readFrameRestart_o : out std_logic;
|
readFrameRestart_o : out std_logic;
|
Line 908... |
Line 977... |
|
|
|
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- Architecture for RioTransmitterCore.
|
-- Architecture for RioTransmitterCore.
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- REMARK: Check that all _o except channel variables are registered...
|
|
architecture RioTransmitterCoreImpl of RioTransmitterCore is
|
architecture RioTransmitterCoreImpl of RioTransmitterCore is
|
|
|
constant NUMBER_STATUS_TRANSMIT : std_logic_vector := "1111";
|
constant NUMBER_STATUS_TRANSMIT : std_logic_vector := "1111";
|
constant NUMBER_LINK_RESPONSE_RETRIES : std_logic_vector := "10";
|
constant NUMBER_LINK_RESPONSE_RETRIES : std_logic_vector := "10";
|
|
|
-- REMARK: Binary coding???
|
constant FRAME_IDLE : std_logic_vector(3 downto 0) := "0000";
|
constant FRAME_IDLE : std_logic_vector(6 downto 0) := "0000001";
|
constant FRAME_BUFFER : std_logic_vector(3 downto 0) := "0001";
|
constant FRAME_START : std_logic_vector(6 downto 0) := "0000010";
|
constant FRAME_START : std_logic_vector(3 downto 0) := "0010";
|
constant FRAME_FIRST : std_logic_vector(6 downto 0) := "0000100";
|
constant FRAME_FIRST : std_logic_vector(3 downto 0) := "0011";
|
constant FRAME_MIDDLE : std_logic_vector(6 downto 0) := "0001000";
|
constant FRAME_MIDDLE : std_logic_vector(3 downto 0) := "0100";
|
constant FRAME_LAST : std_logic_vector(6 downto 0) := "0010000";
|
constant FRAME_LAST_0 : std_logic_vector(3 downto 0) := "0101";
|
constant FRAME_END : std_logic_vector(6 downto 0) := "0100000";
|
constant FRAME_LAST_1 : std_logic_vector(3 downto 0) := "0110";
|
constant FRAME_DISCARD : std_logic_vector(6 downto 0) := "1000000";
|
constant FRAME_END : std_logic_vector(3 downto 0) := "0111";
|
|
constant FRAME_DISCARD : std_logic_vector(3 downto 0) :="1000";
|
|
|
component Crc5ITU is
|
component Crc5ITU is
|
port(
|
port(
|
d_i : in std_logic_vector(18 downto 0);
|
d_i : in std_logic_vector(18 downto 0);
|
crc_o : out std_logic_vector(4 downto 0));
|
crc_o : out std_logic_vector(4 downto 0));
|
Line 984... |
Line 1053... |
rxControlStype0 <= rxControlSymbol_i(12 downto 10);
|
rxControlStype0 <= rxControlSymbol_i(12 downto 10);
|
rxControlParameter0 <= rxControlSymbol_i(9 downto 5);
|
rxControlParameter0 <= rxControlSymbol_i(9 downto 5);
|
rxControlParameter1 <= rxControlSymbol_i(4 downto 0);
|
rxControlParameter1 <= rxControlSymbol_i(4 downto 0);
|
|
|
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
-- N-3
|
-- First pipeline stage.
|
-- Receive stuff from link-partner and timeout supervision.
|
-- Receive stuff from link-partner and timeout supervision.
|
-- Input: ackId, ackIdWindow, timeoutExpired
|
-- Input: ackId, ackIdWindow, timeoutExpired
|
-- Output: sendLinkRequest, sendRestartFromRetry, ackId,
|
-- Output: sendLinkRequest, sendRestartFromRetry, ackId,
|
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
|
|
|
txControlUpdate_o <= txControlUpdateOut and (not txFull_i);
|
|
|
process(clk, areset_n)
|
process(clk, areset_n)
|
begin
|
begin
|
if (areset_n = '0') then
|
if (areset_n = '0') then
|
txControlUpdate_o <= '0';
|
|
readFrame_o <= '0';
|
readFrame_o <= '0';
|
|
|
sendRestartFromRetry <= '0';
|
sendRestartFromRetry <= '0';
|
sendLinkRequest <= '0';
|
sendLinkRequest <= '0';
|
elsif (clk'event and clk = '1') then
|
elsif (clk'event and clk = '1') then
|
txControlUpdate_o <= '0';
|
|
readFrame_o <= '0';
|
readFrame_o <= '0';
|
|
|
if (txFull_i = '0') then
|
if (txFull_i = '0') then
|
txControlUpdate_o <= txControlUpdateOut;
|
|
readFrame_o <= readFrameOut;
|
readFrame_o <= readFrameOut;
|
|
|
sendRestartFromRetry <= sendRestartFromRetryOut;
|
sendRestartFromRetry <= sendRestartFromRetryOut;
|
sendLinkRequest <= sendLinkRequestOut;
|
sendLinkRequest <= sendLinkRequestOut;
|
end if;
|
end if;
|
Line 1041... |
Line 1109... |
|
|
if (fatalError_i = '1') then
|
if (fatalError_i = '1') then
|
outputErrorStopped_o <= '0';
|
outputErrorStopped_o <= '0';
|
fatalError_o <= '0';
|
fatalError_o <= '0';
|
elsif (recoverActive_i = '1') then
|
elsif (recoverActive_i = '1') then
|
if (ackId_i = recoverCounter_i) then
|
if (ackId_i /= recoverCounter_i) then
|
recoverActive_o <= '0';
|
|
outputErrorStopped_o <= '0';
|
|
else
|
|
ackId_o <= std_logic_vector(unsigned(ackId_i) + 1);
|
ackId_o <= std_logic_vector(unsigned(ackId_i) + 1);
|
readFrameOut <= '1';
|
readFrameOut <= '1';
|
|
else
|
|
recoverActive_o <= '0';
|
|
outputErrorStopped_o <= '0';
|
end if;
|
end if;
|
else
|
else
|
if (operational_i = '0') then
|
if (operational_i = '0') then
|
|
-- Not operational mode.
|
|
|
|
-- Check if any new symbol has been received from the link-partner.
|
if (txControlEmpty_i = '0') then
|
if (txControlEmpty_i = '0') then
|
|
-- New symbol from link-partner.
|
|
|
|
-- Check if the symbol is a status-control-symbol.
|
if (txControlStype0 = STYPE0_STATUS) then
|
if (txControlStype0 = STYPE0_STATUS) then
|
-- A status-control symbol has been received.
|
-- A status-control symbol has been received.
|
|
-- Update variables from the input status control symbol.
|
ackId_o <= txControlParameter0;
|
ackId_o <= txControlParameter0;
|
bufferStatus_o <= txControlParameter1;
|
bufferStatus_o <= txControlParameter1;
|
|
outputErrorStopped_o <= '0';
|
statusReceived_o <= '1';
|
statusReceived_o <= '1';
|
else
|
else
|
-- Discard all other received symbols in this state.
|
-- Discard all other received symbols in this state.
|
end if;
|
end if;
|
txControlUpdateOut <= '1';
|
txControlUpdateOut <= '1';
|
Line 1068... |
Line 1144... |
|
|
-- Make sure to reset the status received flag.
|
-- Make sure to reset the status received flag.
|
statusReceived_o <= '0';
|
statusReceived_o <= '0';
|
|
|
-- Check if the oldest frame timeout has expired.
|
-- Check if the oldest frame timeout has expired.
|
-- REMARK: Two link-requests are transmitted when a timeout occurrs...
|
|
if ((ackId_i /= ackIdWindow_i) and
|
if ((ackId_i /= ackIdWindow_i) and
|
(timeSentExpired_i = '1')) then
|
(timeSentExpired_i = '1')) then
|
-- There has been a timeout on a transmitted frame.
|
-- There has been a timeout on a transmitted frame.
|
|
|
-- Reset the timeout to expire when the transmitted link-request has
|
-- Reset the timeout to expire when the transmitted link-request has
|
-- timed out instead.
|
-- timed out instead.
|
timeSentReset_o <= '1';
|
timeSentReset_o <= '1';
|
|
|
|
-- Check if we are in the output-error-stopped state.
|
if (outputErrorStopped_i = '1') then
|
if (outputErrorStopped_i = '1') then
|
-- Count the number of retransmissions and abort if
|
-- In the output-error-stopped state.
|
-- no reply has been received for too many times.
|
|
|
-- Count the number of link-requests that has been sent and abort if
|
|
-- there has been no reply for too many times.
|
if (unsigned(numberSentLinkRequests_i) /= 0) then
|
if (unsigned(numberSentLinkRequests_i) /= 0) then
|
-- Not sent link-request too many times.
|
-- Not sent link-request too many times.
|
|
|
-- Send another link-request.
|
-- Send another link-request.
|
sendLinkRequestOut <= '1';
|
sendLinkRequestOut <= '1';
|
numberSentLinkRequests_o <= std_logic_vector(unsigned(numberSentLinkRequests_i) - 1);
|
numberSentLinkRequests_o <= std_logic_vector(unsigned(numberSentLinkRequests_i) - 1);
|
else
|
else
|
-- No response for too many times.
|
-- No response for too many times.
|
|
|
-- Indicate that a fatal error has occurred.
|
-- Indicate that a fatal error has occurred.
|
fatalError_o <= '1';
|
fatalError_o <= '1';
|
end if;
|
end if;
|
else
|
else
|
|
-- Not in output-error-stopped and there is a timeout.
|
|
-- Enter output-error-stopped state and send a link-request.
|
sendLinkRequestOut <= '1';
|
sendLinkRequestOut <= '1';
|
numberSentLinkRequests_o <= NUMBER_LINK_RESPONSE_RETRIES;
|
numberSentLinkRequests_o <= NUMBER_LINK_RESPONSE_RETRIES;
|
outputErrorStopped_o <= '1';
|
outputErrorStopped_o <= '1';
|
end if;
|
end if;
|
else
|
else
|
Line 1151... |
Line 1229... |
|
|
-- Check if the ackId is the one expected.
|
-- Check if the ackId is the one expected.
|
if (ackId_i = txControlParameter0) then
|
if (ackId_i = txControlParameter0) then
|
-- The ackId to retry is expected.
|
-- The ackId to retry is expected.
|
-- Go to the output-retry-stopped state.
|
-- Go to the output-retry-stopped state.
|
-- REMARK: The output-retry-stopped state is equivalent
|
-- Note that the output-retry-stopped state is equivalent
|
-- to sending a restart-from-retry.
|
-- to sending a restart-from-retry.
|
sendRestartFromRetryOut <= '1';
|
sendRestartFromRetryOut <= '1';
|
else
|
else
|
-- Unexpected ackId to retry.
|
-- Unexpected ackId to retry.
|
sendLinkRequestOut <= '1';
|
sendLinkRequestOut <= '1';
|
Line 1182... |
Line 1260... |
-- that has been received by the link-partner.
|
-- that has been received by the link-partner.
|
recoverCounter_o <= txControlParameter0;
|
recoverCounter_o <= txControlParameter0;
|
recoverActive_o <= '1';
|
recoverActive_o <= '1';
|
else
|
else
|
-- Totally out of sync.
|
-- Totally out of sync.
|
|
|
-- Indicate that a fatal error has occurred.
|
-- Indicate that a fatal error has occurred.
|
fatalError_o <= '1';
|
fatalError_o <= '1';
|
|
|
-- REMARK: What to do here???
|
|
--readWindowReset_o <= '1';
|
|
--stateNext <= STATE_UNINITIALIZED;
|
|
end if;
|
end if;
|
else
|
else
|
-- Dont expect or need a link-response in this state.
|
-- Dont expect or need a link-response in this state.
|
-- Discard it.
|
-- Discard it.
|
end if;
|
end if;
|
Line 1220... |
Line 1293... |
end if;
|
end if;
|
end if;
|
end if;
|
end process;
|
end process;
|
|
|
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
-- N-2 pipeline stage.
|
-- Second pipeline stage.
|
-- Create stype1-part of symbols and data symbols. Save the time when a
|
-- Create stype1-part of symbols and data symbols. Save the time when a
|
-- packet was fully sent.
|
-- packet was fully sent.
|
-- Input: sendRestartFromRetry, sendLinkRequest
|
-- Input: sendRestartFromRetry, sendLinkRequest
|
-- Output: ackIdWindow, frameState, timeout(0 to 31),
|
-- Output: ackIdWindow, frameState, timeout(0 to 31),
|
-- symbolControlStart, symbolControlEnd, symbolControlRestart,
|
-- symbolControlStart, symbolControlEnd, symbolControlRestart,
|
-- symbolControlLinkRequest, symbolData2, symbolData2Content.
|
-- symbolControlLinkRequest, symbolData2, symbolData2Content.
|
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
|
|
|
readFrameRestart_o <= readFrameRestartOut and (not txFull_i);
|
|
readWindowReset_o <= readWindowResetOut and (not txFull_i);
|
|
readWindowNext_o <= readWindowNextOut and (not txFull_i);
|
|
readContent_o <= readContentOut and (not txFull_i);
|
|
|
process(clk, areset_n)
|
process(clk, areset_n)
|
begin
|
begin
|
if (areset_n = '0') then
|
if (areset_n = '0') then
|
readFrameRestart_o <= '0';
|
|
readWindowReset_o <= '0';
|
|
readWindowNext_o <= '0';
|
|
readContent_o <= '0';
|
|
|
|
symbolControlRestart <= '0';
|
symbolControlRestart <= '0';
|
symbolControlLinkRequest <= '0';
|
symbolControlLinkRequest <= '0';
|
symbolControlStart <= '0';
|
symbolControlStart <= '0';
|
symbolControlEnd <= '0';
|
symbolControlEnd <= '0';
|
symbolData <= '0';
|
symbolData <= '0';
|
symbolDataContent <= (others => '0');
|
symbolDataContent <= (others => '0');
|
elsif (clk'event and clk = '1') then
|
elsif (clk'event and clk = '1') then
|
readFrameRestart_o <= '0';
|
|
readWindowReset_o <= '0';
|
|
readWindowNext_o <= '0';
|
|
readContent_o <= '0';
|
|
|
|
if (txFull_i = '0') then
|
if (txFull_i = '0') then
|
readFrameRestart_o <= readFrameRestartOut;
|
|
readWindowReset_o <= readWindowResetOut;
|
|
readWindowNext_o <= readWindowNextOut;
|
|
readContent_o <= readContentOut;
|
|
|
|
symbolControlRestart <= symbolControlRestartOut;
|
symbolControlRestart <= symbolControlRestartOut;
|
symbolControlLinkRequest <= symbolControlLinkRequestOut;
|
symbolControlLinkRequest <= symbolControlLinkRequestOut;
|
symbolControlStart <= symbolControlStartOut;
|
symbolControlStart <= symbolControlStartOut;
|
symbolControlEnd <= symbolControlEndOut;
|
symbolControlEnd <= symbolControlEndOut;
|
symbolData <= symbolDataOut;
|
symbolData <= symbolDataOut;
|
Line 1268... |
Line 1331... |
end process;
|
end process;
|
|
|
-- This process decide which stype1-part of a control symbols to send as well
|
-- This process decide which stype1-part of a control symbols to send as well
|
-- as all data symbols.
|
-- as all data symbols.
|
process(readWindowEmpty_i, bufferStatus_i,
|
process(readWindowEmpty_i, bufferStatus_i,
|
recoverActive_i, recoverCounter_i, ackId_i, operational_i, outputErrorStopped_i, portEnable_i, readContentData_i, readContentWords_i, readContentEnd_i,
|
recoverActive_i, ackId_i, operational_i, outputErrorStopped_i, portEnable_i, readContentData_i, readContentWords_i, readContentEnd_i,
|
frameState_i, frameWordCounter_i, frameContent_i,
|
frameState_i, frameWordCounter_i, frameContent_i,
|
ackIdWindow_i,
|
ackIdWindow_i,
|
sendRestartFromRetry, sendLinkRequest,
|
sendRestartFromRetry, sendLinkRequest,
|
fatalError_i)
|
fatalError_i)
|
begin
|
begin
|
Line 1296... |
Line 1359... |
symbolDataContentOut <= (others => '0');
|
symbolDataContentOut <= (others => '0');
|
|
|
if (fatalError_i = '1') then
|
if (fatalError_i = '1') then
|
readWindowResetOut <= '1';
|
readWindowResetOut <= '1';
|
elsif (recoverActive_i = '1') then
|
elsif (recoverActive_i = '1') then
|
-- REMARK: Make sure idle is generated when this state is active...
|
|
ackIdWindow_o <= ackId_i;
|
ackIdWindow_o <= ackId_i;
|
frameState_o <= FRAME_IDLE;
|
frameState_o <= FRAME_IDLE;
|
readWindowResetOut <= '1';
|
readWindowResetOut <= '1';
|
else
|
else
|
if (operational_i = '0') then
|
if (operational_i = '0') then
|
Line 1308... |
Line 1370... |
-- This state is entered at startup. A port that is not initialized
|
-- This state is entered at startup. A port that is not initialized
|
-- should only transmit idle sequences.
|
-- should only transmit idle sequences.
|
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
|
|
-- Initialize framing before entering the operational state.
|
-- Initialize framing before entering the operational state.
|
-- REMARK: Only do this when the portInitialized becomes asserted???
|
|
frameState_o <= FRAME_IDLE;
|
frameState_o <= FRAME_IDLE;
|
ackIdWindow_o <= ackId_i;
|
ackIdWindow_o <= ackId_i;
|
readWindowResetOut <= '1';
|
readWindowResetOut <= '1';
|
else
|
else
|
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
Line 1350... |
Line 1411... |
(outputErrorStopped_i = '0')) then
|
(outputErrorStopped_i = '0')) then
|
-- Check if a frame transfer is in progress.
|
-- Check if a frame transfer is in progress.
|
-- REMARK: Hold any data symbol if there is a pending symbol from the
|
-- REMARK: Hold any data symbol if there is a pending symbol from the
|
-- receiver side...
|
-- receiver side...
|
|
|
|
-- REMARK: This statemachine does not work... one tick ahead is needed...
|
case frameState_i is
|
case frameState_i is
|
|
|
when FRAME_IDLE =>
|
when FRAME_IDLE =>
|
---------------------------------------------------------------
|
---------------------------------------------------------------
|
-- No frame has been started.
|
-- No frame has been started.
|
Line 1362... |
Line 1424... |
-- Wait for a new frame to arrive from the frame buffer.
|
-- Wait for a new frame to arrive from the frame buffer.
|
if (readWindowEmpty_i = '0') then
|
if (readWindowEmpty_i = '0') then
|
-- Update the output from the frame buffer to contain the
|
-- Update the output from the frame buffer to contain the
|
-- data when it is read later.
|
-- data when it is read later.
|
readContentOut <= '1';
|
readContentOut <= '1';
|
|
frameContent_o <=
|
|
frameContent_i(31 downto 0) & readContentData_i;
|
|
|
-- Indicate that a control symbol has been sent to start the
|
-- Proceed to start the transmission of the packet.
|
-- transmission of the frame.
|
frameState_o <= FRAME_BUFFER;
|
frameState_o <= FRAME_START;
|
|
end if;
|
end if;
|
|
|
when FRAME_START =>
|
when FRAME_BUFFER =>
|
|
-----------------------------------------------------------------
|
|
-- Packet buffer output has been updated. Store the packet
|
|
-- content temporarily.
|
|
-----------------------------------------------------------------
|
|
|
|
readContentOut <= '1';
|
|
frameContent_o <=
|
|
frameContent_i(31 downto 0) & readContentData_i;
|
|
|
|
if (readContentData_i(19 downto 16) = FTYPE_MAINTENANCE_CLASS) then
|
|
maintenanceClass_o <= '1';
|
|
else
|
|
maintenanceClass_o <= '0';
|
|
end if;
|
|
|
|
frameState_o <= FRAME_START;
|
|
|
|
when FRAME_START | FRAME_END =>
|
-------------------------------------------------------
|
-------------------------------------------------------
|
-- Check if we are allowed to transmit this packet.
|
-- Check if we are allowed to transmit this packet.
|
-------------------------------------------------------
|
-------------------------------------------------------
|
-- The packet may be either not allowed, i.e. a non-maintenance
|
-- The packet may be not allowed, i.e. a non-maintenance
|
-- sent when only maintenance is allowed. The link-partner can be
|
-- sent when only maintenance is allowed. The link-partner can be
|
-- busy, i.e. no having enough buffers to receive the new packet
|
-- busy, i.e. not having enough buffers to receive the new packet
|
-- in or the number of outstanding packets may be too large.
|
-- in or the number of outstanding packets may be too large.
|
-- REMARK: Only update readContent_o in the last instance
|
-- REMARK: Only update readContent_o in the last instance
|
-- if cascaded...
|
-- if cascaded...
|
|
|
-- Check if the packet is allowed.
|
-- Check if the packet is allowed.
|
if ((portEnable_i = '1') or
|
if ((portEnable_i = '1') or (maintenanceClass_i = '1')) then
|
(readContentData_i(19 downto 16) = FTYPE_MAINTENANCE_CLASS)) then
|
|
-- Packet is allowed.
|
-- Packet is allowed.
|
|
|
-- Check if the link is able to accept the new frame.
|
-- Check if the link is able to accept the new frame.
|
if ((bufferStatus_i /= "00000") and
|
if ((readWindowEmpty_i = '0') and
|
|
(bufferStatus_i /= "00000") and
|
((unsigned(ackIdWindow_i)+1) /= unsigned(ackId_i))) then
|
((unsigned(ackIdWindow_i)+1) /= unsigned(ackId_i))) then
|
-- New data is available for transmission and there
|
-- New data is available for transmission and there
|
-- is room to receive it at the other side.
|
-- is room to receive it at the other side.
|
-- The packet may be transmitted.
|
-- The packet may be transmitted.
|
|
|
-- Indicate that a control symbol has been sent to start the
|
|
-- transmission of the frame.
|
|
frameWordCounter_o <= readContentWords_i;
|
|
frameContent_o <= readContentData_i;
|
|
readContentOut <= '1';
|
|
|
|
-- Send a control symbol to start the packet and a status to
|
-- Send a control symbol to start the packet and a status to
|
-- complete the symbol.
|
-- complete the symbol.
|
symbolControlStartOut <= '1';
|
symbolControlStartOut <= '1';
|
|
|
|
-- Indicate that a control symbol has been sent to start the
|
|
-- transmission of the frame.
|
|
frameContent_o <=
|
|
frameContent_i(31 downto 0) & readContentData_i;
|
|
readContentOut <= '1';
|
|
|
-- Proceed to send the first packet data symbol containing
|
-- Proceed to send the first packet data symbol containing
|
-- the ackId.
|
-- the ackId.
|
frameState_o <= FRAME_FIRST;
|
frameState_o <= FRAME_FIRST;
|
else
|
else
|
-- The link cannot accept the packet.
|
-- The link cannot accept the packet.
|
-- Wait in this state and dont do anything.
|
-- Wait in this state and dont do anything.
|
|
if (frameState_i = FRAME_END) then
|
|
symbolControlEndOut <= '1';
|
|
end if;
|
|
readFrameRestartOut <= '1';
|
|
frameState_o <= FRAME_IDLE;
|
end if;
|
end if;
|
else
|
else
|
-- The packet is not allowed.
|
-- The packet is not allowed.
|
-- Discard it.
|
-- Discard it.
|
|
if (frameState_i = FRAME_END) then
|
|
symbolControlEndOut <= '1';
|
|
end if;
|
|
--readFrameRestartOut <= '1';
|
frameState_o <= FRAME_DISCARD;
|
frameState_o <= FRAME_DISCARD;
|
end if;
|
end if;
|
|
|
when FRAME_FIRST =>
|
when FRAME_FIRST =>
|
---------------------------------------------------------------
|
---------------------------------------------------------------
|
Line 1423... |
Line 1513... |
---------------------------------------------------------------
|
---------------------------------------------------------------
|
|
|
-- Write a new data symbol and fill in our ackId on the
|
-- Write a new data symbol and fill in our ackId on the
|
-- packet.
|
-- packet.
|
symbolDataOut <= '1';
|
symbolDataOut <= '1';
|
symbolDataContentOut <=
|
symbolDataContentOut <= std_logic_vector(ackIdWindow_i) & "0" &
|
std_logic_vector(ackIdWindow_i) & "0" &
|
frameContent_i(57 downto 32);
|
frameContent_i((32*NUMBER_WORDS)-7 downto (32*(NUMBER_WORDS-1)));
|
frameContent_o <= frameContent_i(31 downto 0) & readContentData_i;
|
|
|
if (unsigned(frameWordCounter_i) /= 0) then
|
-- Check if the frame is ending.
|
frameWordCounter_o <=
|
if (readContentEnd_i = '1') then
|
std_logic_vector(unsigned(frameWordCounter_i) - 1);
|
-- The frame is ending.
|
frameContent_o <=
|
readWindowNextOut <= '1';
|
frameContent_i((32*(NUMBER_WORDS-1))-1 downto 0) & x"00000000";
|
frameState_o <= FRAME_LAST_0;
|
else
|
else
|
frameWordCounter_o <= readContentWords_i;
|
|
frameContent_o <= readContentData_i;
|
|
readContentOut <= '1';
|
readContentOut <= '1';
|
end if;
|
|
|
|
-- Continue to send the rest of the body of the packet.
|
|
frameState_o <= FRAME_MIDDLE;
|
frameState_o <= FRAME_MIDDLE;
|
|
end if;
|
|
|
when FRAME_MIDDLE =>
|
when FRAME_MIDDLE =>
|
---------------------------------------------------------------
|
---------------------------------------------------------------
|
-- The frame has not been fully sent.
|
-- The frame has not been fully sent.
|
-- Send a data symbol until the last part of the packet is
|
-- Send a data symbol until the last part of the packet is
|
-- detected.
|
-- detected.
|
---------------------------------------------------------------
|
---------------------------------------------------------------
|
-- REMARK: Dont send anything if there is a pending symbol in the
|
|
-- rx-control fifo to let it be transmitted in the middle of the
|
|
-- packet...
|
|
|
|
-- Write a new data symbol.
|
-- Write a new data symbol.
|
symbolDataOut <= '1';
|
symbolDataOut <= '1';
|
symbolDataContentOut <=
|
symbolDataContentOut <= frameContent_i(63 downto 32);
|
frameContent_i((32*NUMBER_WORDS)-1 downto (32*(NUMBER_WORDS-1)));
|
frameContent_o <= frameContent_i(31 downto 0) & readContentData_i;
|
|
|
if (unsigned(frameWordCounter_i) /= 0) then
|
|
frameWordCounter_o <=
|
|
std_logic_vector(unsigned(frameWordCounter_i) - 1);
|
|
frameContent_o <=
|
|
frameContent_i((32*(NUMBER_WORDS-1))-1 downto 0) & x"00000000";
|
|
else
|
|
frameWordCounter_o <= readContentWords_i;
|
|
frameContent_o <= readContentData_i;
|
|
|
|
-- Check if the frame is ending.
|
-- Check if the frame is ending.
|
-- REMARK: Dont forget to update RioPacketBuffer to support this...
|
|
if (readContentEnd_i = '1') then
|
if (readContentEnd_i = '1') then
|
-- The frame is ending.
|
-- The frame is ending.
|
|
|
-- Update the window to the next frame.
|
|
-- It takes one tick for the output from the frame
|
|
-- buffer to get updated.
|
|
readWindowNextOut <= '1';
|
readWindowNextOut <= '1';
|
|
frameState_o <= FRAME_LAST_0;
|
-- Proceed to check if there is another frame to start
|
|
-- with directly.
|
|
frameState_o <= FRAME_LAST;
|
|
else
|
else
|
readContentOut <= '1';
|
readContentOut <= '1';
|
end if;
|
end if;
|
end if;
|
|
|
|
when FRAME_LAST =>
|
when FRAME_LAST_0 =>
|
---------------------------------------------------------------
|
-----------------------------------------------------------------
|
-- A frame has ended and the window has been updated.
|
--
|
-- Check if the next symbol should end the frame or if a
|
-----------------------------------------------------------------
|
-- new one should be started.
|
|
---------------------------------------------------------------
|
|
|
|
-- Write a new data symbol.
|
|
symbolDataOut <= '1';
|
symbolDataOut <= '1';
|
symbolDataContentOut <=
|
symbolDataContentOut <= frameContent_i(63 downto 32);
|
frameContent_i((32*NUMBER_WORDS)-1 downto (32*(NUMBER_WORDS-1)));
|
frameContent_o <= frameContent_i(31 downto 0) & readContentData_i;
|
|
if (readWindowEmpty_i = '0') then
|
|
readContentOut <= '1';
|
|
end if;
|
|
frameState_o <= FRAME_LAST_1;
|
|
|
if (unsigned(frameWordCounter_i) /= 0) then
|
when FRAME_LAST_1 =>
|
frameWordCounter_o <=
|
-----------------------------------------------------------------
|
std_logic_vector(unsigned(frameWordCounter_i) - 1);
|
--
|
frameContent_o <=
|
-----------------------------------------------------------------
|
frameContent_i((32*(NUMBER_WORDS-1))-1 downto 0) & x"00000000";
|
|
|
symbolDataOut <= '1';
|
|
symbolDataContentOut <= frameContent_i(63 downto 32);
|
|
frameContent_o <= frameContent_i(31 downto 0) & readContentData_i;
|
|
if (readWindowEmpty_i = '0') then
|
|
if (readContentData_i(19 downto 16) = FTYPE_MAINTENANCE_CLASS) then
|
|
maintenanceClass_o <= '1';
|
else
|
else
|
|
maintenanceClass_o <= '0';
|
|
end if;
|
|
readContentOut <= '1';
|
|
end if;
|
|
|
-- Update the window ackId.
|
-- Update the window ackId.
|
ackIdWindow_o <= std_logic_vector(unsigned(ackIdWindow_i) + 1);
|
ackIdWindow_o <= std_logic_vector(unsigned(ackIdWindow_i) + 1);
|
|
|
-- Start timeout supervision for transmitted frame.
|
-- Start timeout supervision for transmitted frame.
|
timeSentSet_o <= '1';
|
timeSentSet_o <= '1';
|
|
|
-- Note that the packet must be ended if the link-partner
|
-- Proceed to end the frame or start a new one.
|
-- cannot receive it.
|
|
if ((readWindowEmpty_i = '0') and
|
|
(bufferStatus_i /= "00000") and
|
|
((unsigned(ackIdWindow_i)+2) /= unsigned(ackId_i))) then
|
|
readContentOut <= '1';
|
|
frameState_o <= FRAME_START;
|
|
else
|
|
frameState_o <= FRAME_END;
|
frameState_o <= FRAME_END;
|
end if;
|
|
end if;
|
|
|
|
when FRAME_END =>
|
|
-----------------------------------------------------------------
|
|
--
|
|
-----------------------------------------------------------------
|
|
|
|
-- Send a control symbol to end the packet.
|
|
symbolControlEndOut <= '1';
|
|
|
|
-- Start a new frame the next time.
|
|
frameState_o <= FRAME_IDLE;
|
|
|
|
when FRAME_DISCARD =>
|
when FRAME_DISCARD =>
|
---------------------------------------------------------------
|
---------------------------------------------------------------
|
--
|
--
|
---------------------------------------------------------------
|
---------------------------------------------------------------
|
Line 1561... |
Line 1618... |
end if;
|
end if;
|
end if;
|
end if;
|
end process;
|
end process;
|
|
|
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
-- N-1
|
-- Third pipeline stage.
|
-- Create the stype0 and stype1 part of a control symbol.
|
-- Create the stype0 and stype1 part of a control symbol.
|
-- This process makes sure that the buffer status are transmitted at least
|
-- This process makes sure that the buffer status are transmitted at least
|
-- every 255 symbol.
|
-- every 255 symbol.
|
-- At startup it makes sure that at least 16 status symbols are transmitted
|
-- At startup it makes sure that at least 16 status symbols are transmitted
|
-- before the operational-state is entered.
|
-- before the operational-state is entered.
|
Line 1574... |
Line 1631... |
-- Output: symbolsTransmitted_o, operational_o,
|
-- Output: symbolsTransmitted_o, operational_o,
|
-- symbolControl, stype0, parameter0, parameter1, stype1, cmd,
|
-- symbolControl, stype0, parameter0, parameter1, stype1, cmd,
|
-- symbolData1, symbolData1Content
|
-- symbolData1, symbolData1Content
|
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
|
|
|
rxControlUpdate_o <= rxControlUpdateOut and (not txFull_i);
|
|
|
process(clk, areset_n)
|
process(clk, areset_n)
|
begin
|
begin
|
if (areset_n = '0') then
|
if (areset_n = '0') then
|
rxControlUpdate_o <= '0';
|
|
|
|
controlValid <= '0';
|
controlValid <= '0';
|
stype0 <= (others=>'0');
|
stype0 <= (others=>'0');
|
parameter0 <= (others=>'0');
|
parameter0 <= (others=>'0');
|
parameter1 <= (others=>'0');
|
parameter1 <= (others=>'0');
|
stype1 <= STYPE1_NOP;
|
stype1 <= STYPE1_NOP;
|
cmd <= (others=>'0');
|
cmd <= (others=>'0');
|
dataValid <= '0';
|
dataValid <= '0';
|
dataContent <= (others=>'0');
|
dataContent <= (others=>'0');
|
elsif (clk'event and clk = '1') then
|
elsif (clk'event and clk = '1') then
|
if (txFull_i = '0') then
|
if (txFull_i = '0') then
|
rxControlUpdate_o <= rxControlUpdateOut;
|
|
|
|
controlValid <= controlValidOut;
|
controlValid <= controlValidOut;
|
stype0 <= stype0Out;
|
stype0 <= stype0Out;
|
parameter0 <= parameter0Out;
|
parameter0 <= parameter0Out;
|
parameter1 <= parameter1Out;
|
parameter1 <= parameter1Out;
|
stype1 <= STYPE1_NOP;
|
stype1 <= STYPE1_NOP;
|
Line 1710... |
Line 1765... |
-- Check if the port is still initialized.
|
-- Check if the port is still initialized.
|
if (portInitialized_i = '1') then
|
if (portInitialized_i = '1') then
|
-- The port is still initialized.
|
-- The port is still initialized.
|
|
|
-- Check if a status must be sent.
|
-- Check if a status must be sent.
|
-- A status must be sent when there are not other stype0 value to
|
-- A status must be sent when there are no other stype0 value to
|
-- send or if too many symbols without buffer-status has been sent.
|
-- send or if too many symbols without buffer-status has been sent.
|
-- REMARK: Is there a risk of a race when a generated status-symbol
|
-- REMARK: Is there a risk of a race when a generated status-symbol
|
-- is sent before another symbol stored in the rx-control fifo???
|
-- is sent before another symbol stored in the rx-control fifo???
|
if (((symbolControlStype1 = '1') and (rxControlEmpty_i = '1')) or
|
if (((symbolControlStype1 = '1') and (rxControlEmpty_i = '1')) or
|
((symbolControlStype1 = '0') and (symbolData = '0') and
|
((symbolControlStype1 = '0') and (symbolData = '0') and
|
Line 1755... |
Line 1810... |
end if;
|
end if;
|
else
|
else
|
-- The port is not initialized anymore.
|
-- The port is not initialized anymore.
|
-- Change the operational state.
|
-- Change the operational state.
|
operational_o <= '0';
|
operational_o <= '0';
|
|
counter_o <= NUMBER_STATUS_TRANSMIT;
|
|
symbolsTransmitted_o <= (others=>'0');
|
end if;
|
end if;
|
end if;
|
end if;
|
end if;
|
end if;
|
end process;
|
end process;
|
|
|
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
-- N pipeline stage.
|
-- Fourth pipeline stage.
|
-- Make all symbols ready for transmission, i.e. calculate the CRC5 on
|
-- Make all symbols ready for transmission, i.e. calculate the CRC5 on
|
-- control symbols.
|
-- control symbols and choose which symbol to send.
|
-- Inputs: controlValid, stype0, parameter0, parameter1, stype1, cmd,
|
-- Inputs: controlValid, stype0, parameter0, parameter1, stype1, cmd,
|
-- symbolData1, symbolData1Content
|
-- symbolData1, symbolData1Content
|
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
|
|
controlContent(31 downto 29) <= stype0;
|
controlContent(31 downto 29) <= stype0;
|
Line 2820... |
Line 2877... |
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
--
|
--
|
---------------------------------------------------------------------------------
|
---------------------------------------------------------------------------------
|
library ieee;
|
library ieee;
|
use ieee.std_logic_1164.all;
|
use ieee.std_logic_1164.all;
|
|
use ieee.numeric_std.all;
|
|
use work.rio_common.all;
|
|
|
|
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
--
|
--
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
entity RioFifo1 is
|
entity RioFifo is
|
generic(
|
generic(
|
WIDTH : natural);
|
DEPTH_WIDTH : natural;
|
|
DATA_WIDTH : natural);
|
port(
|
port(
|
clk : in std_logic;
|
clk : in std_logic;
|
areset_n : in std_logic;
|
areset_n : in std_logic;
|
|
|
empty_o : out std_logic;
|
empty_o : out std_logic;
|
read_i : in std_logic;
|
read_i : in std_logic;
|
data_o : out std_logic_vector(WIDTH-1 downto 0);
|
data_o : out std_logic_vector(DATA_WIDTH-1 downto 0);
|
|
|
full_o : out std_logic;
|
full_o : out std_logic;
|
write_i : in std_logic;
|
write_i : in std_logic;
|
data_i : in std_logic_vector(WIDTH-1 downto 0));
|
data_i : in std_logic_vector(DATA_WIDTH-1 downto 0));
|
end entity;
|
end entity;
|
|
|
|
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
--
|
--
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
architecture RioFifo1Impl of RioFifo1 is
|
architecture RioFifoImpl of RioFifo is
|
|
|
|
component MemorySimpleDualPortAsync is
|
|
generic(
|
|
ADDRESS_WIDTH : natural := 1;
|
|
DATA_WIDTH : natural := 1;
|
|
INIT_VALUE : std_logic := 'U');
|
|
port(
|
|
clkA_i : in std_logic;
|
|
enableA_i : in std_logic;
|
|
addressA_i : in std_logic_vector(ADDRESS_WIDTH-1 downto 0);
|
|
dataA_i : in std_logic_vector(DATA_WIDTH-1 downto 0);
|
|
|
|
addressB_i : in std_logic_vector(ADDRESS_WIDTH-1 downto 0);
|
|
dataB_o : out std_logic_vector(DATA_WIDTH-1 downto 0));
|
|
end component;
|
|
|
signal empty : std_logic;
|
signal empty : std_logic;
|
signal full : std_logic;
|
signal full : std_logic;
|
|
|
|
signal readAddress : std_logic_vector(DEPTH_WIDTH-1 downto 0);
|
|
signal readAddressInc : std_logic_vector(DEPTH_WIDTH-1 downto 0);
|
|
signal writeAddress : std_logic_vector(DEPTH_WIDTH-1 downto 0);
|
|
signal writeAddressInc : std_logic_vector(DEPTH_WIDTH-1 downto 0);
|
begin
|
begin
|
|
|
|
-- REMARK: Remove full here...
|
empty_o <= empty;
|
empty_o <= empty;
|
full_o <= full;
|
full_o <= full;
|
|
|
|
readAddressInc <= std_logic_vector(unsigned(readAddress) + 1);
|
|
writeAddressInc <= std_logic_vector(unsigned(writeAddress) + 1);
|
|
|
process(areset_n, clk)
|
process(areset_n, clk)
|
begin
|
begin
|
if (areset_n = '0') then
|
if (areset_n = '0') then
|
empty <= '1';
|
empty <= '1';
|
full <= '0';
|
full <= '0';
|
data_o <= (others => '0');
|
readAddress <= (others=>'0');
|
|
writeAddress <= (others=>'0');
|
elsif (clk'event and clk = '1') then
|
elsif (clk'event and clk = '1') then
|
if (empty = '1') then
|
if (empty = '1') then
|
if (write_i = '1') then
|
if (write_i = '1') then
|
empty <= '0';
|
empty <= '0';
|
full <= '1';
|
writeAddress <= writeAddressInc;
|
data_o <= data_i;
|
|
end if;
|
end if;
|
else
|
end if;
|
|
if (full = '1') then
|
if (read_i = '1') then
|
if (read_i = '1') then
|
empty <= '1';
|
|
full <= '0';
|
full <= '0';
|
|
readAddress <= readAddressInc;
|
|
end if;
|
|
end if;
|
|
if (empty = '0') and (full = '0') then
|
|
if (write_i = '1') and (read_i = '0') then
|
|
writeAddress <= writeAddressInc;
|
|
if (writeAddressInc = readAddress) then
|
|
full <= '1';
|
|
end if;
|
|
end if;
|
|
if (write_i = '0') and (read_i = '1') then
|
|
readAddress <= readAddressInc;
|
|
if (readAddressInc = writeAddress) then
|
|
empty <= '1';
|
|
end if;
|
|
end if;
|
|
if (write_i = '1') and (read_i = '1') then
|
|
writeAddress <= writeAddressInc;
|
|
readAddress <= readAddressInc;
|
end if;
|
end if;
|
end if;
|
end if;
|
end if;
|
end if;
|
end process;
|
end process;
|
|
|
|
Memory: MemorySimpleDualPortAsync
|
|
generic map(ADDRESS_WIDTH=>DEPTH_WIDTH,
|
|
DATA_WIDTH=>DATA_WIDTH,
|
|
INIT_VALUE=>'0')
|
|
port map(
|
|
clkA_i=>clk, enableA_i=>write_i,
|
|
addressA_i=>writeAddress, dataA_i=>data_i,
|
|
addressB_i=>readAddress, dataB_o=>data_o);
|
end architecture;
|
end architecture;
|
|
|
|
|
|
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|