]> git.zerfleddert.de Git - proxmark3-svn/blame - fpga/tests/tb_min_max_tracker.v
updated onlineshops
[proxmark3-svn] / fpga / tests / tb_min_max_tracker.v
CommitLineData
3b2fee43 1//-----------------------------------------------------------------------------
2// Copyright (C) 2014 iZsh <izsh at fail0verflow.com>
3//
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
6// the license.
7//-----------------------------------------------------------------------------
8// testbench for min_max_tracker
9`include "min_max_tracker.v"
10
11`define FIN "tb_tmp/data.filtered.gold"
12`define FOUT_MIN "tb_tmp/data.min"
13`define FOUT_MAX "tb_tmp/data.max"
14
15module min_max_tracker_tb;
16
17 integer fin;
18 integer fout_min, fout_max;
19 integer r;
20
21 reg clk;
22 reg [7:0] adc_d;
23 wire [7:0] min;
24 wire [7:0] max;
25
26 initial
27 begin
28 clk = 0;
29 fin = $fopen(`FIN, "r");
30 if (!fin) begin
31 $display("ERROR: can't open the data file");
32 $finish;
33 end
34 fout_min = $fopen(`FOUT_MIN, "w+");
35 fout_max = $fopen(`FOUT_MAX, "w+");
36 if (!$feof(fin))
37 adc_d = $fgetc(fin); // read the first value
38 end
39
40 always
41 # 1 clk = !clk;
42
43 // input
44 initial
45 begin
46 while (!$feof(fin)) begin
47 @(negedge clk) adc_d <= $fgetc(fin);
48 end
49
50 if ($feof(fin))
51 begin
52 # 3 $fclose(fin);
53 $fclose(fout_min);
54 $fclose(fout_max);
55 $finish;
56 end
57 end
58
59 initial
60 begin
61 // $monitor("%d\t min: %x, max: %x", $time, min, max);
62 end
63
64 // output
65 always @(negedge clk)
66 if ($time > 2) begin
67 r = $fputc(min, fout_min);
68 r = $fputc(max, fout_max);
69 end
70
71 // module to test
72 min_max_tracker tracker(clk, adc_d, 8'd127, min, max);
73
74endmodule
Impressum, Datenschutz