source: trunk/MultiChannelUSB/coincidence.v@ 166

Last change on this file since 166 was 159, checked in by demin, 13 years ago

adapt to paella v2

File size: 1.6 KB
RevLine 
[159]1module coincidence
2 #(
3 parameter input_width = 4,
4 parameter window_size = 10,
5 parameter output_width = 3
6 )
7 (
8 input wire clock, frame, reset,
9 input wire [output_width-1:0] cfg_data,
10 input wire [input_width-1:0] trg_data,
11 output wire [output_width-1:0] coi_data,
12 output wire coi_flag
13 );
14
15 reg [window_size-1:0] coi_pipe_reg [input_width-1:0];
16 reg coi_flag_reg;
17
18 wire [output_width-1:0] coi_data_wire;
19 wire [input_width-1:0] int_data_wire;
20
21 integer i;
22 genvar j;
23
24 always @(posedge clock)
25 begin
26 if (reset)
27 begin
28 coi_flag_reg <= 1'b0;
29 for(i = 0; i <= 3; i = i + 1)
30 begin
31 coi_pipe_reg[i] <= 0;
32 end
33 end
34 else if (frame)
35 begin
36 if (coi_data_wire >= cfg_data)
37 begin
38 coi_flag_reg <= 1'b1;
39 for(i = 0; i < input_width; i = i + 1)
40 begin
41 coi_pipe_reg[i] <= 0;
42 end
43 end
44 else
45 begin
46 coi_flag_reg <= 1'b0;
47 for(i = 0; i < input_width; i = i + 1)
48 begin
49 coi_pipe_reg[i] <= {coi_pipe_reg[i][window_size-2:0], trg_data[i]};
50 end
51 end
52 end
53 end
54
55 generate
56 for (j = 0; j < input_width; j = j + 1)
57 begin : INT_DATA
58 assign int_data_wire[j] = (|coi_pipe_reg[j]);
59 end
60 endgenerate
61
62 parallel_add #(
63 .msw_subtract("NO"),
64 .representation("UNSIGNED"),
65 .result_alignment("LSB"),
66 .pipeline(1),
67 .shift(0),
68 .size(input_width),
69 .width(1),
70 .widthr(output_width)) parallel_add_unit (
71 .clock(clock),
72 .data(int_data_wire),
73 .result(coi_data_wire));
74
75
76 assign coi_data = coi_data_wire;
77 assign coi_flag = coi_flag_reg;
78
79endmodule
Note: See TracBrowser for help on using the repository browser.