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

Subversion Repositories heap_sorter

[/] [heap_sorter/] [trunk/] [simplified_version/] [src/] [sorter_sys_tb.vhd] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 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 7 wzab
-- Last update: 2018-03-21
10 2 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
 
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
 
73
  signal end_sim : boolean              := false;
74
  signal div     : integer range 0 to 8 := 0;
75
 
76
begin  -- architecture sort_tb_beh
77
 
78
  -- component instantiation
79
  DUT : entity work.sorter_sys
80
    generic map (
81
      NLEVELS => NLEVELS)
82
    port map (
83
      din   => din,
84
      we    => we,
85
      dout  => dout,
86
      dav   => dav,
87
      clk   => clk,
88
      rst_n => rst_n,
89
      ready => ready);
90
 
91
  -- clock generation
92
  Clk <= not Clk after 10 ns when end_sim = false else '0';
93
 
94
  -- waveform generation
95
  WaveGen_Proc : process
96
    file events_in       : text open read_mode is "events.in";
97
    variable input_line  : line;
98
    file events_out      : text open write_mode is "events.out";
99
    variable output_line : line;
100
    variable rec         : T_DATA_REC;
101
    variable skey       : std_logic_vector(DATA_REC_SORT_KEY_WIDTH-1 downto 0);
102
    variable spayload : std_logic_vector(DATA_REC_PAYLOAD_WIDTH-1 downto 0);
103
  begin
104
    -- insert signal assignments here
105
 
106
    wait until Clk = '1';
107
    wait for 31 ns;
108
    rst_n <= '1';
109
    wait until ready = '1';
110
    loop
111
      wait until Clk = '0';
112
      wait until Clk = '1';
113
      we <= '0';
114
      if div = 3 then
115
        div        <= 0;
116
        exit when endfile(events_in);
117
        readline(events_in, input_line);
118 7 wzab
        read(input_line, rec.invalid);
119 2 wzab
        read(input_line, skey);
120
        read(input_line, spayload);
121
        rec.d_key := unsigned(skey);
122
        rec.d_payload := spayload;
123
        din        <= rec;
124
        we         <= '1';
125
      else
126
        div <= div+1;
127
      end if;
128
      if dav = '1' then
129
        -- Process read event
130
        rec := dout;
131 7 wzab
        write(output_line, rec.invalid);
132 2 wzab
        write(output_line,string'(" "));
133
        write(output_line, std_logic_vector(rec.d_key));
134
        write(output_line,string'(" "));
135
        write(output_line, std_logic_vector(rec.d_payload));
136
        writeline(events_out, output_line);
137
      end if;
138
    end loop;
139
    end_sim   <= true;
140 7 wzab
    rec.invalid := '0';
141 2 wzab
    din       <= rec;
142
    wait;
143
  end process WaveGen_Proc;
144
 
145
 
146
 
147
end architecture sort_tb_beh;
148
 
149
-------------------------------------------------------------------------------
150
 
151
configuration sorter_sys_tb_sort_tb_beh_cfg of sorter_sys_tb is
152
  for sort_tb_beh
153
  end for;
154
end sorter_sys_tb_sort_tb_beh_cfg;
155
 
156
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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