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