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

Subversion Repositories xmatchpro

[/] [xmatchpro/] [trunk/] [xmw4-comdec/] [xmatch_sim7/] [tb_d.vhd] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 eejlny
LIBRARY ieee;
2
USE ieee.std_logic_1164.ALL;
3
USE ieee.numeric_std.ALL;
4
 
5
use ieee.std_logic_textio.all;
6
use std.textio.all;
7
 
8
  ENTITY testbench IS
9
  END testbench;
10
 
11
  ARCHITECTURE behavior OF testbench IS
12
 
13
COMPONENT xmatch_controller
14
PORT
15
(
16
        rst_CODMU       : IN STD_LOGIC;
17
        clk_CODMU       : IN STD_LOGIC;
18
        rst_HOST                : IN STD_LOGIC;
19
        clk_HOST        : IN STD_LOGIC;
20
        din_HOST        : IN STD_LOGIC_VECTOR(31 DOWNTO 0);
21
        wr_en_HOST      : IN STD_LOGIC;
22
        rd_en_HOST      : IN STD_LOGIC;
23
        dout_HOST       : OUT STD_LOGIC_VECTOR(31 DOWNTO 0);
24
        full_HOST       : OUT STD_LOGIC;
25
        empty_HOST      : OUT STD_LOGIC;
26
        command_CR_HOST : in std_logic_vector(31 DOWNTO 0);
27
        status_CDI_HOST : out std_logic_vector(31 DOWNTO 0)
28
);
29
END COMPONENT;
30
 
31
  --Inputs
32
 
33
        signal rst_CODMU : std_logic := '0';
34
        signal clk_CODMU : std_logic := '0';
35
 
36
        signal rst_HOST : std_logic := '1';
37
        signal clk_HOST : std_logic := '0';
38
 
39
        signal din_HOST : std_logic_vector(31 downto 0) := (others => '0');
40
        signal wr_en_HOST : std_logic := '0';
41
        signal rd_en_HOST : std_logic := '0';
42
 
43
 
44
signal command_CR_HOST : std_logic_vector(31 downto 0) := (others => '0');
45
 
46
        --Outputs
47
 
48
   signal dout_HOST : std_logic_vector(31 downto 0);
49
   signal full_HOST : std_logic;
50
   signal empty_HOST : std_logic;
51
 
52
        signal status_CDI_HOST : std_logic_vector(31 downto 0);
53
 
54
   -- Clock period definitions
55
   constant clk_CODMU_period : time := 10 ns;
56
   constant clk_HOST_period : time := 10 ns;
57
 
58
        -- others
59
        signal tlast_boolean : boolean := false;
60
 
61
  BEGIN
62
 
63
  -- Component Instantiation
64
          uut: xmatch_controller PORT MAP(
65
                clk_CODMU                       => clk_CODMU,
66
                rst_CODMU                       => rst_CODMU,
67
                clk_HOST                        => clk_HOST,
68
                rst_HOST                        => rst_HOST,
69
                din_HOST                        => din_HOST,
70
                wr_en_HOST                      => wr_en_HOST,
71
                rd_en_HOST                      => rd_en_HOST,
72
                dout_HOST                       => dout_HOST,
73
                full_HOST                       => full_HOST,
74
                empty_HOST                      => empty_HOST,
75
                command_CR_HOST                         => command_CR_HOST,
76
                status_CDI_HOST => status_CDI_HOST
77
          );
78
 
79
   clk_CODMU_process :process
80
   begin
81
                clk_CODMU <= '1';
82
                wait for clk_CODMU_period/2;
83
                clk_CODMU <= '0';
84
                wait for clk_CODMU_period/2;
85
   end process;
86
 
87
   clk_HOST_process :process
88
   begin
89
                clk_HOST <= '1';
90
                wait for clk_HOST_period/2;
91
                clk_HOST <= '0';
92
                wait for clk_HOST_period/2;
93
   end process;
94
 
95
 
96
--
97
---------------------- COMMENT / UNCOMMENT FOR DECOMPRESSION START HERE --------------------------
98
--
99
        WRITE_CMD_D : process
100
        begin
101
 
102
        wait for clk_CODMU_period*2;
103
        -- command_CR_HOST_HOST (32-bit):
104
        -- addr (4-bit) & ctrl (4-bit) & trhshold (8-bit) & blocksize (16-bit)
105
----    command_CR_HOST <= "10011000000010000000001000000000"; -- BlockSize 512
106
----    command_CR_HOST <= "10011000000010000000010000000000"; -- BlockSize 1024
107
----    command_CR_HOST <= "10011000000010000000100000000000"; -- BlockSize 2048
108
----    command_CR_HOST <= "10011000000010000001000000000000"; -- BlockSize 4096
109
----    command_CR_HOST <= "10011000000010000010000000000000"; -- BlockSize 8192
110
----    command_CR_HOST <= "10011000000010000100000000000000"; -- BlockSize 16384
111
----    command_CR_HOST <= "10011000000010001000000000000000"; -- BlockSize 32768
112
--
113
--      -- addr(4) & ctrl(4) & trhshold(8) & reserved (16)
114
        command_CR_HOST <= "1001100000001000" & "0000000000000000";
115
--      
116
        wait for clk_CODMU_period*50;
117
--      command_CR_HOST         <= "00000000000000101000111001100000"; -- U_alice_167520.txt file
118
--      --command_CR_HOST       <= "00000000000000000010000000000000"; -- U_alice_8192.txt file
119
--      --command_CR_HOST       <= "00000000000000000010000000000000"; -- U_alice_8192.txt file
120
--      --command_CR_HOST       <= "00000000000000001000000000000000"; -- this is the file U_alice_32768.txt
121
command_CR_HOST         <= "00000000000000000001111100000000"; -- this is the file 7936 bytes
122
--                                                                                               
123
        wait for clk_CODMU_period*50;
124
        command_CR_HOST <= "00000000000000000000000000000000";
125
        wait;
126
        end process;
127
--      -- DECOMPRESS
128
        WRITE_D: process
129
--
130
--      --file INPUT_FILE_txt : TEXT open read_mode is "test_file/" & "C_alice_32768_NEW_BLOCKSIZE" & ".txt";
131
        file INPUT_FILE_txt : TEXT open read_mode is "test_file/" & "C_alice_167520_NEW_BLOCKSIZE" & ".txt"; -------------- simulate 1000us
132
--      --file INPUT_FILE_txt : TEXT open read_mode is "test_file/" & "C_alice_8192_NEW_BLOCKSIZE" & ".txt";
133
--      --file INPUT_FILE_txt : TEXT open read_mode is "test_file/" & "C_4KB_TEST_NEW_BLOCKSIZE" & ".txt";
134
        variable LIN : line;
135
        variable SPACE : character;
136
        variable tdata_file : std_logic_vector(31 downto 0);
137
        variable tlast_file : std_logic;
138
--      
139
   begin
140
--      
141
        wait for 0 ns;
142
--      
143
        rst_CODMU <= '1';
144
        rst_HOST <= '1';
145
        wait for clk_CODMU_period*1;
146
 
147
        wr_en_HOST <= '0';
148
 
149
        wait for clk_CODMU_period*1;
150
 
151
        rst_HOST <= '1';
152
        wait for clk_CODMU_period*1;
153
        rst_HOST <= '1';
154
 
155
 
156
        while ((not(endfile(INPUT_FILE_txt)))) loop
157
 
158
        if (full_HOST ='0') then
159
                readline(INPUT_FILE_txt , LIN);
160
                read(LIN , tdata_file);
161
                read(LIN , SPACE);
162
                read(LIN , tlast_file);
163
 
164
                wait for clk_HOST_period;
165
 
166
                        din_HOST <= tdata_file;
167
                        wr_en_HOST <= '1';
168
 
169
                --command_CR_HOST_HOST  <= "00000000000000000000000000000000";
170
--              if tlast_file /= '0' then
171
----                    tlast_boolean <= false;
172
----            else
173
----                    tlast_boolean <= true;
174
----            end if;
175
        else
176
                wait for clk_HOST_period;
177
                wr_en_HOST <= '0';
178
        end if;
179
 
180
        end loop;
181
--              
182
                wait for clk_HOST_period;
183
                wr_en_HOST <= '0';
184
                wait;
185
--       
186
   end process;
187
--
188
        READ_D: process
189
--      
190
   file OUTPUT_FILE_txt : TEXT open write_mode is "test_file/" & "D_alice_32768_NEW_BLOCKSIZE" & ".txt";
191
--      file OUTPUT_FILE_txt : TEXT open write_mode is "test_file/" & "D_alice_167520_NEW_BLOCKSIZE" & ".txt";
192
--      --file OUTPUT_FILE_txt : TEXT open write_mode is "test_file/" & "D_alice_8192_NEW_BLOCKSIZE" & ".txt";
193
--      --file OUTPUT_FILE_txt : TEXT open write_mode is "test_file/" & "D_4KB_TEST_NEW_BLOCKSIZE" & ".txt";
194
   variable  outline  : line;   --line number declaration  
195
        variable    linenumber : integer:=1;
196
        variable C_DATAOUT_std_temp : std_logic_vector(31 downto 0) := x"FFFFFFFF";
197
--      
198
        begin
199
--      
200
        rd_en_HOST <= '0';
201
        wait for 0 ns;
202
        wait for clk_HOST_period*1;
203
--              
204
        while ((empty_HOST ='0')) loop
205
--              
206
                rd_en_HOST <='1';
207
                wait for clk_HOST_period;
208
                rd_en_HOST <='0';
209
                wait for clk_HOST_period;
210
                C_DATAOUT_std_temp := dout_HOST;
211
                write(outline, C_DATAOUT_std_temp);
212
                writeline(OUTPUT_FILE_txt, outline);
213
                linenumber := linenumber + 1;
214
--
215
--              
216
        end loop;
217
 
218
        end process;
219
--
220
--      
221
---------------------- COMMENT / UNCOMMENT FOR DECOMPRESSION END HERE --------------------------
222
 
223
 
224
  END;

powered by: WebSVN 2.1.0

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