source: trunk/MultiChannelUSB/baseline.v@ 84

Last change on this file since 84 was 83, checked in by demin, 15 years ago

first working version

  • Property svn:executable set to *
File size: 680 bytes
Line 
1module baseline
2 (
3 input wire clk, reset,
4 input wire data_ready,
5 input wire [1:0] uwt_flag,
6 input wire [11:0] uwt_data,
7 output wire [11:0] baseline
8 );
9
10 reg [15:0] buffer [15:0];
11 wire [15:0] sample;
12
13 integer i;
14
15 assign sample = {4'd0, uwt_data};
16
17 always @(posedge clk)
18 begin
19 if (reset)
20 begin
21 for(i = 0; i <= 15; i = i + 1)
22 begin
23 buffer[i] <= 12'd0;
24 end
25 end
26 else
27 begin
28 if (data_ready & uwt_flag[1])
29 begin
30 for(i = 0; i < 15; i = i + 1)
31 begin
32 buffer[i+1] <= buffer[i] + sample;
33 end
34 buffer[0] <= sample;
35 end
36 end
37 end
38
39 assign baseline = buffer[15][15:4];
40endmodule
Note: See TracBrowser for help on using the repository browser.