OpenCores
URL https://opencores.org/ocsvn/rio/rio/trunk

Subversion Repositories rio

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 50 to Rev 51
    Reverse comparison

Rev 50 → Rev 51

/rio/branches/2.0.0-development/bench/vhdl/TestRioWbBridge.vhd
372,19 → 372,19
wait until clk'event and clk = '1';
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("TG_RioWbBridge");
PrintS("-----------------------------------------------------------------");
PrintS("TG_RioWbBridge-TC1");
PrintS("Description: Test maintenance requests.");
PrintS("Requirement: XXXXX");
PrintS("-----------------------------------------------------------------");
PrintS("Step 1:");
PrintS("Action: Send maintenance read request for one word on even offset.");
PrintS("Result: Check the accesses on the external configuration port.");
PrintS("-----------------------------------------------------------------");
TestSpec("-----------------------------------------------------------------");
TestSpec("TG_RioWbBridge");
TestSpec("-----------------------------------------------------------------");
TestSpec("TG_RioWbBridge-TC1");
TestSpec("Description: Test maintenance requests.");
TestSpec("Requirement: XXXXX");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 1:");
TestSpec("Action: Send maintenance read request for one word on even offset.");
TestSpec("Result: Check the accesses on the external configuration port.");
TestSpec("-----------------------------------------------------------------");
---------------------------------------------------------------------------
PrintR("TG_RioWbBridge-TC1-Step1");
TestCaseStart("TG_RioWbBridge-TC1-Step1");
---------------------------------------------------------------------------
 
InboundFrame(RioFrameCreate(ackId=>"00000", vc=>'0', crf=>'0', prio=>"00",
416,17 → 416,17
TestWait(outboundEmpty, '1', "outbound frame");
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("TG_RioWbBridge-TC2");
PrintS("Description: Test request class packets.");
PrintS("Requirement: XXXXX");
PrintS("-----------------------------------------------------------------");
PrintS("Step 1:");
PrintS("Action: Send request class NREAD packets for all sizes.");
PrintS("Result: The Wishbone access should match the inbound packet.");
PrintS("-----------------------------------------------------------------");
TestSpec("-----------------------------------------------------------------");
TestSpec("TG_RioWbBridge-TC2");
TestSpec("Description: Test request class packets.");
TestSpec("Requirement: XXXXX");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 1:");
TestSpec("Action: Send request class NREAD packets for all sizes.");
TestSpec("Result: The Wishbone access should match the inbound packet.");
TestSpec("-----------------------------------------------------------------");
---------------------------------------------------------------------------
PrintR("TG_RioWbBridge-TC2-Step1");
TestCaseStart("TG_RioWbBridge-TC2-Step1");
---------------------------------------------------------------------------
-- REMARK: Change the address and tid also...
for i in 0 to 15 loop
438,18 → 438,7
wdptr := '1';
end if;
ioData(0) := x"0001020304050607";
ioData(1) := x"08090a0b0c0d0e0f";
ioData(2) := x"1011121314151617";
ioData(3) := x"18191a1b1c1d1e1f";
ioData(4) := x"2021222324252627";
ioData(5) := x"28292a2b2c2d2e2f";
ioData(6) := x"3031323334353637";
ioData(7) := x"38393a3b3c3d3e3f";
ioData(8) := x"4041424344454647";
ioData(9) := x"48494a4b4c4d4e4f";
ioData(10) := x"5051525354555657";
ioData(11) := x"58595a5b5c5d5e5f";
CreateRandomPayload(ioData, seed1, seed2);
 
InboundFrame(RioFrameCreate(ackId=>"00000", vc=>'0', crf=>'0', prio=>"00",
tt=>"01", ftype=>FTYPE_REQUEST_CLASS,
480,18 → 469,18
end loop;
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("TG_RioWbBridge-TC3");
PrintS("Description: Test write class packets.");
PrintS("Requirement: XXXXX");
PrintS("-----------------------------------------------------------------");
PrintS("Step 1:");
PrintS("Action: Send write class NWRITER packets for all sizes.");
PrintS("Result: The Wishbone access should match the inbound packet and a ");
PrintS(" response should be sent.");
PrintS("-----------------------------------------------------------------");
TestSpec("-----------------------------------------------------------------");
TestSpec("TG_RioWbBridge-TC3");
TestSpec("Description: Test write class packets.");
TestSpec("Requirement: XXXXX");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 1:");
TestSpec("Action: Send write class NWRITER packets for all sizes.");
TestSpec("Result: The Wishbone access should match the inbound packet and a ");
TestSpec(" response should be sent.");
TestSpec("-----------------------------------------------------------------");
---------------------------------------------------------------------------
PrintR("TG_RioWbBridge-TC3-Step1");
TestCaseStart("TG_RioWbBridge-TC3-Step1");
---------------------------------------------------------------------------
-- REMARK: Change the address and tid also...
-- REMARK: Not really all sizes, add sizes in between the fixed as well.
537,13 → 526,13
end loop;
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 2:");
PrintS("Action: Send write class NWRITE packets for all sizes.");
PrintS("Result: The Wishbone access should match the inbound packet.");
PrintS("-----------------------------------------------------------------");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 2:");
TestSpec("Action: Send write class NWRITE packets for all sizes.");
TestSpec("Result: The Wishbone access should match the inbound packet.");
TestSpec("-----------------------------------------------------------------");
---------------------------------------------------------------------------
PrintR("TG_RioWbBridge-TC3-Step2");
TestCaseStart("TG_RioWbBridge-TC3-Step2");
---------------------------------------------------------------------------
-- REMARK: Change the address and tid also...
for i in 0 to 15 loop
/rio/branches/2.0.0-development/bench/vhdl/TestPortPackage.vhd
48,13 → 48,44
-------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.math_real.all;
use std.textio.all;
use work.rio_common.all;
use std.textio.all;
 
-------------------------------------------------------------------------------
--
-------------------------------------------------------------------------------
package TestPortPackage is
-----------------------------------------------------------------------------
-- Types used in simulations.
-----------------------------------------------------------------------------
type ByteArray is array (natural range <>) of
std_logic_vector(7 downto 0);
type HalfwordArray is array (natural range <>) of
std_logic_vector(15 downto 0);
type WordArray is array (natural range <>) of
std_logic_vector(31 downto 0);
type DoublewordArray is array (natural range <>) of
std_logic_vector(63 downto 0);
 
-- Type defining a RapidIO frame.
type RioFrame is record
length : natural range 0 to 69;
payload : WordArray(0 to 68);
end record;
type RioFrameArray is array (natural range <>) of RioFrame;
 
-- Type defining a RapidIO payload.
type RioPayload is record
length : natural range 0 to 133;
data : HalfwordArray(0 to 132);
end record;
 
-----------------------------------------------------------------------------
--
-----------------------------------------------------------------------------
constant ADDRESS_WIDTH_MAX : natural := 64;
constant DATA_WIDTH_MAX : natural := 64;
constant SEL_WIDTH_MAX : natural := 8;
180,6 → 211,9
-- Procedures for test control.
---------------------------------------------------------------------------
 
procedure TestSpec(constant str : string);
procedure TestCaseStart(constant str : string);
procedure TestWarning(constant tag : in string);
procedure TestError(constant tag : in string;
constant stopAtError : in boolean := true);
217,6 → 251,130
 
procedure TestEnd;
 
-----------------------------------------------------------------------------
--
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-- Crc5 calculation function.
-- ITU, polynom=0x15.
-----------------------------------------------------------------------------
function Crc5(constant data : in std_logic_vector(18 downto 0);
constant crc : in std_logic_vector(4 downto 0))
return std_logic_vector;
---------------------------------------------------------------------------
-- Create a RapidIO physical layer control symbol.
---------------------------------------------------------------------------
function RioControlSymbolCreate(
constant stype0 : in std_logic_vector(2 downto 0);
constant parameter0 : in std_logic_vector(4 downto 0);
constant parameter1 : in std_logic_vector(4 downto 0);
constant stype1 : in std_logic_vector(2 downto 0);
constant cmd : in std_logic_vector(2 downto 0))
return std_logic_vector;
 
-----------------------------------------------------------------------------
-- Crc16 calculation function.
-- CITT, polynom=0x1021.
-----------------------------------------------------------------------------
function Crc16(constant data : in std_logic_vector(15 downto 0);
constant crc : in std_logic_vector(15 downto 0))
return std_logic_vector;
---------------------------------------------------------------------------
-- Create a randomly initialized data array.
---------------------------------------------------------------------------
procedure CreateRandomPayload(
variable payload : out HalfwordArray;
variable seed1 : inout positive;
variable seed2 : inout positive);
procedure CreateRandomPayload(
variable payload : out DoublewordArray;
variable seed1 : inout positive;
variable seed2 : inout positive);
 
---------------------------------------------------------------------------
-- Create a generic RapidIO frame.
---------------------------------------------------------------------------
function RioFrameCreate(
constant ackId : in std_logic_vector(4 downto 0);
constant vc : in std_logic;
constant crf : in std_logic;
constant prio : in std_logic_vector(1 downto 0);
constant tt : in std_logic_vector(1 downto 0);
constant ftype : in std_logic_vector(3 downto 0);
constant sourceId : in std_logic_vector(15 downto 0);
constant destId : in std_logic_vector(15 downto 0);
constant payload : in RioPayload)
return RioFrame;
---------------------------------------------------------------------------
-- Create a NWRITE RapidIO frame.
---------------------------------------------------------------------------
function RioNwrite(
constant wrsize : in std_logic_vector(3 downto 0);
constant address : in std_logic_vector(28 downto 0);
constant wdptr : in std_logic;
constant xamsbs : in std_logic_vector(1 downto 0);
constant dataLength : in natural range 1 to 32;
constant data : in DoublewordArray(0 to 31))
return RioPayload;
---------------------------------------------------------------------------
-- Create a NWRITER RapidIO frame.
---------------------------------------------------------------------------
function RioNwriteR(
constant wrsize : in std_logic_vector(3 downto 0);
constant tid : in std_logic_vector(7 downto 0);
constant address : in std_logic_vector(28 downto 0);
constant wdptr : in std_logic;
constant xamsbs : in std_logic_vector(1 downto 0);
constant dataLength : in natural range 1 to 32;
constant data : in DoublewordArray(0 to 31))
return RioPayload;
---------------------------------------------------------------------------
-- Create a NREAD RapidIO frame.
---------------------------------------------------------------------------
function RioNread(
constant rdsize : in std_logic_vector(3 downto 0);
constant tid : in std_logic_vector(7 downto 0);
constant address : in std_logic_vector(28 downto 0);
constant wdptr : in std_logic;
constant xamsbs : in std_logic_vector(1 downto 0))
return RioPayload;
---------------------------------------------------------------------------
-- Create a RESPONSE RapidIO frame.
---------------------------------------------------------------------------
function RioResponse(
constant status : in std_logic_vector(3 downto 0);
constant tid : in std_logic_vector(7 downto 0);
constant dataLength : in natural range 0 to 32;
constant data : in DoublewordArray(0 to 31))
return RioPayload;
---------------------------------------------------------------------------
-- Create a Maintenance RapidIO frame.
---------------------------------------------------------------------------
function RioMaintenance(
constant transaction : in std_logic_vector(3 downto 0);
constant size : in std_logic_vector(3 downto 0);
constant tid : in std_logic_vector(7 downto 0);
constant hopCount : in std_logic_vector(7 downto 0);
constant configOffset : in std_logic_vector(20 downto 0);
constant wdptr : in std_logic;
constant dataLength : in natural range 0 to 8;
constant data : in DoublewordArray(0 to 7))
return RioPayload;
-----------------------------------------------------------------------------
-- Function to convert a std_logic_vector to a string.
-----------------------------------------------------------------------------
function byteToString(constant byte : std_logic_vector(7 downto 0))
return string;
end package;
 
-------------------------------------------------------------------------------
314,6 → 472,25
-- Procedures to handle tests.
---------------------------------------------------------------------------
 
procedure TestSpec(constant str : string) is
file specFile : text;
variable specLine, outputLine : line;
variable fStatus: FILE_OPEN_STATUS;
begin
file_open(fStatus, specFile, "testspec.txt", append_mode);
write(specLine, string'(str));
writeline (specFile, specLine);
file_close(specFile);
end procedure;
 
procedure TestCaseStart(constant str : string) is
file reportFile : text;
variable reportLine, outputLine : line;
variable fStatus: FILE_OPEN_STATUS;
begin
report str severity note;
end procedure;
 
procedure TestWarning(constant tag : in string) is
variable writeBuffer : line;
begin
521,6 → 698,432
std.env.stop(0);
end TestEnd;
 
-----------------------------------------------------------------------------
--
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-- Crc5 calculation function.
-- ITU, polynom=0x15.
-----------------------------------------------------------------------------
function Crc5(constant data : in std_logic_vector(18 downto 0);
constant crc : in std_logic_vector(4 downto 0))
return std_logic_vector is
type crcTableType is array (0 to 31) of std_logic_vector(7 downto 0);
constant crcTable : crcTableType := (
x"00", x"15", x"1f", x"0a", x"0b", x"1e", x"14", x"01",
x"16", x"03", x"09", x"1c", x"1d", x"08", x"02", x"17",
x"19", x"0c", x"06", x"13", x"12", x"07", x"0d", x"18",
x"0f", x"1a", x"10", x"05", x"04", x"11", x"1b", x"0e" );
variable index : natural range 0 to 31;
variable result : std_logic_vector(4 downto 0);
begin
result := crc;
index := to_integer(unsigned(data(18 downto 14) xor result));
result := crcTable(index)(4 downto 0);
index := to_integer(unsigned(data(13 downto 9) xor result));
result := crcTable(index)(4 downto 0);
index := to_integer(unsigned(data(8 downto 4) xor result));
result := crcTable(index)(4 downto 0);
index := to_integer(unsigned((data(3 downto 0) & '0') xor result));
return crcTable(index)(4 downto 0);
end Crc5;
 
---------------------------------------------------------------------------
-- Create a RapidIO physical layer control symbol.
---------------------------------------------------------------------------
function RioControlSymbolCreate(
constant stype0 : in std_logic_vector(2 downto 0);
constant parameter0 : in std_logic_vector(4 downto 0);
constant parameter1 : in std_logic_vector(4 downto 0);
constant stype1 : in std_logic_vector(2 downto 0);
constant cmd : in std_logic_vector(2 downto 0))
return std_logic_vector is
variable returnValue : std_logic_vector(23 downto 0);
variable symbolData : std_logic_vector(18 downto 0);
begin
symbolData(18 downto 16) := stype0;
symbolData(15 downto 11) := parameter0;
symbolData(10 downto 6) := parameter1;
symbolData(5 downto 3) := stype1;
symbolData(2 downto 0) := cmd;
 
returnValue(23 downto 5) := symbolData;
returnValue(4 downto 0) := Crc5(symbolData, "11111");
 
return returnValue;
end function;
 
-----------------------------------------------------------------------------
-- Crc16 calculation function.
-- CITT, polynom=0x1021.
-----------------------------------------------------------------------------
function Crc16(constant data : in std_logic_vector(15 downto 0);
constant crc : in std_logic_vector(15 downto 0))
return std_logic_vector is
type crcTableType is array (0 to 255) of std_logic_vector(15 downto 0);
constant crcTable : crcTableType := (
x"0000", x"1021", x"2042", x"3063", x"4084", x"50a5", x"60c6", x"70e7",
x"8108", x"9129", x"a14a", x"b16b", x"c18c", x"d1ad", x"e1ce", x"f1ef",
x"1231", x"0210", x"3273", x"2252", x"52b5", x"4294", x"72f7", x"62d6",
x"9339", x"8318", x"b37b", x"a35a", x"d3bd", x"c39c", x"f3ff", x"e3de",
x"2462", x"3443", x"0420", x"1401", x"64e6", x"74c7", x"44a4", x"5485",
x"a56a", x"b54b", x"8528", x"9509", x"e5ee", x"f5cf", x"c5ac", x"d58d",
x"3653", x"2672", x"1611", x"0630", x"76d7", x"66f6", x"5695", x"46b4",
x"b75b", x"a77a", x"9719", x"8738", x"f7df", x"e7fe", x"d79d", x"c7bc",
x"48c4", x"58e5", x"6886", x"78a7", x"0840", x"1861", x"2802", x"3823",
x"c9cc", x"d9ed", x"e98e", x"f9af", x"8948", x"9969", x"a90a", x"b92b",
x"5af5", x"4ad4", x"7ab7", x"6a96", x"1a71", x"0a50", x"3a33", x"2a12",
x"dbfd", x"cbdc", x"fbbf", x"eb9e", x"9b79", x"8b58", x"bb3b", x"ab1a",
x"6ca6", x"7c87", x"4ce4", x"5cc5", x"2c22", x"3c03", x"0c60", x"1c41",
x"edae", x"fd8f", x"cdec", x"ddcd", x"ad2a", x"bd0b", x"8d68", x"9d49",
x"7e97", x"6eb6", x"5ed5", x"4ef4", x"3e13", x"2e32", x"1e51", x"0e70",
x"ff9f", x"efbe", x"dfdd", x"cffc", x"bf1b", x"af3a", x"9f59", x"8f78",
x"9188", x"81a9", x"b1ca", x"a1eb", x"d10c", x"c12d", x"f14e", x"e16f",
x"1080", x"00a1", x"30c2", x"20e3", x"5004", x"4025", x"7046", x"6067",
x"83b9", x"9398", x"a3fb", x"b3da", x"c33d", x"d31c", x"e37f", x"f35e",
x"02b1", x"1290", x"22f3", x"32d2", x"4235", x"5214", x"6277", x"7256",
x"b5ea", x"a5cb", x"95a8", x"8589", x"f56e", x"e54f", x"d52c", x"c50d",
x"34e2", x"24c3", x"14a0", x"0481", x"7466", x"6447", x"5424", x"4405",
x"a7db", x"b7fa", x"8799", x"97b8", x"e75f", x"f77e", x"c71d", x"d73c",
x"26d3", x"36f2", x"0691", x"16b0", x"6657", x"7676", x"4615", x"5634",
x"d94c", x"c96d", x"f90e", x"e92f", x"99c8", x"89e9", x"b98a", x"a9ab",
x"5844", x"4865", x"7806", x"6827", x"18c0", x"08e1", x"3882", x"28a3",
x"cb7d", x"db5c", x"eb3f", x"fb1e", x"8bf9", x"9bd8", x"abbb", x"bb9a",
x"4a75", x"5a54", x"6a37", x"7a16", x"0af1", x"1ad0", x"2ab3", x"3a92",
x"fd2e", x"ed0f", x"dd6c", x"cd4d", x"bdaa", x"ad8b", x"9de8", x"8dc9",
x"7c26", x"6c07", x"5c64", x"4c45", x"3ca2", x"2c83", x"1ce0", x"0cc1",
x"ef1f", x"ff3e", x"cf5d", x"df7c", x"af9b", x"bfba", x"8fd9", x"9ff8",
x"6e17", x"7e36", x"4e55", x"5e74", x"2e93", x"3eb2", x"0ed1", x"1ef0" );
variable index : natural range 0 to 255;
variable result : std_logic_vector(15 downto 0);
begin
result := crc;
index := to_integer(unsigned(data(15 downto 8) xor result(15 downto 8)));
result := crcTable(index) xor (result(7 downto 0) & x"00");
index := to_integer(unsigned(data(7 downto 0) xor result(15 downto 8)));
result := crcTable(index) xor (result(7 downto 0) & x"00");
return result;
end Crc16;
---------------------------------------------------------------------------
-- Create a randomly initialized data array.
---------------------------------------------------------------------------
procedure CreateRandomPayload(
variable payload : out HalfwordArray;
variable seed1 : inout positive;
variable seed2 : inout positive) is
variable rand: real;
variable int_rand: integer;
variable stim: std_logic_vector(7 downto 0);
begin
for i in payload'range loop
uniform(seed1, seed2, rand);
int_rand := integer(trunc(rand*256.0));
payload(i)(7 downto 0) := std_logic_vector(to_unsigned(int_rand, 8));
uniform(seed1, seed2, rand);
int_rand := integer(trunc(rand*256.0));
payload(i)(15 downto 8) := std_logic_vector(to_unsigned(int_rand, 8));
end loop;
end procedure;
 
procedure CreateRandomPayload(
variable payload : out DoublewordArray;
variable seed1 : inout positive;
variable seed2 : inout positive) is
variable rand: real;
variable int_rand: integer;
variable stim: std_logic_vector(7 downto 0);
begin
for i in payload'range loop
uniform(seed1, seed2, rand);
int_rand := integer(trunc(rand*256.0));
payload(i)(7 downto 0) := std_logic_vector(to_unsigned(int_rand, 8));
uniform(seed1, seed2, rand);
int_rand := integer(trunc(rand*256.0));
payload(i)(15 downto 8) := std_logic_vector(to_unsigned(int_rand, 8));
uniform(seed1, seed2, rand);
int_rand := integer(trunc(rand*256.0));
payload(i)(23 downto 16) := std_logic_vector(to_unsigned(int_rand, 8));
uniform(seed1, seed2, rand);
int_rand := integer(trunc(rand*256.0));
payload(i)(31 downto 24) := std_logic_vector(to_unsigned(int_rand, 8));
uniform(seed1, seed2, rand);
int_rand := integer(trunc(rand*256.0));
payload(i)(39 downto 32) := std_logic_vector(to_unsigned(int_rand, 8));
uniform(seed1, seed2, rand);
int_rand := integer(trunc(rand*256.0));
payload(i)(47 downto 40) := std_logic_vector(to_unsigned(int_rand, 8));
uniform(seed1, seed2, rand);
int_rand := integer(trunc(rand*256.0));
payload(i)(55 downto 48) := std_logic_vector(to_unsigned(int_rand, 8));
uniform(seed1, seed2, rand);
int_rand := integer(trunc(rand*256.0));
payload(i)(63 downto 56) := std_logic_vector(to_unsigned(int_rand, 8));
end loop;
end procedure;
---------------------------------------------------------------------------
-- Create a generic RapidIO frame.
---------------------------------------------------------------------------
function RioFrameCreate(
constant ackId : in std_logic_vector(4 downto 0);
constant vc : in std_logic;
constant crf : in std_logic;
constant prio : in std_logic_vector(1 downto 0);
constant tt : in std_logic_vector(1 downto 0);
constant ftype : in std_logic_vector(3 downto 0);
constant sourceId : in std_logic_vector(15 downto 0);
constant destId : in std_logic_vector(15 downto 0);
constant payload : in RioPayload) return RioFrame is
variable frame : RioFrame;
variable result : HalfwordArray(0 to 137);
variable crc : std_logic_vector(15 downto 0) := x"ffff";
begin
-- Add the header and addresses.
result(0) := ackId & "0" & vc & crf & prio & tt & ftype;
result(1) := destId;
result(2) := sourceId;
 
-- Update the calculated CRC with the header contents.
crc := Crc16("00000" & result(0)(10 downto 0), crc);
crc := Crc16(result(1), crc);
crc := Crc16(result(2), crc);
 
-- Check if a single CRC should be added or two.
if (payload.length <= 37) then
-- Single CRC.
for i in 0 to payload.length-1 loop
result(i+3) := payload.data(i);
crc := Crc16(payload.data(i), crc);
end loop;
result(payload.length+3) := crc;
 
-- Check if paddning is needed to make the payload even 32-bit.
if ((payload.length mod 2) = 1) then
result(payload.length+4) := x"0000";
frame.length := (payload.length+5) / 2;
else
frame.length := (payload.length+4) / 2;
end if;
else
-- Double CRC.
for i in 0 to 36 loop
result(i+3) := payload.data(i);
crc := Crc16(payload.data(i), crc);
end loop;
 
-- Add in-the-middle crc.
result(40) := crc;
crc := Crc16(crc, crc);
for i in 37 to payload.length-1 loop
result(i+4) := payload.data(i);
crc := Crc16(payload.data(i), crc);
end loop;
result(payload.length+4) := crc;
 
-- Check if paddning is needed to make the payload even 32-bit.
if ((payload.length mod 2) = 0) then
result(payload.length+5) := x"0000";
frame.length := (payload.length+6) / 2;
else
frame.length := (payload.length+5) / 2;
end if;
end if;
-- Update the result length.
for i in 0 to frame.length-1 loop
frame.payload(i) := result(2*i) & result(2*i+1);
end loop;
 
return frame;
end function;
 
-----------------------------------------------------------------------------
--
-----------------------------------------------------------------------------
function RioNwrite(
constant wrsize : in std_logic_vector(3 downto 0);
constant address : in std_logic_vector(28 downto 0);
constant wdptr : in std_logic;
constant xamsbs : in std_logic_vector(1 downto 0);
constant dataLength : in natural range 1 to 32;
constant data : in DoublewordArray(0 to 31))
return RioPayload is
variable payload : RioPayload;
begin
payload.data(0)(15 downto 12) := "0100";
payload.data(0)(11 downto 8) := wrsize;
payload.data(0)(7 downto 0) := (others=>'0');
 
payload.data(1) := address(28 downto 13);
payload.data(2)(15 downto 3) := address(12 downto 0);
payload.data(2)(2) := wdptr;
payload.data(2)(1 downto 0) := xamsbs;
 
for i in 0 to dataLength-1 loop
payload.data(3+4*i) := data(i)(63 downto 48);
payload.data(4+4*i) := data(i)(47 downto 32);
payload.data(5+4*i) := data(i)(31 downto 16);
payload.data(6+4*i) := data(i)(15 downto 0);
end loop;
 
payload.length := 3 + 4*dataLength;
return payload;
end function;
-----------------------------------------------------------------------------
--
-----------------------------------------------------------------------------
function RioNwriteR(
constant wrsize : in std_logic_vector(3 downto 0);
constant tid : in std_logic_vector(7 downto 0);
constant address : in std_logic_vector(28 downto 0);
constant wdptr : in std_logic;
constant xamsbs : in std_logic_vector(1 downto 0);
constant dataLength : in natural range 1 to 32;
constant data : in DoublewordArray(0 to 31))
return RioPayload is
variable payload : RioPayload;
begin
payload.data(0)(15 downto 12) := "0101";
payload.data(0)(11 downto 8) := wrsize;
payload.data(0)(7 downto 0) := tid;
 
payload.data(1) := address(28 downto 13);
payload.data(2)(15 downto 3) := address(12 downto 0);
payload.data(2)(2) := wdptr;
payload.data(2)(1 downto 0) := xamsbs;
 
for i in 0 to dataLength-1 loop
payload.data(3+4*i) := data(i)(63 downto 48);
payload.data(4+4*i) := data(i)(47 downto 32);
payload.data(5+4*i) := data(i)(31 downto 16);
payload.data(6+4*i) := data(i)(15 downto 0);
end loop;
 
payload.length := 3 + 4*dataLength;
return payload;
end function;
-----------------------------------------------------------------------------
--
-----------------------------------------------------------------------------
function RioNread(
constant rdsize : in std_logic_vector(3 downto 0);
constant tid : in std_logic_vector(7 downto 0);
constant address : in std_logic_vector(28 downto 0);
constant wdptr : in std_logic;
constant xamsbs : in std_logic_vector(1 downto 0))
return RioPayload is
variable payload : RioPayload;
begin
payload.data(0)(15 downto 12) := "0100";
payload.data(0)(11 downto 8) := rdsize;
payload.data(0)(7 downto 0) := tid;
 
payload.data(1) := address(28 downto 13);
payload.data(2)(15 downto 3) := address(12 downto 0);
payload.data(2)(2) := wdptr;
payload.data(2)(1 downto 0) := xamsbs;
 
payload.length := 3;
 
return payload;
end function;
---------------------------------------------------------------------------
-- Create a RESPONSE RapidIO frame.
---------------------------------------------------------------------------
function RioResponse(
constant status : in std_logic_vector(3 downto 0);
constant tid : in std_logic_vector(7 downto 0);
constant dataLength : in natural range 0 to 32;
constant data : in DoublewordArray(0 to 31))
return RioPayload is
variable payload : RioPayload;
begin
payload.data(0)(11 downto 8) := status;
payload.data(0)(7 downto 0) := tid;
 
if (dataLength = 0) then
payload.data(0)(15 downto 12) := "0000";
payload.length := 1;
else
payload.data(0)(15 downto 12) := "1000";
for i in 0 to dataLength-1 loop
payload.data(1+4*i) := data(i)(63 downto 48);
payload.data(2+4*i) := data(i)(47 downto 32);
payload.data(3+4*i) := data(i)(31 downto 16);
payload.data(4+4*i) := data(i)(15 downto 0);
end loop;
 
payload.length := 1 + 4*dataLength;
end if;
 
return payload;
end function;
---------------------------------------------------------------------------
-- Create a Maintenance RapidIO frame.
---------------------------------------------------------------------------
function RioMaintenance(
constant transaction : in std_logic_vector(3 downto 0);
constant size : in std_logic_vector(3 downto 0);
constant tid : in std_logic_vector(7 downto 0);
constant hopCount : in std_logic_vector(7 downto 0);
constant configOffset : in std_logic_vector(20 downto 0);
constant wdptr : in std_logic;
constant dataLength : in natural range 0 to 8;
constant data : in DoublewordArray(0 to 7))
return RioPayload is
variable payload : RioPayload;
begin
payload.data(0)(15 downto 12) := transaction;
payload.data(0)(11 downto 8) := size;
payload.data(0)(7 downto 0) := tid;
 
payload.data(1)(15 downto 8) := hopCount;
payload.data(1)(7 downto 0) := configOffset(20 downto 13);
payload.data(2)(15 downto 3) := configOffset(12 downto 0);
payload.data(2)(2) := wdptr;
payload.data(2)(1 downto 0) := "00";
 
if (dataLength = 0) then
payload.length := 3;
else
for i in 0 to dataLength-1 loop
payload.data(3+4*i) := data(i)(63 downto 48);
payload.data(4+4*i) := data(i)(47 downto 32);
payload.data(5+4*i) := data(i)(31 downto 16);
payload.data(6+4*i) := data(i)(15 downto 0);
end loop;
 
payload.length := 3 + 4*dataLength;
end if;
 
return payload;
end function;
-----------------------------------------------------------------------------
-- Function to convert a std_logic_vector to a string.
-----------------------------------------------------------------------------
function byteToString(constant byte : std_logic_vector(7 downto 0))
return string is
constant table : string(1 to 16) := "0123456789abcdef";
variable returnValue : string(1 to 2);
begin
returnValue(1) := table(to_integer(unsigned(byte(7 downto 4))) + 1);
returnValue(2) := table(to_integer(unsigned(byte(3 downto 0))) + 1);
return returnValue;
end function;
end package body;
 
 
/rio/branches/2.0.0-development/bench/vhdl/TestRioSerial.vhd
51,6 → 51,7
library ieee;
use ieee.std_logic_1164.all;
use work.rio_common.all;
use work.TestPortPackage.all;
 
package TestRioSerialPackage is
type MessageSymbol is record
442,18 → 443,18
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("TG_RioSerial");
PrintS("-----------------------------------------------------------------");
PrintS("TG_RioSerial-TC1");
PrintS("Description: Test idle-sequence transmission at startup.");
PrintS("Requirement: XXXXX");
PrintS("-----------------------------------------------------------------");
PrintS("Step 1:");
PrintS("Action: Read transmission port.");
PrintS("Result: Idle sequence symbols should be read.");
TestSpec("-----------------------------------------------------------------");
TestSpec("TG_RioSerial");
TestSpec("-----------------------------------------------------------------");
TestSpec("TG_RioSerial-TC1");
TestSpec("Description: Test idle-sequence transmission at startup.");
TestSpec("Requirement: XXXXX");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 1:");
TestSpec("Action: Read transmission port.");
TestSpec("Result: Idle sequence symbols should be read.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC1-Step1");
TestCaseStart("TG_RioSerial-TC1-Step1");
---------------------------------------------------------------------------
 
-- Make sure only idle-sequences are transmitted at startup.
470,17 → 471,17
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("TG_RioSerial-TC2");
PrintS("Description: Test idle-sequence and status symbol transmission");
PrintS(" when the port has been initialized.");
PrintS("Requirement: XXXXX");
PrintS("-----------------------------------------------------------------");
PrintS("Step 1:");
PrintS("Action: Set port initialized and read transmission port.");
PrintS("Result: Idle sequence and status symbols should be read.");
TestSpec("-----------------------------------------------------------------");
TestSpec("TG_RioSerial-TC2");
TestSpec("Description: Test idle-sequence and status symbol transmission");
TestSpec(" when the port has been initialized.");
TestSpec("Requirement: XXXXX");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 1:");
TestSpec("Action: Set port initialized and read transmission port.");
TestSpec("Result: Idle sequence and status symbols should be read.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC2-Step1");
TestCaseStart("TG_RioSerial-TC2-Step1");
---------------------------------------------------------------------------
 
-- Initialize the port to trigger a change of state.
514,13 → 515,13
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 2:");
PrintS("Action: Toggle port initialized pin and check that no status ");
PrintS(" symbols are transmitted when uninitialized.");
PrintS("Result: Only idle sequences should be read when uninitialized.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 2:");
TestSpec("Action: Toggle port initialized pin and check that no status ");
TestSpec(" symbols are transmitted when uninitialized.");
TestSpec("Result: Only idle sequences should be read when uninitialized.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC2-Step2");
TestCaseStart("TG_RioSerial-TC2-Step2");
---------------------------------------------------------------------------
 
-- Deassert the port initialized flag.
569,14 → 570,14
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 3:");
PrintS("Action: Send one error free status symbol to trigger the ");
PrintS(" transmission of status symbols with a higher frequency.");
PrintS("Result: Idle sequence and status symbols should be read but ");
PrintS(" status symbols should be recived more often.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 3:");
TestSpec("Action: Send one error free status symbol to trigger the ");
TestSpec(" transmission of status symbols with a higher frequency.");
TestSpec("Result: Idle sequence and status symbols should be read but ");
TestSpec(" status symbols should be recived more often.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC2-Step3");
TestCaseStart("TG_RioSerial-TC2-Step3");
---------------------------------------------------------------------------
 
-- A received error-free status triggers transmission of status symbols in
611,26 → 612,26
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 4:");
PrintS("Action: Send one errornous status symbol to restart the status ");
PrintS(" counting.");
PrintS("Result: Idle sequence and status symbols should be read but ");
PrintS(" status symbols should still be received more often.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 4:");
TestSpec("Action: Send one errornous status symbol to restart the status ");
TestSpec(" counting.");
TestSpec("Result: Idle sequence and status symbols should be read but ");
TestSpec(" status symbols should still be received more often.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC2-Step4");
TestCaseStart("TG_RioSerial-TC2-Step4");
---------------------------------------------------------------------------
-- REMARK: Add this...
PrintR("Not implemented.");
TestCaseStart("Not implemented.");
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 5:");
PrintS("Action: Send seven additional status symbols.");
PrintS("Result: The link should become fully initialized.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 5:");
TestSpec("Action: Send seven additional status symbols.");
TestSpec("Result: The link should become fully initialized.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC2-Step5");
TestCaseStart("TG_RioSerial-TC2-Step5");
---------------------------------------------------------------------------
 
-- Make the link fully initialized by sending 7 additional statuses.
660,16 → 661,16
TestWait(outboundSymbolWriteEmpty, '1', "Outbound symbol empty.");
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("TG_RioSerial-TC3");
PrintS("Description: Test port reception.");
PrintS("Requirement: XXXXX");
PrintS("-----------------------------------------------------------------");
PrintS("Step 1:");
PrintS("Action: Send an inbound frame with pad after the CRC.");
PrintS("Result: The frame should end up in a frame buffer.");
TestSpec("-----------------------------------------------------------------");
TestSpec("TG_RioSerial-TC3");
TestSpec("Description: Test port reception.");
TestSpec("Requirement: XXXXX");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 1:");
TestSpec("Action: Send an inbound frame with pad after the CRC.");
TestSpec("Result: The frame should end up in a frame buffer.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC3-Step1");
TestCaseStart("TG_RioSerial-TC3-Step1");
---------------------------------------------------------------------------
 
-- Create the frame.
698,12 → 699,12
TestCompare(inboundFrameWriteEmpty, '1', "Packet was received.");
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 2:");
PrintS("Action: Send an inbound frame without a pad after the CRC.");
PrintS("Result: The frame should end up in a frame buffer.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 2:");
TestSpec("Action: Send an inbound frame without a pad after the CRC.");
TestSpec("Result: The frame should end up in a frame buffer.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC3-Step2");
TestCaseStart("TG_RioSerial-TC3-Step2");
---------------------------------------------------------------------------
-- Create the frame.
733,12 → 734,12
TestCompare(inboundFrameWriteEmpty, '1', "Packet was received.");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 3:");
PrintS("Action: Send an inbound frame with maximum size.");
PrintS("Result: The frame should end up in a frame buffer.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 3:");
TestSpec("Action: Send an inbound frame with maximum size.");
TestSpec("Result: The frame should end up in a frame buffer.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC3-Step3");
TestCaseStart("TG_RioSerial-TC3-Step3");
---------------------------------------------------------------------------
-- Create the frame.
767,12 → 768,12
TestCompare(inboundFrameWriteEmpty, '1', "Packet was received.");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 4:");
PrintS("Action: Send two packets without end-of-packet in between.");
PrintS("Result: Both packets should be accepted.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 4:");
TestSpec("Action: Send two packets without end-of-packet in between.");
TestSpec("Result: Both packets should be accepted.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC3-Step4");
TestCaseStart("TG_RioSerial-TC3-Step4");
---------------------------------------------------------------------------
-- Create the first frame.
819,14 → 820,14
TestCompare(inboundFrameWriteEmpty, '1', "Packet was received.");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 5:");
PrintS("Action: Start to send a packet. Abort it with stomp. Then send ");
PrintS(" another packet.");
PrintS("Result: The first packet should be discarded and the second should");
PrintS(" be accepted. The retried packet should be acknowledged.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 5:");
TestSpec("Action: Start to send a packet. Abort it with stomp. Then send ");
TestSpec(" another packet.");
TestSpec("Result: The first packet should be discarded and the second should");
TestSpec(" be accepted. The retried packet should be acknowledged.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC3-Step5");
TestCaseStart("TG_RioSerial-TC3-Step5");
---------------------------------------------------------------------------
-- Create a frame, send it and abort it with STOMP.
880,14 → 881,14
TestCompare(inboundFrameWriteEmpty, '1', "Packet was received.");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 6:");
PrintS("Action: Start to send a packet but dont send any payload. Abort it");
PrintS(" with stomp. Then send another packet.");
PrintS("Result: The first packet should be discarded and the second should");
PrintS(" be accepted. The retried packet should be acknowledged.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 6:");
TestSpec("Action: Start to send a packet but dont send any payload. Abort it");
TestSpec(" with stomp. Then send another packet.");
TestSpec("Result: The first packet should be discarded and the second should");
TestSpec(" be accepted. The retried packet should be acknowledged.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC3-Step6");
TestCaseStart("TG_RioSerial-TC3-Step6");
---------------------------------------------------------------------------
-- Start the reception of a frame and abort it.
938,15 → 939,15
TestCompare(inboundFrameWriteEmpty, '1', "Packet was received.");
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 7:");
PrintS("Action: Start to send a packet with payload, then send a ");
PrintS(" link-request. Then send another packet.");
PrintS("Result: The first packet should be canceled without any ");
PrintS(" confirmation and a link-response should be returned. The");
PrintS(" second packet should be accepted.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 7:");
TestSpec("Action: Start to send a packet with payload, then send a ");
TestSpec(" link-request. Then send another packet.");
TestSpec("Result: The first packet should be canceled without any ");
TestSpec(" confirmation and a link-response should be returned. The");
TestSpec(" second packet should be accepted.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC3-Step7");
TestCaseStart("TG_RioSerial-TC3-Step7");
---------------------------------------------------------------------------
-- Create a new frame and abort it with a link-request/input-status to
1003,15 → 1004,15
TestCompare(inboundFrameWriteEmpty, '1', "Packet was received.");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 8:");
PrintS("Action: Start to send a packet, no payload, then send a ");
PrintS(" link-request. Then send another packet.");
PrintS("Result: The first packet should be canceled without any ");
PrintS(" confirmation and a link-response should be returned. The");
PrintS(" second packet should be accepted.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 8:");
TestSpec("Action: Start to send a packet, no payload, then send a ");
TestSpec(" link-request. Then send another packet.");
TestSpec("Result: The first packet should be canceled without any ");
TestSpec(" confirmation and a link-response should be returned. The");
TestSpec(" second packet should be accepted.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC3-Step8");
TestCaseStart("TG_RioSerial-TC3-Step8");
---------------------------------------------------------------------------
 
-- Start a frame then send link-request/input-status to abort it.
1056,14 → 1057,14
TestCompare(inboundFrameWriteEmpty, '1', "Packet was received.");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 9:");
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.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 9:");
TestSpec("Action: Send a packet when no buffers are available. Reset receiver");
TestSpec(" with link-request.");
TestSpec("Result: A packet-retry should be transmitted and receiver should");
TestSpec(" enter input-retry-stopped.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC3-Step9");
TestCaseStart("TG_RioSerial-TC3-Step9");
---------------------------------------------------------------------------
 
-- Indicate the inbound frame queue is full.
1113,14 → 1114,14
inboundFrameFull <= '0';
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 10:");
PrintS("Action: Send a packet when no buffers is available. Reset receiver");
PrintS(" with restart-from-retry.");
PrintS("Result: A packet-retry should be transmitted and receiver should");
PrintS(" enter input-retry-stopped.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 10:");
TestSpec("Action: Send a packet when no buffers is available. Reset receiver");
TestSpec(" with restart-from-retry.");
TestSpec("Result: A packet-retry should be transmitted and receiver should");
TestSpec(" enter input-retry-stopped.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC3-Step10");
TestCaseStart("TG_RioSerial-TC3-Step10");
---------------------------------------------------------------------------
 
-- Indicate the inbound frame queue is full.
1170,12 → 1171,12
inboundFrameFull <= '0';
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 11:");
PrintS("Action: Start a new packet when in input-retry-stopped state.");
PrintS("Result: The packet should be discarded.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 11:");
TestSpec("Action: Start a new packet when in input-retry-stopped state.");
TestSpec("Result: The packet should be discarded.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC3-Step11");
TestCaseStart("TG_RioSerial-TC3-Step11");
---------------------------------------------------------------------------
 
-- Indicate the inbound frame queue is full.
1260,14 → 1261,14
TestCompare(inboundFrameWriteEmpty, '1', "Packet was received.");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 12:");
PrintS("Action: Send an erronous control-symbol. Then restore with");
PrintS(" link-request.");
PrintS("Result: Receiver should enter input-error-stopped and return to");
PrintS(" normal operation after the link-request was receiver.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 12:");
TestSpec("Action: Send an erronous control-symbol. Then restore with");
TestSpec(" link-request.");
TestSpec("Result: Receiver should enter input-error-stopped and return to");
TestSpec(" normal operation after the link-request was receiver.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC3-Step12");
TestCaseStart("TG_RioSerial-TC3-Step12");
---------------------------------------------------------------------------
 
-- Create, corrupt and send a control symbol.
1342,13 → 1343,13
TestCompare(inboundFrameWriteEmpty, '1', "Packet was received.");
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 13:");
PrintS("Action: Send an erronous packet. Then restore with link-request.");
PrintS("Result: Receiver should enter input-error-stopped and return to");
PrintS(" normal operation after the link-request was receiver.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 13:");
TestSpec("Action: Send an erronous packet. Then restore with link-request.");
TestSpec("Result: Receiver should enter input-error-stopped and return to");
TestSpec(" normal operation after the link-request was receiver.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC3-Step13");
TestCaseStart("TG_RioSerial-TC3-Step13");
---------------------------------------------------------------------------
 
-- Create a packet and send it with a bit error. It should be discarded.
1413,17 → 1414,17
-- REMARK: Complete with some more error situations: invalid ackId, too
-- short packet, too long packet, etc...
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("TG_RioSerial-TC4");
PrintS("Description: Test port transmission.");
PrintS("Requirement: XXXXX");
PrintS("-----------------------------------------------------------------");
PrintS("Step 1:");
PrintS("Action: Send an outbound frame.");
PrintS("Result: The frame should be read from the frame buffer and ");
PrintS(" received as symbols.");
TestSpec("-----------------------------------------------------------------");
TestSpec("TG_RioSerial-TC4");
TestSpec("Description: Test port transmission.");
TestSpec("Requirement: XXXXX");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 1:");
TestSpec("Action: Send an outbound frame.");
TestSpec("Result: The frame should be read from the frame buffer and ");
TestSpec(" received as symbols.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC4-Step1");
TestCaseStart("TG_RioSerial-TC4-Step1");
---------------------------------------------------------------------------
-- Create the frame.
1467,14 → 1468,14
TestCompare(outboundFrameWriteEmpty, '1', "packet transmitted");
 
---------------------------------------------------------------------------
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.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 2:");
TestSpec("Action: Send one more outbound packets than there are ackIds.");
TestSpec("Result: The packets should be fragmented and received in symbols.");
TestSpec(" The last packet should be delayed and sent once the first");
TestSpec(" packet has been accepted.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC4-Step2");
TestCaseStart("TG_RioSerial-TC4-Step2");
---------------------------------------------------------------------------
-- REMARK: 32 packet should ideally be supported, not just 31...fix.
for i in 0 to 4 loop
1553,12 → 1554,12
TestCompare(outboundFrameWriteEmpty, '1', "packet pending");
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 3:");
PrintS("Action: Send an outbound packet with maximum length.");
PrintS("Result: The packet should be fragmented and received in symbols.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 3:");
TestSpec("Action: Send an outbound packet with maximum length.");
TestSpec("Result: The packet should be fragmented and received in symbols.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC4-Step3");
TestCaseStart("TG_RioSerial-TC4-Step3");
---------------------------------------------------------------------------
-- Create the frame.
1600,13 → 1601,13
TestCompare(outboundFrameWriteEmpty, '1', "packet pending");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
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.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 4:");
TestSpec("Action: Send a packet and confirm it with packet-retry.");
TestSpec("Result: A restart-from-retry should be transmitted and the packet");
TestSpec(" should be retransmitted.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC4-Step4");
TestCaseStart("TG_RioSerial-TC4-Step4");
---------------------------------------------------------------------------
-- Create the frame.
1674,13 → 1675,13
TestCompare(outboundFrameWriteEmpty, '1', "packet pending");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
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.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 5:");
TestSpec("Action: Send a packet and confirm it with packet-not-accepted. ");
TestSpec("Result: A link-request should be transmitted and the packet should");
TestSpec(" be retransmitted.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC4-Step5");
TestCaseStart("TG_RioSerial-TC4-Step5");
---------------------------------------------------------------------------
-- Create the frame.
1749,13 → 1750,13
TestCompare(outboundFrameWriteEmpty, '1', "packet pending");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
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.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 6:");
TestSpec("Action: Let a packet timeout expire. Then answer with link-response.");
TestSpec("Result: A link-request should be transmitted and the packet should");
TestSpec(" be retransmitted.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC4-Step6");
TestCaseStart("TG_RioSerial-TC4-Step6");
---------------------------------------------------------------------------
-- Create the frame.
1835,14 → 1836,14
TestCompare(outboundFrameWriteEmpty, '1', "packet pending");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
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.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 7:");
TestSpec("Action: Let a packet timeout expire. Then answer with link-response");
TestSpec(" that indicates that the packet was received.");
TestSpec("Result: A link-request should be transmitted and the packet should");
TestSpec(" not be retransmitted.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC4-Step7");
TestCaseStart("TG_RioSerial-TC4-Step7");
---------------------------------------------------------------------------
-- Create the frame.
1902,13 → 1903,13
TestCompare(outboundFrameWriteEmpty, '1', "packet pending");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
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.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 8:");
TestSpec("Action: Let a packet timeout expire. No more replies.");
TestSpec("Result: Three link-requests should be transmitted. When the third");
TestSpec(" times out the link will be restarted.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC4-Step8");
TestCaseStart("TG_RioSerial-TC4-Step8");
---------------------------------------------------------------------------
-- Create the frame.
2024,14 → 2025,14
TestCompare(outboundFrameWriteEmpty, '1', "packet pending");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
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.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 9:");
TestSpec("Action: Let a packet timeout expire. Then answer with totally ");
TestSpec(" unexpected ackId.");
TestSpec("Result: A link request should be transmitted and the link should ");
TestSpec(" be restarted.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC4-Step9");
TestCaseStart("TG_RioSerial-TC4-Step9");
---------------------------------------------------------------------------
-- Create the frame.
2136,12 → 2137,12
TestCompare(outboundFrameWriteEmpty, '1', "packet pending");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 10:");
PrintS("Action: Send status with unexpected ackId in normal operation.");
PrintS("Result: The transmitter should disregard the error.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 10:");
TestSpec("Action: Send status with unexpected ackId in normal operation.");
TestSpec("Result: The transmitter should disregard the error.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC4-Step10");
TestCaseStart("TG_RioSerial-TC4-Step10");
---------------------------------------------------------------------------
 
-- Send a status with unexpected ackId.
2162,12 → 2163,12
TestCompare(outboundFrameWriteEmpty, '1', "packet pending");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 11:");
PrintS("Action: Send packet-retry with unexpected ackId in normal operation.");
PrintS("Result: The transmitter should enter output-error-stopped.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 11:");
TestSpec("Action: Send packet-retry with unexpected ackId in normal operation.");
TestSpec("Result: The transmitter should enter output-error-stopped.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC4-Step11");
TestCaseStart("TG_RioSerial-TC4-Step11");
---------------------------------------------------------------------------
-- Send a packet-retry with unexpected ackId.
2222,13 → 2223,13
TestCompare(outboundFrameWriteEmpty, '1', "packet pending");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 12:");
PrintS("Action: Send packet-accepted with unexpected ackId in normal ");
PrintS(" operation.");
PrintS("Result: The transmitter should enter output-error-stopped.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 12:");
TestSpec("Action: Send packet-accepted with unexpected ackId in normal ");
TestSpec(" operation.");
TestSpec("Result: The transmitter should enter output-error-stopped.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC4-Step12");
TestCaseStart("TG_RioSerial-TC4-Step12");
---------------------------------------------------------------------------
 
-- Send a packet-accepted with unexpected ackId.
2283,12 → 2284,12
TestCompare(outboundFrameWriteEmpty, '1', "packet pending");
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 13:");
PrintS("Action: Send a packet and then accept it with unexpected ackId.");
PrintS("Result: The transmitter should enter output-error-stopped.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 13:");
TestSpec("Action: Send a packet and then accept it with unexpected ackId.");
TestSpec("Result: The transmitter should enter output-error-stopped.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC4-Step13");
TestCaseStart("TG_RioSerial-TC4-Step13");
---------------------------------------------------------------------------
-- Create the frame.
2338,18 → 2339,18
TestCompare(outboundFrameWriteEmpty, '1', "packet pending");
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
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.");
TestSpec("-----------------------------------------------------------------");
TestSpec("TG_RioSerial-TC5");
TestSpec("Description: Test mixed port transmission and reception.");
TestSpec("Requirement: XXXXX");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 1:");
TestSpec("Action: Start sending an outbound packet and while in transmission, ");
TestSpec(" start and complete an inbound packet.");
TestSpec("Result: The ack for the inbound packet should be inserted into the");
TestSpec(" outbound packet.");
---------------------------------------------------------------------------
PrintR("TG_RioSerial-TC5-Step1");
TestCaseStart("TG_RioSerial-TC5-Step1");
---------------------------------------------------------------------------
 
-- Send a long outbound frame.
/rio/branches/2.0.0-development/bench/vhdl/TestRioPacketBuffer.vhd
10,7 → 10,9
-- implementation.
--
-- To Do:
-- -
-- - Update this to handle the readContentEnd being output at the last content
-- in a frame in the window-version. There are some errors indicated by this
-- testbench due to this.
--
-- Author(s):
-- - Magnus Rosenius, magro732@opencores.org
53,6 → 55,7
library std;
use std.textio.all;
use work.rio_common.all;
use work.TestPortPackage.all;
 
 
-------------------------------------------------------------------------------
364,19 → 367,19
wait until clk'event and clk = '1';
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("TG_RioPacketBuffer");
PrintS("-----------------------------------------------------------------");
PrintS("TG_RioPacketBuffer-TC1");
PrintS("Description: Test normal operation without using the window. Only");
PrintS(" full frames are tested.");
PrintS("Requirement: XXXXX");
PrintS("-----------------------------------------------------------------");
PrintS("Step 1:");
PrintS("Action: Complete a small frame and read it.");
PrintS("Result: The read frame should be equal to the one written.");
TestSpec("-----------------------------------------------------------------");
TestSpec("TG_RioPacketBuffer");
TestSpec("-----------------------------------------------------------------");
TestSpec("TG_RioPacketBuffer-TC1");
TestSpec("Description: Test normal operation without using the window. Only");
TestSpec(" full frames are tested.");
TestSpec("Requirement: XXXXX");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 1:");
TestSpec("Action: Complete a small frame and read it.");
TestSpec("Result: The read frame should be equal to the one written.");
---------------------------------------------------------------------------
PrintR("TG_RioPacketBuffer-TC1-Step1");
TestCaseStart("TG_RioPacketBuffer-TC1-Step1");
---------------------------------------------------------------------------
-- REMARK: Update testcases for inbound and outbound...
 
421,12 → 424,12
report "Unexpected readFrameEmpty." severity error;
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 2:");
PrintS("Action: Write a rio maximum size frame and read it.");
PrintS("Result: The read frame should be equal to the one written.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 2:");
TestSpec("Action: Write a rio maximum size frame and read it.");
TestSpec("Result: The read frame should be equal to the one written.");
---------------------------------------------------------------------------
PrintR("TG_RioPacketBuffer-TC1-Step2");
TestCaseStart("TG_RioPacketBuffer-TC1-Step2");
---------------------------------------------------------------------------
 
for i in 0 to 68 loop
469,13 → 472,13
report "Unexpected readFrameEmpty." severity error;
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 3:");
PrintS("Action: Fill the maximum number of small frames without filling ");
PrintS(" the memory.");
PrintS("Result: The frame buffer should accept 63 frames.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 3:");
TestSpec("Action: Fill the maximum number of small frames without filling ");
TestSpec(" the memory.");
TestSpec("Result: The frame buffer should accept 63 frames.");
---------------------------------------------------------------------------
PrintR("TG_RioPacketBuffer-TC1-Step3");
TestCaseStart("TG_RioPacketBuffer-TC1-Step3");
---------------------------------------------------------------------------
 
---------------------------------------------------------------------------
562,12 → 565,12
report "Unexpected readFrameEmpty." severity error;
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 4:");
PrintS("Action: Fill the memory to its limit.");
PrintS("Result: The frame buffer should accept 255-69 words.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 4:");
TestSpec("Action: Fill the memory to its limit.");
TestSpec("Result: The frame buffer should accept 255-69 words.");
---------------------------------------------------------------------------
PrintR("TG_RioPacketBuffer-TC1-Step4");
TestCaseStart("TG_RioPacketBuffer-TC1-Step4");
---------------------------------------------------------------------------
 
for i in 0 to 186 loop
608,17 → 611,17
report "Unexpected readFrameEmpty." severity error;
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("TG_RioPacketBuffer-TC2");
PrintS("Description: Test operation when using the window.");
PrintS("Requirement: XXXXX");
PrintS("-----------------------------------------------------------------");
PrintS("Step 1:");
PrintS("Action: Add one frame and update the window.");
PrintS("Result: The window empty flag and the read frame empty flag should");
PrintS(" be updated and it should be possible to read the frame again.");
TestSpec("-----------------------------------------------------------------");
TestSpec("TG_RioPacketBuffer-TC2");
TestSpec("Description: Test operation when using the window.");
TestSpec("Requirement: XXXXX");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 1:");
TestSpec("Action: Add one frame and update the window.");
TestSpec("Result: The window empty flag and the read frame empty flag should");
TestSpec(" be updated and it should be possible to read the frame again.");
---------------------------------------------------------------------------
PrintR("TG_RioPacketBuffer-TC2-Step1");
TestCaseStart("TG_RioPacketBuffer-TC2-Step1");
---------------------------------------------------------------------------
 
assert (outboundWriteFrameFull = '0')
709,12 → 712,12
report "Unexpected readWindowEmpty." severity error;
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 2:");
PrintS("Action: Add two frames and test the window accesses.");
PrintS("Result: .");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 2:");
TestSpec("Action: Add two frames and test the window accesses.");
TestSpec("Result: .");
---------------------------------------------------------------------------
PrintR("TG_RioPacketBuffer-TC2-Step2");
TestCaseStart("TG_RioPacketBuffer-TC2-Step2");
---------------------------------------------------------------------------
 
---------------------------------------------------------------------------
950,12 → 953,12
report "Unexpected readWindowEmpty." severity error;
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 3:");
PrintS("Action: Add maximum number of frames and test the window accesses.");
PrintS("Result: The buffer should be full and not accept more frames.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 3:");
TestSpec("Action: Add maximum number of frames and test the window accesses.");
TestSpec("Result: The buffer should be full and not accept more frames.");
---------------------------------------------------------------------------
PrintR("TG_RioPacketBuffer-TC2-Step3");
TestCaseStart("TG_RioPacketBuffer-TC2-Step3");
---------------------------------------------------------------------------
 
assert (outboundWriteFrameFull = '0')
1130,12 → 1133,12
report "Unexpected readWindowEmpty." severity error;
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 4:");
PrintS("Action: Add maximum number of words and test the window accesses.");
PrintS("Result: The content memory should be full.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 4:");
TestSpec("Action: Add maximum number of words and test the window accesses.");
TestSpec("Result: The content memory should be full.");
---------------------------------------------------------------------------
PrintR("TG_RioPacketBuffer-TC2-Step4");
TestCaseStart("TG_RioPacketBuffer-TC2-Step4");
---------------------------------------------------------------------------
 
assert (outboundWriteFrameFull = '0')
1338,12 → 1341,12
report "Unexpected readWindowEmpty." severity error;
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 5:");
PrintS("Action: Add maximum number of words -1 and test the window accesses.");
PrintS("Result: The content memory should not accept more frames.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 5:");
TestSpec("Action: Add maximum number of words -1 and test the window accesses.");
TestSpec("Result: The content memory should not accept more frames.");
---------------------------------------------------------------------------
PrintR("TG_RioPacketBuffer-TC2-Step5");
TestCaseStart("TG_RioPacketBuffer-TC2-Step5");
---------------------------------------------------------------------------
 
assert (outboundWriteFrameFull = '0')
1458,14 → 1461,14
report "Unexpected readWindowEmpty." severity error;
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 6:");
PrintS("Action: Add two frames and start reading the second, then remove");
PrintS(" the first.");
PrintS("Result: The readContentEnd flag should not be changed when frames");
PrintS(" are removed.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 6:");
TestSpec("Action: Add two frames and start reading the second, then remove");
TestSpec(" the first.");
TestSpec("Result: The readContentEnd flag should not be changed when frames");
TestSpec(" are removed.");
---------------------------------------------------------------------------
PrintR("TG_RioPacketBuffer-TC2-Step6");
TestCaseStart("TG_RioPacketBuffer-TC2-Step6");
---------------------------------------------------------------------------
 
assert (outboundWriteFrameFull = '0')
1603,18 → 1606,18
report "Unexpected readWindowEmpty." severity error;
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("TG_RioPacketBuffer");
PrintS("-----------------------------------------------------------------");
PrintS("TG_RioPacketBuffer-TC3");
PrintS("Description: Test operation when restarting and aborting frames.");
PrintS("Requirement: XXXXX");
PrintS("-----------------------------------------------------------------");
PrintS("Step 1:");
PrintS("Action: Write one frame and abort it.");
PrintS("Result: The aborted frame should be discarded.");
TestSpec("-----------------------------------------------------------------");
TestSpec("TG_RioPacketBuffer");
TestSpec("-----------------------------------------------------------------");
TestSpec("TG_RioPacketBuffer-TC3");
TestSpec("Description: Test operation when restarting and aborting frames.");
TestSpec("Requirement: XXXXX");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 1:");
TestSpec("Action: Write one frame and abort it.");
TestSpec("Result: The aborted frame should be discarded.");
---------------------------------------------------------------------------
PrintR("TG_RioPacketBuffer-TC3-Step1");
TestCaseStart("TG_RioPacketBuffer-TC3-Step1");
---------------------------------------------------------------------------
 
assert (outboundWriteFrameFull = '0')
1643,13 → 1646,13
report "Unexpected readWindowEmpty." severity error;
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 2:");
PrintS("Action: Write one full frame then one more that is aborted.");
PrintS("Result: The first frame should remain and the aborted should be ");
PrintS(" discarded.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 2:");
TestSpec("Action: Write one full frame then one more that is aborted.");
TestSpec("Result: The first frame should remain and the aborted should be ");
TestSpec(" discarded.");
---------------------------------------------------------------------------
PrintR("TG_RioPacketBuffer-TC3-Step2");
TestCaseStart("TG_RioPacketBuffer-TC3-Step2");
---------------------------------------------------------------------------
 
for i in 0 to 3 loop
1775,12 → 1778,12
report "Unexpected readWindowEmpty." severity error;
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 3:");
PrintS("Action: Write one full frame then read one that is restarted.");
PrintS("Result: The content of the first frame should be read twice. ");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 3:");
TestSpec("Action: Write one full frame then read one that is restarted.");
TestSpec("Result: The content of the first frame should be read twice. ");
---------------------------------------------------------------------------
PrintR("TG_RioPacketBuffer-TC3-Step3");
TestCaseStart("TG_RioPacketBuffer-TC3-Step3");
---------------------------------------------------------------------------
 
for i in 0 to 3 loop
1862,18 → 1865,18
report "Unexpected readWindowEmpty." severity error;
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("TG_RioPacketBuffer");
PrintS("-----------------------------------------------------------------");
PrintS("TG_RioPacketBuffer-TC4");
PrintS("Description: Test operation when partial frames are read.");
PrintS("Requirement: XXXXX");
PrintS("-----------------------------------------------------------------");
PrintS("Step 1:");
PrintS("Action: Write a one word frame and read it before it is completed.");
PrintS("Result: Empty signals should reflect the status of the frame.");
TestSpec("-----------------------------------------------------------------");
TestSpec("TG_RioPacketBuffer");
TestSpec("-----------------------------------------------------------------");
TestSpec("TG_RioPacketBuffer-TC4");
TestSpec("Description: Test operation when partial frames are read.");
TestSpec("Requirement: XXXXX");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 1:");
TestSpec("Action: Write a one word frame and read it before it is completed.");
TestSpec("Result: Empty signals should reflect the status of the frame.");
---------------------------------------------------------------------------
PrintR("TG_RioPacketBuffer-TC4-Step1");
TestCaseStart("TG_RioPacketBuffer-TC4-Step1");
---------------------------------------------------------------------------
 
assert (outboundWriteFrameFull = '0')
1936,14 → 1939,14
report "Unexpected readContentEmpty." severity error;
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 2:");
PrintS("Action: Write content to a frame and read it, then abort the frame.");
PrintS("Result: The reader should be notified about the aborted frame. The");
PrintS(" notification should be reset when the frame has been ");
PrintS(" restarted.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 2:");
TestSpec("Action: Write content to a frame and read it, then abort the frame.");
TestSpec("Result: The reader should be notified about the aborted frame. The");
TestSpec(" notification should be reset when the frame has been ");
TestSpec(" restarted.");
---------------------------------------------------------------------------
PrintR("TG_RioPacketBuffer-TC4-Step2");
TestCaseStart("TG_RioPacketBuffer-TC4-Step2");
---------------------------------------------------------------------------
 
SetOutboundWriteContent(std_logic_vector(to_unsigned(1, 32)));
2055,12 → 2058,12
report "Unexpected readFrameAborted." severity error;
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 3:");
PrintS("Action: Write one complete frame then abort a second.");
PrintS("Result: The reader should not notice the aborted frame. ");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 3:");
TestSpec("Action: Write one complete frame then abort a second.");
TestSpec("Result: The reader should not notice the aborted frame. ");
---------------------------------------------------------------------------
PrintR("TG_RioPacketBuffer-TC4-Step3");
TestCaseStart("TG_RioPacketBuffer-TC4-Step3");
---------------------------------------------------------------------------
 
SetOutboundWriteContent(std_logic_vector(to_unsigned(1, 32)));
/rio/branches/2.0.0-development/bench/vhdl/TestRioSwitch.vhd
10,6 → 10,7
--
-- To Do:
-- - Test all sizes of packets that go through the maintenance port.
-- - Make sure all testcases from the 1.0 branch is in here.
--
-- Author(s):
-- - Magnus Rosenius, magro732@opencores.org
89,9 → 90,6
 
readFrameEmpty_i : in Array1(SWITCH_PORTS-1 downto 0);
readFrame_o : out Array1(SWITCH_PORTS-1 downto 0);
readFrameRestart_o : out Array1(SWITCH_PORTS-1 downto 0);
readFrameAborted_i : in Array1(SWITCH_PORTS-1 downto 0);
readContentEmpty_i : in Array1(SWITCH_PORTS-1 downto 0);
readContent_o : out Array1(SWITCH_PORTS-1 downto 0);
readContentEnd_i : in Array1(SWITCH_PORTS-1 downto 0);
readContentData_i : in Array32(SWITCH_PORTS-1 downto 0);
172,9 → 170,6
 
signal readFrameEmpty : Array1(PORTS-1 downto 0);
signal readFrame : Array1(PORTS-1 downto 0);
signal readFrameRestart : Array1(PORTS-1 downto 0);
signal readFrameAborted : Array1(PORTS-1 downto 0);
signal readContentEmpty : Array1(PORTS-1 downto 0);
signal readContent : Array1(PORTS-1 downto 0);
signal readContentEnd : Array1(PORTS-1 downto 0);
signal readContentData : Array32(PORTS-1 downto 0);
383,6 → 378,29
end procedure;
 
---------------------------------------------------------------------------
-- Set a route table entry.
---------------------------------------------------------------------------
procedure RouteSet(constant deviceId : std_logic_vector(15 downto 0);
constant portIndex : std_logic_vector(7 downto 0)) is
variable frame : RioFrame;
begin
WriteConfig32(portIndex=>0, destinationId=>x"ffff", sourceId=>x"ffff", hop=>x"00",
tid=>x"de", address=>x"000070", data=>(x"0000" & deviceId));
WriteConfig32(portIndex=>0, destinationId=>x"ffff", sourceId=>x"ffff", hop=>x"00",
tid=>x"ad", address=>x"000074", data=>(x"000000" & portIndex));
end procedure;
---------------------------------------------------------------------------
-- Set the default route table entry.
---------------------------------------------------------------------------
procedure RouteSetDefault(constant portIndex : std_logic_vector(7 downto 0)) is
variable frame : RioFrame;
begin
WriteConfig32(portIndex=>0, destinationId=>x"ffff", sourceId=>x"ffff", hop=>x"00",
tid=>x"ad", address=>x"000078", data=>(x"000000" & portIndex));
end procedure;
---------------------------------------------------------------------------
--
---------------------------------------------------------------------------
procedure RouteFrame(constant sourcePortIndex : natural range 0 to 7;
480,18 → 498,18
wait until clk'event and clk = '1';
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("TG_RioSwitch");
PrintS("-----------------------------------------------------------------");
PrintS("TG_RioSwitch-TC1");
PrintS("Description: Test switch maintenance accesses on different ports.");
PrintS("Requirement: XXXXX");
PrintS("-----------------------------------------------------------------");
PrintS("Step 1:");
PrintS("Action: Send maintenance read request packets to read switch identity.");
PrintS("Result: The switch should answer with its configured identitiy.");
TestSpec("-----------------------------------------------------------------");
TestSpec("TG_RioSwitch");
TestSpec("-----------------------------------------------------------------");
TestSpec("TG_RioSwitch-TC1");
TestSpec("Description: Test switch maintenance accesses on different ports.");
TestSpec("Requirement: XXXXX");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 1:");
TestSpec("Action: Send maintenance read request packets to read switch identity.");
TestSpec("Result: The switch should answer with its configured identitiy.");
---------------------------------------------------------------------------
PrintR("TG_RioSwitch-TC1-Step1");
TestCaseStart("TG_RioSwitch-TC1-Step1");
---------------------------------------------------------------------------
ReadConfig32(portIndex=>0, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
506,15 → 524,15
ExchangeFrames;
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 2:");
PrintS("Action: Check the switch Processing Element Features.");
PrintS("Result: The expected switch features should be returned. ");
PrintS(" Switch with extended features pointer valid. Common ");
PrintS(" transport large system support and standard route table ");
PrintS(" configuration support.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 2:");
TestSpec("Action: Check the switch Processing Element Features.");
TestSpec("Result: The expected switch features should be returned. ");
TestSpec(" Switch with extended features pointer valid. Common ");
TestSpec(" transport large system support and standard route table ");
TestSpec(" configuration support.");
---------------------------------------------------------------------------
PrintR("TG_RioSwitch-TC1-Step2");
TestCaseStart("TG_RioSwitch-TC1-Step2");
---------------------------------------------------------------------------
 
ReadConfig32(portIndex=>4, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
523,12 → 541,12
ExchangeFrames;
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 3:");
PrintS("Action: Check the switch port information.");
PrintS("Result: The expected port and number of ports should be returned.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 3:");
TestSpec("Action: Check the switch port information.");
TestSpec("Result: The expected port and number of ports should be returned.");
---------------------------------------------------------------------------
PrintR("TG_RioSwitch-TC1-Step3");
TestCaseStart("TG_RioSwitch-TC1-Step3");
---------------------------------------------------------------------------
 
ReadConfig32(portIndex=>2, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
537,12 → 555,12
ExchangeFrames;
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 4:");
PrintS("Action: Check the switch number of supported routes.");
PrintS("Result: The expected number of supported routes should be returned.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 4:");
TestSpec("Action: Check the switch number of supported routes.");
TestSpec("Result: The expected number of supported routes should be returned.");
---------------------------------------------------------------------------
PrintR("TG_RioSwitch-TC1-Step4");
TestCaseStart("TG_RioSwitch-TC1-Step4");
---------------------------------------------------------------------------
 
ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
551,13 → 569,13
ExchangeFrames;
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 5:");
PrintS("Action: Test host base device id lock by reading it, then hold it ");
PrintS(" and try to grab it from another address.");
PrintS("Result: The value should follow the specification.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 5:");
TestSpec("Action: Test host base device id lock by reading it, then hold it ");
TestSpec(" and try to grab it from another address.");
TestSpec("Result: The value should follow the specification.");
---------------------------------------------------------------------------
PrintR("TG_RioSwitch-TC1-Step5");
TestCaseStart("TG_RioSwitch-TC1-Step5");
---------------------------------------------------------------------------
 
-- Check that the lock is released.
607,12 → 625,12
ExchangeFrames;
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 6");
PrintS("Action: Check the component tag register.");
PrintS("Result: The written value in the component tag should be saved.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 6");
TestSpec("Action: Check the component tag register.");
TestSpec("Result: The written value in the component tag should be saved.");
---------------------------------------------------------------------------
PrintR("TG_RioSwitch-TC1-Step6");
TestCaseStart("TG_RioSwitch-TC1-Step6");
---------------------------------------------------------------------------
 
ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
627,12 → 645,12
ExchangeFrames;
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 7");
PrintS("Action: Read and write to the port link timeout.");
PrintS("Result: Check that the portLinkTimeout output from the switch changes.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 7");
TestSpec("Action: Read and write to the port link timeout.");
TestSpec("Result: Check that the portLinkTimeout output from the switch changes.");
---------------------------------------------------------------------------
PrintR("TG_RioSwitch-TC1-Step7");
TestCaseStart("TG_RioSwitch-TC1-Step7");
---------------------------------------------------------------------------
 
assert portLinkTimeout = x"ffffff" report "Unexpected portLinkTimeout." severity error;
651,12 → 669,12
assert portLinkTimeout = x"000001" report "Unexpected portLinkTimeout." severity error;
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 8");
PrintS("Action: Read from the port general control.");
PrintS("Result: Check the discovered bit.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 8");
TestSpec("Action: Read from the port general control.");
TestSpec("Result: Check the discovered bit.");
---------------------------------------------------------------------------
PrintR("TG_RioSwitch-TC1-Step8");
TestCaseStart("TG_RioSwitch-TC1-Step8");
---------------------------------------------------------------------------
 
ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
677,12 → 695,12
ExchangeFrames;
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 9");
PrintS("Action: Read from the port N error and status.");
PrintS("Result: Check the port ok and port uninitialized bits.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 9");
TestSpec("Action: Read from the port N error and status.");
TestSpec("Result: Check the port ok and port uninitialized bits.");
---------------------------------------------------------------------------
PrintR("TG_RioSwitch-TC1-Step9");
TestCaseStart("TG_RioSwitch-TC1-Step9");
---------------------------------------------------------------------------
 
linkInitialized(0) <= '0';
713,12 → 731,12
ExchangeFrames;
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 10");
PrintS("Action: Read and write to/from the port N control.");
PrintS("Result: Check the output/input port enable.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 10");
TestSpec("Action: Read and write to/from the port N control.");
TestSpec("Result: Check the output/input port enable.");
---------------------------------------------------------------------------
PrintR("TG_RioSwitch-TC1-Step10");
TestCaseStart("TG_RioSwitch-TC1-Step10");
---------------------------------------------------------------------------
 
assert outputPortEnable(0) = '0' report "Unexpected outputPortEnable." severity error;
777,12 → 795,12
assert inputPortEnable(2) = '1' report "Unexpected inputPortEnable." severity error;
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 11");
PrintS("Action: Read and write to/from the implementation defined space.");
PrintS("Result: Check the accesses on the external configuration port.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 11");
TestSpec("Action: Read and write to/from the implementation defined space.");
TestSpec("Result: Check the accesses on the external configuration port.");
---------------------------------------------------------------------------
PrintR("TG_RioSwitch-TC1-Step11");
TestCaseStart("TG_RioSwitch-TC1-Step11");
---------------------------------------------------------------------------
 
CreateRandomPayload(maintData, seed1, seed2);
876,17 → 894,17
TestWait(messageEmpty, '1', "config write");
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("TG_RioSwitch-TC2");
PrintS("Description: Test the configuration of the routing table and the ");
PrintS(" routing of packets.");
PrintS("Requirement: XXXXX");
PrintS("-----------------------------------------------------------------");
PrintS("Step 1:");
PrintS("Action: Configure the routing table for address 0->port 1.");
PrintS("Result: A packet to address 0 should be forwarded to port 1.");
TestSpec("-----------------------------------------------------------------");
TestSpec("TG_RioSwitch-TC2");
TestSpec("Description: Test the configuration of the routing table and the ");
TestSpec(" routing of packets.");
TestSpec("Requirement: XXXXX");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 1:");
TestSpec("Action: Configure the routing table for address 0->port 1.");
TestSpec("Result: A packet to address 0 should be forwarded to port 1.");
---------------------------------------------------------------------------
PrintR("TG_RioSwitch-TC2-Step1");
TestCaseStart("TG_RioSwitch-TC2-Step1");
---------------------------------------------------------------------------
 
ReadConfig32(portIndex=>0, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
905,12 → 923,12
ExchangeFrames;
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 2:");
PrintS("Action: Test the configuration of the default route->port 2.");
PrintS("Result: An unknown address should be routed to port 2.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 2:");
TestSpec("Action: Test the configuration of the default route->port 2.");
TestSpec("Result: An unknown address should be routed to port 2.");
---------------------------------------------------------------------------
PrintR("TG_RioSwitch-TC2-Step2");
TestCaseStart("TG_RioSwitch-TC2-Step2");
---------------------------------------------------------------------------
 
ReadConfig32(portIndex=>0, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
929,13 → 947,13
ExchangeFrames;
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 3:");
PrintS("Action: Test to route a maintenance read request from port 2, ");
PrintS(" address 0.");
PrintS("Result: The packet should be routed to port 1 and hop decremented.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 3:");
TestSpec("Action: Test to route a maintenance read request from port 2, ");
TestSpec(" address 0.");
TestSpec("Result: The packet should be routed to port 1 and hop decremented.");
---------------------------------------------------------------------------
PrintR("TG_RioSwitch-TC2-Step3");
TestCaseStart("TG_RioSwitch-TC2-Step3");
---------------------------------------------------------------------------
 
SendFrame(2, RioFrameCreate(ackId=>"00000", vc=>'0', crf=>'0', prio=>"00",
965,13 → 983,13
ExchangeFrames;
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 4:");
PrintS("Action: Test to route a maintenance write request from port 2, ");
PrintS(" address 0.");
PrintS("Result: The packet should be routed to port 1 and hop decremented.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 4:");
TestSpec("Action: Test to route a maintenance write request from port 2, ");
TestSpec(" address 0.");
TestSpec("Result: The packet should be routed to port 1 and hop decremented.");
---------------------------------------------------------------------------
PrintR("TG_RioSwitch-TC2-Step4");
TestCaseStart("TG_RioSwitch-TC2-Step4");
---------------------------------------------------------------------------
 
CreateRandomPayload(maintData, seed1, seed2);
1001,13 → 1019,13
ExchangeFrames;
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 5:");
PrintS("Action: Test to route a maintenance read response from port 2, ");
PrintS(" address 0.");
PrintS("Result: The packet should be routed to port 1 and hop decremented.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 5:");
TestSpec("Action: Test to route a maintenance read response from port 2, ");
TestSpec(" address 0.");
TestSpec("Result: The packet should be routed to port 1 and hop decremented.");
---------------------------------------------------------------------------
PrintR("TG_RioSwitch-TC2-Step5");
TestCaseStart("TG_RioSwitch-TC2-Step5");
---------------------------------------------------------------------------
 
CreateRandomPayload(maintData, seed1, seed2);
1037,13 → 1055,13
ExchangeFrames;
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 6:");
PrintS("Action: Test to route a maintenance write response from port 2, ");
PrintS(" address 0.");
PrintS("Result: The packet should be routed to port 1 and hop decremented.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 6:");
TestSpec("Action: Test to route a maintenance write response from port 2, ");
TestSpec(" address 0.");
TestSpec("Result: The packet should be routed to port 1 and hop decremented.");
---------------------------------------------------------------------------
PrintR("TG_RioSwitch-TC2-Step6");
TestCaseStart("TG_RioSwitch-TC2-Step6");
---------------------------------------------------------------------------
 
SendFrame(2, RioFrameCreate(ackId=>"00000", vc=>'0', crf=>'0', prio=>"00",
1072,12 → 1090,12
ExchangeFrames;
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 7:");
PrintS("Action: ");
PrintS("Result: ");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 7:");
TestSpec("Action: ");
TestSpec("Result: ");
---------------------------------------------------------------------------
PrintR("TG_RioSwitch-TC2-Step7");
TestCaseStart("TG_RioSwitch-TC2-Step7");
---------------------------------------------------------------------------
 
maintData(0) := x"0123456789abcdef";
1116,25 → 1134,35
ExchangeFrames;
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("TG_RioSwitch-TC3");
PrintS("Description: Test the routing of normal packets.");
PrintS("Requirement: XXXXX");
PrintS("-----------------------------------------------------------------");
PrintS("Step 1:");
PrintS("Action: Send two packets but not the same time.");
PrintS("Result: Both packets should be received at the expected ports.");
TestSpec("-----------------------------------------------------------------");
TestSpec("TG_RioSwitch-TC3");
TestSpec("Description: Test the routing of normal packets.");
TestSpec("Requirement: XXXXX");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 1:");
TestSpec("Action: Send two packets but not the same time.");
TestSpec("Result: Both packets should be received at the expected ports.");
---------------------------------------------------------------------------
PrintR("TG_RioSwitch-TC3-Step1");
TestCaseStart("TG_RioSwitch-TC3-Step1");
---------------------------------------------------------------------------
 
-- Setup the routing table for the following steps.
RouteSet(x"0000", x"00");
RouteSet(x"0001", x"00");
RouteSet(x"0002", x"00");
RouteSet(x"0003", x"00");
RouteSet(x"0004", x"01");
RouteSet(x"0005", x"02");
RouteSet(x"0006", x"02");
RouteSetDefault(x"02");
-- Frame on port 0 to port 1.
randomPayload.length := 3;
CreateRandomPayload(randomPayload.data, seed1, seed2);
SendFrame(portIndex=>0,
destinationId=>x"0000", sourceId=>x"ffff", payload=>randomPayload);
destinationId=>x"0004", sourceId=>x"ffff", payload=>randomPayload);
ReceiveFrame(portIndex=>1,
destinationId=>x"0000", sourceId=>x"ffff", payload=>randomPayload);
destinationId=>x"0004", sourceId=>x"ffff", payload=>randomPayload);
 
-- Frame on port 1 to port 6.
randomPayload.length := 4;
1147,14 → 1175,14
ExchangeFrames;
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("Step 2:");
PrintS("Action: Send two packets to the same port with is full and one to");
PrintS(" another that is also full. Then receive the packets one at");
PrintS(" a time.");
PrintS("Result: The packet to the port that is ready should go though.");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 2:");
TestSpec("Action: Send two packets to the same port with is full and one to");
TestSpec(" another that is also full. Then receive the packets one at");
TestSpec(" a time.");
TestSpec("Result: The packet to the port that is ready should go though.");
---------------------------------------------------------------------------
PrintR("TG_RioSwitch-TC3-Step2");
TestCaseStart("TG_RioSwitch-TC3-Step2");
---------------------------------------------------------------------------
 
-- Frame on port 0 to port 1.
1251,11 → 1279,11
readFrameEmpty_o=>readFrameEmpty(portIndex),
readFrame_i=>readFrame(portIndex),
readFrameRestart_i=>'0',
readFrameAborted_o=>readFrameAborted(portIndex),
readFrameAborted_o=>open,
readWindowEmpty_o=>open,
readWindowReset_i=>'0',
readWindowNext_i=>readFrame(portIndex),
readContentEmpty_o=>readContentEmpty(portIndex),
readContentEmpty_o=>open,
readContent_i=>readContent(portIndex),
readContentEnd_o=>readContentEnd(portIndex),
readContentData_o=>readContentData(portIndex),
1284,9 → 1312,7
writeFrame_o=>writeFrame, writeFrameAbort_o=>writeFrameAbort,
writeContent_o=>writeContent, writeContentData_o=>writeContentData,
readFrameEmpty_i=>readFrameEmpty,
readFrame_o=>readFrame, readFrameRestart_o=>readFrameRestart,
readFrameAborted_i=>readFrameAborted,
readContentEmpty_i=>readContentEmpty,
readFrame_o=>readFrame,
readContent_o=>readContent, readContentEnd_i=>readContentEnd,
readContentData_i=>readContentData,
portLinkTimeout_o=>portLinkTimeout,
/rio/branches/2.0.0-development/bench/vhdl/TestRioLogicalCommon.vhd
274,20 → 274,20
wait until clk'event and clk = '1';
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("TG_RioLogicalCommon");
PrintS("-----------------------------------------------------------------");
PrintS("TG_RioLogicalCommon-TC1");
PrintS("Description: Test all sizes of packets in the inbound direction.");
PrintS("Requirement: ");
PrintS("-----------------------------------------------------------------");
PrintS("Step 1:");
PrintS("Action: Add inbound packets in all allowed sized.");
PrintS("Result: The payload of the inbound packets should be received on ");
PrintS(" the other side without CRC.");
PrintS("-----------------------------------------------------------------");
TestSpec("-----------------------------------------------------------------");
TestSpec("TG_RioLogicalCommon");
TestSpec("-----------------------------------------------------------------");
TestSpec("TG_RioLogicalCommon-TC1");
TestSpec("Description: Test all sizes of packets in the inbound direction.");
TestSpec("Requirement: ");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 1:");
TestSpec("Action: Add inbound packets in all allowed sized.");
TestSpec("Result: The payload of the inbound packets should be received on ");
TestSpec(" the other side without CRC.");
TestSpec("-----------------------------------------------------------------");
---------------------------------------------------------------------------
PrintR("TG_RioLogicalCommon-TC1-Step1");
TestCaseStart("TG_RioLogicalCommon-TC1-Step1");
---------------------------------------------------------------------------
-- REMARK: Use random data...
for j in 1 to 133 loop
310,28 → 310,28
TestWait(inboundMessageEmpty, '1', "inboundMessage empty");
---------------------------------------------------------------------------
--PrintS("-----------------------------------------------------------------");
--PrintS("Step 2:");
--PrintS("Action: Send an inbound frame that are too long.");
--PrintS("Result: The tail of the packet should be discarded.");
--PrintS("-----------------------------------------------------------------");
--TestSpec("-----------------------------------------------------------------");
--TestSpec("Step 2:");
--TestSpec("Action: Send an inbound frame that are too long.");
--TestSpec("Result: The tail of the packet should be discarded.");
--TestSpec("-----------------------------------------------------------------");
---------------------------------------------------------------------------
--PrintR("TG_RioLogicalCommon-TC1-Step2");
--TestCaseStart("TG_RioLogicalCommon-TC1-Step2");
---------------------------------------------------------------------------
 
---------------------------------------------------------------------------
PrintS("-----------------------------------------------------------------");
PrintS("TG_RioLogicalCommon-TC2");
PrintS("Description: Test all sizes of packets in the outbound direction.");
PrintS("Requirement: ");
PrintS("-----------------------------------------------------------------");
PrintS("Step 1:");
PrintS("Action: Add outbound packets in all allowed sized.");
PrintS("Result: The payload of the outbound packets should be received on ");
PrintS(" the other side with CRC added.");
PrintS("-----------------------------------------------------------------");
TestSpec("-----------------------------------------------------------------");
TestSpec("TG_RioLogicalCommon-TC2");
TestSpec("Description: Test all sizes of packets in the outbound direction.");
TestSpec("Requirement: ");
TestSpec("-----------------------------------------------------------------");
TestSpec("Step 1:");
TestSpec("Action: Add outbound packets in all allowed sized.");
TestSpec("Result: The payload of the outbound packets should be received on ");
TestSpec(" the other side with CRC added.");
TestSpec("-----------------------------------------------------------------");
---------------------------------------------------------------------------
PrintR("TG_RioLogicalCommon-TC2-Step1");
TestCaseStart("TG_RioLogicalCommon-TC2-Step1");
---------------------------------------------------------------------------
 
for j in 1 to 133 loop
354,13 → 354,13
TestWait(outboundMessageEmpty, '1', "outboundMessage empty");
-----------------------------------------------------------------------------
--PrintS("-----------------------------------------------------------------");
--PrintS("Step 2:");
--PrintS("Action: Send an outbound frame that are too long.");
--PrintS("Result: The tail of the packet should be discarded.");
--PrintS("-----------------------------------------------------------------");
--TestSpec("-----------------------------------------------------------------");
--TestSpec("Step 2:");
--TestSpec("Action: Send an outbound frame that are too long.");
--TestSpec("Result: The tail of the packet should be discarded.");
--TestSpec("-----------------------------------------------------------------");
-----------------------------------------------------------------------------
--PrintR("TG_RioLogicalCommon-TC1-Step2");
--TestCaseStart("TG_RioLogicalCommon-TC1-Step2");
-----------------------------------------------------------------------------
 
---------------------------------------------------------------------------
/rio/branches/2.0.0-development/rtl/vhdl/RioLogicalPackets.vhd
9,7 → 9,10
-- Containing RapidIO packet parsers and generators.
--
-- To Do:
-- -
-- - Add support for all Request-class packets.
-- - Add support for all Write-class packets.
-- - Add support for Doorbell-class packets.
-- - Add support for Message-class packets.
--
-- Author(s):
-- - Magnus Rosenius, magro732@opencores.org
/rio/branches/2.0.0-development/rtl/vhdl/RioCommon.vhd
48,9 → 48,6
-------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.math_real.all;
use std.textio.all;
 
 
-------------------------------------------------------------------------------
402,6 → 399,12
-- Commonly used constants.
-----------------------------------------------------------------------------
-- Symbol types between the serial and the PCS layer.
constant SYMBOL_IDLE : std_logic_vector(1 downto 0) := "00";
constant SYMBOL_CONTROL : std_logic_vector(1 downto 0) := "01";
constant SYMBOL_ERROR : std_logic_vector(1 downto 0) := "10";
constant SYMBOL_DATA : std_logic_vector(1 downto 0) := "11";
-- STYPE0 constants.
constant STYPE0_PACKET_ACCEPTED : std_logic_vector(2 downto 0) := "000";
constant STYPE0_PACKET_RETRY : std_logic_vector(2 downto 0) := "001";
455,171 → 458,6
constant PACKET_NOT_ACCEPTED_CAUSE_LOSS_DESCRAMBLER : std_logic_vector(4 downto 0) := "00111";
constant PACKET_NOT_ACCEPTED_CAUSE_GENERAL_ERROR : std_logic_vector(4 downto 0) := "11111";
-----------------------------------------------------------------------------
-- Types used in simulations.
-----------------------------------------------------------------------------
type ByteArray is array (natural range <>) of
std_logic_vector(7 downto 0);
type HalfwordArray is array (natural range <>) of
std_logic_vector(15 downto 0);
type WordArray is array (natural range <>) of
std_logic_vector(31 downto 0);
type DoublewordArray is array (natural range <>) of
std_logic_vector(63 downto 0);
 
-- Type defining a RapidIO frame.
type RioFrame is record
length : natural range 0 to 69;
payload : WordArray(0 to 68);
end record;
type RioFrameArray is array (natural range <>) of RioFrame;
 
-- Type defining a RapidIO payload.
type RioPayload is record
length : natural range 0 to 133;
data : HalfwordArray(0 to 132);
end record;
 
-----------------------------------------------------------------------------
-- Crc5 calculation function.
-- ITU, polynom=0x15.
-----------------------------------------------------------------------------
function Crc5(constant data : in std_logic_vector(18 downto 0);
constant crc : in std_logic_vector(4 downto 0))
return std_logic_vector;
---------------------------------------------------------------------------
-- Create a RapidIO physical layer control symbol.
---------------------------------------------------------------------------
function RioControlSymbolCreate(
constant stype0 : in std_logic_vector(2 downto 0);
constant parameter0 : in std_logic_vector(4 downto 0);
constant parameter1 : in std_logic_vector(4 downto 0);
constant stype1 : in std_logic_vector(2 downto 0);
constant cmd : in std_logic_vector(2 downto 0))
return std_logic_vector;
 
-----------------------------------------------------------------------------
-- Crc16 calculation function.
-- CITT, polynom=0x1021.
-----------------------------------------------------------------------------
function Crc16(constant data : in std_logic_vector(15 downto 0);
constant crc : in std_logic_vector(15 downto 0))
return std_logic_vector;
---------------------------------------------------------------------------
-- Create a randomly initialized data array.
---------------------------------------------------------------------------
procedure CreateRandomPayload(
variable payload : out HalfwordArray;
variable seed1 : inout positive;
variable seed2 : inout positive);
procedure CreateRandomPayload(
variable payload : out DoublewordArray;
variable seed1 : inout positive;
variable seed2 : inout positive);
 
---------------------------------------------------------------------------
-- Create a generic RapidIO frame.
---------------------------------------------------------------------------
function RioFrameCreate(
constant ackId : in std_logic_vector(4 downto 0);
constant vc : in std_logic;
constant crf : in std_logic;
constant prio : in std_logic_vector(1 downto 0);
constant tt : in std_logic_vector(1 downto 0);
constant ftype : in std_logic_vector(3 downto 0);
constant sourceId : in std_logic_vector(15 downto 0);
constant destId : in std_logic_vector(15 downto 0);
constant payload : in RioPayload)
return RioFrame;
---------------------------------------------------------------------------
-- Create a NWRITE RapidIO frame.
---------------------------------------------------------------------------
function RioNwrite(
constant wrsize : in std_logic_vector(3 downto 0);
constant address : in std_logic_vector(28 downto 0);
constant wdptr : in std_logic;
constant xamsbs : in std_logic_vector(1 downto 0);
constant dataLength : in natural range 1 to 32;
constant data : in DoublewordArray(0 to 31))
return RioPayload;
---------------------------------------------------------------------------
-- Create a NWRITER RapidIO frame.
---------------------------------------------------------------------------
function RioNwriteR(
constant wrsize : in std_logic_vector(3 downto 0);
constant tid : in std_logic_vector(7 downto 0);
constant address : in std_logic_vector(28 downto 0);
constant wdptr : in std_logic;
constant xamsbs : in std_logic_vector(1 downto 0);
constant dataLength : in natural range 1 to 32;
constant data : in DoublewordArray(0 to 31))
return RioPayload;
---------------------------------------------------------------------------
-- Create a NREAD RapidIO frame.
---------------------------------------------------------------------------
function RioNread(
constant rdsize : in std_logic_vector(3 downto 0);
constant tid : in std_logic_vector(7 downto 0);
constant address : in std_logic_vector(28 downto 0);
constant wdptr : in std_logic;
constant xamsbs : in std_logic_vector(1 downto 0))
return RioPayload;
---------------------------------------------------------------------------
-- Create a RESPONSE RapidIO frame.
---------------------------------------------------------------------------
function RioResponse(
constant status : in std_logic_vector(3 downto 0);
constant tid : in std_logic_vector(7 downto 0);
constant dataLength : in natural range 0 to 32;
constant data : in DoublewordArray(0 to 31))
return RioPayload;
---------------------------------------------------------------------------
-- Create a Maintenance RapidIO frame.
---------------------------------------------------------------------------
function RioMaintenance(
constant transaction : in std_logic_vector(3 downto 0);
constant size : in std_logic_vector(3 downto 0);
constant tid : in std_logic_vector(7 downto 0);
constant hopCount : in std_logic_vector(7 downto 0);
constant configOffset : in std_logic_vector(20 downto 0);
constant wdptr : in std_logic;
constant dataLength : in natural range 0 to 8;
constant data : in DoublewordArray(0 to 7))
return RioPayload;
-----------------------------------------------------------------------------
-- Function to convert a std_logic_vector to a string.
-----------------------------------------------------------------------------
function byteToString(constant byte : std_logic_vector(7 downto 0))
return string;
 
---------------------------------------------------------------------------
-- Procedure to print to report file and output
---------------------------------------------------------------------------
procedure PrintR( constant str : string );
 
---------------------------------------------------------------------------
-- Procedure to print to spec file
---------------------------------------------------------------------------
procedure PrintS( constant str : string );
 
---------------------------------------------------------------------------
-- Procedure to Assert Expression
---------------------------------------------------------------------------
procedure AssertE( constant exp: boolean; constant str : string );
 
---------------------------------------------------------------------------
-- Procedure to Print Error
---------------------------------------------------------------------------
procedure PrintE( constant str : string );
 
end package;
 
-------------------------------------------------------------------------------
626,485 → 464,7
-- RioCommon package body description.
-------------------------------------------------------------------------------
package body rio_common is
-----------------------------------------------------------------------------
-- Crc5 calculation function.
-- ITU, polynom=0x15.
-----------------------------------------------------------------------------
function Crc5(constant data : in std_logic_vector(18 downto 0);
constant crc : in std_logic_vector(4 downto 0))
return std_logic_vector is
type crcTableType is array (0 to 31) of std_logic_vector(7 downto 0);
constant crcTable : crcTableType := (
x"00", x"15", x"1f", x"0a", x"0b", x"1e", x"14", x"01",
x"16", x"03", x"09", x"1c", x"1d", x"08", x"02", x"17",
x"19", x"0c", x"06", x"13", x"12", x"07", x"0d", x"18",
x"0f", x"1a", x"10", x"05", x"04", x"11", x"1b", x"0e" );
variable index : natural range 0 to 31;
variable result : std_logic_vector(4 downto 0);
begin
result := crc;
index := to_integer(unsigned(data(18 downto 14) xor result));
result := crcTable(index)(4 downto 0);
index := to_integer(unsigned(data(13 downto 9) xor result));
result := crcTable(index)(4 downto 0);
index := to_integer(unsigned(data(8 downto 4) xor result));
result := crcTable(index)(4 downto 0);
index := to_integer(unsigned((data(3 downto 0) & '0') xor result));
return crcTable(index)(4 downto 0);
end Crc5;
 
---------------------------------------------------------------------------
-- Create a RapidIO physical layer control symbol.
---------------------------------------------------------------------------
function RioControlSymbolCreate(
constant stype0 : in std_logic_vector(2 downto 0);
constant parameter0 : in std_logic_vector(4 downto 0);
constant parameter1 : in std_logic_vector(4 downto 0);
constant stype1 : in std_logic_vector(2 downto 0);
constant cmd : in std_logic_vector(2 downto 0))
return std_logic_vector is
variable returnValue : std_logic_vector(23 downto 0);
variable symbolData : std_logic_vector(18 downto 0);
begin
symbolData(18 downto 16) := stype0;
symbolData(15 downto 11) := parameter0;
symbolData(10 downto 6) := parameter1;
symbolData(5 downto 3) := stype1;
symbolData(2 downto 0) := cmd;
 
returnValue(23 downto 5) := symbolData;
returnValue(4 downto 0) := Crc5(symbolData, "11111");
 
return returnValue;
end function;
 
-----------------------------------------------------------------------------
-- Crc16 calculation function.
-- CITT, polynom=0x1021.
-----------------------------------------------------------------------------
function Crc16(constant data : in std_logic_vector(15 downto 0);
constant crc : in std_logic_vector(15 downto 0))
return std_logic_vector is
type crcTableType is array (0 to 255) of std_logic_vector(15 downto 0);
constant crcTable : crcTableType := (
x"0000", x"1021", x"2042", x"3063", x"4084", x"50a5", x"60c6", x"70e7",
x"8108", x"9129", x"a14a", x"b16b", x"c18c", x"d1ad", x"e1ce", x"f1ef",
x"1231", x"0210", x"3273", x"2252", x"52b5", x"4294", x"72f7", x"62d6",
x"9339", x"8318", x"b37b", x"a35a", x"d3bd", x"c39c", x"f3ff", x"e3de",
x"2462", x"3443", x"0420", x"1401", x"64e6", x"74c7", x"44a4", x"5485",
x"a56a", x"b54b", x"8528", x"9509", x"e5ee", x"f5cf", x"c5ac", x"d58d",
x"3653", x"2672", x"1611", x"0630", x"76d7", x"66f6", x"5695", x"46b4",
x"b75b", x"a77a", x"9719", x"8738", x"f7df", x"e7fe", x"d79d", x"c7bc",
x"48c4", x"58e5", x"6886", x"78a7", x"0840", x"1861", x"2802", x"3823",
x"c9cc", x"d9ed", x"e98e", x"f9af", x"8948", x"9969", x"a90a", x"b92b",
x"5af5", x"4ad4", x"7ab7", x"6a96", x"1a71", x"0a50", x"3a33", x"2a12",
x"dbfd", x"cbdc", x"fbbf", x"eb9e", x"9b79", x"8b58", x"bb3b", x"ab1a",
x"6ca6", x"7c87", x"4ce4", x"5cc5", x"2c22", x"3c03", x"0c60", x"1c41",
x"edae", x"fd8f", x"cdec", x"ddcd", x"ad2a", x"bd0b", x"8d68", x"9d49",
x"7e97", x"6eb6", x"5ed5", x"4ef4", x"3e13", x"2e32", x"1e51", x"0e70",
x"ff9f", x"efbe", x"dfdd", x"cffc", x"bf1b", x"af3a", x"9f59", x"8f78",
x"9188", x"81a9", x"b1ca", x"a1eb", x"d10c", x"c12d", x"f14e", x"e16f",
x"1080", x"00a1", x"30c2", x"20e3", x"5004", x"4025", x"7046", x"6067",
x"83b9", x"9398", x"a3fb", x"b3da", x"c33d", x"d31c", x"e37f", x"f35e",
x"02b1", x"1290", x"22f3", x"32d2", x"4235", x"5214", x"6277", x"7256",
x"b5ea", x"a5cb", x"95a8", x"8589", x"f56e", x"e54f", x"d52c", x"c50d",
x"34e2", x"24c3", x"14a0", x"0481", x"7466", x"6447", x"5424", x"4405",
x"a7db", x"b7fa", x"8799", x"97b8", x"e75f", x"f77e", x"c71d", x"d73c",
x"26d3", x"36f2", x"0691", x"16b0", x"6657", x"7676", x"4615", x"5634",
x"d94c", x"c96d", x"f90e", x"e92f", x"99c8", x"89e9", x"b98a", x"a9ab",
x"5844", x"4865", x"7806", x"6827", x"18c0", x"08e1", x"3882", x"28a3",
x"cb7d", x"db5c", x"eb3f", x"fb1e", x"8bf9", x"9bd8", x"abbb", x"bb9a",
x"4a75", x"5a54", x"6a37", x"7a16", x"0af1", x"1ad0", x"2ab3", x"3a92",
x"fd2e", x"ed0f", x"dd6c", x"cd4d", x"bdaa", x"ad8b", x"9de8", x"8dc9",
x"7c26", x"6c07", x"5c64", x"4c45", x"3ca2", x"2c83", x"1ce0", x"0cc1",
x"ef1f", x"ff3e", x"cf5d", x"df7c", x"af9b", x"bfba", x"8fd9", x"9ff8",
x"6e17", x"7e36", x"4e55", x"5e74", x"2e93", x"3eb2", x"0ed1", x"1ef0" );
variable index : natural range 0 to 255;
variable result : std_logic_vector(15 downto 0);
begin
result := crc;
index := to_integer(unsigned(data(15 downto 8) xor result(15 downto 8)));
result := crcTable(index) xor (result(7 downto 0) & x"00");
index := to_integer(unsigned(data(7 downto 0) xor result(15 downto 8)));
result := crcTable(index) xor (result(7 downto 0) & x"00");
return result;
end Crc16;
---------------------------------------------------------------------------
-- Create a randomly initialized data array.
---------------------------------------------------------------------------
procedure CreateRandomPayload(
variable payload : out HalfwordArray;
variable seed1 : inout positive;
variable seed2 : inout positive) is
variable rand: real;
variable int_rand: integer;
variable stim: std_logic_vector(7 downto 0);
begin
for i in payload'range loop
uniform(seed1, seed2, rand);
int_rand := integer(trunc(rand*256.0));
payload(i)(7 downto 0) := std_logic_vector(to_unsigned(int_rand, 8));
uniform(seed1, seed2, rand);
int_rand := integer(trunc(rand*256.0));
payload(i)(15 downto 8) := std_logic_vector(to_unsigned(int_rand, 8));
end loop;
end procedure;
 
procedure CreateRandomPayload(
variable payload : out DoublewordArray;
variable seed1 : inout positive;
variable seed2 : inout positive) is
variable rand: real;
variable int_rand: integer;
variable stim: std_logic_vector(7 downto 0);
begin
for i in payload'range loop
uniform(seed1, seed2, rand);
int_rand := integer(trunc(rand*256.0));
payload(i)(7 downto 0) := std_logic_vector(to_unsigned(int_rand, 8));
uniform(seed1, seed2, rand);
int_rand := integer(trunc(rand*256.0));
payload(i)(15 downto 8) := std_logic_vector(to_unsigned(int_rand, 8));
uniform(seed1, seed2, rand);
int_rand := integer(trunc(rand*256.0));
payload(i)(23 downto 16) := std_logic_vector(to_unsigned(int_rand, 8));
uniform(seed1, seed2, rand);
int_rand := integer(trunc(rand*256.0));
payload(i)(31 downto 24) := std_logic_vector(to_unsigned(int_rand, 8));
uniform(seed1, seed2, rand);
int_rand := integer(trunc(rand*256.0));
payload(i)(39 downto 32) := std_logic_vector(to_unsigned(int_rand, 8));
uniform(seed1, seed2, rand);
int_rand := integer(trunc(rand*256.0));
payload(i)(47 downto 40) := std_logic_vector(to_unsigned(int_rand, 8));
uniform(seed1, seed2, rand);
int_rand := integer(trunc(rand*256.0));
payload(i)(55 downto 48) := std_logic_vector(to_unsigned(int_rand, 8));
uniform(seed1, seed2, rand);
int_rand := integer(trunc(rand*256.0));
payload(i)(63 downto 56) := std_logic_vector(to_unsigned(int_rand, 8));
end loop;
end procedure;
---------------------------------------------------------------------------
-- Create a generic RapidIO frame.
---------------------------------------------------------------------------
function RioFrameCreate(
constant ackId : in std_logic_vector(4 downto 0);
constant vc : in std_logic;
constant crf : in std_logic;
constant prio : in std_logic_vector(1 downto 0);
constant tt : in std_logic_vector(1 downto 0);
constant ftype : in std_logic_vector(3 downto 0);
constant sourceId : in std_logic_vector(15 downto 0);
constant destId : in std_logic_vector(15 downto 0);
constant payload : in RioPayload) return RioFrame is
variable frame : RioFrame;
variable result : HalfwordArray(0 to 137);
variable crc : std_logic_vector(15 downto 0) := x"ffff";
begin
-- Add the header and addresses.
result(0) := ackId & "0" & vc & crf & prio & tt & ftype;
result(1) := destId;
result(2) := sourceId;
 
-- Update the calculated CRC with the header contents.
crc := Crc16("00000" & result(0)(10 downto 0), crc);
crc := Crc16(result(1), crc);
crc := Crc16(result(2), crc);
 
-- Check if a single CRC should be added or two.
if (payload.length <= 37) then
-- Single CRC.
for i in 0 to payload.length-1 loop
result(i+3) := payload.data(i);
crc := Crc16(payload.data(i), crc);
end loop;
result(payload.length+3) := crc;
 
-- Check if paddning is needed to make the payload even 32-bit.
if ((payload.length mod 2) = 1) then
result(payload.length+4) := x"0000";
frame.length := (payload.length+5) / 2;
else
frame.length := (payload.length+4) / 2;
end if;
else
-- Double CRC.
for i in 0 to 36 loop
result(i+3) := payload.data(i);
crc := Crc16(payload.data(i), crc);
end loop;
 
-- Add in-the-middle crc.
result(40) := crc;
crc := Crc16(crc, crc);
for i in 37 to payload.length-1 loop
result(i+4) := payload.data(i);
crc := Crc16(payload.data(i), crc);
end loop;
result(payload.length+4) := crc;
 
-- Check if paddning is needed to make the payload even 32-bit.
if ((payload.length mod 2) = 0) then
result(payload.length+5) := x"0000";
frame.length := (payload.length+6) / 2;
else
frame.length := (payload.length+5) / 2;
end if;
end if;
-- Update the result length.
for i in 0 to frame.length-1 loop
frame.payload(i) := result(2*i) & result(2*i+1);
end loop;
 
return frame;
end function;
 
-----------------------------------------------------------------------------
--
-----------------------------------------------------------------------------
function RioNwrite(
constant wrsize : in std_logic_vector(3 downto 0);
constant address : in std_logic_vector(28 downto 0);
constant wdptr : in std_logic;
constant xamsbs : in std_logic_vector(1 downto 0);
constant dataLength : in natural range 1 to 32;
constant data : in DoublewordArray(0 to 31))
return RioPayload is
variable payload : RioPayload;
begin
payload.data(0)(15 downto 12) := "0100";
payload.data(0)(11 downto 8) := wrsize;
payload.data(0)(7 downto 0) := (others=>'0');
 
payload.data(1) := address(28 downto 13);
payload.data(2)(15 downto 3) := address(12 downto 0);
payload.data(2)(2) := wdptr;
payload.data(2)(1 downto 0) := xamsbs;
 
for i in 0 to dataLength-1 loop
payload.data(3+4*i) := data(i)(63 downto 48);
payload.data(4+4*i) := data(i)(47 downto 32);
payload.data(5+4*i) := data(i)(31 downto 16);
payload.data(6+4*i) := data(i)(15 downto 0);
end loop;
 
payload.length := 3 + 4*dataLength;
return payload;
end function;
-----------------------------------------------------------------------------
--
-----------------------------------------------------------------------------
function RioNwriteR(
constant wrsize : in std_logic_vector(3 downto 0);
constant tid : in std_logic_vector(7 downto 0);
constant address : in std_logic_vector(28 downto 0);
constant wdptr : in std_logic;
constant xamsbs : in std_logic_vector(1 downto 0);
constant dataLength : in natural range 1 to 32;
constant data : in DoublewordArray(0 to 31))
return RioPayload is
variable payload : RioPayload;
begin
payload.data(0)(15 downto 12) := "0101";
payload.data(0)(11 downto 8) := wrsize;
payload.data(0)(7 downto 0) := tid;
 
payload.data(1) := address(28 downto 13);
payload.data(2)(15 downto 3) := address(12 downto 0);
payload.data(2)(2) := wdptr;
payload.data(2)(1 downto 0) := xamsbs;
 
for i in 0 to dataLength-1 loop
payload.data(3+4*i) := data(i)(63 downto 48);
payload.data(4+4*i) := data(i)(47 downto 32);
payload.data(5+4*i) := data(i)(31 downto 16);
payload.data(6+4*i) := data(i)(15 downto 0);
end loop;
 
payload.length := 3 + 4*dataLength;
return payload;
end function;
-----------------------------------------------------------------------------
--
-----------------------------------------------------------------------------
function RioNread(
constant rdsize : in std_logic_vector(3 downto 0);
constant tid : in std_logic_vector(7 downto 0);
constant address : in std_logic_vector(28 downto 0);
constant wdptr : in std_logic;
constant xamsbs : in std_logic_vector(1 downto 0))
return RioPayload is
variable payload : RioPayload;
begin
payload.data(0)(15 downto 12) := "0100";
payload.data(0)(11 downto 8) := rdsize;
payload.data(0)(7 downto 0) := tid;
 
payload.data(1) := address(28 downto 13);
payload.data(2)(15 downto 3) := address(12 downto 0);
payload.data(2)(2) := wdptr;
payload.data(2)(1 downto 0) := xamsbs;
 
payload.length := 3;
 
return payload;
end function;
---------------------------------------------------------------------------
-- Create a RESPONSE RapidIO frame.
---------------------------------------------------------------------------
function RioResponse(
constant status : in std_logic_vector(3 downto 0);
constant tid : in std_logic_vector(7 downto 0);
constant dataLength : in natural range 0 to 32;
constant data : in DoublewordArray(0 to 31))
return RioPayload is
variable payload : RioPayload;
begin
payload.data(0)(11 downto 8) := status;
payload.data(0)(7 downto 0) := tid;
 
if (dataLength = 0) then
payload.data(0)(15 downto 12) := "0000";
payload.length := 1;
else
payload.data(0)(15 downto 12) := "1000";
for i in 0 to dataLength-1 loop
payload.data(1+4*i) := data(i)(63 downto 48);
payload.data(2+4*i) := data(i)(47 downto 32);
payload.data(3+4*i) := data(i)(31 downto 16);
payload.data(4+4*i) := data(i)(15 downto 0);
end loop;
 
payload.length := 1 + 4*dataLength;
end if;
 
return payload;
end function;
---------------------------------------------------------------------------
-- Create a Maintenance RapidIO frame.
---------------------------------------------------------------------------
function RioMaintenance(
constant transaction : in std_logic_vector(3 downto 0);
constant size : in std_logic_vector(3 downto 0);
constant tid : in std_logic_vector(7 downto 0);
constant hopCount : in std_logic_vector(7 downto 0);
constant configOffset : in std_logic_vector(20 downto 0);
constant wdptr : in std_logic;
constant dataLength : in natural range 0 to 8;
constant data : in DoublewordArray(0 to 7))
return RioPayload is
variable payload : RioPayload;
begin
payload.data(0)(15 downto 12) := transaction;
payload.data(0)(11 downto 8) := size;
payload.data(0)(7 downto 0) := tid;
 
payload.data(1)(15 downto 8) := hopCount;
payload.data(1)(7 downto 0) := configOffset(20 downto 13);
payload.data(2)(15 downto 3) := configOffset(12 downto 0);
payload.data(2)(2) := wdptr;
payload.data(2)(1 downto 0) := "00";
 
if (dataLength = 0) then
payload.length := 3;
else
for i in 0 to dataLength-1 loop
payload.data(3+4*i) := data(i)(63 downto 48);
payload.data(4+4*i) := data(i)(47 downto 32);
payload.data(5+4*i) := data(i)(31 downto 16);
payload.data(6+4*i) := data(i)(15 downto 0);
end loop;
 
payload.length := 3 + 4*dataLength;
end if;
 
return payload;
end function;
-----------------------------------------------------------------------------
-- Function to convert a std_logic_vector to a string.
-----------------------------------------------------------------------------
function byteToString(constant byte : std_logic_vector(7 downto 0))
return string is
constant table : string(1 to 16) := "0123456789abcdef";
variable returnValue : string(1 to 2);
begin
returnValue(1) := table(to_integer(unsigned(byte(7 downto 4))) + 1);
returnValue(2) := table(to_integer(unsigned(byte(3 downto 0))) + 1);
return returnValue;
end function;
---------------------------------------------------------------------------
-- Procedure to print test report
---------------------------------------------------------------------------
procedure PrintR( constant str : string ) is
file reportFile : text;
variable reportLine, outputLine : line;
variable fStatus: FILE_OPEN_STATUS;
begin
--Write report note to wave/transcript window
report str severity NOTE;
end PrintR;
 
---------------------------------------------------------------------------
-- Procedure to print test spec
---------------------------------------------------------------------------
procedure PrintS( constant str : string ) is
file specFile : text;
variable specLine, outputLine : line;
variable fStatus: FILE_OPEN_STATUS;
begin
--Write to spec file
file_open(fStatus, specFile, "testspec.txt", append_mode);
write(specLine, string'(str));
writeline (specFile, specLine);
file_close(specFile);
end PrintS;
 
---------------------------------------------------------------------------
-- Procedure to Assert Expression
---------------------------------------------------------------------------
procedure AssertE( constant exp: boolean; constant str : string ) is
file reportFile : text;
variable reportLine, outputLine : line;
variable fStatus: FILE_OPEN_STATUS;
begin
if (not exp) then
--Write to STD_OUTPUT
report(str) severity error;
else
PrintR("Status: Passed");
PrintS("Status: Passed");
end if;
end AssertE;
 
---------------------------------------------------------------------------
-- Procedure to Print Error
---------------------------------------------------------------------------
procedure PrintE( constant str : string ) is
file reportFile : text;
variable reportLine, outputLine : line;
variable fStatus: FILE_OPEN_STATUS;
begin
--Write to STD_OUTPUT
report str severity error;
end PrintE;
 
end rio_common;
 
 
/rio/branches/2.0.0-development/rtl/vhdl/RioPacketBuffer.vhd
10,7 → 10,10
-- are implemented, one with transmission window support and one without.
--
-- To Do:
-- -
-- - Copy code from Bombardier internal reporitory to get configurable sizes.
-- - Add an additional size-memory to be able to access both window and back at
-- the same time.
-- - Add support for priorities, seperate queue for each level.
--
-- Author(s):
-- - Magnus Rosenius, magro732@opencores.org
/rio/branches/2.0.0-development/rtl/vhdl/RioSwitch.vhd
87,9 → 87,6
 
readFrameEmpty_i : in Array1(SWITCH_PORTS-1 downto 0);
readFrame_o : out Array1(SWITCH_PORTS-1 downto 0);
readFrameRestart_o : out Array1(SWITCH_PORTS-1 downto 0);
readFrameAborted_i : in Array1(SWITCH_PORTS-1 downto 0);
readContentEmpty_i : in Array1(SWITCH_PORTS-1 downto 0);
readContent_o : out Array1(SWITCH_PORTS-1 downto 0);
readContentEnd_i : in Array1(SWITCH_PORTS-1 downto 0);
readContentData_i : in Array32(SWITCH_PORTS-1 downto 0);
257,9 → 254,6
 
readFrameEmpty_i : in std_logic;
readFrame_o : out std_logic;
readFrameRestart_o : out std_logic;
readFrameAborted_i : in std_logic;
readContentEmpty_i : in std_logic;
readContent_o : out std_logic;
readContentEnd_i : in std_logic;
readContentData_i : in std_logic_vector(31 downto 0);
335,25 → 329,34
PORT_INDEX=>portIndex)
port map(
clk=>clk, areset_n=>areset_n,
masterCyc_o=>masterCyc(portIndex), masterStb_o=>masterStb(portIndex),
masterWe_o=>masterWe(portIndex), masterAddr_o=>masterAddr(portIndex),
masterCyc_o=>masterCyc(portIndex),
masterStb_o=>masterStb(portIndex),
masterWe_o=>masterWe(portIndex),
masterAddr_o=>masterAddr(portIndex),
masterData_o=>masterDataWrite(portIndex),
masterData_i=>masterDataRead(portIndex), masterAck_i=>masterAck(portIndex),
slaveCyc_i=>slaveCyc(portIndex), slaveStb_i=>slaveStb(portIndex),
slaveWe_i=>slaveWe(portIndex), slaveAddr_i=>slaveAddr(portIndex),
masterData_i=>masterDataRead(portIndex),
masterAck_i=>masterAck(portIndex),
slaveCyc_i=>slaveCyc(portIndex),
slaveStb_i=>slaveStb(portIndex),
slaveWe_i=>slaveWe(portIndex),
slaveAddr_i=>slaveAddr(portIndex),
slaveData_i=>slaveDataWrite(portIndex),
slaveData_o=>slaveDataRead(portIndex), slaveAck_o=>slaveAck(portIndex),
slaveData_o=>slaveDataRead(portIndex),
slaveAck_o=>slaveAck(portIndex),
lookupStb_o=>masterLookupStb(portIndex),
lookupAddr_o=>masterLookupAddr(portIndex),
lookupData_i=>masterLookupData(portIndex), lookupAck_i=>masterLookupAck(portIndex),
readFrameEmpty_i=>readFrameEmpty_i(portIndex), readFrame_o=>readFrame_o(portIndex),
readFrameRestart_o=>readFrameRestart_o(portIndex),
readFrameAborted_i=>readFrameAborted_i(portIndex),
readContentEmpty_i=>readContentEmpty_i(portIndex), readContent_o=>readContent_o(portIndex),
readContentEnd_i=>readContentEnd_i(portIndex), readContentData_i=>readContentData_i(portIndex),
lookupData_i=>masterLookupData(portIndex),
lookupAck_i=>masterLookupAck(portIndex),
readFrameEmpty_i=>readFrameEmpty_i(portIndex),
readFrame_o=>readFrame_o(portIndex),
readContent_o=>readContent_o(portIndex),
readContentEnd_i=>readContentEnd_i(portIndex),
readContentData_i=>readContentData_i(portIndex),
writeFramePort_o=>open,
writeFrameFull_i=>writeFrameFull_i(portIndex), writeFrame_o=>writeFrame_o(portIndex),
writeFrameAbort_o=>writeFrameAbort_o(portIndex), writeContent_o=>writeContent_o(portIndex),
writeFrameFull_i=>writeFrameFull_i(portIndex),
writeFrame_o=>writeFrame_o(portIndex),
writeFrameAbort_o=>writeFrameAbort_o(portIndex),
writeContent_o=>writeContent_o(portIndex),
writeContentData_o=>writeContentData_o(portIndex));
end generate;
447,9 → 450,6
-- Physical port frame buffer interface.
readFrameEmpty_i : in std_logic;
readFrame_o : out std_logic;
readFrameRestart_o : out std_logic;
readFrameAborted_i : in std_logic;
readContentEmpty_i : in std_logic;
readContent_o : out std_logic;
readContentEnd_i : in std_logic;
readContentData_i : in std_logic_vector(31 downto 0);
502,11 → 502,9
readContent_o <= '0';
readFrame_o <= '0';
readFrameRestart_o <= '0';
elsif (clk'event and clk = '1') then
readContent_o <= '0';
readFrame_o <= '0';
readFrameRestart_o <= '0';
 
case masterState is
 
943,9 → 941,6
 
readFrameEmpty_i : in std_logic;
readFrame_o : out std_logic;
readFrameRestart_o : out std_logic;
readFrameAborted_i : in std_logic;
readContentEmpty_i : in std_logic;
readContent_o : out std_logic;
readContentEnd_i : in std_logic;
readContentData_i : in std_logic_vector(31 downto 0);
1129,9 → 1124,6
lookupAck_i=>'1',
readFrameEmpty_i=>outboundReadFrameEmpty,
readFrame_o=>outboundReadFrame,
readFrameRestart_o=>open,
readFrameAborted_i=>'0',
readContentEmpty_i=>'0',
readContent_o=>outboundReadContent,
readContentEnd_i=>outboundReadContentEnd,
readContentData_i=>outboundReadContentData,
2110,8 → 2102,8
-- Interconnection matrix.
-----------------------------------------------------------------------------
Interconnect: for i in 0 to WIDTH-1 generate
slaveCyc_o(i) <= masterCyc_i(selectedMaster) when (selectedSlave = i) else '0';
slaveStb_o(i) <= masterStb_i(selectedMaster) when (selectedSlave = i) else '0';
slaveCyc_o(i) <= masterCyc_i(selectedMaster) when ((activeCycle = '1') and (selectedSlave = i)) else '0';
slaveStb_o(i) <= masterStb_i(selectedMaster) when ((activeCycle = '1') and (selectedSlave = i)) else '0';
slaveWe_o(i) <= masterWe_i(selectedMaster);
slaveAddr_o(i) <= masterAddr_i(selectedMaster);
slaveData_o(i) <= masterData_i(selectedMaster);

powered by: WebSVN 2.1.0

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