source: trunk/Octopus/analyser.v@ 165

Last change on this file since 165 was 102, checked in by demin, 15 years ago

initial commit

File size: 1.6 KB
RevLine 
[102]1module analyser
2 (
3 input wire clock, frame, reset,
4 input wire [15:0] cfg_data,
5 input wire [1:0] uwt_flag,
6 input wire [11:0] uwt_data,
7 output wire ana_good,
8 output wire [11:0] ana_data
9 );
10
11 reg state_reg, state_next;
12 reg [3:0] counter_reg, counter_next;
13 reg [11:0] minimum_reg, minimum_next;
14 reg good_reg, good_next;
15 reg [11:0] data_reg, data_next;
16
17 always @(posedge clock)
18 begin
19 if (reset)
20 begin
21 state_reg <= 1'b0;
22 counter_reg <= 4'd0;
23 minimum_reg <= 12'd0;
24 good_reg <= 1'b0;
25 data_reg <= 12'd0;
26 end
27 else
28 begin
29 state_reg <= state_next;
30 counter_reg <= counter_next;
31 minimum_reg <= minimum_next;
32 good_reg <= good_next;
33 data_reg <= data_next;
34 end
35 end
36
37 always @*
38 begin
39 state_next = state_reg;
40 counter_next = counter_reg;
41 minimum_next = minimum_reg;
42 good_next = good_reg;
43 data_next = data_reg;
44
45 case (state_reg)
46 0:
47 begin
48 if (frame)
49 begin
50 // minimum
51 if (uwt_flag[0])
52 begin
53 counter_next = cfg_data[3:0];
54 minimum_next = uwt_data;
55 end
56 // counter is not zero
57 else if (|counter_reg)
58 begin
59 counter_next = counter_reg - 4'd1;
60 end
61 // maximum
62 else if ((uwt_flag[1]) & (uwt_data > minimum_reg))
63 begin
64 data_next = uwt_data - minimum_reg;
65 state_next = 1'b1;
66 end
67 end
68 end
69
70 1:
71 begin
72 good_next = (data_reg >= cfg_data[15:4]);
73 state_next = 1'b0;
74 end
75
76 endcase
77 end
78
79 assign ana_good = good_reg;
80 assign ana_data = data_reg;
81
82endmodule
Note: See TracBrowser for help on using the repository browser.