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