Line 47... |
Line 47... |
--
|
--
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
library ieee;
|
library ieee;
|
use ieee.std_logic_1164.all;
|
use ieee.std_logic_1164.all;
|
use work.rio_common.all;
|
use work.rio_common.all;
|
|
use std.textio.all;
|
|
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
--
|
--
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
package TestPortPackage is
|
package TestPortPackage is
|
Line 167... |
Line 168... |
signal messageSignal : out TestPortMessagePacketBuffer;
|
signal messageSignal : out TestPortMessagePacketBuffer;
|
signal ackSignal : in std_logic;
|
signal ackSignal : in std_logic;
|
constant frame : in RioFrame;
|
constant frame : in RioFrame;
|
constant willAbort : in boolean := false);
|
constant willAbort : in boolean := false);
|
|
|
|
-----------------------------------------------------------------------------
|
|
-- Function to print a std_logic_vector.
|
|
-----------------------------------------------------------------------------
|
|
function to_string(constant value : std_logic_vector)
|
|
return string;
|
|
|
|
---------------------------------------------------------------------------
|
|
-- Procedures for test control.
|
|
---------------------------------------------------------------------------
|
|
|
|
procedure TestWarning(constant tag : in string);
|
|
procedure TestError(constant tag : in string;
|
|
constant stopAtError : in boolean := true);
|
|
procedure TestCompare(constant expression : in boolean;
|
|
constant tag : in string := "";
|
|
constant stopAtError : in boolean := true);
|
|
procedure TestCompare(constant got : in std_logic;
|
|
constant expected : in std_logic;
|
|
constant tag : in string := "";
|
|
constant stopAtError : in boolean := true);
|
|
procedure TestCompare(constant got : in std_logic_vector;
|
|
constant expected : in std_logic_vector;
|
|
constant tag : in string := "";
|
|
constant stopAtError : in boolean := true);
|
|
procedure TestCompare(constant got : in natural;
|
|
constant expected : in natural;
|
|
constant tag : in string := "";
|
|
constant stopAtError : in boolean := true);
|
|
procedure TestCompare(constant got : in time;
|
|
constant expected : in time;
|
|
constant tag : in string := "";
|
|
constant stopAtError : in boolean := true);
|
|
|
|
procedure TestWait(signal waitSignal : in std_logic;
|
|
constant waitValue : in std_logic;
|
|
constant tag : in string := "";
|
|
constant waitTime : in time := 1 ms;
|
|
constant stopAtError : in boolean := true);
|
|
procedure TestWait(signal waitSignal : in std_logic;
|
|
constant waitValue : in std_logic;
|
|
signal ackSignal : inout std_logic;
|
|
constant tag : in string := "";
|
|
constant waitTime : in time := 1 ms;
|
|
constant stopAtError : in boolean := true);
|
|
|
|
procedure TestEnd;
|
|
|
end package;
|
end package;
|
|
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
--
|
--
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
Line 218... |
Line 266... |
wait until ackSignal = '1';
|
wait until ackSignal = '1';
|
writeSignal <= '0';
|
writeSignal <= '0';
|
wait until ackSignal = '0';
|
wait until ackSignal = '0';
|
end procedure;
|
end procedure;
|
|
|
|
-----------------------------------------------------------------------------
|
|
-- Function to print std_logic_vector.
|
|
-----------------------------------------------------------------------------
|
|
function to_string(constant value : std_logic) return string is
|
|
variable s : string(1 to 1);
|
|
begin
|
|
if (value = '0') then
|
|
s(1) := '0';
|
|
elsif (value = '1') then
|
|
s(1) := '1';
|
|
elsif (value = 'U') then
|
|
s(1) := 'U';
|
|
elsif (value = 'X') then
|
|
s(1) := 'X';
|
|
else
|
|
s(1) := '?';
|
|
end if;
|
|
return s;
|
|
end function;
|
|
function to_string(constant value : std_logic_vector) return string is
|
|
variable s : string(1 to value'length);
|
|
variable index : positive;
|
|
variable i : natural;
|
|
begin
|
|
index := 1;
|
|
for i in value'range loop
|
|
if (value(i) = '0') then
|
|
s(index) := '0';
|
|
elsif (value(i) = '1') then
|
|
s(index) := '1';
|
|
elsif (value(i) = 'U') then
|
|
s(index) := 'U';
|
|
elsif (value(i) = 'X') then
|
|
s(index) := 'X';
|
|
else
|
|
s(index) := '?';
|
|
end if;
|
|
index := index + 1;
|
|
end loop;
|
|
return s;
|
|
end function;
|
|
|
|
---------------------------------------------------------------------------
|
|
-- Procedures to handle tests.
|
|
---------------------------------------------------------------------------
|
|
|
|
procedure TestWarning(constant tag : in string) is
|
|
variable writeBuffer : line;
|
|
begin
|
|
write(writeBuffer, now);
|
|
write(writeBuffer, string'(":WARNING:"));
|
|
write(writeBuffer, tag);
|
|
writeline(OUTPUT, writeBuffer);
|
|
end procedure;
|
|
|
|
procedure TestError(constant tag : in string;
|
|
constant stopAtError : in boolean := true) is
|
|
variable writeBuffer : line;
|
|
begin
|
|
write(writeBuffer, now);
|
|
write(writeBuffer, string'(":FAILED:"));
|
|
write(writeBuffer, tag);
|
|
writeline(OUTPUT, writeBuffer);
|
|
|
|
if (stopAtError) then
|
|
std.env.stop(0);
|
|
end if;
|
|
end procedure;
|
|
|
|
procedure TestCompare(constant expression : in boolean;
|
|
constant tag : in string := "";
|
|
constant stopAtError : in boolean := true) is
|
|
variable writeBuffer : line;
|
|
begin
|
|
write(writeBuffer, now);
|
|
if (not expression) then
|
|
write(writeBuffer, string'(":FAILED:"));
|
|
else
|
|
write(writeBuffer, string'(":PASSED:"));
|
|
end if;
|
|
write(writeBuffer, tag);
|
|
writeline(OUTPUT, writeBuffer);
|
|
|
|
if (stopAtError) and (not expression) then
|
|
std.env.stop(0);
|
|
end if;
|
|
end procedure;
|
|
|
|
procedure TestCompare(constant got : in std_logic;
|
|
constant expected : in std_logic;
|
|
constant tag : in string := "";
|
|
constant stopAtError : in boolean := true) is
|
|
variable writeBuffer : line;
|
|
begin
|
|
write(writeBuffer, now);
|
|
if (expected /= got) then
|
|
write(writeBuffer, string'(":FAILED:"));
|
|
write(writeBuffer, tag);
|
|
write(writeBuffer, ":got=" & to_string(got));
|
|
write(writeBuffer, ":expected=" & to_string(expected));
|
|
else
|
|
write(writeBuffer, string'(":PASSED:"));
|
|
write(writeBuffer, tag);
|
|
end if;
|
|
writeline(OUTPUT, writeBuffer);
|
|
|
|
if (stopAtError) and (expected /= got) then
|
|
std.env.stop(0);
|
|
end if;
|
|
end procedure;
|
|
|
|
procedure TestCompare(constant got : in std_logic_vector;
|
|
constant expected : in std_logic_vector;
|
|
constant tag : in string := "";
|
|
constant stopAtError : in boolean := true) is
|
|
variable writeBuffer : line;
|
|
begin
|
|
write(writeBuffer, now);
|
|
if (expected /= got) then
|
|
write(writeBuffer, string'(":FAILED:"));
|
|
write(writeBuffer, tag);
|
|
write(writeBuffer, ":got=" & to_string(got));
|
|
write(writeBuffer, ":expected=" & to_string(expected));
|
|
else
|
|
write(writeBuffer, string'(":PASSED:"));
|
|
write(writeBuffer, tag);
|
|
end if;
|
|
writeline(OUTPUT, writeBuffer);
|
|
|
|
if (stopAtError) and (expected /= got) then
|
|
std.env.stop(0);
|
|
end if;
|
|
end procedure;
|
|
|
|
procedure TestCompare(constant got : in natural;
|
|
constant expected : in natural;
|
|
constant tag : in string := "";
|
|
constant stopAtError : in boolean := true) is
|
|
variable writeBuffer : line;
|
|
begin
|
|
write(writeBuffer, now);
|
|
if (expected /= got) then
|
|
write(writeBuffer, string'(":FAILED:"));
|
|
write(writeBuffer, tag);
|
|
write(writeBuffer, ":got=" & integer'image(got));
|
|
write(writeBuffer, ":expected=" & integer'image(expected));
|
|
else
|
|
write(writeBuffer, string'(":PASSED:"));
|
|
write(writeBuffer, tag);
|
|
end if;
|
|
writeline(OUTPUT, writeBuffer);
|
|
|
|
if (stopAtError) and (expected /= got) then
|
|
std.env.stop(0);
|
|
end if;
|
|
end procedure;
|
|
|
|
procedure TestCompare(constant got : in time;
|
|
constant expected : in time;
|
|
constant tag : in string := "";
|
|
constant stopAtError : in boolean := true) is
|
|
variable writeBuffer : line;
|
|
begin
|
|
write(writeBuffer, now);
|
|
if (expected /= got) then
|
|
write(writeBuffer, string'(":FAILED:"));
|
|
write(writeBuffer, tag);
|
|
write(writeBuffer, string'(":got="));
|
|
write(writeBuffer, got);
|
|
write(writeBuffer, string'(":expected="));
|
|
write(writeBuffer, expected);
|
|
else
|
|
write(writeBuffer, string'(":PASSED:"));
|
|
write(writeBuffer, tag);
|
|
end if;
|
|
writeline(OUTPUT, writeBuffer);
|
|
|
|
if (stopAtError) and (expected /= got) then
|
|
std.env.stop(0);
|
|
end if;
|
|
end procedure;
|
|
|
|
procedure TestWait(signal waitSignal : in std_logic;
|
|
constant waitValue : in std_logic;
|
|
constant tag : in string := "";
|
|
constant waitTime : in time := 1 ms;
|
|
constant stopAtError : in boolean := true) is
|
|
variable writeBuffer : line;
|
|
begin
|
|
if (waitSignal /= waitValue) then
|
|
wait until waitSignal = waitValue for waitTime;
|
|
if (waitSignal /= waitValue) then
|
|
write(writeBuffer, now);
|
|
write(writeBuffer, string'(":FAILED:"));
|
|
write(writeBuffer, tag);
|
|
writeline(OUTPUT, writeBuffer);
|
|
|
|
if (stopAtError) then
|
|
std.env.stop(0);
|
|
end if;
|
|
end if;
|
|
end if;
|
|
end procedure;
|
|
|
|
procedure TestWait(signal waitSignal : in std_logic;
|
|
constant waitValue : in std_logic;
|
|
signal ackSignal : inout std_logic;
|
|
constant tag : in string := "";
|
|
constant waitTime : in time := 1 ms;
|
|
constant stopAtError : in boolean := true) is
|
|
variable writeBuffer : line;
|
|
begin
|
|
if (waitSignal /= waitValue) then
|
|
|
|
wait until waitSignal = waitValue for waitTime;
|
|
|
|
if (waitSignal /= waitValue) then
|
|
write(writeBuffer, now);
|
|
write(writeBuffer, string'(":FAILED:"));
|
|
write(writeBuffer, tag);
|
|
writeline(OUTPUT, writeBuffer);
|
|
|
|
if (stopAtError) then
|
|
std.env.stop(0);
|
|
end if;
|
|
end if;
|
|
end if;
|
|
|
|
ackSignal <= not ackSignal;
|
|
|
|
wait until waitSignal /= waitValue for waitTime;
|
|
|
|
if (waitSignal = waitValue) then
|
|
write(writeBuffer, now);
|
|
write(writeBuffer, string'(":FAILED:"));
|
|
write(writeBuffer, tag);
|
|
writeline(OUTPUT, writeBuffer);
|
|
|
|
if (stopAtError) then
|
|
std.env.stop(0);
|
|
end if;
|
|
end if;
|
|
end procedure;
|
|
|
|
procedure TestEnd is
|
|
variable writeBuffer : line;
|
|
begin
|
|
write(writeBuffer, now);
|
|
write(writeBuffer, string'(":COMPLETED"));
|
|
writeline(OUTPUT, writeBuffer);
|
|
std.env.stop(0);
|
|
end TestEnd;
|
|
|
end package body;
|
end package body;
|
|
|
|
|
|
|
|
|
Line 280... |
Line 581... |
|
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
--
|
--
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
architecture TestPortPacketBufferPortImpl of TestPortPacketBuffer is
|
architecture TestPortPacketBufferPortImpl of TestPortPacketBuffer is
|
constant QUEUE_SIZE : natural := 63;
|
constant QUEUE_SIZE : natural := 255;
|
type QueueArray is array (natural range <>) of TestPortMessagePacketBuffer;
|
type QueueArray is array (natural range <>) of TestPortMessagePacketBuffer;
|
|
|
function QueueIndexInc(constant i : natural) return natural is
|
function QueueIndexInc(constant i : natural) return natural is
|
variable returnValue : natural;
|
variable returnValue : natural;
|
begin
|
begin
|
Line 325... |
Line 626... |
loop
|
loop
|
wait until clk = '1' or readWrite_i = '1';
|
wait until clk = '1' or readWrite_i = '1';
|
|
|
if (clk'event) then
|
if (clk'event) then
|
if (readFrame_i = '1') then
|
if (readFrame_i = '1') then
|
|
if ((not frameQueue(back).willAbort) and (frameIndex < frameQueue(back).frame.length)) then
|
|
TestError("READ:BACK:reading unfinished frame");
|
|
end if;
|
if (back /= front) then
|
if (back /= front) then
|
back := QueueIndexInc(back);
|
back := QueueIndexInc(back);
|
else
|
else
|
TestError("READ:BACK:reading when no frame is present");
|
TestError("READ:BACK:reading when no frame is present");
|
end if;
|
end if;
|
Line 407... |
Line 711... |
readEmpty_o <= '0';
|
readEmpty_o <= '0';
|
end if;
|
end if;
|
elsif (readWrite_i'event) then
|
elsif (readWrite_i'event) then
|
frameQueue(front) := readMessage_i;
|
frameQueue(front) := readMessage_i;
|
front := QueueIndexInc(front);
|
front := QueueIndexInc(front);
|
|
if (front = back) then
|
|
TestError("Queue full");
|
|
end if;
|
|
|
readEmpty_o <= '0';
|
readEmpty_o <= '0';
|
readAck_o <= '1';
|
readAck_o <= '1';
|
wait until readWrite_i = '0';
|
wait until readWrite_i = '0';
|
readAck_o <= '0';
|
readAck_o <= '0';
|
Line 486... |
Line 793... |
writeEmpty_o <= '0';
|
writeEmpty_o <= '0';
|
end if;
|
end if;
|
elsif (writeWrite_i'event) then
|
elsif (writeWrite_i'event) then
|
frameQueue(front) := writeMessage_i;
|
frameQueue(front) := writeMessage_i;
|
front := QueueIndexInc(front);
|
front := QueueIndexInc(front);
|
|
if (front = back) then
|
|
TestError("Queue full");
|
|
end if;
|
|
|
writeEmpty_o <= '0';
|
writeEmpty_o <= '0';
|
writeAck_o <= '1';
|
writeAck_o <= '1';
|
wait until writeWrite_i = '0';
|
wait until writeWrite_i = '0';
|
writeAck_o <= '0';
|
writeAck_o <= '0';
|