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

Subversion Repositories xmatchpro

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

powered by: WebSVN 2.1.0

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