Changeset 84 for trunk/MultiChannelUSB/analyser.v
- Timestamp:
- Dec 21, 2009, 5:09:06 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MultiChannelUSB/analyser.v
r76 r84 4 4 input wire data_ready, 5 5 input wire [1:0] uwt_flag, 6 output wire peak_ready 6 output wire peak_ready, 7 output wire peak_debug 7 8 ); 8 9 10 reg flag_reg, flag_next; 9 11 reg [1:0] state_reg, state_next; 10 reg [ 3:0] counter_reg, counter_next;11 reg peak_ready_reg , peak_ready_next;12 reg [4:0] counter_reg, counter_next; 13 reg peak_ready_reg; 12 14 13 15 wire counter_max = (&counter_reg); 16 wire peak_ready_int = (flag_reg & data_ready & uwt_flag[0] & counter_max); 14 17 15 18 always @(posedge clk) … … 17 20 if (reset) 18 21 begin 22 flag_reg <= 1'b0; 19 23 state_reg <= 2'd0; 20 counter_reg <= 4'd0;24 counter_reg <= 5'd0; 21 25 peak_ready_reg <= 1'b0; 22 26 end 23 27 else 24 28 begin 29 flag_reg <= flag_next; 25 30 state_reg <= state_next; 26 31 counter_reg <= counter_next; 27 peak_ready_reg <= peak_ready_ next;32 peak_ready_reg <= peak_ready_int; 28 33 end 29 34 end … … 31 36 always @* 32 37 begin 38 flag_next = flag_reg; 33 39 state_next = state_reg; 34 40 counter_next = counter_reg; 35 peak_ready_next = peak_ready_reg;36 41 case (state_reg) 37 42 0: // skip first 16 samples 38 43 begin 39 peak_ready_next = 1'b0;44 flag_next = 1'b0; 40 45 if (data_ready) 41 46 begin 42 counter_next = counter_reg + 4'd1;47 counter_next = counter_reg + 5'd1; 43 48 if (counter_max) 44 49 begin … … 50 55 1: // skip first 16 minima 51 56 begin 57 flag_next = 1'b0; 52 58 if (data_ready & uwt_flag[1]) 53 59 begin 54 counter_next = counter_reg + 4'd1;60 counter_next = counter_reg + 5'd1; 55 61 if (counter_max) 56 62 begin … … 62 68 2: 63 69 begin 64 if (data_ready & uwt_flag[0] & counter_max) 70 flag_next = 1'b1; 71 if (data_ready) 65 72 begin 66 counter_next = 4'd0;67 peak_ready_next = 1'b1;68 end69 else70 begin71 73 if (~counter_max) 72 74 begin 73 counter_next = counter_reg + 4'd1;75 counter_next = counter_reg + 5'd1; 74 76 end 75 peak_ready_next = 1'b0; 76 end 77 if (peak_ready_int) 78 begin 79 counter_next = 5'd0; 80 end 81 end 77 82 end 78 83 79 84 default: 80 85 begin 86 flag_next = 1'b0; 81 87 state_next = 2'd0; 82 counter_next = 4'd0; 83 peak_ready_next = 1'b0; 88 counter_next = 5'd0; 84 89 end 85 90 endcase 86 91 end 87 92 88 assign peak_ready = peak_ready_reg; 93 assign peak_ready = peak_ready_int; 94 assign peak_debug = peak_ready_reg; 89 95 endmodule
Note:
See TracChangeset
for help on using the changeset viewer.