OpenCores
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 39 to Rev 40
    Reverse comparison

Rev 39 → Rev 40

/branches/singleSymbol/bench/vhdl/TestRioSerial.vhd
40,9 → 40,36
-- from http://www.opencores.org/lgpl.shtml
--
-------------------------------------------------------------------------------
-- REMARK: Add testcase to check that no packets are sent when the linkpartner
-- has no buffers left.
 
 
-------------------------------------------------------------------------------
--
-------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use work.rio_common.all;
 
package TestRioSerialPackage is
type MessageSymbol is record
symbolType : std_logic_vector(1 downto 0);
symbolContent : std_logic_vector(31 downto 0);
ignoreIdle : boolean;
end record;
type MessageFrame is record
frame : RioFrame;
willAbort : boolean;
end record;
end package;
 
package body TestRioSerialPackage is
 
end package body;
 
 
 
-------------------------------------------------------------------------------
-- TestRioSerial.
-------------------------------------------------------------------------------
 
52,6 → 79,7
library std;
use std.textio.all;
use work.rio_common.all;
use work.TestRioSerialPackage.all;
 
 
-------------------------------------------------------------------------------
67,20 → 95,20
architecture TestRioSerialImpl of TestRioSerial is
component TestSwitchPort is
generic(
NUMBER_WORDS : natural range 1 to 8 := 1);
port(
clk : in std_logic;
areset_n : in std_logic;
 
frameValid_i : in std_logic_vector(0 to 63);
frameWrite_i : in RioFrameArray(0 to 63);
frameComplete_o : out std_logic_vector(0 to 63);
outboundWriteEmpty_o : out std_logic;
outboundWrite_i : in std_logic;
outboundWriteMessage_i : in MessageFrame;
outboundWriteAck_o : out std_logic;
frameExpected_i : in std_logic;
frameRead_i : in RioFrame;
frameReceived_o : out std_logic;
 
inboundWriteEmpty_o : out std_logic;
inboundWrite_i : in std_logic;
inboundWriteMessage_i : in MessageFrame;
inboundWriteAck_o : out std_logic;
readFrameEmpty_o : out std_logic;
readFrame_i : in std_logic;
readFrameRestart_i : in std_logic;
95,7 → 123,6
readContentEnd_o : out std_logic;
readContentData_o : out std_logic_vector(31 downto 0);
writeFrameFull_o : out std_logic;
writeFrame_i : in std_logic;
writeFrameAbort_i : in std_logic;
writeContent_i : in std_logic;
117,7 → 144,7
linkInitialized_o : out std_logic;
inputPortEnable_i : in std_logic;
outputPortEnable_i : in std_logic;
localAckIdWrite_i : in std_logic;
clrOutstandingAckId_i : in std_logic;
inboundAckId_i : in std_logic_vector(4 downto 0);
126,7 → 153,7
inboundAckId_o : out std_logic_vector(4 downto 0);
outstandingAckId_o : out std_logic_vector(4 downto 0);
outboundAckId_o : out std_logic_vector(4 downto 0);
readFrameEmpty_i : in std_logic;
readFrame_o : out std_logic;
readFrameRestart_o : out std_logic;
156,12 → 183,37
inboundDataSymbol_i : in std_logic_vector(31 downto 0));
end component;
 
component TestSymbolPort is
port(
clk : in std_logic;
areset_n : in std_logic;
 
portInitialized_i : in std_logic;
outboundControlValid_i : in std_logic;
outboundControlSymbol_i : in std_logic_vector(23 downto 0);
outboundDataValid_i : in std_logic;
outboundDataSymbol_i : in std_logic_vector(31 downto 0);
inboundControlValid_o : out std_logic;
inboundControlSymbol_o : out std_logic_vector(23 downto 0);
inboundDataValid_o : out std_logic;
inboundDataSymbol_o : out std_logic_vector(31 downto 0);
 
outboundWriteEmpty_o : out std_logic;
outboundWrite_i : in std_logic;
outboundWriteMessage_i : in MessageSymbol;
outboundWriteAck_o : out std_logic;
inboundWriteEmpty_o : out std_logic;
inboundWrite_i : in std_logic;
inboundWriteMessage_i : in MessageSymbol;
inboundWriteAck_o : out std_logic);
end component;
 
signal clk : std_logic;
signal areset_n : std_logic;
signal enable : std_logic;
 
signal portLinkTimeout : std_logic_vector(10 downto 0);
signal linkInitialized : std_logic;
signal linkInitialized, linkInitializedExpected : std_logic;
signal inputPortEnable : std_logic;
signal outputPortEnable : std_logic;
186,7 → 238,6
signal readContentEnd : std_logic;
signal readContentData : std_logic_vector(31 downto 0);
 
signal writeFrameFull : std_logic;
signal writeFrame : std_logic;
signal writeFrameAbort : std_logic;
signal writeContent : std_logic;
202,17 → 253,24
signal inboundDataValid : std_logic;
signal inboundDataSymbol : std_logic_vector(31 downto 0);
 
signal frameValid : std_logic_vector(0 to 63);
signal frameWrite : RioFrameArray(0 to 63);
signal frameComplete : std_logic_vector(0 to 63);
signal frameExpected : std_logic;
signal frameRead : RioFrame;
signal frameReceived : std_logic;
signal outboundFrameWriteEmpty : std_logic;
signal outboundFrameWrite : std_logic;
signal outboundFrameWriteMessage : MessageFrame;
signal outboundFrameWriteAck : std_logic;
signal inboundFrameWriteEmpty : std_logic;
signal inboundFrameWrite : std_logic;
signal inboundFrameWriteMessage : MessageFrame;
signal inboundFrameWriteAck : std_logic;
signal inboundFrameFull : std_logic;
 
signal outboundControlExpected : std_logic;
signal outboundControlSymbolExpected : std_logic_vector(23 downto 0);
signal outboundDataExpected : std_logic;
signal outboundDataSymbolExpected : std_logic_vector(31 downto 0);
signal outboundSymbolWriteEmpty : std_logic;
signal outboundSymbolWrite : std_logic;
signal outboundSymbolWriteMessage : MessageSymbol;
signal outboundSymbolWriteAck : std_logic;
signal inboundSymbolWriteEmpty : std_logic;
signal inboundSymbolWrite : std_logic;
signal inboundSymbolWriteMessage : MessageSymbol;
signal inboundSymbolWriteAck : std_logic;
 
begin
234,56 → 292,108
TestDriver: process
 
---------------------------------------------------------------------------
-- Procedure to receive a symbol.
-- Procedures to receive symbols.
---------------------------------------------------------------------------
procedure ReceiveSymbolIdle is
procedure OutboundSymbolIdle is
begin
outboundControlExpected <= '0';
outboundDataExpected <= '0';
outboundSymbolWrite <= '1';
outboundSymbolWriteMessage.symbolType <= "00";
outboundSymbolWriteMessage.symbolContent <= (others=>'U');
outboundSymbolWriteMessage.ignoreIdle <= false;
wait until outboundSymbolWriteAck = '1';
outboundSymbolWrite <= '0';
wait until outboundSymbolWriteAck = '0';
end procedure;
 
procedure ReceiveSymbolControl(constant symbolContent : in std_logic_vector(23 downto 0)) is
procedure OutboundSymbolControl(constant symbolContent : in std_logic_vector(23 downto 0);
constant ignoreIdle : in boolean := false) is
begin
outboundControlExpected <= '1';
outboundControlSymbolExpected <= symbolContent;
outboundDataExpected <= '0';
outboundSymbolWrite <= '1';
outboundSymbolWriteMessage.symbolType <= "01";
outboundSymbolWriteMessage.symbolContent <= x"00" & symbolContent;
outboundSymbolWriteMessage.ignoreIdle <= ignoreIdle;
wait until outboundSymbolWriteAck = '1';
outboundSymbolWrite <= '0';
wait until outboundSymbolWriteAck = '0';
end procedure;
 
procedure ReceiveSymbolData(constant symbolContent : in std_logic_vector(31 downto 0)) is
procedure OutboundSymbolData(constant symbolContent : in std_logic_vector(31 downto 0);
constant ignoreIdle : in boolean := false) is
begin
outboundControlExpected <= '0';
outboundDataExpected <= '1';
outboundDataSymbolExpected <= symbolContent;
outboundSymbolWrite <= '1';
outboundSymbolWriteMessage.symbolType <= "10";
outboundSymbolWriteMessage.symbolContent <= symbolContent;
outboundSymbolWriteMessage.ignoreIdle <= ignoreIdle;
wait until outboundSymbolWriteAck = '1';
outboundSymbolWrite <= '0';
wait until outboundSymbolWriteAck = '0';
end procedure;
 
---------------------------------------------------------------------------
-- Procedure to send a symbol.
-- Procedures to send symbols.
---------------------------------------------------------------------------
procedure SendSymbolIdle is
procedure InboundSymbolIdle is
begin
inboundControlValid <= '0';
inboundControlSymbol <= (others=>'U');
inboundDataValid <= '0';
inboundDataSymbol <= (others=>'U');
inboundSymbolWrite <= '1';
inboundSymbolWriteMessage.symbolType <= "00";
inboundSymbolWriteMessage.symbolContent <= (others=>'U');
inboundSymbolWriteMessage.ignoreIdle <= false;
wait until inboundSymbolWriteAck = '1';
inboundSymbolWrite <= '0';
wait until inboundSymbolWriteAck = '0';
end procedure;
 
procedure SendSymbolControl(constant symbolContent : in std_logic_vector(23 downto 0)) is
procedure InboundSymbolControl(constant symbolContent : in std_logic_vector(23 downto 0);
constant ignoreIdle : in boolean := false) is
begin
inboundControlValid <= '1';
inboundControlSymbol <= symbolContent;
inboundDataValid <= '0';
inboundDataSymbol <= (others=>'U');
inboundSymbolWrite <= '1';
inboundSymbolWriteMessage.symbolType <= "01";
inboundSymbolWriteMessage.symbolContent <= x"00" & symbolContent;
inboundSymbolWriteMessage.ignoreIdle <= ignoreIdle;
wait until inboundSymbolWriteAck = '1';
inboundSymbolWrite <= '0';
wait until inboundSymbolWriteAck = '0';
end procedure;
 
procedure SendSymbolData(constant symbolContent : in std_logic_vector(31 downto 0)) is
procedure InboundSymbolData(constant symbolContent : in std_logic_vector(31 downto 0);
constant ignoreIdle : in boolean := false) is
begin
inboundControlValid <= '0';
inboundControlSymbol <= (others=>'U');
inboundDataValid <= '1';
inboundDataSymbol <= symbolContent;
inboundSymbolWrite <= '1';
inboundSymbolWriteMessage.symbolType <= "10";
inboundSymbolWriteMessage.symbolContent <= symbolContent;
inboundSymbolWriteMessage.ignoreIdle <= ignoreIdle;
wait until inboundSymbolWriteAck = '1';
inboundSymbolWrite <= '0';
wait until inboundSymbolWriteAck = '0';
end procedure;
 
---------------------------------------------------------------------------
--
---------------------------------------------------------------------------
procedure OutboundFrame(constant frame : in RioFrame;
constant willAbort : boolean := false) is
begin
outboundFrameWrite <= '1';
outboundFrameWriteMessage.frame <= frame;
outboundFrameWriteMessage.willAbort <= willAbort;
wait until outboundFrameWriteAck = '1';
outboundFrameWrite <= '0';
wait until outboundFrameWriteAck = '0';
end procedure;
procedure InboundFrame(constant frame : in RioFrame;
constant willAbort : boolean := false) is
begin
inboundFrameWrite <= '1';
inboundFrameWriteMessage.frame <= frame;
inboundFrameWriteMessage.willAbort <= willAbort;
wait until inboundFrameWriteAck = '1';
inboundFrameWrite <= '0';
wait until inboundFrameWriteAck = '0';
end procedure;
 
---------------------------------------------------------------------------
-- Process variables.
---------------------------------------------------------------------------
variable seed1 : positive := 1;
291,6 → 401,8
variable payload : RioPayload;
variable frame : RioFrame;
variable frameOutbound : RioFrame;
variable frameInbound : RioFrame;
 
begin
---------------------------------------------------------------------------
297,18 → 409,11
-- Test case initialization.
---------------------------------------------------------------------------
 
frameValid <= (others=>'0');
frameExpected <= '0';
portLinkTimeout <= (others=>'1');
inputPortEnable <= '1';
outputPortEnable <= '1';
portInitialized <= '0';
outboundControlExpected <= '0';
outboundDataExpected <= '0';
inboundControlValid <= '0';
inboundDataValid <= '0';
 
localAckIdWrite <= '0';
clrOutstandingAckId <= '0';
317,14 → 422,22
outboundAckIdWrite <= (others=>'0');
 
enable <= '1';
 
linkInitializedExpected <= '0';
outboundSymbolWrite <= '0';
inboundSymbolWrite <= '0';
 
outboundFrameWrite <= '0';
inboundFrameWrite <= '0';
inboundFrameFull <= '0';
-- Generate a startup reset pulse.
areset_n <= '0';
wait until clk'event and clk = '1';
wait until clk'event and clk = '1';
areset_n <= '1';
wait until clk'event and clk = '1';
wait until clk'event and clk = '1';
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
340,12 → 453,19
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC1-Step1");
---------------------------------------------------------------------------
 
-- Make sure only idle-sequences are transmitted at startup.
ReceiveSymbolIdle;
for i in 0 to 1024 loop
wait until clk = '1';
for i in 0 to 512 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
for i in 0 to 512 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
366,33 → 486,31
-- The transmitter should send idle sequences at startup and a status once
-- in a while.
ReceiveSymbolIdle;
for i in 0 to 17 loop
wait until clk = '1';
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_NOP, "000"));
InboundSymbolIdle;
 
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_NOP, "000"));
wait until clk = '1';
 
ReceiveSymbolIdle;
for i in 0 to 16 loop
wait until clk = '1';
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_NOP, "000"));
InboundSymbolIdle;
 
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_NOP, "000"));
wait until clk = '1';
 
ReceiveSymbolIdle;
for i in 0 to 16 loop
wait until clk = '1';
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_NOP, "000"));
InboundSymbolIdle;
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
 
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_NOP, "000"));
wait until clk = '1';
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 2:");
407,10 → 525,16
portInitialized <= '0';
-- Make sure only idle-sequences are transmitted at startup.
ReceiveSymbolIdle;
for i in 0 to 1024 loop
wait until clk = '1';
for i in 0 to 512 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
wait until outboundSymbolWriteEmpty = '1';
for i in 0 to 512 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
 
-- Initialize the port to trigger a change of state.
portInitialized <= '1';
417,32 → 541,30
-- The transmitter should send idle sequences at startup and a status once
-- in a while.
ReceiveSymbolIdle;
for i in 0 to 17 loop
wait until clk = '1';
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_NOP, "000"));
InboundSymbolIdle;
 
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_NOP, "000"));
wait until clk = '1';
 
ReceiveSymbolIdle;
for i in 0 to 16 loop
wait until clk = '1';
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_NOP, "000"));
InboundSymbolIdle;
 
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_NOP, "000"));
wait until clk = '1';
 
ReceiveSymbolIdle;
for i in 0 to 16 loop
wait until clk = '1';
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
 
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_NOP, "000"));
wait until clk = '1';
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_NOP, "000"));
InboundSymbolIdle;
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
457,35 → 579,35
 
-- A received error-free status triggers transmission of status symbols in
-- a more rapid past.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_NOP, "000"));
ReceiveSymbolIdle;
wait until clk = '1';
SendSymbolIdle;
ReceiveSymbolIdle;
OutboundSymbolIdle;
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_NOP, "000"));
for i in 0 to 15 loop
wait until clk = '1';
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
 
-- The transmitter should send at least 15 additional statuses after
-- receiving an error free status.
for j in 0 to 14 loop
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_NOP, "000"));
wait until clk = '1';
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_NOP, "000"));
InboundSymbolIdle;
 
ReceiveSymbolIdle;
for i in 0 to 16 loop
wait until clk = '1';
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
end loop;
 
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_NOP, "000"));
wait until clk = '1';
ReceiveSymbolIdle;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_NOP, "000"));
InboundSymbolIdle;
 
OutboundSymbolIdle;
InboundSymbolIdle;
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 4:");
510,22 → 632,30
---------------------------------------------------------------------------
 
-- Make the link fully initialized by sending 7 additional statuses.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_NOP, "000"));
for i in 0 to 6 loop
wait until clk = '1';
OutboundSymbolIdle;
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_NOP, "000"));
end loop;
SendSymbolIdle;
for i in 0 to 8 loop
wait until clk = '1';
 
-- Compensate for some ticks before the link becomes initialized.
for i in 0 to 3 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_NOP, "000"));
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
 
-- Tick the transmitter by reading it and check that the link is initialized.
if (linkInitialized = '0') then
wait until linkInitialized = '1';
end if;
linkInitializedExpected <= '1';
 
-- Receive a status-control-symbol.
for i in 0 to 4 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_NOP, "000"));
InboundSymbolIdle;
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
547,34 → 677,24
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
frameExpected <= '1';
frameRead <= frame;
InboundFrame(frame);
-- Start the reception of a frame.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
 
-- Send the data symbols of the frame.
-- Fill in the symbols that the packet will be fragmented into.
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
for i in 0 to frame.length-1 loop
SendSymbolData(frame.payload(i));
InboundSymbolData(frame.payload(i));
end loop;
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_END_OF_PACKET, "000"));
for i in 0 to 6 loop
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00000", "11111",
STYPE1_NOP, "000"), true);
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
TestCompare(inboundFrameWriteEmpty, '1', "Packet was received.");
-- End the reception of the frame.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_END_OF_PACKET, "000"));
 
-- Check that the frame has been received in the frame buffer.
wait until frameReceived = '1';
frameExpected <= '0';
-- Receive an idle symbol left in the FIFO before the ack was generated.
ReceiveSymbolIdle;
-- Receive acknowledge for the transmitted frame.
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00000", "11111",
STYPE1_NOP, "000"));
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 2:");
591,33 → 711,25
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
frameExpected <= '1';
frameRead <= frame;
InboundFrame(frame);
-- Start the reception of a frame.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
 
-- Send the data symbols of the frame.
-- Fill in the symbols that the packet will be fragmented into.
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
for i in 0 to frame.length-1 loop
SendSymbolData(frame.payload(i));
InboundSymbolData(frame.payload(i));
end loop;
-- End the reception of the frame.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_END_OF_PACKET, "000"));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_END_OF_PACKET, "000"));
for i in 0 to 6 loop
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00001", "11111",
STYPE1_NOP, "000"), true);
 
-- Check that the frame has been received in the frame buffer.
wait until frameReceived = '1';
frameExpected <= '0';
-- Receive an idle symbol left in the FIFO before the ack was generated.
ReceiveSymbolIdle;
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
TestCompare(inboundFrameWriteEmpty, '1', "Packet was received.");
 
-- Receive acknowledge for the transmited frame.
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00001", "11111",
STYPE1_NOP, "000"));
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 3:");
634,34 → 746,24
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
frameExpected <= '1';
frameRead <= frame;
InboundFrame(frame);
-- Start the reception of a frame.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
 
-- Send the data symbols of the frame.
-- Fill in the symbols that the packet will be fragmented into.
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
for i in 0 to frame.length-1 loop
SendSymbolData(frame.payload(i));
InboundSymbolData(frame.payload(i));
end loop;
-- End the reception of the frame.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_END_OF_PACKET, "000"));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_END_OF_PACKET, "000"));
for i in 0 to 6 loop
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00010", "11111",
STYPE1_NOP, "000"), true);
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
TestCompare(inboundFrameWriteEmpty, '1', "Packet was received.");
 
-- Check that the frame has been received in the frame buffer.
wait until frameReceived = '1';
frameExpected <= '0';
-- Receive an idle symbol left in the FIFO before the ack was generated.
ReceiveSymbolIdle;
 
-- Receive acknowledge for the transmitted frame.
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00010", "11111",
STYPE1_NOP, "000"));
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 4:");
678,34 → 780,15
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
frameExpected <= '1';
frameRead <= frame;
-- Start the reception of a frame.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
 
-- Send the data symbols of the frame.
InboundFrame(frame);
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
for i in 0 to frame.length-1 loop
SendSymbolData(frame.payload(i));
InboundSymbolData(frame.payload(i));
end loop;
-- Start the reception of a frame, implicitly ending the previous.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
 
-- Check that the frame has been received in the frame buffer.
wait until frameReceived = '1';
frameExpected <= '0';
wait until clk'event and clk = '1';
-- Receive an idle symbol left in the FIFO before the ack was generated.
ReceiveSymbolIdle;
 
-- Receive acknowledge for the transmitted frame.
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00011", "11111",
STYPE1_NOP, "000"));
 
-- Create the second frame.
CreateRandomPayload(payload.data, seed1, seed2);
payload.length := 13;
713,28 → 796,25
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
frameExpected <= '1';
frameRead <= frame;
-- Send the data symbols of the frame.
InboundFrame(frame);
for i in 0 to frame.length-1 loop
SendSymbolData(frame.payload(i));
InboundSymbolData(frame.payload(i));
end loop;
-- End the reception of the frame.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_END_OF_PACKET, "000"));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_END_OF_PACKET, "000"));
for i in 0 to 6 loop
InboundSymbolIdle;
end loop;
 
-- Check that the frame has been received in the frame buffer.
wait until frameReceived = '1';
frameExpected <= '0';
-- Receive an idle symbol left in the FIFO before the ack was generated.
ReceiveSymbolIdle;
-- Add expected packet-accepted symbols.
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00011", "11111",
STYPE1_NOP, "000"), true);
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00100", "11111",
STYPE1_NOP, "000"), true);
 
-- Receive acknowledge for the transmitted frame.
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00100", "11111",
STYPE1_NOP, "000"));
-- Wait for all symbols to be transfered and check that the packet was received.
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
TestCompare(inboundFrameWriteEmpty, '1', "Packet was received.");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
747,7 → 827,7
PrintR("TG_RioSerial-TC3-Step5");
---------------------------------------------------------------------------
-- Create the frame.
-- Create a frame, send it and abort it with STOMP.
CreateRandomPayload(payload.data, seed1, seed2);
payload.length := 7;
frame := RioFrameCreate(ackId=>"00101", vc=>'0', crf=>'0', prio=>"00",
754,36 → 834,20
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
frameExpected <= '1';
frameRead <= frame;
-- Start the reception of a frame.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
 
-- Send the data symbols of the frame.
InboundFrame(frame, true);
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
for i in 0 to frame.length-1 loop
SendSymbolData(frame.payload(i));
InboundSymbolData(frame.payload(i));
end loop;
-- Abort the reception of the frame.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_STOMP, "000"));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_STOMP, "000"));
for i in 0 to 6 loop
InboundSymbolIdle;
end loop;
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_RESTART_FROM_RETRY, "000"));
 
-- Dont expect the aborted frame anymore.
frameExpected <= '0';
-- Receive an idle symbol left in the FIFO before the retry was generated.
ReceiveSymbolIdle;
 
-- Receive acknowledge for the transmitted frame.
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_RETRY, "00101", "11111",
STYPE1_NOP, "000"));
 
-- Acknowledge the canceled packet.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_RESTART_FROM_RETRY, "000"));
 
-- Create a new frame.
CreateRandomPayload(payload.data, seed1, seed2);
payload.length := 8;
791,33 → 855,28
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
frameExpected <= '1';
frameRead <= frame;
-- Start the reception of a frame.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
 
-- Send the data symbols of the frame.
InboundFrame(frame);
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
for i in 0 to frame.length-1 loop
SendSymbolData(frame.payload(i));
InboundSymbolData(frame.payload(i));
end loop;
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_END_OF_PACKET, "000"));
for i in 0 to 6 loop
InboundSymbolIdle;
end loop;
 
-- Receive acknowledge of the stomped packet.
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_RETRY, "00101", "11111",
STYPE1_NOP, "000"), true);
-- Abort the reception of the frame.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_END_OF_PACKET, "000"));
-- Check that the frame has been received in the frame buffer.
wait until frameReceived = '1';
frameExpected <= '0';
-- Receive an idle symbol left in the FIFO before the ack was generated.
ReceiveSymbolIdle;
-- Receive acknowledge for the transmitted frame.
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00101", "11111",
STYPE1_NOP, "000"), true);
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
TestCompare(inboundFrameWriteEmpty, '1', "Packet was received.");
 
-- Receive acknowledge for the transmitted frame.
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00101", "11111",
STYPE1_NOP, "000"));
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 6:");
829,24 → 888,26
PrintR("TG_RioSerial-TC3-Step6");
---------------------------------------------------------------------------
-- Start the reception of a frame.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
-- Start the reception of a frame and abort it.
frame.length := 0;
InboundFrame(frame, true);
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_STOMP, "000"));
for i in 0 to 6 loop
InboundSymbolIdle;
end loop;
 
-- Abort the reception of the frame.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_STOMP, "000"));
 
-- Receive an idle symbol left in the FIFO before the retry was generated.
ReceiveSymbolIdle;
 
-- Receive acknowledge for the transmitted frame.
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_RETRY, "00110", "11111",
STYPE1_NOP, "000"));
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_RETRY, "00110", "11111",
STYPE1_NOP, "000"), true);
 
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
-- Acknowledge the canceled packet.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_RESTART_FROM_RETRY, "000"));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_RESTART_FROM_RETRY, "000"));
 
-- Create a new frame.
CreateRandomPayload(payload.data, seed1, seed2);
855,33 → 916,25
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
frameExpected <= '1';
frameRead <= frame;
 
-- Start the reception of a frame.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
 
-- Send the data symbols of the frame.
InboundFrame(frame);
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
for i in 0 to frame.length-1 loop
SendSymbolData(frame.payload(i));
InboundSymbolData(frame.payload(i));
end loop;
-- Abort the reception of the frame.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_END_OF_PACKET, "000"));
-- Check that the frame has been received in the frame buffer.
wait until frameReceived = '1';
frameExpected <= '0';
-- Receive an idle symbol left in the FIFO before the ack was generated.
ReceiveSymbolIdle;
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_END_OF_PACKET, "000"));
for i in 0 to 6 loop
InboundSymbolIdle;
end loop;
 
-- Receive acknowledge for the transmitted frame.
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00110", "11111",
STYPE1_NOP, "000"));
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00110", "11111",
STYPE1_NOP, "000"), true);
 
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
TestCompare(inboundFrameWriteEmpty, '1', "Packet was received.");
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 7:");
894,7 → 947,8
PrintR("TG_RioSerial-TC3-Step7");
---------------------------------------------------------------------------
-- Create a new frame.
-- Create a new frame and abort it with a link-request/input-status to
-- abort the current packet.
CreateRandomPayload(payload.data, seed1, seed2);
payload.length := 9;
frame := RioFrameCreate(ackId=>"00111", vc=>'0', crf=>'0', prio=>"00",
901,32 → 955,25
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
frameExpected <= '1';
frameRead <= frame;
 
-- Start the reception of a frame.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
 
-- Send the data symbols of the frame.
InboundFrame(frame, true);
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
for i in 0 to frame.length-1 loop
SendSymbolData(frame.payload(i));
InboundSymbolData(frame.payload(i));
end loop;
-- Send a link-request/input-status to abort the current packet.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_LINK_REQUEST, "100"));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_LINK_REQUEST, "100"));
for i in 0 to 6 loop
InboundSymbolIdle;
end loop;
 
-- Receive an idle symbol left in the FIFO before the ack was generated.
ReceiveSymbolIdle;
 
-- The frame should be canceled by the link-request, dont expect it anymore.
frameExpected <= '0';
-- Receive link-response indicating normal operation and expected ackId.
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "00111", "10000",
STYPE1_NOP, "000"));
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "00111", "10000",
STYPE1_NOP, "000"), true);
 
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
TestCompare(inboundFrameWriteEmpty, '1', "Packet was received.");
 
-- Create a new frame.
CreateRandomPayload(payload.data, seed1, seed2);
payload.length := 10;
934,33 → 981,25
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
frameExpected <= '1';
frameRead <= frame;
 
-- Start the reception of a frame.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
 
-- Send the data symbols of the frame.
InboundFrame(frame);
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
for i in 0 to frame.length-1 loop
SendSymbolData(frame.payload(i));
InboundSymbolData(frame.payload(i));
end loop;
-- Abort the reception of the frame.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_END_OF_PACKET, "000"));
-- Check that the frame has been received in the frame buffer.
wait until frameReceived = '1';
frameExpected <= '0';
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_END_OF_PACKET, "000"));
for i in 0 to 6 loop
InboundSymbolIdle;
end loop;
 
-- Receive an idle symbol left in the FIFO before the ack was generated.
ReceiveSymbolIdle;
-- Receive acknowledge for the transmitted frame.
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00111", "11111",
STYPE1_NOP, "000"), true);
 
-- Receive acknowledge for the transmitted frame.
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00111", "11111",
STYPE1_NOP, "000"));
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
TestCompare(inboundFrameWriteEmpty, '1', "Packet was received.");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 8:");
973,26 → 1012,20
PrintR("TG_RioSerial-TC3-Step8");
---------------------------------------------------------------------------
 
-- Expect an empty packet to be aborted.
frameExpected <= '1';
-- Start the reception of a frame.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
-- Start a frame then send link-request/input-status to abort it.
frame.length := 0;
InboundFrame(frame, true);
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_LINK_REQUEST, "100"));
for i in 0 to 6 loop
InboundSymbolIdle;
end loop;
 
-- Send a link-request/input-status to abort the current packet.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_LINK_REQUEST, "100"));
 
-- Receive an idle symbol left in the FIFO before the ack was generated.
ReceiveSymbolIdle;
 
-- Dont expect any frames anymore.
frameExpected <= '0';
-- Receive link-response indicating normal operation and expected ackId.
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "01000", "10000",
STYPE1_NOP, "000"));
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "01000", "10000",
STYPE1_NOP, "000"), true);
 
-- Create a new frame.
CreateRandomPayload(payload.data, seed1, seed2);
1001,37 → 1034,29
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
frameExpected <= '1';
frameRead <= frame;
 
-- Start the reception of a frame.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
 
-- Send the data symbols of the frame.
InboundFrame(frame);
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
for i in 0 to frame.length-1 loop
SendSymbolData(frame.payload(i));
InboundSymbolData(frame.payload(i));
end loop;
-- Abort the reception of the frame.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_END_OF_PACKET, "000"));
-- Check that the frame has been received in the frame buffer.
wait until frameReceived = '1';
frameExpected <= '0';
-- Receive an idle symbol left in the FIFO before the ack was generated.
ReceiveSymbolIdle;
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_END_OF_PACKET, "000"));
for i in 0 to 6 loop
InboundSymbolIdle;
end loop;
 
-- Receive acknowledge for the transmitted frame.
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "01000", "11111",
STYPE1_NOP, "000"));
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "01000", "11111",
STYPE1_NOP, "000"), true);
 
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
TestCompare(inboundFrameWriteEmpty, '1', "Packet was received.");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 9:");
PrintS("Action: Send a packet when no buffers is available. Reset receiver");
PrintS("Action: Send a packet when no buffers are available. Reset receiver");
PrintS(" with link-request.");
PrintS("Result: A packet-retry should be transmitted and receiver should");
PrintS(" enter input-retry-stopped.");
1039,7 → 1064,10
PrintR("TG_RioSerial-TC3-Step9");
---------------------------------------------------------------------------
 
-- Create a new frame.
-- Indicate the inbound frame queue is full.
inboundFrameFull <= '1';
-- Create a new frame and start sending it.
CreateRandomPayload(payload.data, seed1, seed2);
payload.length := 11;
frame := RioFrameCreate(ackId=>"01001", vc=>'0', crf=>'0', prio=>"00",
1046,32 → 1074,42
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
-- Start the reception of a frame.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
SendSymbolData(frame.payload(0));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
InboundSymbolData(frame.payload(0));
for i in 0 to 6 loop
InboundSymbolIdle;
end loop;
 
-- Receive notification about that the packet needs to be retried.
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_RETRY, "01001", "11111",
STYPE1_NOP, "000"));
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_RETRY, "01001", "11111",
STYPE1_NOP, "000"), true);
 
-- Check the status of the input port and verify the input-retry-stopped state.
-- This should also set the receiver into normal operation.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_LINK_REQUEST, "100"));
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "01001", "00100",
STYPE1_NOP, "000"));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_LINK_REQUEST, "100"));
for i in 0 to 6 loop
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "01001", "00100",
STYPE1_NOP, "000"), true);
 
-- Check the status of the input port and verify the input-retry-stopped state.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_LINK_REQUEST, "100"));
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "01001", "10000",
STYPE1_NOP, "000"));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_LINK_REQUEST, "100"));
for i in 0 to 6 loop
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "01001", "10000",
STYPE1_NOP, "000"), true);
 
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
TestCompare(inboundFrameWriteEmpty, '1', "Packet was received.");
 
-- Indicate the inbound frame queue is ready to accept new packets again.
inboundFrameFull <= '0';
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 10:");
1083,6 → 1121,9
PrintR("TG_RioSerial-TC3-Step10");
---------------------------------------------------------------------------
 
-- Indicate the inbound frame queue is full.
inboundFrameFull <= '1';
-- Create a new frame.
CreateRandomPayload(payload.data, seed1, seed2);
payload.length := 11;
1090,32 → 1131,41
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
-- Start the reception of a frame.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
SendSymbolData(frame.payload(0));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
InboundSymbolData(frame.payload(0));
for i in 0 to 6 loop
InboundSymbolIdle;
end loop;
 
-- Receive notification about that the packet needs to be retried.
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_RETRY, "01001", "11111",
STYPE1_NOP, "000"));
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_RETRY, "01001", "11111",
STYPE1_NOP, "000"), true);
 
-- Acknowledge the retried packet.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_RESTART_FROM_RETRY, "000"));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_RESTART_FROM_RETRY, "000"));
 
-- Check the status of the input port and verify the input-retry-stopped state.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_LINK_REQUEST, "100"));
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "01001", "10000",
STYPE1_NOP, "000"));
-- Request the status of the input port.
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_LINK_REQUEST, "100"));
for i in 0 to 6 loop
InboundSymbolIdle;
end loop;
 
-- Verify the input-retry-stopped state.
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "01001", "10000",
STYPE1_NOP, "000"), true);
 
-- Always receive a status after a link response when leaving input-error-stopped.
-- ReceiveSymbol(SYMBOL_CONTROL,
-- OutboundSymbol(SYMBOL_CONTROL,
-- RioControlSymbolCreate(STYPE0_STATUS, "01001", "11111",
-- STYPE1_NOP, "000"));
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
TestCompare(inboundFrameWriteEmpty, '1', "Packet was received.");
-- Indicate the inbound frame queue is ready to accept new packets again.
inboundFrameFull <= '0';
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
1126,6 → 1176,9
PrintR("TG_RioSerial-TC3-Step11");
---------------------------------------------------------------------------
 
-- Indicate the inbound frame queue is full.
inboundFrameFull <= '1';
-- Create a new frame.
CreateRandomPayload(payload.data, seed1, seed2);
payload.length := 11;
1135,16 → 1188,19
payload=>payload);
-- Start the reception of a frame.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
SendSymbolData(frame.payload(0));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
InboundSymbolData(frame.payload(0));
for i in 0 to 6 loop
InboundSymbolIdle;
end loop;
 
-- Receive notification about that the packet needs to be retried.
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_RETRY, "01001", "11111",
STYPE1_NOP, "000"));
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_RETRY, "01001", "11111",
STYPE1_NOP, "000"), true);
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
 
-- Create a packet and send it. It should be discarded.
-- Create a packet and send it. It should be silently discarded.
CreateRandomPayload(payload.data, seed1, seed2);
payload.length := 12;
frame := RioFrameCreate(ackId=>"01001", vc=>'0', crf=>'0', prio=>"00",
1151,18 → 1207,30
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
OutboundSymbolIdle;
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
for i in 0 to frame.length-1 loop
SendSymbolData(frame.payload(i));
OutboundSymbolIdle;
InboundSymbolData(frame.payload(i));
end loop;
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_END_OF_PACKET, "000"));
OutboundSymbolIdle;
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_END_OF_PACKET, "000"));
-- Acknowledge the retried packet.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_RESTART_FROM_RETRY, "000"));
OutboundSymbolIdle;
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_RESTART_FROM_RETRY, "000"));
for i in 0 to 6 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
 
-- Indicate the inbound frame queue is ready to accept new packets again.
inboundFrameFull <= '0';
 
-- Create a packet and send it.
CreateRandomPayload(payload.data, seed1, seed2);
payload.length := 13;
1170,23 → 1238,25
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
frameExpected <= '1';
frameRead <= frame;
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
InboundFrame(frame);
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
for i in 0 to frame.length-1 loop
SendSymbolData(frame.payload(i));
InboundSymbolData(frame.payload(i));
end loop;
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_END_OF_PACKET, "000"));
wait until frameReceived = '1';
frameExpected <= '0';
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_END_OF_PACKET, "000"));
for i in 0 to 6 loop
InboundSymbolIdle;
end loop;
 
-- Receive acknowledge for the transmitted frame.
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "01001", "11111",
STYPE1_NOP, "000"));
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "01001", "11111",
STYPE1_NOP, "000"), true);
 
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
TestCompare(inboundFrameWriteEmpty, '1', "Packet was received.");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 12:");
1199,13 → 1269,15
---------------------------------------------------------------------------
 
-- Create, corrupt and send a control symbol.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000") xor x"00100000");
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000") xor x"100000");
for i in 0 to 6 loop
InboundSymbolIdle;
end loop;
 
-- Receive a packet-not-accepted indicating error in control-symbol crc.
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_NOT_ACCEPTED, "00000", "00010",
STYPE1_NOP, "000"));
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_NOT_ACCEPTED, "00000", "00010",
STYPE1_NOP, "000"), true);
 
-- Create a packet and send it. It should be discarded.
CreateRandomPayload(payload.data, seed1, seed2);
1214,24 → 1286,30
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
OutboundSymbolIdle;
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
for i in 0 to frame.length-1 loop
SendSymbolData(frame.payload(i));
OutboundSymbolIdle;
InboundSymbolData(frame.payload(i));
end loop;
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_END_OF_PACKET, "000"));
OutboundSymbolIdle;
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_END_OF_PACKET, "000"));
-- Make the receiver go back to normal operation by sending a link-request.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_LINK_REQUEST, "100"));
OutboundSymbolIdle;
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_LINK_REQUEST, "100"));
for i in 0 to 6 loop
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "01010", "00101",
STYPE1_NOP, "000"), true);
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
 
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "01010", "00101",
STYPE1_NOP, "000"));
 
-- Always receive a status after a link response when leaving input-error-stopped.
-- ReceiveSymbol(SYMBOL_CONTROL,
-- OutboundSymbol(SYMBOL_CONTROL,
-- RioControlSymbolCreate(STYPE0_STATUS, "01010", "11111",
-- STYPE1_NOP, "000"));
1242,23 → 1320,25
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
frameExpected <= '1';
frameRead <= frame;
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
InboundFrame(frame);
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
for i in 0 to frame.length-1 loop
SendSymbolData(frame.payload(i));
InboundSymbolData(frame.payload(i));
end loop;
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_END_OF_PACKET, "000"));
wait until frameReceived = '1';
frameExpected <= '0';
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_END_OF_PACKET, "000"));
for i in 0 to 6 loop
InboundSymbolIdle;
end loop;
 
-- Receive acknowledge for the transmitted frame.
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "01010", "11111",
STYPE1_NOP, "000"));
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "01010", "11111",
STYPE1_NOP, "000"), true);
 
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
TestCompare(inboundFrameWriteEmpty, '1', "Packet was received.");
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 13:");
1277,32 → 1357,31
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
frame.payload(0) := frame.payload(0) xor x"00000010";
frameExpected <= '1';
frameRead <= frame;
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
InboundFrame(frame, true);
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
for i in 0 to frame.length-1 loop
SendSymbolData(frame.payload(i));
InboundSymbolData(frame.payload(i));
end loop;
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_END_OF_PACKET, "000"));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_END_OF_PACKET, "000"));
for i in 0 to 6 loop
InboundSymbolIdle;
end loop;
-- Receive a packet-not-accepted indicating error in control-symbol crc.
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_NOT_ACCEPTED, "00000", "00100",
STYPE1_NOP, "000"));
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_NOT_ACCEPTED, "00000", "00100",
STYPE1_NOP, "000"), true);
 
-- Dont expect any frame anymore.
frameExpected <= '0';
 
-- Make the receiver go back to normal operation by sending a link-request.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_LINK_REQUEST, "100"));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_LINK_REQUEST, "100"));
for i in 0 to 6 loop
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "01011", "00101",
STYPE1_NOP, "000"), true);
 
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "01011", "00101",
STYPE1_NOP, "000"));
 
-- Send a new frame without error.
CreateRandomPayload(payload.data, seed1, seed2);
payload.length := 16;
1310,26 → 1389,27
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
frameExpected <= '1';
frameRead <= frame;
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
InboundFrame(frame);
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_START_OF_PACKET, "000"));
for i in 0 to frame.length-1 loop
SendSymbolData(frame.payload(i));
InboundSymbolData(frame.payload(i));
end loop;
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_END_OF_PACKET, "000"));
wait until frameReceived = '1';
frameExpected <= '0';
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
STYPE1_END_OF_PACKET, "000"));
for i in 0 to 6 loop
InboundSymbolIdle;
end loop;
 
-- Receive acknowledge for the transmitted frame.
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "01011", "11111",
STYPE1_NOP, "000"));
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "01011", "11111",
STYPE1_NOP, "000"), true);
 
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
TestCompare(inboundFrameWriteEmpty, '1', "Packet was received.");
 
-- REMARK: Complete with some more error situations: invalid ackId, too
-- short packet, too long packet, etc...
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("TG_RioSerial-TC4");
1345,51 → 1425,138
---------------------------------------------------------------------------
-- Create the frame.
-- Make sure the transmitter fills in the correct ackId and dont use the
-- one in the input packet.
CreateRandomPayload(payload.data, seed1, seed2);
payload.length := 3;
frame := RioFrameCreate(ackId=>"00000", vc=>'0', crf=>'0', prio=>"00",
frame := RioFrameCreate(ackId=>"UUUUU", vc=>'0', crf=>'0', prio=>"00",
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
frameValid(0) <= '1';
frameWrite(0) <= frame;
OutboundFrame(frame);
frame.payload(0)(31 downto 27) := "00000";
 
-- Make sure the transmitter fills in the correct ackId and dont use the
-- one in the input packet.
frameWrite(0).payload(0)(31 downto 27) <= "UUUUU";
-- Receive the frame.
for i in 0 to 4 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
InboundSymbolIdle;
for i in 0 to frame.length-1 loop
OutboundSymbolData(frame.payload(i));
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
InboundSymbolIdle;
 
-- Receive an idle symbol left in the FIFO before the start of the frame was
-- generated.
ReceiveSymbolIdle;
-- Send acknowledge that the frame was received.
OutboundSymbolIdle;
InboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00000", "11111",
STYPE1_NOP, "000"));
for i in 0 to 4 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty");
TestCompare(outboundFrameWriteEmpty, '1', "packet transmitted");
 
-- Receive the start of the frame.
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 2:");
PrintS("Action: Send one more outbound packets than there are ackIds.");
PrintS("Result: The packets should be fragmented and received in symbols.");
PrintS(" The last packet should be delayed and sent once the first");
PrintS(" packet has been accepted.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC4-Step2");
---------------------------------------------------------------------------
-- REMARK: 32 packet should ideally be supported, not just 31...fix.
for i in 0 to 4 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
for i in 1 to 31 loop
-- Create a frame.
CreateRandomPayload(payload.data, seed1, seed2);
payload.length := 3+i;
frame := RioFrameCreate(ackId=>"UUUUU", vc=>'0', crf=>'0', prio=>"00",
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
OutboundFrame(frame);
frame.payload(0)(31 downto 27) := std_logic_vector(to_unsigned(i mod 32, 5));
 
-- Receive the data symbols of the frame.
-- Receive the frame.
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
InboundSymbolIdle;
for i in 0 to frame.length-1 loop
OutboundSymbolData(frame.payload(i));
InboundSymbolIdle;
end loop;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
InboundSymbolIdle;
-- Create a frame that cannot be sent since there are no available ackids left.
CreateRandomPayload(payload.data, seed1, seed2);
payload.length := 3+32;
frame := RioFrameCreate(ackId=>"UUUUU", vc=>'0', crf=>'0', prio=>"00",
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
OutboundFrame(frame);
frame.payload(0)(31 downto 27) := std_logic_vector(to_unsigned(0, 5));
-- Send acknowledge that the frames was received.
OutboundSymbolIdle;
InboundSymbolControl(
RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, std_logic_vector(to_unsigned(1, 5)), "11111",
STYPE1_NOP, "000"));
for i in 0 to 7 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
 
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
InboundSymbolIdle;
for i in 0 to frame.length-1 loop
ReceiveSymbolData(frame.payload(i));
OutboundSymbolData(frame.payload(i));
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
InboundSymbolIdle;
 
-- Wait for the frame to complete.
wait until frameComplete(0) = '1' and clk'event and clk = '1';
frameValid(0) <= '0';
-- Receive the end of the frame.
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
 
-- Send acknowledge that the frame was received.
SendSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00000", "11111",
STYPE1_NOP, "000"));
 
for i in 2 to 32 loop
OutboundSymbolIdle;
InboundSymbolControl(
RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, std_logic_vector(to_unsigned(i mod 32, 5)), "11111",
STYPE1_NOP, "000"));
end loop;
for i in 0 to 4 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
TestWait(outboundSymbolWriteEmpty, '1', "symbols pending");
TestCompare(outboundFrameWriteEmpty, '1', "packet pending");
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 2:");
PrintS("Step 3:");
PrintS("Action: Send an outbound packet with maximum length.");
PrintS("Result: The packet should be fragmented and received in symbols.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC4-Step2");
PrintR("TG_RioSerial-TC4-Step3");
---------------------------------------------------------------------------
-- Create the frame.
1399,42 → 1566,45
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
frameValid(1) <= '1';
frameWrite(1) <= frame;
OutboundFrame(frame);
 
-- Receive an idle symbol left in the FIFO before the start of the frame was
-- generated.
ReceiveSymbolIdle;
for i in 0 to 4 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
 
-- Receive the start of the frame.
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
 
-- Receive the data symbols of the frame.
-- Receive the frame.
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
InboundSymbolIdle;
for i in 0 to frame.length-1 loop
ReceiveSymbolData(frame.payload(i));
OutboundSymbolData(frame.payload(i));
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
InboundSymbolIdle;
 
-- Wait for the frame to complete.
wait until frameComplete(1) = '1' and clk'event and clk = '1';
frameValid(1) <= '0';
-- Receive the end of the frame.
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
 
-- Send acknowledge that the frame was received.
SendSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00001", "11111",
STYPE1_NOP, "000"));
OutboundSymbolIdle;
InboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00001", "11111",
STYPE1_NOP, "000"));
for i in 0 to 4 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
 
---------------------------------------------------------------------------
TestWait(outboundSymbolWriteEmpty, '1', "symbols pending");
TestCompare(outboundFrameWriteEmpty, '1', "packet pending");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 3:");
PrintS("Step 4:");
PrintS("Action: Send a packet and confirm it with packet-retry.");
PrintS("Result: A restart-from-retry should be transmitted and the packet");
PrintS(" should be retransmitted.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC4-Step3");
PrintR("TG_RioSerial-TC4-Step4");
---------------------------------------------------------------------------
-- Create the frame.
1444,64 → 1614,71
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
frameValid(2) <= '1';
frameWrite(2) <= frame;
OutboundFrame(frame);
 
-- Receive an idle symbol left in the FIFO before the start of the frame was
-- generated.
ReceiveSymbolIdle;
 
-- Receive the start of the frame.
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
 
-- Receive the data symbols of the frame.
for i in 0 to 4 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
-- Send the frame and acknowledge it with packet-retry.
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
InboundSymbolIdle;
for i in 0 to frame.length-1 loop
ReceiveSymbolData(frame.payload(i));
OutboundSymbolData(frame.payload(i));
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_RETRY, "00010", "11111",
STYPE1_NOP, "000"));
for i in 0 to 6 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
 
-- Receive the end of the frame.
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
 
-- Send packet-retry that the frame should be retransmitted.
SendSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_RETRY, "00010", "11111",
STYPE1_NOP, "000"));
 
-- Receive the acknowledgement for the retransmission.
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_RESTART_FROM_RETRY, "000"));
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_RESTART_FROM_RETRY, "000"));
InboundSymbolIdle;
 
-- Receive the start of the retransmitted frame.
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
 
-- Receive the data symbols of the retransmitted frame.
OutboundSymbolIdle;
InboundSymbolIdle;
-- Receive the retransmitted frame.
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
InboundSymbolIdle;
for i in 0 to frame.length-1 loop
ReceiveSymbolData(frame.payload(i));
OutboundSymbolData(frame.payload(i));
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
InboundSymbolIdle;
 
-- Wait for the frame to complete.
wait until frameComplete(2) = '1' and clk'event and clk = '1';
frameValid(2) <= '0';
-- Send acknowledge that the frame was received.
InboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00010", "11111",
STYPE1_NOP, "000"));
OutboundSymbolIdle;
-- Receive the end of the retransmitted frame.
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
for i in 0 to 4 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
TestWait(outboundSymbolWriteEmpty, '1', "symbols pending");
TestCompare(outboundFrameWriteEmpty, '1', "packet pending");
 
-- Send acknowledge that the frame was received.
SendSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00010", "11111",
STYPE1_NOP, "000"));
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 4:");
PrintS("Step 5:");
PrintS("Action: Send a packet and confirm it with packet-not-accepted. ");
PrintS("Result: A link-request should be transmitted and the packet should");
PrintS(" be retransmitted.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC4-Step4");
PrintR("TG_RioSerial-TC4-Step5");
---------------------------------------------------------------------------
-- Create the frame.
1511,64 → 1688,72
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
frameValid(3) <= '1';
frameWrite(3) <= frame;
OutboundFrame(frame);
 
-- Receive the start of the frame.
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
 
-- Receive the data symbols of the frame.
-- Receive the frame.
for i in 0 to 4 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
InboundSymbolIdle;
for i in 0 to frame.length-1 loop
ReceiveSymbolData(frame.payload(i));
OutboundSymbolData(frame.payload(i));
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_NOT_ACCEPTED, "00000", "11111",
STYPE1_NOP, "000"));
 
-- Receive the end of the frame.
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
-- Receive the link-request and answer back with a link-response.
for i in 0 to 6 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_LINK_REQUEST, "100"));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "00011", "11111",
STYPE1_NOP, "000"));
 
-- Send packet-retry that the frame should be retransmitted.
SendSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_NOT_ACCEPTED, "00000", "11111",
STYPE1_NOP, "000"));
 
-- Receive the acknowledgement for the retransmission.
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_LINK_REQUEST, "100"));
SendSymbolControl(RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "00011", "11111",
STYPE1_NOP, "000"));
 
-- Receive the start of the retransmitted frame.
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
 
-- Receive the data symbols of the retransmitted frame.
-- Receive the retransmitted frame.
-- Allow some ticks to pass to let the transmitter recover the error.
for i in 0 to 8 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
InboundSymbolIdle;
for i in 0 to frame.length-1 loop
ReceiveSymbolData(frame.payload(i));
OutboundSymbolData(frame.payload(i));
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
InboundSymbolIdle;
 
-- Wait for the frame to complete.
wait until frameComplete(3) = '1' and clk'event and clk = '1';
frameValid(3) <= '0';
-- Send acknowledge that the frame was received.
OutboundSymbolIdle;
InboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00011", "11111",
STYPE1_NOP, "000"));
for i in 0 to 4 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
-- Receive the end of the retransmitted frame.
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
TestWait(outboundSymbolWriteEmpty, '1', "symbols pending");
TestCompare(outboundFrameWriteEmpty, '1', "packet pending");
 
-- Send acknowledge that the frame was received.
SendSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00011", "11111",
STYPE1_NOP, "000"));
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 5:");
PrintS("Step 6:");
PrintS("Action: Let a packet timeout expire. Then answer with link-response.");
PrintS("Result: A link-request should be transmitted and the packet should");
PrintS(" be retransmitted.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC4-Step5");
PrintR("TG_RioSerial-TC4-Step6");
---------------------------------------------------------------------------
-- Create the frame.
1578,60 → 1763,84
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
frameValid(4) <= '1';
frameWrite(4) <= frame;
OutboundFrame(frame);
 
-- Receive the frame.
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
for i in 0 to 4 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
InboundSymbolIdle;
for i in 0 to frame.length-1 loop
ReceiveSymbolData(frame.payload(i));
OutboundSymbolData(frame.payload(i));
InboundSymbolIdle;
end loop;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
InboundSymbolIdle;
 
-- Wait a while to let the timer expire and receive the link-request.
for i in 0 to 2048 loop
wait until clk'event and clk = '1';
for j in 1 to 7 loop
for i in 0 to 256 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_NOP, "000"));
InboundSymbolIdle;
TestWait(outboundSymbolWriteEmpty, '1', "symbols pending");
end loop;
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_LINK_REQUEST, "100"));
 
-- Send a link-response to make the transmitter to back to normal mode.
SendSymbolControl(RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "00100", "11111",
STYPE1_NOP, "000"));
for i in 0 to 242 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
-- Receive the link-request and answer back with a link-response.
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_LINK_REQUEST, "100"));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "00100", "11111",
STYPE1_NOP, "000"));
-- Receive the retransmitted frame.
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
-- Allow some ticks to pass to let the transmitter recover the error.
for i in 0 to 8 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
InboundSymbolIdle;
for i in 0 to frame.length-1 loop
ReceiveSymbolData(frame.payload(i));
OutboundSymbolData(frame.payload(i));
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
InboundSymbolIdle;
 
-- Wait for the frame to complete.
wait until frameComplete(4) = '1' and clk'event and clk = '1';
frameValid(4) <= '0';
-- Send acknowledge that the frame was received.
OutboundSymbolIdle;
InboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00100", "11111",
STYPE1_NOP, "000"));
for i in 0 to 4 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
TestWait(outboundSymbolWriteEmpty, '1', "symbols pending");
TestCompare(outboundFrameWriteEmpty, '1', "packet pending");
 
-- Send acknowledge that the frame was received.
SendSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00100", "11111",
STYPE1_NOP, "000"));
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 6:");
PrintS("Step 7:");
PrintS("Action: Let a packet timeout expire. Then answer with link-response");
Prints(" that indicates that the packet was received.");
PrintS("Result: A link-request should be transmitted and the packet should");
PrintS(" not be retransmitted.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC4-Step6");
PrintR("TG_RioSerial-TC4-Step7");
---------------------------------------------------------------------------
-- Create the frame.
1641,44 → 1850,63
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
frameValid(5) <= '1';
frameWrite(5) <= frame;
OutboundFrame(frame);
 
-- Receive the frame.
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
for i in 0 to 4 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
InboundSymbolIdle;
for i in 0 to frame.length-1 loop
ReceiveSymbolData(frame.payload(i));
OutboundSymbolData(frame.payload(i));
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
InboundSymbolIdle;
 
wait until frameComplete(5) = '1' and clk'event and clk = '1';
frameValid(5) <= '0';
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
 
-- Wait a while to let the timer expire and receive the link-request.
for i in 0 to 2048 loop
wait until clk'event and clk = '1';
for j in 1 to 7 loop
for i in 0 to 256 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_NOP, "000"));
InboundSymbolIdle;
TestWait(outboundSymbolWriteEmpty, '1', "symbols pending");
end loop;
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_LINK_REQUEST, "100"));
for i in 0 to 242 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
 
-- Receive the link-request and answer back with a link-response.
-- Send a link-response that indicates that the frame was received to make
-- the transmitter to back to normal mode.
SendSymbolControl(RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "00110", "11111",
STYPE1_NOP, "000"));
-- the transmitter go back to normal mode.
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_LINK_REQUEST, "100"));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "00110", "11111",
STYPE1_NOP, "000"));
for i in 0 to 8 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
TestWait(outboundSymbolWriteEmpty, '1', "symbols pending");
TestCompare(outboundFrameWriteEmpty, '1', "packet pending");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 7:");
PrintS("Step 8:");
PrintS("Action: Let a packet timeout expire. No more replies.");
PrintS("Result: Three link-requests should be transmitted. When the third");
PrintS(" times out the link will be restarted.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC4-Step7");
PrintR("TG_RioSerial-TC4-Step8");
---------------------------------------------------------------------------
-- Create the frame.
1688,88 → 1916,120
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
frameValid(6) <= '1';
frameWrite(6) <= frame;
OutboundFrame(frame);
 
-- Receive the frame.
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
for i in 0 to 4 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
InboundSymbolIdle;
for i in 0 to frame.length-1 loop
ReceiveSymbolData(frame.payload(i));
OutboundSymbolData(frame.payload(i));
InboundSymbolIdle;
end loop;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
InboundSymbolIdle;
 
-- Wait a while to let the timer expire and receive the link-request.
for i in 0 to 2048 loop
wait until clk'event and clk = '1';
-- Let 3 link-requests timeout.
for k in 1 to 3 loop
-- Wait a while to let the timer expire and receive the link-request.
for j in 1 to 7 loop
for i in 0 to 256 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_NOP, "000"));
InboundSymbolIdle;
TestWait(outboundSymbolWriteEmpty, '1', "symbols pending");
end loop;
for i in 0 to 242 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_LINK_REQUEST, "100"));
InboundSymbolIdle;
TestWait(outboundSymbolWriteEmpty, '1', "symbols pending");
end loop;
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_LINK_REQUEST, "100"));
 
-- Wait a while to let the timer expire and receive the link-request.
for i in 0 to 2048 loop
wait until clk'event and clk = '1';
-- Wait for the third link-request to timeout.
for j in 1 to 7 loop
for i in 0 to 256 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_NOP, "000"));
InboundSymbolIdle;
TestWait(outboundSymbolWriteEmpty, '1', "symbols pending");
end loop;
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_LINK_REQUEST, "100"));
 
-- Wait a while to let the timer expire and receive the link-request.
for i in 0 to 2048 loop
wait until clk'event and clk = '1';
for i in 0 to 240 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_LINK_REQUEST, "100"));
TestWait(outboundSymbolWriteEmpty, '1', "symbols pending");
linkInitializedExpected <= '0';
 
-- Wait a while to let the timer expire and receive the link-request.
for i in 0 to 2048 loop
wait until clk'event and clk = '1';
end loop;
 
-- Reinitialize the transmitter.
for i in 0 to 255 loop
ReceiveSymbolIdle;
OutboundSymbolIdle;
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00110", "11111",
STYPE1_NOP, "000"));
for i in 0 to 14 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_NOP, "000"));
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00110", "11111",
STYPE1_NOP, "000"));
for j in 0 to 14 loop
for i in 0 to 15 loop
ReceiveSymbolIdle;
for j in 0 to 13 loop
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_NOP, "000"));
InboundSymbolIdle;
for i in 0 to 16 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_NOP, "000"));
end loop;
TestWait(outboundSymbolWriteEmpty, '1', "symbols pending");
linkInitializedExpected <= '1';
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_NOP, "000"));
InboundSymbolIdle;
 
-- Receive the frame.
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
for i in 0 to 2 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
InboundSymbolIdle;
for i in 0 to frame.length-1 loop
ReceiveSymbolData(frame.payload(i));
OutboundSymbolData(frame.payload(i));
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00110", "11111",
STYPE1_NOP, "000"));
for i in 0 to 4 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
 
wait until frameComplete(6) = '1' and clk'event and clk = '1';
frameValid(6) <= '0';
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
SendSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00110", "11111",
STYPE1_NOP, "000"));
TestWait(outboundSymbolWriteEmpty, '1', "symbols pending");
TestCompare(outboundFrameWriteEmpty, '1', "packet pending");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 8:");
PrintS("Step 9:");
PrintS("Action: Let a packet timeout expire. Then answer with totally ");
PrintS(" unexpected ackId.");
PrintS("Result: A link request should be transmitted and the link should ");
PrintS(" be restarted.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC4-Step8");
PrintR("TG_RioSerial-TC4-Step9");
---------------------------------------------------------------------------
-- Create the frame.
1779,102 → 2039,152
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
frameValid(7) <= '1';
frameWrite(7) <= frame;
OutboundFrame(frame);
 
-- Receive the frame.
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
for i in 0 to 4 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
InboundSymbolIdle;
for i in 0 to frame.length-1 loop
ReceiveSymbolData(frame.payload(i));
OutboundSymbolData(frame.payload(i));
InboundSymbolIdle;
end loop;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
InboundSymbolIdle;
 
-- Wait a while to let the timer expire and receive the link-request.
for i in 0 to 2048 loop
wait until clk'event and clk = '1';
for j in 1 to 7 loop
for i in 0 to 256 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_NOP, "000"));
InboundSymbolIdle;
TestWait(outboundSymbolWriteEmpty, '1', "symbols pending");
end loop;
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_LINK_REQUEST, "100"));
for i in 0 to 242 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
 
-- Send a link-response with unexpected ackId.
SendSymbolControl(RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "10000", "11111",
STYPE1_NOP, "000"));
-- Receive the link-request and answer back with a link-response.
-- Send a link-response that indicates a totally unexpected ackId.
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_LINK_REQUEST, "100"));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "10000", "11111",
STYPE1_NOP, "000"));
for i in 0 to 4 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
TestWait(outboundSymbolWriteEmpty, '1', "symbols pending");
linkInitializedExpected <= '0';
-- Reinitialize the transmitter.
for i in 0 to 255 loop
ReceiveSymbolIdle;
OutboundSymbolIdle;
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00111", "11111",
STYPE1_NOP, "000"));
for i in 0 to 250 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_NOP, "000"));
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "00111", "11111",
STYPE1_NOP, "000"));
for j in 0 to 14 loop
for i in 0 to 15 loop
ReceiveSymbolIdle;
for j in 0 to 13 loop
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_NOP, "000"));
InboundSymbolIdle;
for i in 0 to 16 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_NOP, "000"));
end loop;
TestWait(outboundSymbolWriteEmpty, '1', "symbols pending");
linkInitializedExpected <= '1';
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_NOP, "000"));
InboundSymbolIdle;
 
-- Receive the frame.
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
for i in 0 to 2 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
InboundSymbolIdle;
for i in 0 to frame.length-1 loop
ReceiveSymbolData(frame.payload(i));
OutboundSymbolData(frame.payload(i));
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00111", "11111",
STYPE1_NOP, "000"));
for i in 0 to 4 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
 
wait until frameComplete(7) = '1' and clk'event and clk = '1';
frameValid(7) <= '0';
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
SendSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00111", "11111",
STYPE1_NOP, "000"));
TestWait(outboundSymbolWriteEmpty, '1', "symbols pending");
TestCompare(outboundFrameWriteEmpty, '1', "packet pending");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 9:");
PrintS("Step 10:");
PrintS("Action: Send status with unexpected ackId in normal operation.");
PrintS("Result: The transmitter should disregard the error.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC4-Step9");
PrintR("TG_RioSerial-TC4-Step10");
---------------------------------------------------------------------------
 
-- Send a status with unexpected ackId.
SendSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "10000", "11111",
STYPE1_NOP, "000"));
OutboundSymbolIdle;
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "10000", "11111",
STYPE1_NOP, "000"));
 
-- Receive no change.
ReceiveSymbolIdle;
ReceiveSymbolIdle;
for i in 0 to 250 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_NOP, "000"));
InboundSymbolIdle;
 
TestWait(outboundSymbolWriteEmpty, '1', "symbols pending");
TestCompare(outboundFrameWriteEmpty, '1', "packet pending");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 10:");
PrintS("Step 11:");
PrintS("Action: Send packet-retry with unexpected ackId in normal operation.");
PrintS("Result: The transmitter should enter output-error-stopped.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC4-Step10");
PrintR("TG_RioSerial-TC4-Step11");
---------------------------------------------------------------------------
-- Send a packet-retry with unexpected ackId.
SendSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_RETRY, "10000", "11111",
STYPE1_NOP, "000"));
OutboundSymbolIdle;
InboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_RETRY, "10000", "11111",
STYPE1_NOP, "000"));
for i in 0 to 6 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
 
-- Receive link-request.
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_LINK_REQUEST, "100"));
 
-- Send a link-response with unexpected ackId.
SendSymbolControl(RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "01000", "11111",
STYPE1_NOP, "000"));
-- Create the frame.
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_LINK_REQUEST, "100"));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "01000", "11111",
STYPE1_NOP, "000"));
TestWait(outboundSymbolWriteEmpty, '1', "symbols pending");
-- Create a frame.
CreateRandomPayload(payload.data, seed1, seed2);
payload.length := 10;
frame := RioFrameCreate(ackId=>"01000", vc=>'0', crf=>'0', prio=>"00",
1881,48 → 2191,60
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
frameValid(8) <= '1';
frameWrite(8) <= frame;
OutboundFrame(frame);
 
-- Wait for the transmitter to recover the previous error.
for i in 0 to 8 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
-- Receive the frame.
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
InboundSymbolIdle;
for i in 0 to frame.length-1 loop
ReceiveSymbolData(frame.payload(i));
OutboundSymbolData(frame.payload(i));
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "01000", "11111",
STYPE1_NOP, "000"));
for i in 0 to 4 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
TestWait(outboundSymbolWriteEmpty, '1', "symbols pending");
TestCompare(outboundFrameWriteEmpty, '1', "packet pending");
 
wait until frameComplete(8) = '1' and clk'event and clk = '1';
frameValid(8) <= '0';
 
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
SendSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "01000", "11111",
STYPE1_NOP, "000"));
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 11:");
PrintS("Step 12:");
PrintS("Action: Send packet-accepted with unexpected ackId in normal ");
PrintS(" operation.");
PrintS("Result: The transmitter should enter output-error-stopped.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC4-Step11");
PrintR("TG_RioSerial-TC4-Step12");
---------------------------------------------------------------------------
 
-- Send a packet-accepted with unexpected ackId.
SendSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "10000", "11111",
STYPE1_NOP, "000"));
OutboundSymbolIdle;
InboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "10000", "11111",
STYPE1_NOP, "000"));
for i in 0 to 6 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
 
-- Receive link-request.
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_LINK_REQUEST, "100"));
 
-- Send a link-response with unexpected ackId.
SendSymbolControl(RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "01001", "11111",
STYPE1_NOP, "000"));
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_LINK_REQUEST, "100"));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "01001", "11111",
STYPE1_NOP, "000"));
TestWait(outboundSymbolWriteEmpty, '1', "symbols pending");
-- Create the frame.
CreateRandomPayload(payload.data, seed1, seed2);
payload.length := 11;
1930,32 → 2252,41
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
frameValid(9) <= '1';
frameWrite(9) <= frame;
OutboundFrame(frame);
 
-- Wait for the transmitter to recover the previous error.
for i in 0 to 8 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
 
-- Receive the frame.
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
InboundSymbolIdle;
for i in 0 to frame.length-1 loop
ReceiveSymbolData(frame.payload(i));
OutboundSymbolData(frame.payload(i));
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "01001", "11111",
STYPE1_NOP, "000"));
for i in 0 to 4 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
TestWait(outboundSymbolWriteEmpty, '1', "symbols pending");
TestCompare(outboundFrameWriteEmpty, '1', "packet pending");
 
wait until frameComplete(9) = '1' and clk'event and clk = '1';
frameValid(9) <= '0';
 
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
SendSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "01001", "11111",
STYPE1_NOP, "000"));
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 12:");
PrintS("Step 13:");
PrintS("Action: Send a packet and then accept it with unexpected ackId.");
PrintS("Result: The transmitter should enter output-error-stopped.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC4-Step12");
PrintR("TG_RioSerial-TC4-Step13");
---------------------------------------------------------------------------
-- Create the frame.
1965,178 → 2296,153
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
frameValid(10) <= '1';
frameWrite(10) <= frame;
OutboundFrame(frame);
 
-- Receive the frame.
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
-- Send unexpected ackId in packet-accepted.
for i in 0 to 4 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
InboundSymbolIdle;
for i in 0 to frame.length-1 loop
ReceiveSymbolData(frame.payload(i));
OutboundSymbolData(frame.payload(i));
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "10000", "11111",
STYPE1_NOP, "000"));
 
wait until frameComplete(10) = '1' and clk'event and clk = '1';
frameValid(10) <= '0';
-- Receive link-request.
for i in 0 to 6 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_LINK_REQUEST, "100"));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "01011", "11111",
STYPE1_NOP, "000"));
 
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
-- Wait some additional ticks to let the transmitter recover the previous error.
for i in 0 to 6 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
-- Send unexpected ackId in packet-accepted.
SendSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "10000", "11111",
STYPE1_NOP, "000"));
 
-- Receive link-request.
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_LINK_REQUEST, "100"));
 
-- Send a link-response with expected ackId.
SendSymbolControl(RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "01011", "11111",
STYPE1_NOP, "000"));
 
TestWait(outboundSymbolWriteEmpty, '1', "symbols pending");
TestCompare(outboundFrameWriteEmpty, '1', "packet pending");
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 13:");
PrintS("Action: Set two valid packets.");
PrintS("Result: The two packet should be sent without waiting for ");
PrintS(" packet-accepted.");
PrintS("TG_RioSerial-TC5");
PrintS("Description: Test mixed port transmission and reception.");
PrintS("Requirement: XXXXX");
PrintS("-----------------------------------------------------------------");
PrintS("Step 1:");
PrintS("Action: Start sending an outbound packet and while in transmission, ");
PrintS(" start and complete an inbound packet.");
PrintS("Result: The ack for the inbound packet should be inserted into the");
PrintS(" outbound packet.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC4-Step13");
PrintR("TG_RioSerial-TC5-Step1");
---------------------------------------------------------------------------
 
-- Create the first frame.
-- Send a long outbound frame.
CreateRandomPayload(payload.data, seed1, seed2);
payload.length := 13;
frame := RioFrameCreate(ackId=>"01011", vc=>'0', crf=>'0', prio=>"00",
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
frameValid(11) <= '1';
frameWrite(11) <= frame;
payload.length := 133;
frameOutbound := RioFrameCreate(ackId=>"01011", vc=>'0', crf=>'0', prio=>"00",
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
OutboundFrame(frameOutbound);
 
-- Create the second frame.
-- Receive a short inbound frame.
CreateRandomPayload(payload.data, seed1, seed2);
payload.length := 14;
frame := RioFrameCreate(ackId=>"01100", vc=>'0', crf=>'0', prio=>"00",
payload.length := 2;
frameInbound := RioFrameCreate(ackId=>"01100", vc=>'0', crf=>'0', prio=>"00",
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
frameValid(12) <= '1';
frameWrite(12) <= frame;
InboundFrame(frameInbound);
 
-- Receive the frame.
ReceiveSymbolIdle;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
for i in 0 to frameWrite(11).length-1 loop
ReceiveSymbolData(frameWrite(11).payload(i));
-- Receive the outbound frame and start a short inbound frame at the same time.
for i in 0 to 4 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
 
-- Receive the frame.
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
InboundSymbolIdle;
 
OutboundSymbolData(frameOutbound.payload(0));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "10000", "11111",
STYPE1_START_OF_PACKET, "000"));
for i in 0 to frameWrite(12).length-1 loop
ReceiveSymbolData(frameWrite(12).payload(i));
end loop;
 
wait until frameComplete(11) = '1' and clk'event and clk = '1';
frameValid(11) <= '0';
wait until frameComplete(12) = '1' and clk'event and clk = '1';
frameValid(12) <= '0';
OutboundSymbolData(frameOutbound.payload(1));
InboundSymbolData(frameInbound.payload(0));
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
OutboundSymbolData(frameOutbound.payload(2));
InboundSymbolData(frameInbound.payload(1));
OutboundSymbolData(frameOutbound.payload(3));
InboundSymbolData(frameInbound.payload(2));
OutboundSymbolData(frameOutbound.payload(4));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "10000", "11111",
STYPE1_END_OF_PACKET, "000"));
-- Send packet-accepted for both packets.
SendSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "01011", "11111",
STYPE1_NOP, "000"));
SendSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "01100", "11111",
STYPE1_NOP, "000"));
OutboundSymbolData(frameOutbound.payload(5));
InboundSymbolIdle;
OutboundSymbolData(frameOutbound.payload(6));
InboundSymbolIdle;
OutboundSymbolData(frameOutbound.payload(7));
InboundSymbolIdle;
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 14:");
PrintS("Action: Set maximum number of valid packets.");
PrintS("Result: Maximum 31 packets should be sent without waiting for ");
PrintS(" packet-accepted.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC4-Step14");
---------------------------------------------------------------------------
OutboundSymbolData(frameOutbound.payload(8));
InboundSymbolIdle;
 
---------------------------------------------------------------------------
-- Create the frames.
---------------------------------------------------------------------------
OutboundSymbolData(frameOutbound.payload(9));
InboundSymbolIdle;
 
for j in 0 to 47 loop
CreateRandomPayload(payload.data, seed1, seed2);
payload.length := j+13;
frame := RioFrameCreate(ackId=>std_logic_vector(to_unsigned((j+13) mod 32, 5)),
vc=>'0', crf=>'0', prio=>"00",
tt=>"01", ftype=>"0000",
sourceId=>x"0000", destId=>x"0000",
payload=>payload);
frameValid(j+13) <= '1';
frameWrite(j+13) <= frame;
end loop;
OutboundSymbolData(frameOutbound.payload(10));
InboundSymbolIdle;
 
---------------------------------------------------------------------------
-- Receive the frames.
---------------------------------------------------------------------------
OutboundSymbolData(frameOutbound.payload(11));
InboundSymbolIdle;
 
ReceiveSymbolIdle;
for j in 0 to 29 loop
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
for i in 0 to frameWrite(j+13).length-1 loop
ReceiveSymbolData(frameWrite(j+13).payload(i));
end loop;
OutboundSymbolData(frameOutbound.payload(12));
InboundSymbolIdle;
 
wait until frameComplete(j+13) = '1' and clk'event and clk = '1';
frameValid(j+13) <= '0';
end loop;
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "01100", "11111",
STYPE1_NOP, "000"));
InboundSymbolIdle;
 
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_START_OF_PACKET, "000"));
for i in 0 to frameWrite(43).length-1 loop
ReceiveSymbolData(frameWrite(43).payload(i));
for i in 13 to frameOutbound.length-1 loop
OutboundSymbolData(frameOutbound.payload(i));
InboundSymbolIdle;
end loop;
ReceiveSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
STYPE1_END_OF_PACKET, "000"));
wait until frameComplete(43) = '1' and clk'event and clk = '1';
frameValid(43) <= '0';
 
-- REMARK: Complete the testcase and acknowledge all transmitted packets...
SendSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "01101", "11111",
STYPE1_NOP, "000"));
OutboundSymbolControl(RioControlSymbolCreate(STYPE0_STATUS, "01101", "11111",
STYPE1_END_OF_PACKET, "000"));
InboundSymbolControl(RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "01011", "11111",
STYPE1_NOP, "000"));
 
for i in 0 to 4 loop
OutboundSymbolIdle;
InboundSymbolIdle;
end loop;
TestWait(outboundSymbolWriteEmpty, '1', "symbols pending");
TestCompare(outboundFrameWriteEmpty, '1', "packet pending");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step X:");
PrintS("Action: Start sending an outbound packet and while in transmission, ");
PrintS(" start and complete an inbound packet.");
PrintS("Result: The ack for the inbound packet should be inserted into the");
PrintS(" outbound packet.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC4-StepX");
---------------------------------------------------------------------------
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step X:");
PrintS("Action: Send a packet but not all content is available yet.");
PrintS("Result: Idle symbols should be inserted into the packet.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC4-StepX");
---------------------------------------------------------------------------
---------------------------------------------------------------------------
-- REMARK: Send long frames with a CRC in the middle...
---------------------------------------------------------------------------
---------------------------------------------------------------------------
-- Test completed.
---------------------------------------------------------------------------
 
2143,50 → 2449,28
TestEnd;
end process;
 
-----------------------------------------------------------------------------
--
-- Instantiate interface simulator models.
-----------------------------------------------------------------------------
OutboundSymbolCheck: process
 
process
begin
wait until clk = '1';
assert not ((outboundControlValid = '1') and (outboundDataValid = '1'))
report "Unallowed symbol sent."
severity error;
if (outboundControlExpected = '1') then
assert outboundControlValid = '1'
report "Expected an outbound control symbol."
severity error;
assert outboundControlSymbol = outboundControlSymbolExpected
report "Unexpected outbound control symbol content."
severity error;
elsif (outboundDataExpected = '1') then
assert outboundDataValid = '1'
report "Expected an outbound data symbol."
severity error;
assert outboundDataSymbol = outboundDataSymbolExpected
report "Unexpected outbound data symbol content."
severity error;
else
assert outboundControlValid = '0'
report "Not expecting outbound control symbol."
severity error;
assert outboundDataValid = '0'
report "Not expecting outbound data symbol."
severity error;
end if;
TestCompare(linkInitialized, linkInitializedExpected, "link initialized");
end process;
-----------------------------------------------------------------------------
-- Instantiate a SwitchPort emulator.
-----------------------------------------------------------------------------
 
TestPort: TestSwitchPort
generic map(
NUMBER_WORDS=>1)
SwitchPort: TestSwitchPort
port map(
clk=>clk, areset_n=>areset_n,
frameValid_i=>frameValid, frameWrite_i=>frameWrite, frameComplete_o=>frameComplete,
frameExpected_i=>frameExpected, frameRead_i=>frameRead, frameReceived_o=>frameReceived,
outboundWriteEmpty_o=>outboundFrameWriteEmpty,
outboundWrite_i=>outboundFrameWrite,
outboundWriteMessage_i=>outboundFrameWriteMessage,
outboundWriteAck_o=>outboundFrameWriteAck,
inboundWriteEmpty_o=>inboundFrameWriteEmpty,
inboundWrite_i=>inboundFrameWrite,
inboundWriteMessage_i=>inboundFrameWriteMessage,
inboundWriteAck_o=>inboundFrameWriteAck,
readFrameEmpty_o=>readFrameEmpty, readFrame_i=>readFrame,
readFrameRestart_i=>readFrameRestart, readFrameAborted_o=>readFrameAborted,
readWindowEmpty_o=>readWindowEmpty,
2193,9 → 2477,30
readWindowReset_i=>readWindowReset, readWindowNext_i=>readWindowNext,
readContentEmpty_o=>readContentEmpty, readContent_i=>readContent,
readContentEnd_o=>readContentEnd, readContentData_o=>readContentData,
writeFrameFull_o=>writeFrameFull, writeFrame_i=>writeFrame, writeFrameAbort_i=>writeFrameAbort,
writeFrame_i=>writeFrame, writeFrameAbort_i=>writeFrameAbort,
writeContent_i=>writeContent, writeContentData_i=>writeContentData);
 
PcsPort: TestSymbolPort
port map(
clk=>clk, areset_n=>areset_n,
portInitialized_i=>portInitialized,
outboundControlValid_i=>outboundControlValid,
outboundControlSymbol_i=>outboundControlSymbol,
outboundDataValid_i=>outboundDataValid,
outboundDataSymbol_i=>outboundDataSymbol,
inboundControlValid_o=>inboundControlValid,
inboundControlSymbol_o=>inboundControlSymbol,
inboundDataValid_o=>inboundDataValid,
inboundDataSymbol_o=>inboundDataSymbol,
outboundWriteEmpty_o=>outboundSymbolWriteEmpty,
outboundWrite_i=>outboundSymbolWrite,
outboundWriteMessage_i=>outboundSymbolWriteMessage,
outboundWriteAck_o=>outboundSymbolWriteAck,
inboundWriteEmpty_o=>inboundSymbolWriteEmpty,
inboundWrite_i=>inboundSymbolWrite,
inboundWriteMessage_i=>inboundSymbolWriteMessage,
inboundWriteAck_o=>inboundSymbolWriteAck);
-----------------------------------------------------------------------------
-- Instantiate the test object.
-----------------------------------------------------------------------------
2228,7 → 2533,7
readContent_o=>readContent,
readContentEnd_i=>readContentEnd,
readContentData_i=>readContentData,
writeFrameFull_i=>writeFrameFull,
writeFrameFull_i=>inboundFrameFull,
writeFrame_o=>writeFrame,
writeFrameAbort_o=>writeFrameAbort,
writeContent_o=>writeContent,
2256,41 → 2561,39
library std;
use std.textio.all;
use work.rio_common.all;
use work.TestRioSerialPackage.all;
 
 
-------------------------------------------------------------------------------
--
-------------------------------------------------------------------------------
entity TestSwitchPort is
generic(
NUMBER_WORDS : natural range 1 to 8 := 1);
port(
clk : in std_logic;
areset_n : in std_logic;
 
frameValid_i : in std_logic_vector(0 to 63);
frameWrite_i : in RioFrameArray(0 to 63);
frameComplete_o : out std_logic_vector(0 to 63);
outboundWriteEmpty_o : out std_logic;
outboundWrite_i : in std_logic;
outboundWriteMessage_i : in MessageFrame;
outboundWriteAck_o : out std_logic;
frameExpected_i : in std_logic;
frameRead_i : in RioFrame;
frameReceived_o : out std_logic;
 
inboundWriteEmpty_o : out std_logic;
inboundWrite_i : in std_logic;
inboundWriteMessage_i : in MessageFrame;
inboundWriteAck_o : out std_logic;
readFrameEmpty_o : out std_logic;
readFrame_i : in std_logic;
readFrameRestart_i : in std_logic;
readFrameAborted_o : out std_logic;
 
readWindowEmpty_o : out std_logic;
readWindowReset_i : in std_logic;
readWindowNext_i : in std_logic;
readContentEmpty_o : out std_logic;
readContent_i : in std_logic;
readContentEnd_o : out std_logic;
readContentData_o : out std_logic_vector(31 downto 0);
writeFrameFull_o : out std_logic;
writeFrame_i : in std_logic;
writeFrameAbort_i : in std_logic;
writeContent_i : in std_logic;
2302,101 → 2605,126
--
-------------------------------------------------------------------------------
architecture TestSwitchPortImpl of TestSwitchPort is
constant QUEUE_SIZE : natural := 63;
type QueueArray is array (natural range <>) of MessageFrame;
function QueueIndexInc(constant i : natural) return natural is
variable returnValue : natural;
begin
if(i = QUEUE_SIZE) then
returnValue := 0;
else
returnValue := i + 1;
end if;
return returnValue;
end function;
begin
-----------------------------------------------------------------------------
--
-----------------------------------------------------------------------------
FrameSender: process
variable frameComplete : std_logic_vector(0 to 63);
variable frameIndex : natural range 0 to 70;
variable backIndex, frontIndex : natural range 0 to 63;
Outbound: process
variable frameQueue : QueueArray(0 to QUEUE_SIZE);
variable front, back, window : natural range 0 to QUEUE_SIZE;
variable frameIndex : natural;
begin
wait until areset_n = '1';
readFrameEmpty_o <= '1';
readFrameAborted_o <= '0';
readWindowEmpty_o <= '1';
readContentEmpty_o <= '1';
readContentEnd_o <= '0';
readContentData_o <= (others=>'U');
frameComplete_o <= (others=>'0');
frameComplete := (others=>'0');
backIndex := 0;
frontIndex := 0;
wait until areset_n = '1';
readContentData_o <= (others=>'0');
 
front := 0;
back := 0;
window := 0;
frameIndex := 0;
outboundWriteEmpty_o <= '1';
outboundWriteAck_o <= '0';
 
loop
wait until clk'event and clk = '1';
wait until clk = '1' or outboundWrite_i = '1';
 
if (readFrame_i = '1') then
assert (frontIndex - backIndex) >= 0 report "Unexpected readFrame." severity error;
if(backIndex < 63) then
backIndex := backIndex + 1;
else
backIndex := 0;
if (clk'event) then
if (readFrame_i = '1') then
if (back /= front) then
back := QueueIndexInc(back);
else
TestError("OUTBOUND:BACK:reading when no frame is present");
end if;
end if;
end if;
if (readWindowReset_i = '1') then
frameComplete := (others=>'0');
frameIndex := 0;
frontIndex := backIndex;
readContentEnd_o <= '0';
readContentData_o <= (others=>'U');
end if;
 
if (readWindowNext_i = '1') then
assert frameComplete(frontIndex) = '0' report "Reading next frame too fast." severity error;
assert frameIndex = frameWrite_i(frontIndex).length report "Did not read all frame content." severity error;
readContentEnd_o <= '0';
readContentData_o <= (others=>'U');
frameComplete(frontIndex) := '1';
frameIndex := 0;
if(frontIndex < 63) then
frontIndex := frontIndex + 1;
else
frontIndex := 0;
if (readFrameRestart_i = '1') then
frameIndex := 0;
end if;
end if;
if (readWindowReset_i = '1') then
window := back;
frameIndex := 0;
end if;
 
for i in 0 to 63 loop
if (frameComplete(i) = '1') and (frameValid_i(i) = '0') then
frameComplete(i) := '0';
if (readWindowNext_i = '1') then
if (window /= front) then
window := QueueIndexInc(window);
frameIndex := 0;
else
TestError("OUTBOUND:WINDOW:reading when no frame is present");
end if;
end if;
end loop;
frameComplete_o <= frameComplete;
if (readContent_i = '1') then
if (back /= front) then
if (frameIndex < frameQueue(window).frame.length) then
readContentData_o <= frameQueue(window).frame.payload(frameIndex);
frameIndex := frameIndex + 1;
if (frameIndex = frameQueue(window).frame.length) then
readContentEnd_o <= '1';
else
readContentEnd_o <= '0';
end if;
else
TestError("OUTBOUND:CONTENT:reading when frame has ended");
end if;
else
TestError("OUTBOUND:CONTENT:reading when no frame is present");
end if;
end if;
 
if ((frameComplete(frontIndex) = '0') and
(frameValid_i(frontIndex) = '1')) then
readWindowEmpty_o <= '0';
else
readWindowEmpty_o <= '1';
end if;
 
if (readFrameRestart_i = '1') then
frameIndex := 0;
readContentEnd_o <= '0';
readContentData_o <= (others=>'U');
end if;
if (readContent_i = '1') then
assert frameValid_i(frontIndex) = '1' report "Unexpected content read." severity error;
readContentData_o <= frameWrite_i(frontIndex).payload(frameIndex);
frameIndex := frameIndex + 1;
if (frameIndex /= frameWrite_i(frontIndex).length) then
readContentEnd_o <= '0';
if (front = back) then
readFrameEmpty_o <= '1';
else
readContentEnd_o <= '1';
readFrameEmpty_o <= '0';
end if;
end if;
if (front = window) then
readWindowEmpty_o <= '1';
readContentEmpty_o <= '1';
else
readWindowEmpty_o <= '0';
if (frameIndex /= frameQueue(window).frame.length) then
readContentEmpty_o <= '0';
else
readContentEmpty_o <= '1';
end if;
end if;
if (front = back) then
outboundWriteEmpty_o <= '1';
else
outboundWriteEmpty_o <= '0';
end if;
elsif (outboundWrite_i'event) then
frameQueue(front) := outboundWriteMessage_i;
front := QueueIndexInc(front);
 
if(frameValid_i(frontIndex) = '1') and (frameComplete(frontIndex) = '0') then
readFrameEmpty_o <= '0';
readContentEmpty_o <= '0';
else
readFrameEmpty_o <= '1';
readContentEmpty_o <= '1';
outboundWriteEmpty_o <= '0';
outboundWriteAck_o <= '1';
wait until outboundWrite_i = '0';
outboundWriteAck_o <= '0';
end if;
end loop;
end process;
 
2403,58 → 2731,287
-----------------------------------------------------------------------------
--
-----------------------------------------------------------------------------
FrameReader: process
type StateType is (STATE_IDLE, STATE_READ, STATE_UPDATE);
variable state : StateType;
Inbound: process
variable frameQueue : QueueArray(0 to QUEUE_SIZE);
variable front, back : natural range 0 to QUEUE_SIZE;
variable frameIndex : natural range 0 to 69;
begin
writeFrameFull_o <= '1';
frameReceived_o <= '0';
wait until areset_n = '1';
 
state := STATE_IDLE;
inboundWriteEmpty_o <= '1';
inboundWriteAck_o <= '0';
 
front := 0;
back := 0;
frameIndex := 0;
 
loop
wait until clk'event and clk = '1';
case state is
when STATE_IDLE =>
frameReceived_o <= '0';
if (frameExpected_i = '1') then
state := STATE_READ;
frameIndex := 0;
writeFrameFull_o <= '0';
wait until clk = '1' or inboundWrite_i = '1';
 
if (clk'event) then
 
if (writeFrame_i = '1') then
if (frameIndex = 0) then
TestError("INBOUND:Empty frame written.");
end if;
assert writeFrame_i = '0' report "Unexpected frame received." severity error;
--assert writeFrameAbort_i = '0' report "Unexpected frame aborted received." severity error;
assert writeContent_i = '0' report "Unexpected content received." severity error;
when STATE_READ =>
if (writeFrame_i = '1') then
state := STATE_UPDATE;
frameReceived_o <= '1';
writeFrameFull_o <= '1';
assert frameIndex = frameRead_i.length report "Did not finish the expected frame." severity error;
if (frameIndex /= frameQueue(back).frame.length) then
TestError("INBOUND:Frame with unmatching length was written.");
end if;
if (writeFrameAbort_i = '1') then
frameIndex := 0;
if (back /= front) then
back := QueueIndexInc(back);
else
TestError("INBOUND:Unexpected frame written.");
end if;
if (writeContent_i = '1') then
assert writeContentData_i(32*NUMBER_WORDS-1 downto 0) = frameRead_i.payload(frameIndex)
report "Unexpected frame content received." severity error;
frameIndex := 0;
end if;
 
if (writeFrameAbort_i = '1') then
if (back /= front) then
if (frameQueue(back).willAbort) then
if (frameIndex /= frameQueue(back).frame.length) then
TestError("INBOUND:Frame with unmatching length was aborted.");
end if;
back := QueueIndexInc(back);
else
TestError("INBOUND:Not expecting this frame to abort.");
end if;
end if;
frameIndex := 0;
end if;
 
if (writeContent_i = '1') then
if (frameIndex < frameQueue(back).frame.length) then
if (frameQueue(back).frame.payload(frameIndex) /= writeContentData_i) then
TestError("INBOUND:Unexpected frame content written.");
end if;
frameIndex := frameIndex + 1;
else
TestError("INBOUND:Receiving more frame content than expected.");
end if;
if (frameExpected_i = '0') then
state := STATE_IDLE;
end if;
if (front = back) then
inboundWriteEmpty_o <= '1';
else
inboundWriteEmpty_o <= '0';
end if;
elsif (inboundWrite_i'event) then
frameQueue(front) := inboundWriteMessage_i;
front := QueueIndexInc(front);
 
inboundWriteEmpty_o <= '0';
inboundWriteAck_o <= '1';
wait until inboundWrite_i = '0';
inboundWriteAck_o <= '0';
end if;
end loop;
end process;
 
end architecture;
 
 
 
-------------------------------------------------------------------------------
--
-------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
library std;
use std.textio.all;
use work.rio_common.all;
use work.TestRioSerialPackage.all;
 
 
-------------------------------------------------------------------------------
--
-------------------------------------------------------------------------------
entity TestSymbolPort is
port(
clk : in std_logic;
areset_n : in std_logic;
 
portInitialized_i : in std_logic;
outboundControlValid_i : in std_logic;
outboundControlSymbol_i : in std_logic_vector(23 downto 0);
outboundDataValid_i : in std_logic;
outboundDataSymbol_i : in std_logic_vector(31 downto 0);
inboundControlValid_o : out std_logic;
inboundControlSymbol_o : out std_logic_vector(23 downto 0);
inboundDataValid_o : out std_logic;
inboundDataSymbol_o : out std_logic_vector(31 downto 0);
 
outboundWriteEmpty_o : out std_logic;
outboundWrite_i : in std_logic;
outboundWriteMessage_i : in MessageSymbol;
outboundWriteAck_o : out std_logic;
 
inboundWriteEmpty_o : out std_logic;
inboundWrite_i : in std_logic;
inboundWriteMessage_i : in MessageSymbol;
inboundWriteAck_o : out std_logic);
end entity;
 
 
-------------------------------------------------------------------------------
--
-------------------------------------------------------------------------------
architecture TestSymbolPortImpl of TestSymbolPort is
constant QUEUE_SIZE : natural := 2047;
type QueueArray is array (natural range <>) of MessageSymbol;
 
function QueueIndexInc(constant i : natural) return natural is
variable returnValue : natural;
begin
if(i = QUEUE_SIZE) then
returnValue := 0;
else
returnValue := i + 1;
end if;
return returnValue;
end function;
 
begin
-----------------------------------------------------------------------------
--
-----------------------------------------------------------------------------
Outbound: process
variable front, back : natural range 0 to QUEUE_SIZE;
variable symbolQueue : QueueArray(0 to QUEUE_SIZE);
begin
wait until areset_n = '1';
 
front := 0;
back := 0;
outboundWriteEmpty_o <= '1';
outboundWriteAck_o <= '0';
 
loop
wait until clk = '1' or outboundWrite_i = '1';
 
if (clk'event) then
if (back /= front) then
if (symbolQueue(back).symbolType = "01") then
if (not ((symbolQueue(back).ignoreIdle) and
(outboundControlValid_i = '0') and
(outboundDataValid_i = '0'))) then
TestCompare(outboundControlValid_i, '1', "OUTBOUND:control symbol");
TestCompare(outboundControlSymbol_i(23 downto 21), symbolQueue(back).symbolContent(23 downto 21),
"OUTBOUND:stype0=" & to_string(symbolQueue(back).symbolContent(23 downto 21)));
TestCompare(outboundControlSymbol_i(20 downto 16), symbolQueue(back).symbolContent(20 downto 16),
"OUTBOUND:parameter0=" & to_string(symbolQueue(back).symbolContent(20 downto 16)));
TestCompare(outboundControlSymbol_i(15 downto 11), symbolQueue(back).symbolContent(15 downto 11),
"OUTBOUND:parameter1=" & to_string(symbolQueue(back).symbolContent(15 downto 11)));
TestCompare(outboundControlSymbol_i(10 downto 8), symbolQueue(back).symbolContent(10 downto 8),
"OUTBOUND:stype1=" & to_string(symbolQueue(back).symbolContent(10 downto 8)));
TestCompare(outboundControlSymbol_i(7 downto 5), symbolQueue(back).symbolContent(7 downto 5),
"OUTBOUND:cmd=" & to_string(symbolQueue(back).symbolContent(7 downto 5)));
TestCompare(outboundControlSymbol_i(4 downto 0), symbolQueue(back).symbolContent(4 downto 0),
"OUTBOUND:crc5=" & to_string(symbolQueue(back).symbolContent(4 downto 0)));
TestCompare(outboundDataValid_i, '0', "OUTBOUND:no data symbol");
back := QueueIndexInc(back);
end if;
elsif (symbolQueue(back).symbolType = "10") then
if (not ((symbolQueue(back).ignoreIdle) and
(outboundControlValid_i = '0') and
(outboundDataValid_i = '0'))) then
TestCompare(outboundDataValid_i, '1', "OUTBOUND:valid data symbol");
TestCompare(outboundDataSymbol_i, symbolQueue(back).symbolContent(31 downto 0),
"OUTBOUND:data symbol content");
TestCompare(outboundControlValid_i, '0', "OUTBOUND:valid control symbol");
back := QueueIndexInc(back);
end if;
elsif (symbolQueue(back).symbolType = "00") then
TestCompare(outboundControlValid_i, '0', "OUTBOUND:valid control symbol");
TestCompare(outboundDataValid_i, '0', "OUTBOUND:valid data symbol");
back := QueueIndexInc(back);
else
TestCompare(outboundControlValid_i, '1', "OUTBOUND:valid control symbol");
TestCompare(outboundDataValid_i, '1', "OUTBOUND:valid data symbol");
back := QueueIndexInc(back);
end if;
 
when STATE_UPDATE =>
if (frameExpected_i = '0') then
state := STATE_IDLE;
if (front = back) then
outboundWriteEmpty_o <= '1';
else
outboundWriteEmpty_o <= '0';
end if;
end case;
end loop;
else
TestError("OUTBOUND:empty symbol queue");
end if;
elsif (outboundWrite_i'event) then
symbolQueue(front) := outboundWriteMessage_i;
front := QueueIndexInc(front);
 
outboundWriteEmpty_o <= '0';
outboundWriteAck_o <= '1';
wait until outboundWrite_i = '0';
outboundWriteAck_o <= '0';
end if;
end loop;
end process;
 
-----------------------------------------------------------------------------
--
-----------------------------------------------------------------------------
Inbound: process
variable front, back : natural range 0 to QUEUE_SIZE;
variable symbolQueue : QueueArray(0 to QUEUE_SIZE);
begin
wait until areset_n = '1';
 
front := 0;
back := 0;
inboundWriteEmpty_o <= '1';
inboundWriteAck_o <= '0';
 
inboundControlValid_o <= '0';
inboundControlSymbol_o <= (others=>'U');
inboundDataValid_o <= '0';
inboundDataSymbol_o <= (others=>'U');
loop
wait until clk = '1' or inboundWrite_i = '1';
 
if (clk'event) then
if (back /= front) then
if (symbolQueue(back).symbolType = "00") then
inboundControlValid_o <= '0';
inboundDataValid_o <= '0';
elsif (symbolQueue(back).symbolType = "01") then
inboundControlValid_o <= '1';
inboundControlSymbol_o <= symbolQueue(back).symbolContent(23 downto 0);
inboundDataValid_o <= '0';
elsif (symbolQueue(back).symbolType = "10") then
inboundControlValid_o <= '0';
inboundDataValid_o <= '1';
inboundDataSymbol_o <= symbolQueue(back).symbolContent(31 downto 0);
else
inboundControlValid_o <= '1';
inboundDataValid_o <= '1';
end if;
 
back := QueueIndexInc(back);
 
if (front = back) then
inboundWriteEmpty_o <= '1';
else
inboundWriteEmpty_o <= '0';
end if;
else
TestError("INBOUND:empty symbol queue");
end if;
elsif (inboundWrite_i'event) then
symbolQueue(front) := inboundWriteMessage_i;
front := QueueIndexInc(front);
 
inboundWriteEmpty_o <= '0';
inboundWriteAck_o <= '1';
wait until inboundWrite_i = '0';
inboundWriteAck_o <= '0';
end if;
end loop;
end process;
 
end architecture;
/branches/singleSymbol/rtl/vhdl/RioCommon.vhd
269,6 → 269,12
function byteToString(constant byte : std_logic_vector(7 downto 0))
return string;
 
-----------------------------------------------------------------------------
-- Function to print a std_logic_vector.
-----------------------------------------------------------------------------
function to_string(constant value : std_logic_vector)
return string;
---------------------------------------------------------------------------
-- Procedure to print to report file and output
---------------------------------------------------------------------------
290,8 → 296,44
procedure PrintE( constant str : string );
 
---------------------------------------------------------------------------
-- Procedure to end a test.
-- Procedures for test control.
---------------------------------------------------------------------------
 
procedure TestWarning(constant tag : in string);
procedure TestError(constant tag : in string;
constant stopAtError : in boolean := true);
procedure TestCompare(constant expression : in boolean;
constant tag : in string := "";
constant stopAtError : in boolean := true);
procedure TestCompare(constant got : in std_logic;
constant expected : in std_logic;
constant tag : in string := "";
constant stopAtError : in boolean := true);
procedure TestCompare(constant got : in std_logic_vector;
constant expected : in std_logic_vector;
constant tag : in string := "";
constant stopAtError : in boolean := true);
procedure TestCompare(constant got : in natural;
constant expected : in natural;
constant tag : in string := "";
constant stopAtError : in boolean := true);
procedure TestCompare(constant got : in time;
constant expected : in time;
constant tag : in string := "";
constant stopAtError : in boolean := true);
procedure TestWait(signal waitSignal : in std_logic;
constant waitValue : in std_logic;
constant tag : in string := "";
constant waitTime : in time := 1 ms;
constant stopAtError : in boolean := true);
procedure TestWait(signal waitSignal : in std_logic;
constant waitValue : in std_logic;
signal ackSignal : inout std_logic;
constant tag : in string := "";
constant waitTime : in time := 1 ms;
constant stopAtError : in boolean := true);
 
procedure TestEnd;
 
end package;
688,6 → 730,48
return returnValue;
end function;
-----------------------------------------------------------------------------
-- Function to print std_logic_vector.
-----------------------------------------------------------------------------
function to_string(constant value : std_logic) return string is
variable s : string(1 to 1);
begin
if (value = '0') then
s(1) := '0';
elsif (value = '1') then
s(1) := '1';
elsif (value = 'U') then
s(1) := 'U';
elsif (value = 'X') then
s(1) := 'X';
else
s(1) := '?';
end if;
return s;
end function;
function to_string(constant value : std_logic_vector) return string is
variable s : string(1 to value'length);
variable index : positive;
variable i : natural;
begin
index := 1;
for i in value'range loop
if (value(i) = '0') then
s(index) := '0';
elsif (value(i) = '1') then
s(index) := '1';
elsif (value(i) = 'U') then
s(index) := 'U';
elsif (value(i) = 'X') then
s(index) := 'X';
else
s(index) := '?';
end if;
index := index + 1;
end loop;
return s;
end function;
---------------------------------------------------------------------------
-- Procedure to print test report
---------------------------------------------------------------------------
745,14 → 829,216
end PrintE;
 
---------------------------------------------------------------------------
-- Procedure to end a test.
-- Procedures to handle tests.
---------------------------------------------------------------------------
 
procedure TestWarning(constant tag : in string) is
variable writeBuffer : line;
begin
write(writeBuffer, now);
write(writeBuffer, string'(":WARNING:"));
write(writeBuffer, tag);
writeline(OUTPUT, writeBuffer);
end procedure;
procedure TestError(constant tag : in string;
constant stopAtError : in boolean := true) is
variable writeBuffer : line;
begin
write(writeBuffer, now);
write(writeBuffer, string'(":FAILED:"));
write(writeBuffer, tag);
writeline(OUTPUT, writeBuffer);
if (stopAtError) then
std.env.stop(0);
end if;
end procedure;
procedure TestCompare(constant expression : in boolean;
constant tag : in string := "";
constant stopAtError : in boolean := true) is
variable writeBuffer : line;
begin
write(writeBuffer, now);
if (not expression) then
write(writeBuffer, string'(":FAILED:"));
else
write(writeBuffer, string'(":PASSED:"));
end if;
write(writeBuffer, tag);
writeline(OUTPUT, writeBuffer);
if (stopAtError) and (not expression) then
std.env.stop(0);
end if;
end procedure;
procedure TestCompare(constant got : in std_logic;
constant expected : in std_logic;
constant tag : in string := "";
constant stopAtError : in boolean := true) is
variable writeBuffer : line;
begin
write(writeBuffer, now);
if (expected /= got) then
write(writeBuffer, string'(":FAILED:"));
write(writeBuffer, tag);
write(writeBuffer, ":got=" & to_string(got));
write(writeBuffer, ":expected=" & to_string(expected));
else
write(writeBuffer, string'(":PASSED:"));
write(writeBuffer, tag);
end if;
writeline(OUTPUT, writeBuffer);
 
if (stopAtError) and (expected /= got) then
std.env.stop(0);
end if;
end procedure;
procedure TestCompare(constant got : in std_logic_vector;
constant expected : in std_logic_vector;
constant tag : in string := "";
constant stopAtError : in boolean := true) is
variable writeBuffer : line;
begin
write(writeBuffer, now);
if (expected /= got) then
write(writeBuffer, string'(":FAILED:"));
write(writeBuffer, tag);
write(writeBuffer, ":got=" & to_string(got));
write(writeBuffer, ":expected=" & to_string(expected));
else
write(writeBuffer, string'(":PASSED:"));
write(writeBuffer, tag);
end if;
writeline(OUTPUT, writeBuffer);
 
if (stopAtError) and (expected /= got) then
std.env.stop(0);
end if;
end procedure;
procedure TestCompare(constant got : in natural;
constant expected : in natural;
constant tag : in string := "";
constant stopAtError : in boolean := true) is
variable writeBuffer : line;
begin
write(writeBuffer, now);
if (expected /= got) then
write(writeBuffer, string'(":FAILED:"));
write(writeBuffer, tag);
write(writeBuffer, ":got=" & integer'image(got));
write(writeBuffer, ":expected=" & integer'image(expected));
else
write(writeBuffer, string'(":PASSED:"));
write(writeBuffer, tag);
end if;
writeline(OUTPUT, writeBuffer);
 
if (stopAtError) and (expected /= got) then
std.env.stop(0);
end if;
end procedure;
procedure TestCompare(constant got : in time;
constant expected : in time;
constant tag : in string := "";
constant stopAtError : in boolean := true) is
variable writeBuffer : line;
begin
write(writeBuffer, now);
if (expected /= got) then
write(writeBuffer, string'(":FAILED:"));
write(writeBuffer, tag);
write(writeBuffer, string'(":got="));
write(writeBuffer, got);
write(writeBuffer, string'(":expected="));
write(writeBuffer, expected);
else
write(writeBuffer, string'(":PASSED:"));
write(writeBuffer, tag);
end if;
writeline(OUTPUT, writeBuffer);
 
if (stopAtError) and (expected /= got) then
std.env.stop(0);
end if;
end procedure;
 
procedure TestWait(signal waitSignal : in std_logic;
constant waitValue : in std_logic;
constant tag : in string := "";
constant waitTime : in time := 1 ms;
constant stopAtError : in boolean := true) is
variable writeBuffer : line;
begin
if (waitSignal /= waitValue) then
wait until waitSignal = waitValue for waitTime;
if (waitSignal /= waitValue) then
write(writeBuffer, now);
write(writeBuffer, string'(":FAILED:"));
write(writeBuffer, tag);
writeline(OUTPUT, writeBuffer);
if (stopAtError) then
std.env.stop(0);
end if;
end if;
end if;
end procedure;
procedure TestWait(signal waitSignal : in std_logic;
constant waitValue : in std_logic;
signal ackSignal : inout std_logic;
constant tag : in string := "";
constant waitTime : in time := 1 ms;
constant stopAtError : in boolean := true) is
variable writeBuffer : line;
begin
if (waitSignal /= waitValue) then
 
wait until waitSignal = waitValue for waitTime;
if (waitSignal /= waitValue) then
write(writeBuffer, now);
write(writeBuffer, string'(":FAILED:"));
write(writeBuffer, tag);
writeline(OUTPUT, writeBuffer);
if (stopAtError) then
std.env.stop(0);
end if;
end if;
end if;
ackSignal <= not ackSignal;
wait until waitSignal /= waitValue for waitTime;
if (waitSignal = waitValue) then
write(writeBuffer, now);
write(writeBuffer, string'(":FAILED:"));
write(writeBuffer, tag);
writeline(OUTPUT, writeBuffer);
if (stopAtError) then
std.env.stop(0);
end if;
end if;
end procedure;
 
procedure TestEnd is
variable writeBuffer : line;
begin
assert false report "Test complete." severity failure;
wait;
write(writeBuffer, now);
write(writeBuffer, string'(":COMPLETED"));
writeline(OUTPUT, writeBuffer);
std.env.stop(0);
end TestEnd;
 
end rio_common;
 
 
/branches/singleSymbol/rtl/vhdl/RioSerial.vhd
180,7 → 180,7
-- the window-pins and the normal-pins... Add another singlememory...
-- REMARK: Make the pipe-line stages into block-statements to make the code more readable...
-- REMARK: Be consistent, tx->outbound and rx->inbound or egress/ingress...
-- REMARK: Add enable to fifo:s...
-- REMARK: Always send status after a link-response?
 
library ieee;
use ieee.std_logic_1164.all;
264,6 → 264,7
port(
clk : in std_logic;
areset_n : in std_logic;
enable : in std_logic;
 
empty_o : out std_logic;
read_i : in std_logic;
435,7 → 436,7
TxSymbolFifo: RioFifo
generic map(DEPTH_WIDTH=>5, DATA_WIDTH=>13)
port map(
clk=>clk, areset_n=>areset_n,
clk=>clk, areset_n=>areset_n, enable=>enable,
empty_o=>txControlReadEmpty(i),
read_i=>txControlRead(i),
data_o=>txControlReadSymbol(12*(i+1) downto 12*i),
445,7 → 446,7
RxSymbolFifo: RioFifo
generic map(DEPTH_WIDTH=>5, DATA_WIDTH=>13)
port map(
clk=>clk, areset_n=>areset_n,
clk=>clk, areset_n=>areset_n, enable=>enable,
empty_o=>rxControlReadEmpty(i),
read_i=>rxControlRead(i),
data_o=>rxControlReadSymbol(12*(i+1) downto 12*i),
727,14 → 728,16
timeSentDelta <= (others=>'0');
timeCurrent <= (others=>'0');
elsif (clk'event and clk = '1') then
if (timeSentEnable = '0') then
timeSentElapsed <= unsigned(timeCurrent) - unsigned(timeSentReadData);
timeSentDelta <= unsigned('0' & portLinkTimeout_i) - timeSentElapsed;
else
timeSentElapsed <= (others=>'0');
timeSentDelta <= (others=>'0');
if (enable = '1') then
if (timeSentEnable = '0') then
timeSentElapsed <= unsigned(timeCurrent) - unsigned(timeSentReadData);
timeSentDelta <= unsigned('0' & portLinkTimeout_i) - timeSentElapsed;
else
timeSentElapsed <= (others=>'0');
timeSentDelta <= (others=>'0');
end if;
timeCurrent <= std_logic_vector(unsigned(timeCurrent) + 1);
end if;
timeCurrent <= std_logic_vector(unsigned(timeCurrent) + 1);
end if;
end process;
1079,10 → 1082,13
sendRestartFromRetryOut <= '0';
sendLinkRequestOut <= '0';
 
-- Check the current state of the transmitter.
if (fatalError_i = '1') then
-- Fatal error has been encountered.
outputErrorStopped_o <= '0';
fatalError_o <= '0';
elsif (recoverActive_i = '1') then
-- Controlled recovering due to an earlier error is ongoing.
if (ackId_i /= recoverCounter_i) then
ackId_o <= std_logic_vector(unsigned(ackId_i) + 1);
readFrameOut <= '1';
1091,6 → 1097,9
outputErrorStopped_o <= '0';
end if;
else
-- No fatal error or recovering active.
 
-- Check if operational.
if (operational_i = '0') then
-- Not operational mode.
 
1215,6 → 1224,8
end if;
when STYPE0_PACKET_NOT_ACCEPTED =>
-- The link partner has rejected a packet.
 
if (outputErrorStopped_i = '0') then
-- Packet was rejected by the link-partner.
sendLinkRequestOut <= '1';
1223,6 → 1234,7
end if;
when STYPE0_LINK_RESPONSE =>
if (outputErrorStopped_i = '1') then
-- Check if the link partner return value is acceptable.
if ((unsigned(txControlParameter0) - unsigned(ackId_i)) <=
1748,7 → 1760,7
end if;
end if;
end process;
 
process(clk, areset_n)
begin
if (areset_n = '0') then
1803,33 → 1815,37
sendStatusRequired <= '0';
symbolCounter <= (others=>'0');
elsif (clk'event and clk = '1') then
if (portInitialized_i = '0') then
sendStatusRequired <= '0';
symbolCounter <=
std_logic_vector(to_unsigned(TICKS_SEND_STATUS_STARTUP,
SYMBOL_COUNTER_WIDTH));
elsif (enable = '1') then
if ((controlValid = '1') and
((stype0 = STYPE0_STATUS) or
(stype0 = STYPE0_PACKET_ACCEPTED) or
(stype0 = STYPE0_PACKET_RETRY))) then
if (operational_i = '0') then
symbolCounter <=
std_logic_vector(to_unsigned(TICKS_SEND_STATUS_STARTUP,
SYMBOL_COUNTER_WIDTH));
if (enable = '1') then
if (portInitialized_i = '0') then
sendStatusRequired <= '0';
symbolCounter <=
std_logic_vector(to_unsigned(TICKS_SEND_STATUS_STARTUP,
SYMBOL_COUNTER_WIDTH));
elsif (enable = '1') then
-- REMARK: Rewrite this, the status-control-symbols are output with a
-- slightly longer period than required...
if ((controlValid = '1') and
((stype0 = STYPE0_STATUS) or
(stype0 = STYPE0_PACKET_ACCEPTED) or
(stype0 = STYPE0_PACKET_RETRY))) then
if (operational_i = '0') then
symbolCounter <=
std_logic_vector(to_unsigned(TICKS_SEND_STATUS_STARTUP,
SYMBOL_COUNTER_WIDTH));
else
symbolCounter <=
std_logic_vector(to_unsigned(TICKS_SEND_STATUS_OPERATIONAL,
SYMBOL_COUNTER_WIDTH));
end if;
else
symbolCounter <=
std_logic_vector(to_unsigned(TICKS_SEND_STATUS_OPERATIONAL,
SYMBOL_COUNTER_WIDTH));
if (unsigned(symbolCounter) = 0) then
sendStatusRequired <= '1';
symbolCounter <= std_logic_vector(unsigned(symbolCounter) - 1);
else
sendStatusRequired <= '0';
symbolCounter <= std_logic_vector(unsigned(symbolCounter) - 1);
end if;
end if;
else
if (unsigned(symbolCounter) = 0) then
sendStatusRequired <= '1';
symbolCounter <= std_logic_vector(unsigned(symbolCounter) - 1);
else
sendStatusRequired <= '0';
symbolCounter <= std_logic_vector(unsigned(symbolCounter) - 1);
end if;
end if;
end if;
end if;
2317,6 → 2333,14
else
stype1LinkRequest <= '0';
end if;
else
txControlWrite_o <= '0';
stype0Status <= '0';
stype1Start <= '0';
stype1End <= '0';
stype1Stomp <= '0';
stype1RestartFromRetry <= '0';
stype1LinkRequest <= '0';
end if;
end if;
end if;
2330,12 → 2354,6
-- Generate reply symbols to the link-partner.
-----------------------------------------------------------------------------
 
-- Set the output to save when writing new frame content.
writeFrame_o <= writeFrameOut and enable;
writeFrameAbort_o <= writeFrameAbortOut and enable;
writeContent_o <= writeContentOut and enable;
writeContentData_o <= symbolDataContent1;
-- Create the new input depending on the current frame position.
crc16Data(31 downto 26) <= "000000" when (unsigned(frameIndex_i) = 1) else
symbolDataContent1(31 downto 26);
2460,8 → 2478,7
if (symbolControlCrcValid1 = '1') then
-- The symbol is correct.
 
-- Check if a packet is starting or ending.
if (((stype1Start = '1') or (stype1End = '1')) and
if ((stype1Start = '1') and
(inputRetryStopped_i = '0') and (inputErrorStopped_i = '0')) then
-------------------------------------------------------------
-- Start the reception of a new frame or end a currently
2469,18 → 2486,15
-------------------------------------------------------------
-- Check if a frame has already been started.
if ((unsigned(frameIndex_i) /= 0) or (stype1End = '1')) then
-- A frame is already started or is ending.
if (unsigned(frameIndex_i) /= 0) then
-- A frame is already started.
-- Complete the last frame and start to ackumulate a new one
-- and update the ackId.
 
-- Check if the frame is too short.
-- Check if the frame is large enough.
if (unsigned(frameIndex_i) > 3) then
-- The frame is not too short.
-- The frame is large enough.
 
-- Reset the frame index to indicate the frame is started.
frameIndex_o <= "0000001";
-- Check the CRC-16 and the length of the received frame.
if (crc16Valid = '1') then
-- The CRC-16 is ok.
2495,8 → 2509,6
-- Send packet-accepted.
-- The buffer status is appended by the transmitter
-- when sent to get the latest number.
-- REMARK: Move this out of this process and into pipeline
-- stage 4.
rxControlWriteOut <= '1';
rxControlSymbolOut <= STYPE0_PACKET_ACCEPTED &
std_logic_vector(ackId_i) &
2513,7 → 2525,7
inputErrorStopped_o <= '1';
end if;
else
-- The packet is too short.
-- This packet is too small.
-- Make the transmitter send a packet-not-accepted to indicated
-- that the received packet was too small.
rxControlWriteOut <= '1';
2522,16 → 2534,66
PACKET_NOT_ACCEPTED_CAUSE_GENERAL_ERROR;
inputErrorStopped_o <= '1';
end if;
end if;
-- Reset the frame index to indicate the frame is started.
frameIndex_o <= "0000001";
end if;
if ((stype1End = '1') and
(inputRetryStopped_i = '0') and (inputErrorStopped_i = '0')) then
-------------------------------------------------------------
-- End the reception of an old frame.
-------------------------------------------------------------
-- Check if a frame has already been started.
if (unsigned(frameIndex_i) > 3) then
-- A frame has been started and it is large enough.
-- Check the CRC-16 and the length of the received frame.
if (crc16Valid = '1') then
-- The CRC-16 is ok.
 
-- Update the frame buffer to indicate that the frame has
-- been completly received.
writeFrameOut <= '1';
 
-- Update ackId.
ackId_o <= ackId_i + 1;
 
-- Send packet-accepted.
-- The buffer status is appended by the transmitter
-- when sent to get the latest number.
rxControlWriteOut <= '1';
rxControlSymbolOut <= STYPE0_PACKET_ACCEPTED &
std_logic_vector(ackId_i) &
"11111";
else
-- The CRC-16 is not ok.
 
-- Make the transmitter send a packet-not-accepted to indicate
-- that the received packet contained a CRC error.
rxControlWriteOut <= '1';
rxControlSymbolOut <= STYPE0_PACKET_NOT_ACCEPTED &
"00000" &
PACKET_NOT_ACCEPTED_CAUSE_PACKET_CRC;
inputErrorStopped_o <= '1';
end if;
else
-- No frame has been started.
-- This is the normal case when there was no frame started
-- before.
-- Reset the frame index to indicate the frame is started.
frameIndex_o <= "0000001";
-- This packet is too small.
-- Make the transmitter send a packet-not-accepted to indicate
-- that the received packet was too small.
rxControlWriteOut <= '1';
rxControlSymbolOut <= STYPE0_PACKET_NOT_ACCEPTED &
"00000" &
PACKET_NOT_ACCEPTED_CAUSE_GENERAL_ERROR;
inputErrorStopped_o <= '1';
end if;
 
-- Reset frame reception to indicate that no frame is ongoing.
frameIndex_o <= "0000000";
end if;
 
if ((stype1Stomp = '1') and
(inputRetryStopped_i = '0') and (inputErrorStopped_i = '0')) then
-------------------------------------------------------------
2558,7 → 2620,7
-------------------------------------------------------------
 
-- Abort the frame and reset frame reception.
frameIndex_o <= (others => '0');
frameIndex_o <= (others=>'0');
writeFrameAbortOut <= '1';
-- Go back to the normal operational state.
2568,7 → 2630,7
-- The receiver indicates a restart from a retry sent
-- from us.
-------------------------------------------------------------
-- See 5.10 in the standard.
-- See 5.10 in the 2.2 standard.
-- Protocol error, this symbol should not be received here since
-- we should have been in input-retry-stopped.
2588,7 → 2650,7
-------------------------------------------------------------
-- Check the command part.
if (symbolControlContent1(15 downto 13) = "100") then
if (symbolControlContent1(7 downto 5) = "100") then
-- Return input port status command.
-- This functions as a link-request(restart-from-error)
-- control symbol under error situations.
2714,16 → 2776,23
end if;
end process;
 
-- REMARK: Add writeContentXXX-registers...
process(clk, areset_n)
begin
if (areset_n = '0') then
rxControlWrite_o <= '0';
rxControlSymbol_o <= (others=>'0');
writeFrame_o <= '0';
writeFrameAbort_o <= '0';
writeContent_o <= '0';
writeContentData_o <= (others=>'0');
elsif (clk'event and clk = '1') then
if (enable = '1') then
rxControlWrite_o <= rxControlWriteOut and symbolControlValid1;
rxControlWrite_o <= rxControlWriteOut and (symbolControlValid1 or symbolDataValid1);
rxControlSymbol_o <= rxControlSymbolOut;
writeFrame_o <= writeFrameOut;
writeFrameAbort_o <= writeFrameAbortOut;
writeContent_o <= writeContentOut;
writeContentData_o <= symbolDataContent1;
end if;
end if;
end process;
2751,6 → 2820,7
port(
clk : in std_logic;
areset_n : in std_logic;
enable : in std_logic;
 
empty_o : out std_logic;
read_i : in std_logic;
2784,6 → 2854,8
signal empty : std_logic;
signal full : std_logic;
 
signal writeEnable : 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);
2803,38 → 2875,42
readAddress <= (others=>'0');
writeAddress <= (others=>'0');
elsif (clk'event and clk = '1') then
if (empty = '1') then
if (write_i = '1') then
empty <= '0';
writeAddress <= writeAddressInc;
if (enable = '1') then
if (empty = '1') then
if (write_i = '1') then
empty <= '0';
writeAddress <= writeAddressInc;
end if;
end if;
end if;
if (full = '1') then
if (read_i = '1') then
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';
if (full = '1') then
if (read_i = '1') then
full <= '0';
readAddress <= readAddressInc;
end if;
end if;
if (write_i = '0') and (read_i = '1') then
readAddress <= readAddressInc;
if (readAddressInc = writeAddress) then
empty <= '1';
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;
if (write_i = '1') and (read_i = '1') then
writeAddress <= writeAddressInc;
readAddress <= readAddressInc;
end if;
end if;
end if;
end process;
 
writeEnable <= enable and write_i;
Memory: MemorySimpleDualPortAsync
generic map(ADDRESS_WIDTH=>DEPTH_WIDTH,
2841,7 → 2917,7
DATA_WIDTH=>DATA_WIDTH,
INIT_VALUE=>'0')
port map(
clkA_i=>clk, enableA_i=>write_i,
clkA_i=>clk, enableA_i=>writeEnable,
addressA_i=>writeAddress, dataA_i=>data_i,
addressB_i=>readAddress, dataB_o=>data_o);
end architecture;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.