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
RevLine 
[146]1
2(* ALTERA_ATTRIBUTE = {"{-to int_data_p} DDIO_INPUT_REGISTER=HIGH; {-to int_data_n} DDIO_INPUT_REGISTER=LOW"} *)
3
[41]4module adc_lvds
[63]5 #(
[140]6 parameter size = 8, // number of channels
7 parameter width = 24 // channel resolution
[63]8 )
[41]9 (
[107]10 input wire clock,
11
[63]12 input wire lvds_dco,
13 input wire lvds_fco,
[72]14 input wire [size-1:0] lvds_d,
[41]15
[107]16 output wire adc_frame,
[140]17 output wire [size*width-1:0] adc_data
[107]18
[41]19 );
[140]20
[107]21 reg state, int_rdreq, adc_frame_reg;
22 wire int_wrfull, int_rdempty;
[41]23
[140]24 reg [size-1:0] int_data_p, int_data_n;
[63]25
[147]26 reg [size*width-1:0] int_data_reg;
27 wire [size*width-1:0] int_data_wire;
[107]28
[140]29 wire [size*width-1:0] int_q_wire;
30 reg [size*width-1:0] adc_data_reg;
[107]31
32
[140]33
[63]34 genvar j;
35
[107]36 generate
[140]37 for (j = 0; j < size; j = j + 1)
[107]38 begin : INT_DATA
[140]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
[147]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]};
[107]43 end
44 endgenerate
45
46 dcfifo #(
[41]47 .intended_device_family("Cyclone III"),
[107]48 .lpm_numwords(16),
49 .lpm_showahead("ON"),
50 .lpm_type("dcfifo"),
[140]51 .lpm_width(size*width),
[107]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 (
[147]58 .data(int_data_wire),
[107]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());
[41]71
[107]72 always @ (posedge clock)
[41]73 begin
[107]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
[42]93 end
[107]94
95 always @ (negedge lvds_dco)
[42]96 begin
[140]97 int_data_n <= lvds_d;
[41]98 end
99
[107]100 always @ (posedge lvds_dco)
[42]101 begin
[140]102 int_data_p <= lvds_d;
[107]103 int_data_reg <= int_data_wire;
[147]104
[42]105 end
[41]106
[107]107 assign adc_frame = adc_frame_reg;
108 assign adc_data = adc_data_reg;
[63]109
[58]110endmodule
Note: See TracBrowser for help on using the repository browser.