Line 4... |
Line 4... |
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- File : sorter_pkg.vhd
|
-- File : sorter_pkg.vhd
|
-- Author : Wojciech M. Zabolotny <wzab@ise.pw.edu.pl>
|
-- Author : Wojciech M. Zabolotny <wzab@ise.pw.edu.pl>
|
-- Company :
|
-- Company :
|
-- Created : 2010-05-14
|
-- Created : 2010-05-14
|
-- Last update: 2011-07-11
|
-- Last update: 2018-03-12
|
-- Platform :
|
-- Platform :
|
-- Standard : VHDL'93
|
-- Standard : VHDL'93
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- Description:
|
-- Description:
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
Line 67... |
Line 67... |
valid => '1',
|
valid => '1',
|
d_payload => (others => '0')
|
d_payload => (others => '0')
|
);
|
);
|
|
|
|
|
function sort_cmp_lt (
|
|
constant v1 : T_DATA_REC;
|
|
constant v2 : T_DATA_REC)
|
|
return boolean;
|
|
|
|
function tdrec2stlv (
|
function tdrec2stlv (
|
constant drec : T_DATA_REC)
|
constant drec : T_DATA_REC)
|
return std_logic_vector;
|
return std_logic_vector;
|
|
|
function stlv2tdrec (
|
function stlv2tdrec (
|
Line 127... |
Line 122... |
j := j+DATA_REC_PAYLOAD_WIDTH;
|
j := j+DATA_REC_PAYLOAD_WIDTH;
|
return result;
|
return result;
|
end tdrec2stlv;
|
end tdrec2stlv;
|
|
|
|
|
-- Function sort_cmp_lt returns TRUE when the first opperand is ``less'' than
|
|
-- the second one
|
|
function sort_cmp_lt (
|
|
constant v1 : T_DATA_REC;
|
|
constant v2 : T_DATA_REC)
|
|
return boolean is
|
|
variable rline : line;
|
|
variable dcomp : unsigned(DATA_REC_SORT_KEY_WIDTH-1 downto 0) := (others => '0');
|
|
begin -- sort_cmp_lt
|
|
-- Check the special cases
|
|
if (v1.init = '1') and (v2.init = '0') then
|
|
-- v1 is the special record, v2 is the standard one
|
|
if v1.valid = '0' then
|
|
-- initialization record - ``smaller'' than all standard records
|
|
return true;
|
|
else
|
|
-- end record - ``bigger'' than all standard records
|
|
return false;
|
|
end if;
|
|
elsif (v1.init = '0') and (v2.init = '1') then
|
|
-- v2 is the special record, v1 is the standard one
|
|
if (v2.valid = '0') then
|
|
-- v2 is the initialization record - it is ``smaller'' than standard record v1
|
|
return false;
|
|
else
|
|
-- v2 is the end record - it is ``bigger'' than standard record v1
|
|
return true;
|
|
end if;
|
|
elsif (v1.init = '1') and (v2.init = '1') then
|
|
-- both v1 and v2 are special records
|
|
if (v1.valid = '0') and (v2.valid = '1') then
|
|
-- v1 - initial record, v2 - end record
|
|
return true;
|
|
else
|
|
-- v1 is end record, so it is ``bigger'' or ``equal'' to other records
|
|
return false;
|
|
end if;
|
|
elsif (v1.init = '0') and (v2.init = '0') then
|
|
-- We compare standard words
|
|
-- We must consider the fact, that in longer sequences of data records
|
|
-- the sort keys may wrap around
|
|
-- therefore we perform subtraction modulo
|
|
-- 2**DATA_REC_SORT_KEY_WIDTH and check the MSB
|
|
dcomp := v1.d_key-v2.d_key;
|
|
if dcomp(DATA_REC_SORT_KEY_WIDTH-1) = '1' then
|
|
--if signed(v1.d_key - v2.d_key)<0 then -- old implementation
|
|
return true;
|
|
elsif v2.d_key = v1.d_key then
|
|
if v2.valid = '1' then
|
|
return true;
|
|
else
|
|
-- Empty data records should wait
|
|
return false;
|
|
end if;
|
|
else
|
|
return false;
|
|
end if;
|
|
else
|
|
--assert false report "Wrong records in sort_cmp_lt" severity error;
|
|
return false;
|
|
end if;
|
|
return false; -- should never happen
|
|
end sort_cmp_lt;
|
|
|
|
|
|
--procedure wrstlv (
|
--procedure wrstlv (
|
-- rline : inout string;
|
-- rline : inout string;
|
-- constant vect : std_logic_vector) is
|
-- constant vect : std_logic_vector) is
|
--begin -- stlv2str
|
--begin -- stlv2str
|
-- for i in vect'left downto vect'right loop
|
-- for i in vect'left downto vect'right loop
|