1 //-----------------------------------------------------------------------------
2 // Copyright (C) 2014 iZsh <izsh at fail0verflow.com>
4 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
5 // at your option, any later version. See the LICENSE.txt file for the text of
7 //-----------------------------------------------------------------------------
8 // testbench for min_max_tracker
9 `include "min_max_tracker.v"
11 `define FIN "tb_tmp/data.filtered.gold"
12 `define FOUT_MIN "tb_tmp/data.min"
13 `define FOUT_MAX "tb_tmp/data.max"
15 module min_max_tracker_tb;
18 integer fout_min, fout_max;
29 fin = $fopen(`FIN, "r");
31 $display("ERROR: can't open the data file");
34 fout_min = $fopen(`FOUT_MIN, "w+");
35 fout_max = $fopen(`FOUT_MAX, "w+");
37 adc_d = $fgetc(fin); // read the first value
46 while (!$feof(fin)) begin
47 @(negedge clk) adc_d <= $fgetc(fin);
61 // $monitor("%d\t min: %x, max: %x", $time, min, max);
67 r = $fputc(min, fout_min);
68 r = $fputc(max, fout_max);
72 min_max_tracker tracker(clk, adc_d, 8'd127, min, max);