1//
2// Copyright 2012 Ettus Research LLC
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program.  If not, see <http://www.gnu.org/licenses/>.
16//
17
18
19module power_trig_tb();
20   initial $dumpfile("power_trig_tb.vcd");
21   initial $dumpvars(0,power_trig_tb);
22
23   reg clk = 0;
24   always #10 clk <= ~clk;
25   reg rst = 1;
26   initial #100 rst <= 0;
27
28   initial
29     begin
30	set_stb <= 0;
31	#1000;
32	set_stb <= 1;
33     end
34
35   reg [31:0] sample_in;
36   reg 	      strobe_in;
37   wire [31:0] sample_out;
38   wire        strobe_out;
39   reg 	       set_stb, run;
40
41   power_trig #(.BASE(0)) power_trig
42     (.clk(clk), .reset(rst), .enable(1),
43      .set_stb(set_stb), .set_addr(0), .set_data(32'h000B_B000),
44      .run(run),
45
46      .ddc_out_sample(sample_in), .ddc_out_strobe(strobe_in),
47      .bb_sample(sample_out), .bb_strobe(strobe_out));
48
49   initial sample_in <= 32'h0100_0300;
50
51   always @(posedge clk)
52     if(~strobe_in)
53       sample_in <= sample_in + 32'h0001_0001;
54
55   initial
56     #100000 $finish;
57
58   initial
59     begin
60	run <= 0;
61	#2000 run <= 1;
62	#30000 run <= 0;
63     end
64
65   always @(posedge clk)
66     if(rst | ~run)
67       strobe_in <= 0;
68     else
69       strobe_in <= ~strobe_in;
70
71endmodule // power_trig_tb
72