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

Subversion Repositories xmatchpro

[/] [xmatchpro/] [trunk/] [xmw4-comdec/] [xmatch_sim7/] [tb.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 COMPRESSION START HERE --------------------------
98
 
99
        WRITE_CMD : process
100
        begin
101
        wait for clk_CODMU_period*2;
102
        -- command_CR_HOST (32-bit):
103
        -- addr(4) & ctrl(4) & trhshold(8) & blocksize(16)
104
--      command_CR_HOST <= "11011100000010000000001000000000"; -- BlockSize 512
105
--      command_CR_HOST <= "11011100000010000000010000000000"; -- BlockSize 1024
106
--      command_CR_HOST <= "11011100000010000000100000000000"; -- BlockSize 2048
107
--      command_CR_HOST <= "11011100000010000001000000000000"; -- BlockSize 4096
108
--      command_CR_HOST <= "11011100000010000010000000000000"; -- BlockSize 8192
109
--      command_CR_HOST <= "11011100000010000100000000000000"; -- BlockSize 16384
110
--      command_CR_HOST <= "11011100000010001000000000000000"; -- BlockSize 32768
111
 
112
        -- addr(4) & ctrl(4) & trhshold(8) & reserved (16)
113
        command_CR_HOST <= "1101110000001000" & "0000000000000000";
114
 
115
        wait for clk_CODMU_period*50;
116
        command_CR_HOST         <=    "00000000000010110000101111100000"; --sp_bin
117
        --command_CR_HOST       <= "00000000000000101000111001100000"; -- this is the file U_alice_167520.txt, the file is 167520 Bytes, where there are 41880 words 
118
        --command_CR_HOST       <= "00000000000000000010000000000000"; -- this is the file U_alice_8192.txt
119
        -- command_CR_HOST      <= "00000000000000010000000000000000"; -- this is the file U_alice_32768.txt
120
        --command_CR_HOST       <= "00000000000000000001111100000000"; -- this is the file 7936 bytes
121
        --command_CR_HOST       <= "00000000000000000001000000000000"; -- this is the file U_4KB_TEST.txt, the file is 4096 Bytes, so the binary should use 4096; where there are 1024 words 
122
--      command_CR_HOST <= "00100000000000000000010000000000"; -- the first 4-bit 0010 is without optimization -- 1KB size
123
        --command_CR_HOST       <= "00100000000000000001000000000000"; -- the first 4-bit 0010 is without optimization -- 4KB size
124
        --command_CR_HOST       <= "00000000000000001000000000000000"; -- this is the file U_alice_32768.txt
125
 
126
        wait for clk_CODMU_period*50;
127
        command_CR_HOST <= "00000000000000000000000000000000";
128
 
129
        wait;
130
        end process;
131
 
132
        -- COMPRESS
133
        WRITE_C: process
134
 
135
        --file INPUT_FILE_txt : TEXT open read_mode is "test_file/" & "U_723936_S" & ".txt";
136
        --file INPUT_FILE_txt : TEXT open read_mode is "test_file/" & "U_alice_32768" & ".txt";
137
        --file INPUT_FILE_txt : TEXT open read_mode is "test_file/" & "U_alice_8192" & ".txt";
138
        --file INPUT_FILE_txt : TEXT open read_mode is "test_file/" & "U_alice_167520" & ".txt";
139
        file INPUT_FILE_txt : TEXT open read_mode is "test_file/" & "U_723936_S" & ".txt";
140
        --file INPUT_FILE_txt : TEXT open read_mode is "test_file/" & "U_4KB_TEST" & ".txt";
141
        -- file INPUT_FILE_txt : TEXT open read_mode is "test_file/" & "U_64KB_A" & ".txt";
142
        --file INPUT_FILE_txt : TEXT open read_mode is "test_file/" & "tvin_c" & ".txt";
143
        variable LIN : line;
144
        variable SPACE : character;
145
        variable tdata_file : std_logic_vector(31 downto 0);
146
        variable tlast_file : std_logic;
147
 
148
   begin
149
 
150
        wait for 0 ns;
151
 
152
        rst_CODMU <= '1';
153
        rst_HOST <= '1';
154
        wait for clk_CODMU_period*1;
155
 
156
        wr_en_HOST <= '0';
157
 
158
        wait for clk_CODMU_period*1;
159
        rst_HOST <= '1';
160
        wait for clk_CODMU_period*1;
161
        rst_HOST <= '1';
162
 
163
 
164
        while ((not(endfile(INPUT_FILE_txt)))) loop
165
 
166
        if (full_HOST ='0') then
167
                readline(INPUT_FILE_txt , LIN);
168
                read(LIN , tdata_file);
169
                read(LIN , SPACE);
170
                read(LIN , tlast_file);
171
 
172
                wait for clk_HOST_period;
173
 
174
 
175
                        din_HOST <= tdata_file;
176
                        wr_en_HOST <= '1';
177
 
178
 
179
                --command_CR_HOST_HOST  <= "00000000000000000000000000000000";
180
--              if tlast_file /= '0' then
181
--                      tlast_boolean <= false;
182
--              else
183
--                      tlast_boolean <= true;
184
--              end if;
185
        else
186
                wait for clk_HOST_period;
187
                wr_en_HOST <= '0';
188
        end if;
189
 
190
        end loop;
191
 
192
                wait for clk_HOST_period;
193
                wr_en_HOST <= '0';
194
                wait;
195
 
196
   end process;
197
 
198
        READ_C: process
199
 
200
        file OUTPUT_FILE_txt : TEXT open write_mode is "test_file/" & "C_alice_167520_NEW_BLOCKSIZE" & ".txt"; -------------- simulate 1000us
201
        --file OUTPUT_FILE_txt : TEXT open write_mode is "test_file/" & "C_alice_32768_NEW_BLOCKSIZE" & ".txt";
202
        --file OUTPUT_FILE_txt : TEXT open write_mode is "test_file/" & "C_alice_167520_NEW_BLOCKSIZE" & ".txt";
203
        --file OUTPUT_FILE_txt : TEXT open write_mode is "test_file/" & "C_alice_8192_NEW_BLOCKSIZE" & ".txt";
204
        --file OUTPUT_FILE_txt : TEXT open write_mode is "test_file/" & "C_4KB_TEST_NEW_BLOCKSIZE" & ".txt";
205
   variable  outline  : line;   --line number declaration  
206
        variable    linenumber : integer:=1;
207
        variable C_DATAOUT_std_temp : std_logic_vector(31 downto 0) := x"FFFFFFFF";
208
 
209
        begin
210
 
211
        rd_en_HOST <= '0';
212
        --wait for 150 ns; -- DO NOT EVER TRY TO SIMULATE WAIT FOR xx ns!! If not, there will be a CRC ERROR bit!!
213
        wait for 0 ns;
214
        wait for clk_HOST_period*1;
215
 
216
        while ((empty_HOST ='0')) loop
217
 
218
                rd_en_HOST <='1';
219
                wait for clk_HOST_period;
220
                rd_en_HOST <='0';
221
                wait for clk_HOST_period;
222
                C_DATAOUT_std_temp := dout_HOST;
223
                write(outline, C_DATAOUT_std_temp);
224
                writeline(OUTPUT_FILE_txt, outline);
225
                linenumber := linenumber + 1;
226
 
227
        end loop;
228
 
229
        end process;
230
 
231
-----------------------------
232
--
233
--
234
---------------------- COMMENT / UNCOMMENT FOR COMPRESSION START HERE --------------------------
235
 
236
 
237
 
238
 
239
 
240
 
241
 
242
 
243
 
244
 
245
 
246
 
247
 
248
 
249
 
250
 
251
--
252
---------------------- COMMENT / UNCOMMENT FOR DECOMPRESSION START HERE --------------------------
253
--
254
--      WRITE_CMD_D : process
255
--      begin
256
--      
257
--      wait for clk_CODMU_period*2;
258
--      -- command_CR_HOST_HOST (32-bit):
259
--      -- addr (4-bit) & ctrl (4-bit) & trhshold (8-bit) & blocksize (16-bit)
260
----    command_CR_HOST <= "10011000000010000000001000000000"; -- BlockSize 512
261
----    command_CR_HOST <= "10011000000010000000010000000000"; -- BlockSize 1024
262
----    command_CR_HOST <= "10011000000010000000100000000000"; -- BlockSize 2048
263
----    command_CR_HOST <= "10011000000010000001000000000000"; -- BlockSize 4096
264
----    command_CR_HOST <= "10011000000010000010000000000000"; -- BlockSize 8192
265
----    command_CR_HOST <= "10011000000010000100000000000000"; -- BlockSize 16384
266
----    command_CR_HOST <= "10011000000010001000000000000000"; -- BlockSize 32768
267
--
268
--      -- addr(4) & ctrl(4) & trhshold(8) & reserved (16)
269
--      command_CR_HOST <= "1001100000001000" & "0000000000000000";
270
--      
271
--      wait for clk_CODMU_period*50;
272
--      command_CR_HOST         <= "00000000000000101000111001100000"; -- U_alice_167520.txt file
273
--      --command_CR_HOST       <= "00000000000000000010000000000000"; -- U_alice_8192.txt file
274
--      --command_CR_HOST       <= "00000000000000000010000000000000"; -- U_alice_8192.txt file
275
--      --command_CR_HOST       <= "00000000000000001000000000000000"; -- this is the file U_alice_32768.txt
276
--                                                                                               
277
--      wait for clk_CODMU_period*50;
278
--      command_CR_HOST <= "00000000000000000000000000000000";
279
--      wait;
280
--      end process;
281
--      -- DECOMPRESS
282
--      WRITE_D: process
283
--
284
--      --file INPUT_FILE_txt : TEXT open read_mode is "test_file/" & "C_alice_32768_NEW_BLOCKSIZE" & ".txt";
285
--      file INPUT_FILE_txt : TEXT open read_mode is "test_file/" & "C_alice_167520_NEW_BLOCKSIZE" & ".txt"; -------------- simulate 1000us
286
--      --file INPUT_FILE_txt : TEXT open read_mode is "test_file/" & "C_alice_8192_NEW_BLOCKSIZE" & ".txt";
287
--      --file INPUT_FILE_txt : TEXT open read_mode is "test_file/" & "C_4KB_TEST_NEW_BLOCKSIZE" & ".txt";
288
--      variable LIN : line;
289
--      variable SPACE : character;
290
--      variable tdata_file : std_logic_vector(31 downto 0);
291
--      variable tlast_file : std_logic;
292
--      
293
--   begin              
294
--      
295
--      wait for 0 ns;  
296
--      
297
--      rst_CODMU <= '1';
298
--      rst_HOST <= '1';
299
--      wait for clk_CODMU_period*1;
300
--      
301
--      wr_en_HOST <= '0';
302
--      
303
----    wait for clk_CODMU_period*1;
304
----    rst_HOST <= '1';
305
----    wait for clk_CODMU_period*1;
306
----    rst_HOST <= '1';
307
--
308
--              
309
--      while ((not(endfile(INPUT_FILE_txt)))) loop     
310
--              
311
--      if (full_HOST ='0') then
312
--              readline(INPUT_FILE_txt , LIN);
313
--              read(LIN , tdata_file);
314
--              read(LIN , SPACE);
315
--              read(LIN , tlast_file);
316
--              
317
--              wait for clk_HOST_period;
318
--              
319
--                      din_HOST <= tdata_file;
320
--                      wr_en_HOST <= '1';
321
--
322
--              --command_CR_HOST_HOST  <= "00000000000000000000000000000000";
323
----            if tlast_file /= '0' then
324
----                    tlast_boolean <= false;
325
----            else
326
----                    tlast_boolean <= true;
327
----            end if;
328
--      else
329
--              wait for clk_HOST_period;
330
--              wr_en_HOST <= '0';
331
--      end if;
332
--      
333
--      end loop;
334
--              
335
--              wait for clk_HOST_period;
336
--              wr_en_HOST <= '0';
337
--              wait;
338
--       
339
--   end process;
340
--
341
--      READ_D: process
342
--      
343
--      --file OUTPUT_FILE_txt : TEXT open write_mode is "test_file/" & "D_alice_32768_NEW_BLOCKSIZE" & ".txt";
344
--      file OUTPUT_FILE_txt : TEXT open write_mode is "test_file/" & "D_alice_167520_NEW_BLOCKSIZE" & ".txt";
345
--      --file OUTPUT_FILE_txt : TEXT open write_mode is "test_file/" & "D_alice_8192_NEW_BLOCKSIZE" & ".txt";
346
--      --file OUTPUT_FILE_txt : TEXT open write_mode is "test_file/" & "D_4KB_TEST_NEW_BLOCKSIZE" & ".txt";
347
--   variable  outline  : line;   --line number declaration  
348
--      variable    linenumber : integer:=1; 
349
--      variable C_DATAOUT_std_temp : std_logic_vector(31 downto 0) := x"FFFFFFFF";
350
--      
351
--      begin                                            
352
--      
353
--      rd_en_HOST <= '0';
354
--      wait for 0 ns;
355
--      wait for clk_HOST_period*1;
356
--              
357
--      while ((empty_HOST ='0')) loop  
358
--              
359
--              rd_en_HOST <='1';               
360
--              wait for clk_HOST_period;
361
--              rd_en_HOST <='0';               
362
--              wait for clk_HOST_period;
363
--              C_DATAOUT_std_temp := dout_HOST;
364
--              write(outline, C_DATAOUT_std_temp);
365
--              writeline(OUTPUT_FILE_txt, outline);
366
--              linenumber := linenumber + 1;
367
--
368
--              
369
--      end loop;          
370
--      
371
--      end process;
372
--
373
--      
374
---------------------- COMMENT / UNCOMMENT FOR DECOMPRESSION END HERE --------------------------
375
 
376
 
377
  END;

powered by: WebSVN 2.1.0

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