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_sys_tb.vhd] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 wzab
-------------------------------------------------------------------------------
2
-- Title      : Testbench for design "heap-sorter"
3
-- Project    : heap-sorter
4
-------------------------------------------------------------------------------
5
-- File       : sorter_sys_tb.vhd
6
-- Author     : Wojciech M. Zabolotny <wzab@ise.pw.edu.pl>
7
-- Company    : 
8
-- Created    : 2010-05-14
9
-- Last update: 2018-03-11
10
-- 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
 
29
library ieee;
30
use ieee.std_logic_1164.all;
31
use ieee.numeric_std.all;
32
use ieee.std_logic_textio.all;
33
use std.textio.all;
34
library work;
35
use work.sys_config.all;
36
use work.sorter_pkg.all;
37
 
38
 
39
-------------------------------------------------------------------------------
40
 
41
entity sorter_sys_tb is
42
 
43
end entity sorter_sys_tb;
44
 
45
-------------------------------------------------------------------------------
46
 
47
architecture sort_tb_beh of sorter_sys_tb is
48
 
49
  constant NLEVELS : integer := SYS_NLEVELS;
50
  -- component ports
51
  signal din   : T_DATA_REC := DATA_REC_INIT_DATA;
52
  signal dout  : T_DATA_REC;
53
  signal we    : std_logic  := '0';
54
  signal dav   : std_logic  := '0';
55
  signal rst_n : std_logic  := '0';
56
  signal ready : std_logic  := '0';
57
 
58
  component sorter_sys
59
    generic (
60
      NADDRBITS : integer);
61
    port (
62
      din   : in  T_DATA_REC;
63
      we    : in  std_logic;
64
      dout  : out T_DATA_REC;
65
      dav   : out std_logic;
66
      clk   : in  std_logic;
67
      rst_n : in  std_logic;
68
      ready : out std_logic);
69
  end component;
70
  -- clock
71
  signal Clk : std_logic := '1';
72
  --signal Clk2 : std_logic := '1';
73
 
74
  signal end_sim : boolean              := false;
75
  signal div     : integer range 0 to 8 := 0;
76
 
77
begin  -- architecture sort_tb_beh
78
 
79
  -- component instantiation
80
  DUT : entity work.sorter_sys
81
    generic map (
82
      NLEVELS => NLEVELS)
83
    port map (
84
      din   => din,
85
      we    => we,
86
      dout  => dout,
87
      dav   => dav,
88
      clk   => clk,
89
      rst_n => rst_n,
90
      ready => ready);
91
 
92
  -- clock generation
93
  --Clk2 <= not Clk2 after 5 ns when end_sim = false else '0';
94
  Clk <= not Clk after 10 ns when end_sim = false else '0';
95
 
96
  -- waveform generation
97
  WaveGen_Proc : process
98
    file events_in       : text open read_mode is "./events.in";
99
    variable input_line  : line;
100
    file events_out      : text open write_mode is "./events.out";
101
    variable output_line : line;
102
    variable rec         : T_DATA_REC;
103
    variable skey       : std_logic_vector(DATA_REC_SORT_KEY_WIDTH-1 downto 0);
104
    variable spayload : std_logic_vector(DATA_REC_PAYLOAD_WIDTH-1 downto 0);
105
  begin
106
    -- insert signal assignments here
107
 
108
    wait until Clk = '1';
109
    wait for 31 ns;
110
    rst_n <= '1';
111
    wait until ready = '1';
112
    loop
113
      wait until Clk = '0';
114
      wait until Clk = '1';
115
      we <= '0';
116
      if div = 3 then
117
        div        <= 0;
118
        exit when endfile(events_in);
119
        readline(events_in, input_line);
120
        read(input_line, rec.init);
121
        read(input_line, rec.valid);
122
        read(input_line, skey);
123
        read(input_line, spayload);
124
        rec.d_key := unsigned(skey);
125
        rec.d_payload := spayload;
126
        din        <= rec;
127
        we         <= '1';
128
      else
129
        div <= div+1;
130
      end if;
131
      if dav = '1' then
132
        -- Process read event
133
        rec := dout;
134
        write(output_line, rec.init);
135
        write(output_line, rec.valid);
136
        write(output_line,string'(" "));
137
        write(output_line, std_logic_vector(rec.d_key));
138
        write(output_line,string'(" "));
139
        write(output_line, std_logic_vector(rec.d_payload));
140
        writeline(events_out, output_line);
141
      end if;
142
    end loop;
143
    end_sim   <= true;
144
    rec.valid := '0';
145
    din       <= rec;
146
    wait;
147
  end process WaveGen_Proc;
148
 
149
 
150
 
151
end architecture sort_tb_beh;
152
 
153
-------------------------------------------------------------------------------
154
 
155
configuration sorter_sys_tb_sort_tb_beh_cfg of sorter_sys_tb is
156
  for sort_tb_beh
157
  end for;
158
end sorter_sys_tb_sort_tb_beh_cfg;
159
 
160
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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