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

Subversion Repositories heap_sorter

[/] [heap_sorter/] [trunk/] [high_speed_pipelined_4clk_per_word/] [src/] [sorter_pkg.vhd] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 wzab
-------------------------------------------------------------------------------
2
-- Title      : Definitions for heap-sorter
3
-- Project    : heap-sorter
4
-------------------------------------------------------------------------------
5
-- File       : sorter_pkg.vhd
6
-- Author     : Wojciech M. Zabolotny <wzab@ise.pw.edu.pl>
7
-- Company    : 
8
-- Created    : 2010-05-14
9 6 wzab
-- Last update: 2018-03-12
10 5 wzab
-- Platform   : 
11
-- Standard   : VHDL'93
12
-------------------------------------------------------------------------------
13
-- Description: 
14
-------------------------------------------------------------------------------
15
-- Copyright (c) 2010 Wojciech M. Zabolotny
16
-- This file is published under the BSD license, so you can freely adapt
17
-- it for your own purposes.
18
-- Additionally this design has been described in my article:
19
--    Wojciech M. Zabolotny, "Dual port memory based Heapsort implementation
20
--    for FPGA", Proc. SPIE 8008, 80080E (2011); doi:10.1117/12.905281
21
-- I'd be glad if you cite this article when you publish something based
22
-- on my design.
23
-------------------------------------------------------------------------------
24
-- Revisions  :
25
-- Date        Version  Author  Description
26
-- 2010-05-14  1.0      wzab    Created
27
-------------------------------------------------------------------------------
28
library ieee;
29
use ieee.std_logic_1164.all;
30
use ieee.numeric_std.all;
31
use ieee.std_logic_textio.all;
32
use std.textio.all;
33
library work;
34
use work.sys_config.all;
35
 
36
package sorter_pkg is
37
  constant DATA_REC_WIDTH : integer := DATA_REC_SORT_KEY_WIDTH +
38
                                       DATA_REC_PAYLOAD_WIDTH + 2;
39
 
40
 
41
  subtype T_SORT_KEY is unsigned (DATA_REC_SORT_KEY_WIDTH - 1 downto 0);
42
  subtype T_PAYLOAD is std_logic_vector(DATA_REC_PAYLOAD_WIDTH - 1 downto 0);
43
 
44
  --alias T_SORT_KEY is unsigned (12 downto 0);
45
  type T_DATA_REC is record
46
    d_key     : T_SORT_KEY;
47
    init      : std_logic;
48
    valid     : std_logic;
49
    d_payload : T_PAYLOAD;
50
  end record;
51
 
52
  type T_DATA_REC_ARR is array (natural range <>) of T_DATA_REC;
53
 
54
  -- Special constant used to initially fill the sorter
55
  -- Must be sorted so, that is smaller, than any other data
56
  constant DATA_REC_INIT_DATA : T_DATA_REC := (
57
    d_key     => to_unsigned(0, DATA_REC_SORT_KEY_WIDTH),
58
    init      => '1',
59
    valid     => '0',
60
    d_payload => (others => '0')
61
    );
62
 
63
  -- Special constant used to ``flush'' the sorter at the end
64
  constant DATA_REC_END_DATA : T_DATA_REC := (
65
    d_key     => to_unsigned(0, DATA_REC_SORT_KEY_WIDTH),
66
    init      => '1',
67
    valid     => '1',
68
    d_payload => (others => '0')
69
    );
70
 
71
 
72
  function tdrec2stlv (
73
    constant drec : T_DATA_REC)
74
    return std_logic_vector;
75
 
76
  function stlv2tdrec (
77
    constant dstlv : std_logic_vector)
78
    return T_DATA_REC;
79
 
80
  --procedure wrstlv (
81
  --  rline         : inout line;
82
  --  constant vect :       std_logic_vector);
83
 
84
  file reports : text open write_mode is "STD_OUTPUT";
85
 
86
end sorter_pkg;
87
 
88
package body sorter_pkg is
89
 
90
  function stlv2tdrec (
91
    constant dstlv : std_logic_vector)
92
    return T_DATA_REC is
93
    variable result : T_DATA_REC;
94
    variable j      : integer := 0;
95
  begin  -- stlv2drec
96
    j                := 0;
97
    result.d_key     := unsigned(dstlv(j-1+DATA_REC_SORT_KEY_WIDTH downto j));
98
    j                := j+DATA_REC_SORT_KEY_WIDTH;
99
    result.valid     := dstlv(j);
100
    j                := j+1;
101
    result.init      := dstlv(j);
102
    j                := j+1;
103
    result.d_payload := dstlv(j-1+DATA_REC_PAYLOAD_WIDTH downto j);
104
    j                := j+DATA_REC_PAYLOAD_WIDTH;
105
    return result;
106
  end stlv2tdrec;
107
 
108
  function tdrec2stlv (
109
    constant drec : T_DATA_REC)
110
    return std_logic_vector is
111
    variable result : std_logic_vector(DATA_REC_WIDTH-1 downto 0);
112
    variable j      : integer := 0;
113
  begin  -- tdrec2stlv
114
    j                                            := 0;
115
    result(j-1+DATA_REC_SORT_KEY_WIDTH downto j) := std_logic_vector(drec.d_key);
116
    j                                            := j+DATA_REC_SORT_KEY_WIDTH;
117
    result(j)                                    := drec.valid;
118
    j                                            := j+1;
119
    result(j)                                    := drec.init;
120
    j                                            := j+1;
121
    result(j-1+DATA_REC_PAYLOAD_WIDTH downto j)  := std_logic_vector(drec.d_payload);
122
    j                                            := j+DATA_REC_PAYLOAD_WIDTH;
123
    return result;
124
  end tdrec2stlv;
125
 
126
 
127
  --procedure wrstlv (
128
  --  rline         : inout string;
129
  --  constant vect :       std_logic_vector) is
130
  --begin  -- stlv2str
131
  --  for i in vect'left downto vect'right loop
132
  --    case vect(i) is
133
  --      when 'U'    => write(line(rline), string'("u"));
134
  --      when 'Z'    => write(line(rline), string'("z"));
135
  --      when 'X'    => write(line(rline), string'("x"));
136
  --      when 'L'    => write(line(rline), string'("L"));
137
  --      when 'H'    => write(line(rline), string'("H"));
138
  --      when '1'    => write(line(rline), string'("1"));
139
  --      when '0'    => write(line(rline), string'("0"));
140
  --      when others => write(line(rline), string'("?"));
141
  --    end case;
142
  --  end loop;  -- i
143
  --end wrstlv;
144
 
145
end sorter_pkg;
146
 

powered by: WebSVN 2.1.0

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