| Rev | Line | |
|---|
| [44] | 1 | module analyser
|
|---|
| 2 | (
|
|---|
| 3 | input wire clk, reset,
|
|---|
| 4 | input wire data_ready,
|
|---|
| 5 | input wire [1:0] uwt_flag,
|
|---|
| [76] | 6 | output wire peak_ready
|
|---|
| [44] | 7 | );
|
|---|
| 8 |
|
|---|
| 9 | reg [1:0] state_reg, state_next;
|
|---|
| 10 | reg [3:0] counter_reg, counter_next;
|
|---|
| 11 | reg peak_ready_reg, peak_ready_next;
|
|---|
| 12 |
|
|---|
| [76] | 13 | wire counter_max = (&counter_reg);
|
|---|
| 14 |
|
|---|
| [44] | 15 | always @(posedge clk)
|
|---|
| 16 | begin
|
|---|
| 17 | if (reset)
|
|---|
| 18 | begin
|
|---|
| 19 | state_reg <= 2'd0;
|
|---|
| 20 | counter_reg <= 4'd0;
|
|---|
| 21 | peak_ready_reg <= 1'b0;
|
|---|
| 22 | end
|
|---|
| 23 | else
|
|---|
| 24 | begin
|
|---|
| 25 | state_reg <= state_next;
|
|---|
| 26 | counter_reg <= counter_next;
|
|---|
| 27 | peak_ready_reg <= peak_ready_next;
|
|---|
| 28 | end
|
|---|
| 29 | end
|
|---|
| 30 |
|
|---|
| 31 | always @*
|
|---|
| 32 | begin
|
|---|
| 33 | state_next = state_reg;
|
|---|
| 34 | counter_next = counter_reg;
|
|---|
| [50] | 35 | peak_ready_next = peak_ready_reg;
|
|---|
| [44] | 36 | case (state_reg)
|
|---|
| 37 | 0: // skip first 16 samples
|
|---|
| 38 | begin
|
|---|
| [50] | 39 | peak_ready_next = 1'b0;
|
|---|
| [44] | 40 | if (data_ready)
|
|---|
| 41 | begin
|
|---|
| 42 | counter_next = counter_reg + 4'd1;
|
|---|
| [76] | 43 | if (counter_max)
|
|---|
| [44] | 44 | begin
|
|---|
| [45] | 45 | state_next = 2'd1;
|
|---|
| [44] | 46 | end
|
|---|
| 47 | end
|
|---|
| 48 | end
|
|---|
| 49 |
|
|---|
| 50 | 1: // skip first 16 minima
|
|---|
| 51 | begin
|
|---|
| 52 | if (data_ready & uwt_flag[1])
|
|---|
| 53 | begin
|
|---|
| 54 | counter_next = counter_reg + 4'd1;
|
|---|
| [76] | 55 | if (counter_max)
|
|---|
| [44] | 56 | begin
|
|---|
| [45] | 57 | state_next = 2'd2;
|
|---|
| [44] | 58 | end
|
|---|
| 59 | end
|
|---|
| 60 | end
|
|---|
| 61 |
|
|---|
| [76] | 62 | 2:
|
|---|
| [44] | 63 | begin
|
|---|
| [76] | 64 | if (data_ready & uwt_flag[0] & counter_max)
|
|---|
| [44] | 65 | begin
|
|---|
| [76] | 66 | counter_next = 4'd0;
|
|---|
| [72] | 67 | peak_ready_next = 1'b1;
|
|---|
| [44] | 68 | end
|
|---|
| [50] | 69 | else
|
|---|
| 70 | begin
|
|---|
| [76] | 71 | if (~counter_max)
|
|---|
| 72 | begin
|
|---|
| 73 | counter_next = counter_reg + 4'd1;
|
|---|
| 74 | end
|
|---|
| [50] | 75 | peak_ready_next = 1'b0;
|
|---|
| 76 | end
|
|---|
| [44] | 77 | end
|
|---|
| 78 |
|
|---|
| 79 | default:
|
|---|
| 80 | begin
|
|---|
| [76] | 81 | state_next = 2'd0;
|
|---|
| 82 | counter_next = 4'd0;
|
|---|
| [50] | 83 | peak_ready_next = 1'b0;
|
|---|
| [44] | 84 | end
|
|---|
| 85 | endcase
|
|---|
| 86 | end
|
|---|
| 87 |
|
|---|
| 88 | assign peak_ready = peak_ready_reg;
|
|---|
| 89 | endmodule
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.