URL
https://opencores.org/ocsvn/rio/rio/trunk
Subversion Repositories rio
Compare Revisions
- This comparison shows the changes necessary to convert path
/rio
- from Rev 32 to Rev 33
- ↔ Reverse comparison
Rev 32 → Rev 33
/branches/singleSymbol/rtl/vhdl/RioSerial.vhd
1358,251 → 1358,245
|
discardFrameOut <= '0'; |
|
if (fatalError_i = '1') then |
readWindowResetOut <= '1'; |
elsif (recoverActive_i = '1') then |
if ((fatalError_i = '1') or (recoverActive_i = '1') or |
(operational_i = '0')) then |
----------------------------------------------------------------------- |
-- This state is entered at startup or if any error has occurred. |
-- A port that is not initialized or in an error state should not |
-- transmit any packets. |
----------------------------------------------------------------------- |
|
-- Initialize framing before entering the operational state. |
frameState_o <= FRAME_IDLE; |
ackIdWindow_o <= ackId_i; |
frameState_o <= FRAME_IDLE; |
readWindowResetOut <= '1'; |
else |
if (operational_i = '0') then |
----------------------------------------------------------------------- |
-- This state is entered at startup. A port that is not initialized |
-- should only transmit idle sequences. |
----------------------------------------------------------------------- |
------------------------------------------------------------------- |
-- This state is the operational state. It relays frames and handle |
-- flow control. |
------------------------------------------------------------------- |
|
if (sendRestartFromRetry = '1') then |
-- Required to send a restart-from-retry. |
|
-- Initialize framing before entering the operational state. |
-- Send a restart-from-retry control symbol to acknowledge the restart |
-- of the frame. |
symbolControlRestartOut <= '1'; |
|
-- Make sure there wont be any timeout before the frame is |
-- starting to be retransmitted. |
timeSentSet_o <= '1'; |
|
-- Restart the frame transmission. |
-- Since the transmission-window is reset, it is ok to go to the |
-- FRAME_IDLE-state even if the present state was FRAME_DISCARD since |
-- we will end up in the discard state anyway after the frames has |
-- been resent. |
ackIdWindow_o <= ackId_i; |
frameState_o <= FRAME_IDLE; |
ackIdWindow_o <= ackId_i; |
readWindowResetOut <= '1'; |
else |
------------------------------------------------------------------- |
-- This state is the operational state. It relays frames and handle |
-- flow control. |
------------------------------------------------------------------- |
|
if (sendRestartFromRetry = '1') then |
-- Required to send a restart-from-retry. |
|
-- Send a restart-from-retry control symbol to acknowledge the restart |
-- of the frame. |
symbolControlRestartOut <= '1'; |
elsif (sendLinkRequest = '1') then |
-- Required to send a link-request. |
-- There is no need to restart the packet transmission since we do |
-- not yet know which packets that was successfully received by our |
-- link partner. Wait for the reply before anything is discarded. |
|
-- Make sure there wont be any timeout before the frame is |
-- starting to be retransmitted. |
timeSentSet_o <= '1'; |
-- Send a link-request symbol. |
symbolControlLinkRequestOut <= '1'; |
|
-- Restart the frame transmission. |
-- Since the transmission-window is reset, it is ok to go to the |
-- FRAME_IDLE-state even if the present state was FRAME_DISCARD since |
-- we will end up in the discard state anyway after the frames has |
-- been resent. |
ackIdWindow_o <= ackId_i; |
frameState_o <= FRAME_IDLE; |
readWindowResetOut <= '1'; |
elsif (sendLinkRequest = '1') then |
-- Required to send a link-request. |
-- There is no need to restart the packet transmission since we do |
-- not yet know which packets that was successfully received by our |
-- link partner. Wait for the reply before anything is discarded. |
-- Write the current timer value. |
timeSentSet_o <= '1'; |
elsif ((sendRestartFromRetry = '0') and (sendLinkRequest = '0') and |
(outputErrorStopped_i = '0')) then |
-- No control-symbol is required to be sent to the link-partner. |
-- Proceed to send a pending packet. |
|
-- Send a link-request symbol. |
symbolControlLinkRequestOut <= '1'; |
-- Check the current state of the frame transfer. |
case frameState_i is |
|
when FRAME_IDLE => |
--------------------------------------------------------------- |
-- No frame has been started. |
--------------------------------------------------------------- |
|
-- Write the current timer value. |
timeSentSet_o <= '1'; |
elsif ((sendRestartFromRetry = '0') and (sendLinkRequest = '0') and |
(outputErrorStopped_i = '0')) then |
-- No control-symbol is required to be sent to the link-partner. |
-- Proceed to send a pending packet. |
-- Wait for a new frame to arrive from the frame buffer. |
if (readWindowEmpty_i = '0') then |
-- Update the output from the frame buffer to contain the |
-- data when it is read later. |
readContentOut <= '1'; |
frameState_o <= FRAME_START; |
end if; |
|
-- Check the current state of the frame transfer. |
case frameState_i is |
|
when FRAME_IDLE => |
--------------------------------------------------------------- |
-- No frame has been started. |
--------------------------------------------------------------- |
when FRAME_START | FRAME_START_CONTINUE => |
------------------------------------------------------- |
-- Check if we are allowed to transmit this packet. |
------------------------------------------------------- |
-- The packet may be not allowed, i.e. a non-maintenance |
-- sent when only maintenance is allowed. The link-partner can be |
-- busy, i.e. not having enough buffers to receive the new packet |
-- in or the number of outstanding packets may be too large. |
-- This state should result in a start-of-frame if possible or |
-- end-of-frame if a frame has not been ended properly yet. |
|
-- Wait for a new frame to arrive from the frame buffer. |
if (readWindowEmpty_i = '0') then |
-- Update the output from the frame buffer to contain the |
-- data when it is read later. |
readContentOut <= '1'; |
frameState_o <= FRAME_START; |
end if; |
-- Check if the packet is allowed. |
if ((portEnable_i = '1') or |
(readContentData_i(19 downto 16) = FTYPE_MAINTENANCE_CLASS)) then |
-- Packet is allowed. |
|
when FRAME_START | FRAME_START_CONTINUE => |
------------------------------------------------------- |
-- Check if we are allowed to transmit this packet. |
------------------------------------------------------- |
-- The packet may be not allowed, i.e. a non-maintenance |
-- sent when only maintenance is allowed. The link-partner can be |
-- busy, i.e. not having enough buffers to receive the new packet |
-- in or the number of outstanding packets may be too large. |
-- This state should result in a start-of-frame if possible or |
-- end-of-frame if a frame has not been ended properly yet. |
-- Check if the link is able to accept the new frame. |
if ((bufferStatus_i /= "00000") and |
((unsigned(ackIdWindow_i)+1) /= unsigned(ackId_i))) then |
-- There are buffers ready to receive the new packet at the other |
-- side and there are ackIds left to tag it. |
-- The packet may be transmitted. |
|
-- Check if the packet is allowed. |
if ((portEnable_i = '1') or |
(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)+1) /= unsigned(ackId_i))) then |
-- There are buffers ready to receive the new packet at the other |
-- side and there are ackIds left to tag it. |
-- The packet may be transmitted. |
|
-- Read the next packet content and buffer the current output. |
readContentOut <= '1'; |
frameContent_o <= readContentData_i; |
|
-- Send a control symbol to start the packet and a status to |
-- complete the symbol. |
symbolControlStartOut <= '1'; |
|
-- Proceed to send the first packet data symbol containing |
-- the ackId. |
frameState_o <= FRAME_FIRST; |
else |
-- The link cannot accept the packet. |
-- Wait in this state and dont do anything. |
if (frameState_i = FRAME_START_CONTINUE) then |
symbolControlEndOut <= '1'; |
end if; |
readFrameRestartOut <= '1'; |
frameState_o <= FRAME_IDLE; |
end if; |
-- Read the next packet content and buffer the current output. |
readContentOut <= '1'; |
frameContent_o <= readContentData_i; |
|
-- Send a control symbol to start the packet and a status to |
-- complete the symbol. |
symbolControlStartOut <= '1'; |
|
-- Proceed to send the first packet data symbol containing |
-- the ackId. |
frameState_o <= FRAME_FIRST; |
else |
-- The packet is not allowed. |
-- Discard it. |
-- The link cannot accept the packet. |
-- Wait in this state and dont do anything. |
if (frameState_i = FRAME_START_CONTINUE) then |
symbolControlEndOut <= '1'; |
end if; |
frameState_o <= FRAME_DISCARD; |
readFrameRestartOut <= '1'; |
frameState_o <= FRAME_IDLE; |
end if; |
else |
-- The packet is not allowed. |
-- Discard it. |
if (frameState_i = FRAME_START_CONTINUE) then |
symbolControlEndOut <= '1'; |
end if; |
frameState_o <= FRAME_DISCARD; |
end if; |
|
when FRAME_FIRST => |
--------------------------------------------------------------- |
-- Send the first packet content containing our current |
-- ackId. |
--------------------------------------------------------------- |
when FRAME_FIRST => |
--------------------------------------------------------------- |
-- Send the first packet content containing our current |
-- ackId. |
--------------------------------------------------------------- |
|
-- Write a new data symbol and fill in our ackId on the |
-- packet. |
symbolDataOut <= '1'; |
symbolDataContentOut <= |
std_logic_vector(ackIdWindow_i) & "0" & frameContent_i(25 downto 0); |
-- Write a new data symbol and fill in our ackId on the |
-- packet. |
symbolDataOut <= '1'; |
symbolDataContentOut <= |
std_logic_vector(ackIdWindow_i) & "0" & frameContent_i(25 downto 0); |
|
-- Read the next frame content and go to next state to send it. |
-- Read the next frame content and go to next state to send it. |
readContentOut <= '1'; |
frameContent_o <= readContentData_i; |
frameState_o <= FRAME_MIDDLE; |
|
when FRAME_MIDDLE | FRAME_INSERT_WAIT => |
--------------------------------------------------------------- |
-- The frame has not been fully sent. |
-- Send a data symbol until the last part of the packet is |
-- detected. |
--------------------------------------------------------------- |
|
-- Write a new data symbol. |
symbolDataOut <= '1'; |
symbolDataContentOut <= frameContent_i; |
frameContent_o <= readContentData_i; |
|
-- Check if the packet is ending. |
if (readContentEnd_i = '1') then |
-- The packet is ending. |
readWindowNextOut <= '1'; |
frameState_o <= FRAME_LAST; |
elsif ((frameState_i = FRAME_MIDDLE) and (rxControlEmpty_i = '0')) then |
-- There is a pending control-symbol from the receiver. |
-- This must only be entered if the previous state was a data |
-- symbol, not if an idle symbol was inserted. |
frameState_o <= FRAME_INSERT_IDLE; |
else |
-- The packet is not ending. |
readContentOut <= '1'; |
frameContent_o <= readContentData_i; |
frameState_o <= FRAME_MIDDLE; |
|
when FRAME_MIDDLE | FRAME_INSERT_WAIT => |
--------------------------------------------------------------- |
-- The frame has not been fully sent. |
-- Send a data symbol until the last part of the packet is |
-- detected. |
--------------------------------------------------------------- |
|
-- Write a new data symbol. |
symbolDataOut <= '1'; |
symbolDataContentOut <= frameContent_i; |
frameContent_o <= readContentData_i; |
end if; |
|
-- Check if the packet is ending. |
if (readContentEnd_i = '1') then |
-- The packet is ending. |
readWindowNextOut <= '1'; |
frameState_o <= FRAME_LAST; |
elsif ((frameState_i = FRAME_MIDDLE) and (rxControlEmpty_i = '0')) then |
-- There is a pending control-symbol from the receiver. |
-- This must only be entered if the previous state was a data |
-- symbol, not if an idle symbol was inserted. |
frameState_o <= FRAME_INSERT_IDLE; |
else |
-- The packet is not ending. |
readContentOut <= '1'; |
frameState_o <= FRAME_MIDDLE; |
end if; |
when FRAME_INSERT_IDLE => |
----------------------------------------------------------------- |
-- Dont send a data-symbol this tick to allow for a pending |
-- control-symbol from the receiver to be inserted into the stream. |
----------------------------------------------------------------- |
|
when FRAME_INSERT_IDLE => |
----------------------------------------------------------------- |
-- Dont send a data-symbol this tick to allow for a pending |
-- control-symbol from the receiver to be inserted into the stream. |
----------------------------------------------------------------- |
symbolDataOut <= '0'; |
readContentOut <= '1'; |
frameState_o <= FRAME_INSERT_WAIT; |
|
when FRAME_LAST => |
----------------------------------------------------------------- |
-- Sending the last data symbol of a packet. |
-- If there are pending packets, they can be started immediatly, |
-- otherwise, the current packet should be ended. |
----------------------------------------------------------------- |
|
symbolDataOut <= '0'; |
-- Send the last data symbol of the packet. |
symbolDataOut <= '1'; |
symbolDataContentOut <= frameContent_i; |
|
-- Check if there are pending packets. |
if (readWindowEmpty_i = '0') then |
-- Pending packet exist. |
readContentOut <= '1'; |
frameState_o <= FRAME_INSERT_WAIT; |
|
when FRAME_LAST => |
----------------------------------------------------------------- |
-- Sending the last data symbol of a packet. |
-- If there are pending packets, they can be started immediatly, |
-- otherwise, the current packet should be ended. |
----------------------------------------------------------------- |
frameState_o <= FRAME_START_CONTINUE; |
else |
-- No pending packets. |
frameState_o <= FRAME_END; |
end if; |
|
-- Send the last data symbol of the packet. |
symbolDataOut <= '1'; |
symbolDataContentOut <= frameContent_i; |
-- Update the window ackId. |
ackIdWindow_o <= std_logic_vector(unsigned(ackIdWindow_i) + 1); |
|
-- Check if there are pending packets. |
if (readWindowEmpty_i = '0') then |
-- Pending packet exist. |
readContentOut <= '1'; |
frameState_o <= FRAME_START_CONTINUE; |
else |
-- No pending packets. |
frameState_o <= FRAME_END; |
end if; |
-- Start timeout supervision for the transmitted frame. |
timeSentSet_o <= '1'; |
|
-- Update the window ackId. |
ackIdWindow_o <= std_logic_vector(unsigned(ackIdWindow_i) + 1); |
when FRAME_END => |
----------------------------------------------------------------- |
-- There are no packets to directly follow the one that is ending. |
-- Mark the current packet as ended. |
----------------------------------------------------------------- |
|
-- Start timeout supervision for the transmitted frame. |
timeSentSet_o <= '1'; |
-- Send a control symbol to end the frame. |
symbolControlEndOut <= '1'; |
frameState_o <= FRAME_IDLE; |
|
when FRAME_END => |
----------------------------------------------------------------- |
-- There are no packets to directly follow the one that is ending. |
-- Mark the current packet as ended. |
----------------------------------------------------------------- |
when FRAME_DISCARD => |
--------------------------------------------------------------- |
-- The packet should be discarded. |
-- Hold any pending packets until there are no outstanding ones. |
--------------------------------------------------------------- |
|
-- Send a control symbol to end the frame. |
symbolControlEndOut <= '1'; |
-- Check that there are no outstanding packets. |
if(unsigned(ackIdWindow_i) = unsigned(ackId_i)) then |
-- No unacknowledged packets. |
-- It is now safe to remove the unallowed packet. |
discardFrameOut <= '1'; |
|
-- Go back and send a new frame. |
frameState_o <= FRAME_IDLE; |
|
when FRAME_DISCARD => |
--------------------------------------------------------------- |
-- The packet should be discarded. |
-- Hold any pending packets until there are no outstanding ones. |
--------------------------------------------------------------- |
|
-- Check that there are no outstanding packets. |
if(unsigned(ackIdWindow_i) = unsigned(ackId_i)) then |
-- No unacknowledged packets. |
-- It is now safe to remove the unallowed packet. |
discardFrameOut <= '1'; |
|
-- Go back and send a new frame. |
frameState_o <= FRAME_IDLE; |
else |
-- Still outstanding packets. |
-- Dont do anything. |
end if; |
|
when others => |
--------------------------------------------------------------- |
-- |
--------------------------------------------------------------- |
null; |
|
end case; |
end if; |
else |
-- Still outstanding packets. |
-- Dont do anything. |
end if; |
|
when others => |
--------------------------------------------------------------- |
-- |
--------------------------------------------------------------- |
null; |
|
end case; |
end if; |
end if; |
end process; |
/branches/singleSymbol/rtl/vhdl/RioLogicalCommon.vhd
0,0 → 1,512
------------------------------------------------------------------------------- |
-- RioLogicalCommon. |
------------------------------------------------------------------------------- |
-- Ingress: |
-- * Removes in-the-middle-CRC. |
-- * Forwards packets to logical-layer handlers depending on ftype and |
-- transaction (output as address). |
-- * Outputs header and deviceIDs in seperate accesses to facilitate 8- and |
-- 16-bit deviceAddress support. All fields are right-justified. |
-- Egress: |
-- * Adds CRC. |
-- * Receives packets from logical-layer handlers. |
------------------------------------------------------------------------------- |
-- REMARK: Egress; Places packets in different queues depending on the packet priority? |
-- REMARK: Use inputOutput/message/maintenance/gsm/...-strobes instead? |
-- REMARK: If the deviceId:s are removed, it will work for both 8/16-bit deviceIds. |
-- case (ftype) is |
-- when x"1" => |
-- -- Intervention-request class. |
-- gsmStb_o <= '1'; |
-- when x"2" => |
-- -- Request-class. |
-- if ((transaction = "0100") or |
-- (transaction = "1100") or (transaction = "1101") or |
-- (transaction = "1110") or (transaction = "1111")) then |
-- inputOutputStb_o <= '1'; |
-- else |
-- gsmStb_o <= '1'; |
-- end if; |
-- when x"5" => |
-- -- Write-class. |
-- if ((transaction = "0100") or (transaction = "0101") or |
-- (transaction = "1100") or (transaction = "1101") or |
-- (transaction = "1110")) then |
-- inputOutputStb_o <= '1'; |
-- elsif ((transaction = "0000") or (transaction = "0001")) then |
-- gsmStb_o <= '1'; |
-- end if; |
-- when x"6" => |
-- -- Streaming-Write class. |
-- inputOutputStb_o <= '1'; |
-- when x"7" => |
-- -- Flow-control class. |
-- flowControlStb_o <= '1'; |
-- when x"8" => |
-- -- Maintenance class. |
-- maintenanceStb_o <= '1'; |
-- when x"9" => |
-- -- Data-Streaming class. |
-- dataStreamingStb_o <= '1'; |
-- when x"a" => |
-- -- Doorbell class. |
-- -- REMARK: Make this belong to input/output since the packets |
-- -- and their responses look the same? |
-- messagePassingStb_o <= '1'; |
-- when x"b" => |
-- -- Message class. |
-- messagePassingStb_o <= '1'; |
-- when x"d" => |
-- -- Response class. |
-- -- REMARK: Seperate strobe for this??? |
-- if ((transaction = "0000") or (transaction = "1000")) then |
-- -- REMARK: Doorbell-response going in here as well... *sigh* |
-- -- REMARK: GSM-responses going in here as well... |
-- responseStb_o <= '1'; |
-- elsif (transaction = "0001") then |
-- messagePassing <= '1'; |
-- end if; |
-- when others => |
-- -- Unsupported ftype. |
-- -- REMARK: Discard this packet. |
-- end case; |
|
-- tt=00 |
-- 0: header(15:0);dest(7:0);src(7:0); |
-- 1: transaction(3:0) |
-- shifter: 32 (32 empty) |
-- tt=01 |
-- 0: header(15:0);dest(15:0); |
-- 1: src(15:0);transaction(3:0) |
-- shifter: 16 (48 empty) |
|
library ieee; |
use ieee.numeric_std.all; |
use ieee.std_logic_1164.all; |
use ieee.std_logic_unsigned.all; |
use work.rio_common.all; |
|
------------------------------------------------------------------------------- |
-- Entity for RioLogicalCommonIngress. |
------------------------------------------------------------------------------- |
entity RioLogicalCommonIngress is |
port( |
clk : in std_logic; |
areset_n : in std_logic; |
|
readFrameEmpty_i : in std_logic; |
readFrame_o : out std_logic; |
readContent_o : out std_logic; |
readContentEnd_i : in std_logic; |
readContentData_i : in std_logic_vector(31 downto 0); |
|
masterCyc_o : out std_logic; |
masterStb_o : out std_logic; |
masterAddress_o : out std_logic_vector(7 downto 0); |
masterData_o : out std_logic_vector(31 downto 0); |
masterAck_i : in std_logic); |
end entity; |
|
|
------------------------------------------------------------------------------- |
-- |
------------------------------------------------------------------------------- |
architecture RioLogicalCommonIngress of RioLogicalCommonIngress is |
|
begin |
|
process(clk, areset_n) |
begin |
if (areset_n = '0') then |
|
elsif (clk'event and clk = '1') then |
readContent_o <= '0'; |
|
case state is |
when IDLE => |
--------------------------------------------------------------------- |
-- |
--------------------------------------------------------------------- |
packetPosition <= 0; |
if (readFrameEmpty_i = '0') then |
readContent_o <= '1'; |
state <= WAIT_HEADER_0; |
end if; |
|
when WAIT_HEADER_0 => |
--------------------------------------------------------------------- |
-- |
--------------------------------------------------------------------- |
readContent_o <= '1'; |
state <= HEADER_0; |
|
when HEADER_0 => |
--------------------------------------------------------------------- |
-- |
--------------------------------------------------------------------- |
packetContent <= packetContent(31 downto 0) & readContentData_i; |
packetPosition <= packetPosition + 1; |
readContent_o <= '1'; |
|
tt <= readContentData_i(21 downto 20); |
ftype <= readContentData_i(19 downto 16); |
|
state <= HEADER_1; |
|
when HEADER_1 => |
--------------------------------------------------------------------- |
-- |
--------------------------------------------------------------------- |
packetContent <= packetContent(31 downto 0) & readContentData_i; |
packetPosition <= packetPosition + 1; |
|
if (tt = "00") then |
transaction <= readContentData_i(31 downto 28); |
elsif (tt = "01") then |
transaction <= readContentData_i(15 downto 12); |
end if; |
|
state <= SEND_HEADER; |
|
when SEND_HEADER => |
--------------------------------------------------------------------- |
-- |
--------------------------------------------------------------------- |
masterStb_o <= '1'; |
masterAddress_o <= ftype & transaction; |
masterData_o <= x"0000" & packetContent(63 downto 48); |
packetContent <= packetContent(47 downto 0) & x"0000"; |
|
state <= SEND_DESTINATION; |
|
when SEND_DESTINATION => |
--------------------------------------------------------------------- |
-- |
--------------------------------------------------------------------- |
if (masterAck_i = '1') then |
if (tt = "00") then |
masterData_o <= x"000000" & packetContent(63 downto 56); |
packetContent <= packetContent(55 downto 0) & x"00"; |
elsif (tt = "01") then |
masterData_o <= x"0000" & packetContent(63 downto 48); |
packetContent <= packetContent(31 downto 0) & readContentData_i; |
readContent_o <= '1'; |
end if; |
|
state <= SEND_SOURCE; |
end if; |
|
when SEND_SOURCE => |
--------------------------------------------------------------------- |
-- |
--------------------------------------------------------------------- |
if (masterAck_i = '1') then |
if (tt = "00") then |
masterData_o <= x"000000" & packetContent(63 downto 56); |
packetContent <= packetContent(55 downto 0) & x"00"; |
elsif (tt = "01") then |
masterData_o <= x"0000" & packetContent(63 downto 48); |
packetContent <= packetContent(47 downto 0) & x"0000"; |
end if; |
|
state <= FORWARD; |
end if; |
|
when FORWARD => |
--------------------------------------------------------------------- |
-- |
--------------------------------------------------------------------- |
if (masterAck_i = '1') then |
masterData_o <= packetContent(63 downto 32); |
|
packetPosition <= packetPosition + 1; |
|
-- REMARK: Rewrite depending on tt-field to compensate for |
-- different number of valid bits in the shifter... |
if (packetPosition < 20) then |
packetContent <= |
packetContent(31 downto 0) & readContentData_i; |
elsif (packetPosition = 20) then |
packetContent <= |
packetContent(31 downto 0) & readContentData_i(15 downto 0) & x"0000"; |
else |
packetContent <= |
packetContent(15 downto 0) & readContentData_i & x"0000"; |
end if; |
|
if (readContentEnd_i = '0') then |
readContent_o <= '1'; |
else |
readFrame_o <= '1'; |
state <= FORWARD_LAST; |
end if; |
end if; |
|
when FORWARD_LAST => |
--------------------------------------------------------------------- |
-- |
--------------------------------------------------------------------- |
if (masterAck_i = '1') then |
masterData_o <= packetContent(63 downto 32); |
state <= END_PACKET; |
end if; |
|
when END_PACKET => |
--------------------------------------------------------------------- |
-- |
--------------------------------------------------------------------- |
if (masterAck_i = '1') then |
state <= IDLE; |
end if; |
|
when others => |
--------------------------------------------------------------------- |
-- |
--------------------------------------------------------------------- |
state <= IDLE; |
end case; |
end if; |
end process; |
|
end architecture; |
|
|
|
|
------------------------------------------------------------------------------- |
-- RioLogicalMaintenanceRequest |
-- Addresses: 0x80 (maint read request) and 0x81 (maint write request). |
------------------------------------------------------------------------------- |
library ieee; |
use ieee.numeric_std.ALL; |
use ieee.std_logic_1164.all; |
use ieee.std_logic_unsigned.all; |
use work.rio_common.all; |
|
------------------------------------------------------------------------------- |
-- Entity for RioLogicalMaintenanceRequest. |
------------------------------------------------------------------------------- |
entity RioLogicalMaintenanceRequest is |
generic( |
DEVICE_IDENTITY : std_logic_vector(15 downto 0); |
DEVICE_VENDOR_IDENTITY : std_logic_vector(15 downto 0); |
DEVICE_REV : std_logic_vector(31 downto 0); |
ASSY_IDENTITY : std_logic_vector(15 downto 0); |
ASSY_VENDOR_IDENTITY : std_logic_vector(15 downto 0); |
ASSY_REV : std_logic_vector(15 downto 0); |
DEFAULT_BASE_DEVICE_ID : std_logic_vector(15 downto 0) := x"ffff"); |
port( |
clk : in std_logic; |
areset_n : in std_logic; |
|
slaveCyc_i : in std_logic; |
slaveStb_i : in std_logic; |
slaveAddress_i : in std_logic_vector(7 downto 0); |
slaveData_i : in std_logic_vector(31 downto 0); |
slaveAck_o : out std_logic); |
end entity; |
|
architecture RioLogicalMaintenanceRequest of RioLogicalMaintenanceRequest is |
|
begin |
|
slaveAck_o <= slaveAck; |
MaintenanceRequest: process(clk, areset_n) |
begin |
if (areset_n = '0') then |
|
elsif (clk'event and clk = '1') then |
if (slaveCyc_i = '0') then |
packetIndex <= 0; |
elsif (slaveStb_i = '1') then |
if (slaveAck = '0') then |
if (slaveAddress_i = x"80") then |
case (packetIndex) is |
when 0 => |
-- x"0000" & ackid & vc & crf & prio & tt & ftype |
when 1 => |
-- destId |
when 2 => |
-- srcId |
when 3 => |
-- transaction & wrsize & srcTID & hop & config_offset(20:13) |
when 4 => |
-- config_offset(12:0) & wdptr & rsrv & double-word(63:48) |
when 5 => |
-- double-word(47:16) |
when 6 => |
-- double-word(15:0) & crc(15:0) |
when others => |
-- REMARK: Larger packets not supported. |
end case; |
elsif (slaveAddress_i = x"81") then |
case (packetIndex) is |
when 0 => |
-- x"0000" & ackid & vc & crf & prio & tt & ftype |
when 1 => |
-- destId |
when 2 => |
-- srcId |
when 3 => |
-- transaction & rdsize & srcTID & hop & config_offset(20:13) |
when 4 => |
-- config_offset(12:0) & wdptr & rsrv & crc(15:0) |
when others => |
-- REMARK: Larger packets not supported. |
end case; |
end if; |
slaveAck <= '1'; |
else |
packetIndex <= packetIndex + 1; |
slaveAck <= '0'; |
end if; |
end if; |
end if; |
end process; |
|
|
----------------------------------------------------------------------------- |
-- findInPayload |
-- find out number of the bytes and first byte's position in the payload. |
----------------------------------------------------------------------------- |
findInPayload: process(wdptr, size) |
begin |
case size is |
when "0000" => |
reserved <= '0'; |
numberOfByte <= 1; |
if wdptr = '1' then |
pos <= 4; |
else |
pos <= 0; |
end if; |
when "0001" => |
reserved <= '0'; |
numberOfByte <= 1; |
if wdptr = '1' then |
pos <= 5; |
else |
pos <= 1; |
end if; |
when "0010" => |
reserved <= '0'; |
numberOfByte <= 1; |
if wdptr = '1' then |
pos <= 6; |
else |
pos <= 2; |
end if; |
when "0011" => |
reserved <= '0'; |
numberOfByte <= 1; |
if wdptr = '1' then |
pos <= 7; |
else |
pos <= 3; |
end if; |
when "0100" => |
reserved <= '0'; |
numberOfByte <= 2; |
if wdptr = '1' then |
pos <= 4; |
else |
pos <= 0; |
end if; |
when "0101" => |
reserved <= '0'; |
numberOfByte <= 3; |
if wdptr = '1' then |
pos <= 5; |
else |
pos <= 0; |
end if; |
when "0110" => |
reserved <= '0'; |
numberOfByte <= 2; |
if wdptr = '1' then |
pos <= 6; |
else |
pos <= 2; |
end if; |
when "0111" => |
reserved <= '0'; |
numberOfByte <= 5; |
if wdptr = '1' then |
pos <= 3; |
else |
pos <= 0; |
end if; |
when "1000" => |
reserved <= '0'; |
numberOfByte <= 4; |
if wdptr = '1' then |
pos <= 4; |
else |
pos <= 0; |
end if; |
when "1001" => |
reserved <= '0'; |
numberOfByte <= 6; |
if wdptr = '1' then |
pos <= 2; |
else |
pos <= 0; |
end if; |
when "1010" => |
reserved <= '0'; |
numberOfByte <= 7; |
if wdptr = '1' then |
pos <= 1; |
else |
pos <= 0; |
end if; |
when "1011" => |
reserved <= '0'; |
if wdptr = '1' then |
numberOfByte <= 16; |
else |
numberOfByte <= 8; |
end if; |
pos <= 0; |
when "1100" => |
reserved <= '0'; |
if wdptr = '1' then |
numberOfByte <= 64; |
else |
numberOfByte <= 32; |
end if; |
pos <= 0; |
when "1101" => |
if wdptr = '1' then |
reserved <= '0'; |
numberOfByte <= 128; |
else |
reserved <= '1'; |
numberOfByte <= 96; |
end if; |
pos <= 0; |
when "1110" => |
if wdptr = '1' then |
numberOfByte <= 192; |
else |
numberOfByte <= 160; |
end if; |
reserved <= '1'; |
pos <= 0; |
when "1111" => |
if wdptr = '1' then |
reserved <= '0'; |
numberOfByte <= 256; |
else |
reserved <= '1'; |
numberOfByte <= 224; |
end if; |
pos <= 0; |
when others => |
reserved <= '1'; |
numberOfByte <= 0; |
pos <= 0; |
end case; |
end process; |
|
end architecture; |