source: sandbox/MultiChannelUSB/adc_lvds.v@ 147

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

add DDIO_INPUT_REGISTER attribute

File size: 2.3 KB
Line 
1
2(* ALTERA_ATTRIBUTE = {"{-to int_data_p} DDIO_INPUT_REGISTER=HIGH; {-to int_data_n} DDIO_INPUT_REGISTER=LOW"} *)
3
4module adc_lvds
5 #(
6 parameter size = 8, // number of channels
7 parameter width = 24 // channel resolution
8 )
9 (
10 input wire clock,
11
12 input wire lvds_dco,
13 input wire lvds_fco,
14 input wire [size-1:0] lvds_d,
15
16 output wire adc_frame,
17 output wire [size*width-1:0] adc_data
18
19 );
20
21 reg state, int_rdreq, adc_frame_reg;
22 wire int_wrfull, int_rdempty;
23
24 reg [size-1:0] int_data_p, int_data_n;
25
26 reg [size*width-1:0] int_data_reg;
27 wire [size*width-1:0] int_data_wire;
28
29 wire [size*width-1:0] int_q_wire;
30 reg [size*width-1:0] adc_data_reg;
31
32
33
34 genvar j;
35
36 generate
37 for (j = 0; j < size; j = j + 1)
38 begin : INT_DATA
39// MSB first
40// assign int_data_wire[j*width+width-1:j*width] = {int_data_reg[j*width+width-3:j*width], int_data_p[j], int_data_n[j]};
41// LSB first
42 assign int_data_wire[j*width+width-1:j*width] = {int_data_n[j], int_data_p[j], int_data_reg[j*width+width-1:j*width+2]};
43 end
44 endgenerate
45
46 dcfifo #(
47 .intended_device_family("Cyclone III"),
48 .lpm_numwords(16),
49 .lpm_showahead("ON"),
50 .lpm_type("dcfifo"),
51 .lpm_width(size*width),
52 .lpm_widthu(4),
53 .rdsync_delaypipe(4),
54 .wrsync_delaypipe(4),
55 .overflow_checking("ON"),
56 .underflow_checking("ON"),
57 .use_eab("ON")) fifo_unit (
58 .data(int_data_wire),
59 .rdclk(clock),
60 .rdreq((~int_rdempty) & int_rdreq),
61 .wrclk(lvds_fco),
62 .wrreq(~int_wrfull),
63 .q(int_q_wire),
64 .rdempty(int_rdempty),
65 .wrfull(int_wrfull),
66 .aclr(),
67 .rdfull(),
68 .rdusedw(),
69 .wrempty(),
70 .wrusedw());
71
72 always @ (posedge clock)
73 begin
74 case (state)
75 1'b0:
76 begin
77 int_rdreq <= 1'b1;
78 adc_frame_reg <= 1'b0;
79 state <= 1'b1;
80 end
81
82 1'b1:
83 begin
84 if (~int_rdempty)
85 begin
86 int_rdreq <= 1'b0;
87 adc_frame_reg <= 1'b1;
88 adc_data_reg <= int_q_wire;
89 state <= 1'b0;
90 end
91 end
92 endcase
93 end
94
95 always @ (negedge lvds_dco)
96 begin
97 int_data_n <= lvds_d;
98 end
99
100 always @ (posedge lvds_dco)
101 begin
102 int_data_p <= lvds_d;
103 int_data_reg <= int_data_wire;
104
105 end
106
107 assign adc_frame = adc_frame_reg;
108 assign adc_data = adc_data_reg;
109
110endmodule
Note: See TracBrowser for help on using the repository browser.