Line 612... |
Line 612... |
statusReceived_o : out std_logic;
|
statusReceived_o : out std_logic;
|
numberSentLinkRequests_i : in std_logic_vector(1 downto 0);
|
numberSentLinkRequests_i : in std_logic_vector(1 downto 0);
|
numberSentLinkRequests_o : out std_logic_vector(1 downto 0);
|
numberSentLinkRequests_o : out std_logic_vector(1 downto 0);
|
outputErrorStopped_i : in std_logic;
|
outputErrorStopped_i : in std_logic;
|
outputErrorStopped_o : out std_logic;
|
outputErrorStopped_o : out std_logic;
|
|
fatalError_i : in std_logic;
|
|
fatalError_o : out std_logic;
|
recoverActive_i : in std_logic;
|
recoverActive_i : in std_logic;
|
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(4 downto 0);
|
frameState_i : in std_logic_vector(6 downto 0);
|
frameState_o : out std_logic_vector(4 downto 0);
|
frameState_o : out std_logic_vector(6 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(32*NUMBER_WORDS-1 downto 0);
|
frameContent_o : out std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
frameContent_o : out std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
counter_i : in std_logic_vector(3 downto 0);
|
counter_i : in std_logic_vector(3 downto 0);
|
Line 677... |
Line 679... |
signal ackIdCurrent, ackIdNext : std_logic_vector(4 downto 0);
|
signal ackIdCurrent, ackIdNext : std_logic_vector(4 downto 0);
|
signal bufferStatusCurrent, bufferStatusNext : std_logic_vector(4 downto 0);
|
signal bufferStatusCurrent, bufferStatusNext : std_logic_vector(4 downto 0);
|
signal statusReceivedCurrent, statusReceivedNext : std_logic;
|
signal statusReceivedCurrent, statusReceivedNext : std_logic;
|
signal numberSentLinkRequestsCurrent, numberSentLinkRequestsNext : std_logic_vector(1 downto 0);
|
signal numberSentLinkRequestsCurrent, numberSentLinkRequestsNext : std_logic_vector(1 downto 0);
|
signal outputErrorStoppedCurrent, outputErrorStoppedNext : std_logic;
|
signal outputErrorStoppedCurrent, outputErrorStoppedNext : std_logic;
|
|
signal fatalErrorCurrent, fatalErrorNext : std_logic;
|
signal recoverActiveCurrent, recoverActiveNext : std_logic;
|
signal recoverActiveCurrent, recoverActiveNext : std_logic;
|
signal recoverCounterCurrent, recoverCounterNext : std_logic_vector(4 downto 0);
|
signal recoverCounterCurrent, recoverCounterNext : std_logic_vector(4 downto 0);
|
signal ackIdWindowCurrent, ackIdWindowNext : std_logic_vector(4 downto 0);
|
signal ackIdWindowCurrent, ackIdWindowNext : std_logic_vector(4 downto 0);
|
signal frameStateCurrent, frameStateNext : std_logic_vector(4 downto 0);
|
signal frameStateCurrent, frameStateNext : std_logic_vector(6 downto 0);
|
signal frameWordCounterCurrent, frameWordCounterNext : std_logic_vector(1 downto 0);
|
signal frameWordCounterCurrent, frameWordCounterNext : std_logic_vector(1 downto 0);
|
signal frameContentCurrent, frameContentNext : std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
signal frameContentCurrent, frameContentNext : std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
signal counterCurrent, counterNext : std_logic_vector(3 downto 0);
|
signal counterCurrent, counterNext : std_logic_vector(3 downto 0);
|
signal symbolsTransmittedCurrent, symbolsTransmittedNext : std_logic_vector(7 downto 0);
|
signal symbolsTransmittedCurrent, symbolsTransmittedNext : std_logic_vector(7 downto 0);
|
|
|
Line 722... |
Line 725... |
ackIdCurrent <= (others=>'0');
|
ackIdCurrent <= (others=>'0');
|
bufferStatusCurrent <= (others=>'0');
|
bufferStatusCurrent <= (others=>'0');
|
statusReceivedCurrent <= '0';
|
statusReceivedCurrent <= '0';
|
numberSentLinkRequestsCurrent <= (others=>'0');
|
numberSentLinkRequestsCurrent <= (others=>'0');
|
outputErrorStoppedCurrent <= '0';
|
outputErrorStoppedCurrent <= '0';
|
|
fatalErrorCurrent <= '0';
|
recoverActiveCurrent <= '0';
|
recoverActiveCurrent <= '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');
|
Line 738... |
Line 742... |
ackIdCurrent <= ackIdNext;
|
ackIdCurrent <= ackIdNext;
|
bufferStatusCurrent <= bufferStatusNext;
|
bufferStatusCurrent <= bufferStatusNext;
|
statusReceivedCurrent <= statusReceivedNext;
|
statusReceivedCurrent <= statusReceivedNext;
|
numberSentLinkRequestsCurrent <= numberSentLinkRequestsNext;
|
numberSentLinkRequestsCurrent <= numberSentLinkRequestsNext;
|
outputErrorStoppedCurrent <= outputErrorStoppedNext;
|
outputErrorStoppedCurrent <= outputErrorStoppedNext;
|
|
fatalErrorCurrent <= fatalErrorNext;
|
recoverActiveCurrent <= recoverActiveNext;
|
recoverActiveCurrent <= recoverActiveNext;
|
recoverCounterCurrent <= recoverCounterNext;
|
recoverCounterCurrent <= recoverCounterNext;
|
ackIdWindowCurrent <= ackIdWindowNext;
|
ackIdWindowCurrent <= ackIdWindowNext;
|
frameStateCurrent <= frameStateNext;
|
frameStateCurrent <= frameStateNext;
|
frameWordCounterCurrent <= frameWordCounterNext;
|
frameWordCounterCurrent <= frameWordCounterNext;
|
Line 777... |
Line 782... |
ackId_i=>ackIdCurrent, ackId_o=>ackIdNext,
|
ackId_i=>ackIdCurrent, ackId_o=>ackIdNext,
|
bufferStatus_i=>bufferStatusCurrent, bufferStatus_o=>bufferStatusNext,
|
bufferStatus_i=>bufferStatusCurrent, bufferStatus_o=>bufferStatusNext,
|
statusReceived_i=>statusReceivedCurrent, statusReceived_o=>statusReceivedNext,
|
statusReceived_i=>statusReceivedCurrent, statusReceived_o=>statusReceivedNext,
|
numberSentLinkRequests_i=>numberSentLinkRequestsCurrent, numberSentLinkRequests_o=>numberSentLinkRequestsNext,
|
numberSentLinkRequests_i=>numberSentLinkRequestsCurrent, numberSentLinkRequests_o=>numberSentLinkRequestsNext,
|
outputErrorStopped_i=>outputErrorStoppedCurrent, outputErrorStopped_o=>outputErrorStoppedNext,
|
outputErrorStopped_i=>outputErrorStoppedCurrent, outputErrorStopped_o=>outputErrorStoppedNext,
|
|
fatalError_i=>fatalErrorCurrent, fatalError_o=>fatalErrorNext,
|
recoverActive_i=>recoverActiveCurrent, recoverActive_o=>recoverActiveNext,
|
recoverActive_i=>recoverActiveCurrent, recoverActive_o=>recoverActiveNext,
|
recoverCounter_i=>recoverCounterCurrent, recoverCounter_o=>recoverCounterNext,
|
recoverCounter_i=>recoverCounterCurrent, recoverCounter_o=>recoverCounterNext,
|
ackIdWindow_i=>ackIdWindowCurrent, ackIdWindow_o=>ackIdWindowNext,
|
ackIdWindow_i=>ackIdWindowCurrent, ackIdWindow_o=>ackIdWindowNext,
|
frameState_i=>frameStateCurrent, frameState_o=>frameStateNext,
|
frameState_i=>frameStateCurrent, frameState_o=>frameStateNext,
|
frameWordCounter_i=>frameWordCounterCurrent, frameWordCounter_o=>frameWordCounterNext,
|
frameWordCounter_i=>frameWordCounterCurrent, frameWordCounter_o=>frameWordCounterNext,
|
Line 864... |
Line 870... |
statusReceived_o : out std_logic;
|
statusReceived_o : out std_logic;
|
numberSentLinkRequests_i : in std_logic_vector(1 downto 0);
|
numberSentLinkRequests_i : in std_logic_vector(1 downto 0);
|
numberSentLinkRequests_o : out std_logic_vector(1 downto 0);
|
numberSentLinkRequests_o : out std_logic_vector(1 downto 0);
|
outputErrorStopped_i : in std_logic;
|
outputErrorStopped_i : in std_logic;
|
outputErrorStopped_o : out std_logic;
|
outputErrorStopped_o : out std_logic;
|
|
fatalError_i : in std_logic;
|
|
fatalError_o : out std_logic;
|
recoverActive_i : in std_logic;
|
recoverActive_i : in std_logic;
|
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(4 downto 0);
|
frameState_i : in std_logic_vector(6 downto 0);
|
frameState_o : out std_logic_vector(4 downto 0);
|
frameState_o : out std_logic_vector(6 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(32*NUMBER_WORDS-1 downto 0);
|
frameContent_o : out std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
frameContent_o : out std_logic_vector(32*NUMBER_WORDS-1 downto 0);
|
counter_i : in std_logic_vector(3 downto 0);
|
counter_i : in std_logic_vector(3 downto 0);
|
Line 907... |
Line 915... |
|
|
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???
|
-- REMARK: Binary coding???
|
constant FRAME_START : std_logic_vector(4 downto 0) := "00001";
|
constant FRAME_IDLE : std_logic_vector(6 downto 0) := "0000001";
|
constant FRAME_CHECK : std_logic_vector(4 downto 0) := "00010";
|
constant FRAME_START : std_logic_vector(6 downto 0) := "0000010";
|
constant FRAME_ACKID : std_logic_vector(4 downto 0) := "00100";
|
constant FRAME_FIRST : std_logic_vector(6 downto 0) := "0000100";
|
constant FRAME_BODY : std_logic_vector(4 downto 0) := "01000";
|
constant FRAME_MIDDLE : std_logic_vector(6 downto 0) := "0001000";
|
constant FRAME_END : std_logic_vector(4 downto 0) := "10000";
|
constant FRAME_LAST : std_logic_vector(6 downto 0) := "0010000";
|
|
constant FRAME_END : std_logic_vector(6 downto 0) := "0100000";
|
|
constant FRAME_DISCARD : std_logic_vector(6 downto 0) := "1000000";
|
|
|
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 1008... |
Line 1018... |
ackId_i, ackIdWindow_i, bufferStatus_i, statusReceived_i,
|
ackId_i, ackIdWindow_i, bufferStatus_i, statusReceived_i,
|
numberSentLinkRequests_i,
|
numberSentLinkRequests_i,
|
operational_i,
|
operational_i,
|
txControlEmpty_i, txControlStype0,
|
txControlEmpty_i, txControlStype0,
|
txControlParameter0, txControlParameter1,
|
txControlParameter0, txControlParameter1,
|
timeSentExpired_i)
|
timeSentExpired_i,
|
|
fatalError_i)
|
begin
|
begin
|
outputErrorStopped_o <= outputErrorStopped_i;
|
outputErrorStopped_o <= outputErrorStopped_i;
|
|
fatalError_o <= fatalError_i;
|
recoverActive_o <= recoverActive_i;
|
recoverActive_o <= recoverActive_i;
|
recoverCounter_o <= recoverCounter_i;
|
recoverCounter_o <= recoverCounter_i;
|
ackId_o <= ackId_i;
|
ackId_o <= ackId_i;
|
bufferStatus_o <= bufferStatus_i;
|
bufferStatus_o <= bufferStatus_i;
|
statusReceived_o <= statusReceived_i;
|
statusReceived_o <= statusReceived_i;
|
Line 1025... |
Line 1037... |
readFrameOut <= '0';
|
readFrameOut <= '0';
|
|
|
sendRestartFromRetryOut <= '0';
|
sendRestartFromRetryOut <= '0';
|
sendLinkRequestOut <= '0';
|
sendLinkRequestOut <= '0';
|
|
|
if (recoverActive_i = '1') then
|
if (fatalError_i = '1') then
|
if (ackId_i /= recoverCounter_i) then
|
outputErrorStopped_o <= '0';
|
ackId_o <= std_logic_vector(unsigned(ackId_i) + 1);
|
fatalError_o <= '0';
|
readFrameOut <= '1';
|
elsif (recoverActive_i = '1') then
|
else
|
if (ackId_i = recoverCounter_i) then
|
recoverActive_o <= '0';
|
recoverActive_o <= '0';
|
outputErrorStopped_o <= '0';
|
outputErrorStopped_o <= '0';
|
|
else
|
|
ackId_o <= std_logic_vector(unsigned(ackId_i) + 1);
|
|
readFrameOut <= '1';
|
end if;
|
end if;
|
else
|
else
|
if (operational_i = '0') then
|
if (operational_i = '0') then
|
if (txControlEmpty_i = '0') then
|
if (txControlEmpty_i = '0') then
|
if (txControlStype0 = STYPE0_STATUS) then
|
if (txControlStype0 = STYPE0_STATUS) then
|
Line 1073... |
Line 1088... |
-- 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.
|
-- REMARK: What to do here???
|
|
--readWindowReset_o <= '1';
|
-- Indicate that a fatal error has occurred.
|
--stateNext <= STATE_UNINITIALIZED;
|
fatalError_o <= '1';
|
end if;
|
end if;
|
else
|
else
|
sendLinkRequestOut <= '1';
|
sendLinkRequestOut <= '1';
|
numberSentLinkRequests_o <= NUMBER_LINK_RESPONSE_RETRIES;
|
numberSentLinkRequests_o <= NUMBER_LINK_RESPONSE_RETRIES;
|
outputErrorStopped_o <= '1';
|
outputErrorStopped_o <= '1';
|
Line 1167... |
Line 1182... |
-- 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.
|
|
fatalError_o <= '1';
|
|
|
-- REMARK: What to do here???
|
-- REMARK: What to do here???
|
--readWindowReset_o <= '1';
|
--readWindowReset_o <= '1';
|
--stateNext <= STATE_UNINITIALIZED;
|
--stateNext <= STATE_UNINITIALIZED;
|
end if;
|
end if;
|
else
|
else
|
Line 1252... |
Line 1271... |
-- 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, recoverCounter_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)
|
begin
|
begin
|
readFrameRestartOut <= '0';
|
readFrameRestartOut <= '0';
|
readWindowResetOut <= '0';
|
readWindowResetOut <= '0';
|
readWindowNextOut <= '0';
|
readWindowNextOut <= '0';
|
readContentOut <= '0';
|
readContentOut <= '0';
|
Line 1273... |
Line 1293... |
symbolControlStartOut <= '0';
|
symbolControlStartOut <= '0';
|
symbolControlEndOut <= '0';
|
symbolControlEndOut <= '0';
|
symbolDataOut <= '0';
|
symbolDataOut <= '0';
|
symbolDataContentOut <= (others => '0');
|
symbolDataContentOut <= (others => '0');
|
|
|
if (recoverActive_i = '1') then
|
if (fatalError_i = '1') then
|
|
readWindowResetOut <= '1';
|
|
elsif (recoverActive_i = '1') then
|
-- REMARK: Make sure idle is generated when this state is active...
|
-- REMARK: Make sure idle is generated when this state is active...
|
ackIdWindow_o <= recoverCounter_i;
|
ackIdWindow_o <= ackId_i;
|
frameState_o <= FRAME_START;
|
frameState_o <= FRAME_IDLE;
|
|
|
if (ackId_i /= recoverCounter_i) then
|
|
-- REMARK: Discard packets; readFrameOut <= '1';
|
|
else
|
|
readWindowResetOut <= '1';
|
readWindowResetOut <= '1';
|
end if;
|
|
else
|
else
|
if (operational_i = '0') then
|
if (operational_i = '0') then
|
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
-- 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???
|
-- REMARK: Only do this when the portInitialized becomes asserted???
|
frameState_o <= FRAME_START;
|
frameState_o <= FRAME_IDLE;
|
ackIdWindow_o <= ackId_i;
|
ackIdWindow_o <= ackId_i;
|
readWindowResetOut <= '1';
|
readWindowResetOut <= '1';
|
else
|
else
|
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
-- This state is the operational state. It relays frames and handle
|
-- This state is the operational state. It relays frames and handle
|
Line 1312... |
Line 1329... |
-- starting to be retransmitted.
|
-- starting to be retransmitted.
|
timeSentSet_o <= '1';
|
timeSentSet_o <= '1';
|
|
|
-- Restart the frame transmission.
|
-- Restart the frame transmission.
|
ackIdWindow_o <= ackId_i;
|
ackIdWindow_o <= ackId_i;
|
frameState_o <= FRAME_START;
|
frameState_o <= FRAME_IDLE;
|
readWindowResetOut <= '1';
|
readWindowResetOut <= '1';
|
end if;
|
end if;
|
|
|
if (sendLinkRequest = '1') then
|
if (sendLinkRequest = '1') then
|
-- Dont restart the packet transmission since we do not yet know which
|
-- Dont restart the packet transmission since we do not yet know which
|
Line 1335... |
Line 1352... |
-- 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...
|
|
|
case frameState_i is
|
case frameState_i is
|
|
|
when FRAME_START =>
|
when FRAME_IDLE =>
|
---------------------------------------------------------------
|
---------------------------------------------------------------
|
-- No frame has been started.
|
-- No frame has been started.
|
---------------------------------------------------------------
|
---------------------------------------------------------------
|
|
|
-- Wait for a new frame to arrive from the frame buffer,
|
-- Wait for a new frame to arrive from the frame buffer.
|
-- for new buffers to be available at the link-partner
|
if (readWindowEmpty_i = '0') then
|
-- and also check that a maximum 31 frames are outstanding.
|
|
-- REMARK: Only update readContent_o in the last instance
|
|
-- if cascaded...
|
|
if ((readWindowEmpty_i = '0') and
|
|
(bufferStatus_i /= "00000") and
|
|
((unsigned(ackIdWindow_i) - unsigned(ackId_i)) /= 31)) then
|
|
-- New data is available for transmission and there
|
|
-- is room to receive it at the other side.
|
|
|
|
-- Indicate that a control symbol has been sent to start the
|
|
-- transmission of the frame.
|
|
frameState_o <= FRAME_CHECK;
|
|
|
|
-- 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';
|
|
|
|
-- Indicate that a control symbol has been sent to start the
|
|
-- transmission of the frame.
|
|
frameState_o <= FRAME_START;
|
end if;
|
end if;
|
|
|
when FRAME_CHECK =>
|
when FRAME_START =>
|
-------------------------------------------------------
|
-------------------------------------------------------
|
-- Check if we are allowed to transmit this packet.
|
-- Check if we are allowed to transmit this packet.
|
-------------------------------------------------------
|
-------------------------------------------------------
|
-- REMARK: Merge this state with the one above or it will be
|
-- The packet may be either not allowed, i.e. a non-maintenance
|
-- impossible to send packet back-to-back...
|
-- sent when only maintenance is allowed. The link-partner can be
|
|
-- busy, i.e. no having enough buffers to receive the new packet
|
|
-- in or the number of outstanding packets may be too large.
|
|
-- REMARK: Only update readContent_o in the last instance
|
|
-- if cascaded...
|
|
|
-- Check if this packet is allowed to be transmitted.
|
-- Check if the packet is allowed.
|
if ((portEnable_i = '1') or
|
if ((portEnable_i = '1') or
|
(readContentData_i(19 downto 16) = FTYPE_MAINTENANCE_CLASS)) then
|
(readContentData_i(19 downto 16) = FTYPE_MAINTENANCE_CLASS)) then
|
|
-- Packet is allowed.
|
|
|
|
-- Check if the link is able to accept the new frame.
|
|
if ((bufferStatus_i /= "00000") and
|
|
((unsigned(ackIdWindow_i) - unsigned(ackId_i)) /= 31)) then
|
|
-- New data is available for transmission and there
|
|
-- 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
|
-- Indicate that a control symbol has been sent to start the
|
-- transmission of the frame.
|
-- transmission of the frame.
|
frameState_o <= FRAME_ACKID;
|
|
frameWordCounter_o <= readContentWords_i;
|
frameWordCounter_o <= readContentWords_i;
|
frameContent_o <= readContentData_i;
|
frameContent_o <= readContentData_i;
|
readContentOut <= '1';
|
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';
|
else
|
|
-- The packet should be discarded.
|
|
-- Send idle-sequence.
|
|
|
|
-- Check that there are no outstanding packets that
|
|
-- has not been acknowledged.
|
|
if(unsigned(ackIdWindow_i) = unsigned(ackId_i)) then
|
|
-- No unacknowledged packets.
|
|
-- It is now safe to remove the unallowed frame.
|
|
-- REMARK: Discard packets; readFrameOut <= '1';
|
|
|
|
-- Go back and send a new frame.
|
-- Proceed to send the first packet data symbol containing
|
frameState_o <= FRAME_START;
|
-- the ackId.
|
|
frameState_o <= FRAME_FIRST;
|
|
else
|
|
-- The link cannot accept the packet.
|
|
-- Wait in this state and dont do anything.
|
end if;
|
end if;
|
|
else
|
|
-- The packet is not allowed.
|
|
-- Discard it.
|
|
frameState_o <= FRAME_DISCARD;
|
end if;
|
end if;
|
|
|
when FRAME_ACKID =>
|
when FRAME_FIRST =>
|
---------------------------------------------------------------
|
---------------------------------------------------------------
|
-- Send the first packet content containing our current
|
-- Send the first packet content containing our current
|
-- ackId.
|
-- ackId.
|
---------------------------------------------------------------
|
---------------------------------------------------------------
|
|
|
Line 1424... |
Line 1440... |
frameContent_o <= readContentData_i;
|
frameContent_o <= readContentData_i;
|
readContentOut <= '1';
|
readContentOut <= '1';
|
end if;
|
end if;
|
|
|
-- Continue to send the rest of the body of the packet.
|
-- Continue to send the rest of the body of the packet.
|
frameState_o <= FRAME_BODY;
|
frameState_o <= FRAME_MIDDLE;
|
|
|
when FRAME_BODY =>
|
when FRAME_MIDDLE =>
|
---------------------------------------------------------------
|
---------------------------------------------------------------
|
-- The frame has not been fully sent.
|
-- The frame has not been fully sent.
|
-- Send a data symbol.
|
-- Send a data symbol until the last part of the packet is
|
|
-- detected.
|
---------------------------------------------------------------
|
---------------------------------------------------------------
|
-- REMARK: There will be idle symbols generated here if the
|
|
-- end-of-packet cannot be generated directly following the last
|
|
-- data symbol... need to rewrite PacketBufferWindow to indicate
|
|
-- the end at the last word.
|
|
-- REMARK: Dont send anything if there is a pending symbol in the
|
-- 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
|
-- rx-control fifo to let it be transmitted in the middle of the
|
-- packet...
|
-- packet...
|
|
|
-- Write a new data symbol.
|
-- Write a new data symbol.
|
Line 1450... |
Line 1463... |
frameWordCounter_o <=
|
frameWordCounter_o <=
|
std_logic_vector(unsigned(frameWordCounter_i) - 1);
|
std_logic_vector(unsigned(frameWordCounter_i) - 1);
|
frameContent_o <=
|
frameContent_o <=
|
frameContent_i((32*(NUMBER_WORDS-1))-1 downto 0) & x"00000000";
|
frameContent_i((32*(NUMBER_WORDS-1))-1 downto 0) & x"00000000";
|
else
|
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.
|
-- Update the window to the next frame.
|
-- It takes one tick for the output from the frame
|
-- It takes one tick for the output from the frame
|
-- buffer to get updated.
|
-- buffer to get updated.
|
readWindowNextOut <= '1';
|
readWindowNextOut <= '1';
|
|
|
-- Proceed to check if there is another frame to start
|
-- Proceed to check if there is another frame to start
|
-- with directly.
|
-- with directly.
|
frameState_o <= FRAME_END;
|
frameState_o <= FRAME_LAST;
|
else
|
else
|
frameWordCounter_o <= readContentWords_i;
|
|
frameContent_o <= readContentData_i;
|
|
readContentOut <= '1';
|
readContentOut <= '1';
|
end if;
|
end if;
|
end if;
|
end if;
|
|
|
when FRAME_END =>
|
when FRAME_LAST =>
|
---------------------------------------------------------------
|
---------------------------------------------------------------
|
-- A frame has ended and the window has been updated.
|
-- A frame has ended and the window has been updated.
|
-- Check if the next symbol should end the frame or if a
|
-- Check if the next symbol should end the frame or if a
|
-- new one should be started.
|
-- new one should be started.
|
---------------------------------------------------------------
|
---------------------------------------------------------------
|
|
|
-- Check if there is a new frame pending.
|
-- Write a new data symbol.
|
if (readWindowEmpty_i = '1') then
|
symbolDataOut <= '1';
|
-- No new frame is pending.
|
symbolDataContentOut <=
|
|
frameContent_i((32*NUMBER_WORDS)-1 downto (32*(NUMBER_WORDS-1)));
|
-- Send a control symbol to end the packet.
|
|
symbolControlEndOut <= '1';
|
|
end if;
|
|
|
|
|
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
|
-- 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';
|
|
|
-- Start a new frame the next time.
|
-- Note that the packet must be ended if the link-partner
|
|
-- cannot receive it.
|
|
if ((readWindowEmpty_i = '0') and
|
|
(bufferStatus_i /= "00000") and
|
|
((unsigned(ackIdWindow_i) - unsigned(ackId_i)) /= 31)) then
|
|
readContentOut <= '1';
|
frameState_o <= FRAME_START;
|
frameState_o <= FRAME_START;
|
|
else
|
|
frameState_o <= FRAME_END;
|
|
end if;
|
|
end if;
|
|
|
|
when FRAME_END =>
|
|
-----------------------------------------------------------------
|
|
--
|
|
-----------------------------------------------------------------
|
|
|
|
-- Start a new frame the next time.
|
|
frameState_o <= FRAME_IDLE;
|
|
|
|
-- Send a control symbol to end the packet.
|
|
symbolControlEndOut <= '1';
|
|
|
|
when FRAME_DISCARD =>
|
|
---------------------------------------------------------------
|
|
--
|
|
---------------------------------------------------------------
|
|
-- The packet should be discarded.
|
|
-- Send idle-sequence.
|
|
|
|
-- Check that there are no outstanding packets that
|
|
-- has not been acknowledged.
|
|
if(unsigned(ackIdWindow_i) = unsigned(ackId_i)) then
|
|
-- No unacknowledged packets.
|
|
-- It is now safe to remove the unallowed frame.
|
|
-- REMARK: Discard packet; readFrameOut <= '1';
|
|
|
|
-- Go back and send a new frame.
|
|
frameState_o <= FRAME_IDLE;
|
|
end if;
|
|
|
when others =>
|
when others =>
|
---------------------------------------------------------------
|
---------------------------------------------------------------
|
--
|
--
|
---------------------------------------------------------------
|
---------------------------------------------------------------
|
Line 1570... |
Line 1626... |
|
|
process(linkInitialized_i, ackIdStatus_i, portInitialized_i,
|
process(linkInitialized_i, ackIdStatus_i, portInitialized_i,
|
operational_i, counter_i, statusReceived_i, symbolsTransmitted_i,
|
operational_i, counter_i, statusReceived_i, symbolsTransmitted_i,
|
rxControlEmpty_i,
|
rxControlEmpty_i,
|
symbolControlStype1, symbolData,
|
symbolControlStype1, symbolData,
|
rxControlStype0, rxControlParameter0, rxControlParameter1)
|
rxControlStype0, rxControlParameter0, rxControlParameter1,
|
|
fatalError_i)
|
begin
|
begin
|
operational_o <= operational_i;
|
operational_o <= operational_i;
|
counter_o <= counter_i;
|
counter_o <= counter_i;
|
symbolsTransmitted_o <= symbolsTransmitted_i;
|
symbolsTransmitted_o <= symbolsTransmitted_i;
|
rxControlUpdateOut <= '0';
|
rxControlUpdateOut <= '0';
|
Line 1582... |
Line 1639... |
controlValidOut <= '0';
|
controlValidOut <= '0';
|
stype0Out <= STYPE0_STATUS;
|
stype0Out <= STYPE0_STATUS;
|
parameter0Out <= ackIdStatus_i;
|
parameter0Out <= ackIdStatus_i;
|
parameter1Out <= "11111";
|
parameter1Out <= "11111";
|
|
|
|
if (fatalError_i = '1') then
|
|
operational_o <= '0';
|
|
counter_o <= NUMBER_STATUS_TRANSMIT;
|
|
symbolsTransmitted_o <= (others=>'0');
|
|
else
|
-- Check the operational state.
|
-- Check the operational state.
|
if (operational_i = '0') then
|
if (operational_i = '0') then
|
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
-- 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.
|
Line 1696... |
Line 1758... |
-- 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';
|
end if;
|
end if;
|
end if;
|
end if;
|
|
end if;
|
end process;
|
end process;
|
|
|
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
-- N pipeline stage.
|
-- N 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
|