1 | module adc_lvds
|
---|
2 | #(
|
---|
3 | parameter size = 3, // number of channels
|
---|
4 | parameter width = 12 // channel resolution
|
---|
5 | )
|
---|
6 | (
|
---|
7 | input wire lvds_dco,
|
---|
8 | input wire lvds_fco,
|
---|
9 | input wire [size-1:0] lvds_d,
|
---|
10 |
|
---|
11 | output wire [size*width-1:0] adc_data
|
---|
12 | );
|
---|
13 |
|
---|
14 | wire [size-1:0] int_data_h, int_data_l;
|
---|
15 | reg [width-1:0] int_data_next [size-1:0];
|
---|
16 | // reg [2*width:0] int_data_next [size-1:0];
|
---|
17 | reg [width-1:0] int_data_reg [size-1:0];
|
---|
18 | // reg [2*width:0] int_data_reg [size-1:0];
|
---|
19 |
|
---|
20 | reg [width-1:0] int_adc_data [size-1:0];
|
---|
21 |
|
---|
22 | integer i;
|
---|
23 | genvar j;
|
---|
24 |
|
---|
25 | altddio_in #(
|
---|
26 | .intended_device_family("Cyclone III"),
|
---|
27 | .invert_input_clocks("ON"),
|
---|
28 | // .invert_input_clocks("OFF"),
|
---|
29 | .lpm_type("altddio_in"),
|
---|
30 | .width(size)) altddio_in_unit (
|
---|
31 | .datain(lvds_d),
|
---|
32 | .inclock(lvds_dco),
|
---|
33 | .aclr(1'b0),
|
---|
34 | .dataout_h(int_data_h),
|
---|
35 | .dataout_l(int_data_l),
|
---|
36 | .aset(1'b0),
|
---|
37 | .inclocken(1'b1),
|
---|
38 | .sclr(1'b0),
|
---|
39 | .sset(1'b0));
|
---|
40 |
|
---|
41 | always @ (posedge lvds_dco)
|
---|
42 | begin
|
---|
43 | for (i = 0; i < size; i = i + 1)
|
---|
44 | begin
|
---|
45 | int_data_reg[i] <= int_data_next[i];
|
---|
46 | end
|
---|
47 | end
|
---|
48 |
|
---|
49 | always @ (posedge lvds_fco)
|
---|
50 | begin
|
---|
51 | for (i = 0; i < size; i = i + 1)
|
---|
52 | begin
|
---|
53 | int_adc_data[i] <= int_data_next[i];
|
---|
54 | // int_data_next[i] = {int_data_reg[i][2*width-2:0], int_data_l[i], int_data_h[i]};
|
---|
55 | end
|
---|
56 | end
|
---|
57 |
|
---|
58 | always @*
|
---|
59 | begin
|
---|
60 | for (i = 0; i < size; i = i + 1)
|
---|
61 | begin
|
---|
62 | int_data_next[i] = {int_data_reg[i][width-3:0], int_data_l[i], int_data_h[i]};
|
---|
63 | // int_data_next[i] = {int_data_reg[i][2*width-2:0], int_data_l[i], int_data_h[i]};
|
---|
64 | end
|
---|
65 | end
|
---|
66 |
|
---|
67 | generate
|
---|
68 | for (j = 0; j < size; j = j + 1)
|
---|
69 | begin : ADC_LVDS_OUTPUT
|
---|
70 | assign adc_data[j*width+width-1:j*width] = int_adc_data[j];
|
---|
71 | end
|
---|
72 | endgenerate
|
---|
73 |
|
---|
74 | endmodule
|
---|