Changeset 123 for sandbox/MultiChannelUSB/amplitude.v
- Timestamp:
- Feb 21, 2011, 12:33:56 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/MultiChannelUSB/amplitude.v
r107 r123 1 1 module amplitude 2 #( 3 parameter width = 12 // bit width of the input data 4 ) 2 5 ( 3 input wire clock, frame, reset, 4 input wire [11:0] cfg_data, 5 input wire [1:0] uwt_flag, 6 input wire [11:0] uwt_data, 7 output wire amp_good, 8 output wire [11:0] amp_data 6 input wire clock, frame, reset, 7 input wire [width-1:0] cfg_data, 8 input wire [width-1:0] inp_data, 9 output wire [width-1:0] out_data, 10 output wire out_flag 9 11 ); 10 12 11 reg state_reg, state_next; 12 reg [11:0] minimum_reg, minimum_next; 13 reg amp_good_reg, amp_good_next; 14 reg [11:0] amp_data_reg, amp_data_next; 15 reg [11:0] uwt_data_reg, uwt_data_next; 13 reg int_case_reg, int_case_next; 14 reg out_flag_reg, out_flag_next; 15 reg int_flag_reg, int_flag_next; 16 reg [width-1:0] int_mini_reg, int_mini_next; 17 reg [width-1:0] out_data_reg, out_data_next; 18 reg [width-1:0] inp_data_reg, inp_data_next; 19 20 wire int_comp_wire; 21 reg int_comp_reg, int_comp_next; 22 23 assign int_comp_wire = (inp_data_reg < inp_data); 16 24 17 25 always @(posedge clock) … … 19 27 if (reset) 20 28 begin 21 state_reg <= 1'b0; 22 minimum_reg <= 12'd0; 23 amp_good_reg <= 1'b0; 24 amp_data_reg <= 12'd0; 25 uwt_data_reg <= 12'd0; 29 int_case_reg <= 1'b0; 30 int_mini_reg <= {(width){1'b0}}; 31 inp_data_reg <= {(width){1'b0}}; 32 out_data_reg <= {(width){1'b0}}; 33 out_flag_reg <= 1'b0; 34 int_flag_reg <= 1'b0; 35 int_comp_reg <= 1'b0; 26 36 end 27 37 else 28 38 begin 29 state_reg <= state_next; 30 minimum_reg <= minimum_next; 31 amp_good_reg <= amp_good_next; 32 amp_data_reg <= amp_data_next; 33 uwt_data_reg <= uwt_data_next; 39 int_case_reg <= int_case_next; 40 int_mini_reg <= int_mini_next; 41 inp_data_reg <= inp_data_next; 42 out_data_reg <= out_data_next; 43 out_flag_reg <= out_flag_next; 44 int_flag_reg <= int_flag_next; 45 int_comp_reg <= int_comp_next; 34 46 end 35 47 end … … 37 49 always @* 38 50 begin 39 state_next = state_reg; 40 minimum_next = minimum_reg; 41 amp_good_next = amp_good_reg; 42 amp_data_next = amp_data_reg; 43 uwt_data_next = uwt_data_reg; 51 int_case_next = int_case_reg; 52 int_mini_next = int_mini_reg; 53 inp_data_next = inp_data_reg; 54 out_data_next = out_data_reg; 55 out_flag_next = out_flag_reg; 56 int_flag_next = int_flag_reg; 57 int_comp_next = int_comp_reg; 44 58 45 case ( state_reg)59 case (int_case_reg) 46 60 0: 47 61 begin 48 62 if (frame) 49 63 begin 50 uwt_data_next = uwt_data; 51 amp_good_next = 1'b0; 64 inp_data_next = inp_data; 65 int_comp_next = int_comp_wire; 66 out_data_next = {(width){1'b0}}; 67 out_flag_next = 1'b0; 52 68 // minimum 53 if ( uwt_flag[0])69 if ((~int_comp_reg) & (int_comp_wire)) 54 70 begin 55 minimum_next = uwt_data_reg; 71 int_mini_next = inp_data_reg; 72 int_flag_next = 1'b1; 56 73 end 57 else if ((uwt_flag[1]) & (uwt_data > minimum_reg)) 74 // maximum 75 else if ((int_comp_reg) & (~int_comp_wire) & (int_flag_reg)) 58 76 begin 59 amp_data_next = uwt_data - minimum_reg; 60 state_next = 1'b1; 77 out_data_next = inp_data_reg - int_mini_reg; 78 int_flag_next = 1'b0; 79 int_case_next = 1'b1; 61 80 end 62 81 end … … 65 84 1: 66 85 begin 67 amp_good_next = (amp_data_reg >= cfg_data);68 state_next = 1'b0;86 out_flag_next = (out_data_reg >= cfg_data); 87 int_case_next = 1'b0; 69 88 end 70 89 … … 72 91 end 73 92 74 assign amp_good = amp_good_reg;75 assign amp_data = amp_data_reg;93 assign out_data = out_data_reg; 94 assign out_flag = out_flag_reg; 76 95 77 96 endmodule
Note:
See TracChangeset
for help on using the changeset viewer.