source: sandbox/MultiChannelUSB/amplitude.v@ 120

Last change on this file since 120 was 107, checked in by demin, 14 years ago

Starting to test signal shaping algorithms

File size: 1.6 KB
Line 
1module amplitude
2 (
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
9 );
10
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;
16
17 always @(posedge clock)
18 begin
19 if (reset)
20 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;
26 end
27 else
28 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;
34 end
35 end
36
37 always @*
38 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;
44
45 case (state_reg)
46 0:
47 begin
48 if (frame)
49 begin
50 uwt_data_next = uwt_data;
51 amp_good_next = 1'b0;
52 // minimum
53 if (uwt_flag[0])
54 begin
55 minimum_next = uwt_data_reg;
56 end
57 else if ((uwt_flag[1]) & (uwt_data > minimum_reg))
58 begin
59 amp_data_next = uwt_data - minimum_reg;
60 state_next = 1'b1;
61 end
62 end
63 end
64
65 1:
66 begin
67 amp_good_next = (amp_data_reg >= cfg_data);
68 state_next = 1'b0;
69 end
70
71 endcase
72 end
73
74 assign amp_good = amp_good_reg;
75 assign amp_data = amp_data_reg;
76
77endmodule
Note: See TracBrowser for help on using the repository browser.