Changeset 107 for sandbox/MultiChannelUSB/adc_lvds.v
- Timestamp:
- Jan 17, 2011, 5:56:35 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/MultiChannelUSB/adc_lvds.v
r98 r107 5 5 ) 6 6 ( 7 input wire clock, 8 7 9 input wire lvds_dco, 8 10 input wire lvds_fco, 9 11 input wire [size-1:0] lvds_d, 10 12 11 output wire [size*width-1:0] adc_data 13 input wire [11:0] test, 14 input wire [11:0] trig, 15 16 output wire adc_frame, 17 output wire [size*width-1+12:0] adc_data 18 12 19 ); 13 20 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]; 21 reg state, int_rdreq, adc_frame_reg; 22 wire int_wrfull, int_rdempty; 19 23 20 reg [width-1:0] int_adc_data [size-1:0];24 reg [size-1:0] int_data_h, int_data_l; 21 25 22 integer i; 26 reg [size*width-1:0] int_data_reg; 27 wire [size*width-1:0] int_data_wire; 28 29 wire [size*width-1+12:0] int_q_wire; 30 reg [size*width-1+12:0] adc_data_reg; 31 32 23 33 genvar j; 24 34 25 altddio_in #( 35 generate 36 for (j = 0; j < size-1; j = j + 1) 37 begin : INT_DATA 38 assign int_data_wire[j*width+width-1:j*width] = {int_data_reg[j*width+width-3:j*width], int_data_h[j], int_data_l[j]}; 39 // assign int_data_wire[j*width+width-1:j*width] = test; 40 end 41 endgenerate 42 assign int_data_wire[(size-1)*width+width-1:(size-1)*width] = test; 43 44 dcfifo #( 26 45 .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)); 46 .lpm_numwords(16), 47 .lpm_showahead("ON"), 48 .lpm_type("dcfifo"), 49 .lpm_width(size*width+12), 50 .lpm_widthu(4), 51 .rdsync_delaypipe(4), 52 .wrsync_delaypipe(4), 53 .overflow_checking("ON"), 54 .underflow_checking("ON"), 55 .use_eab("ON")) fifo_unit ( 56 .data({trig, int_data_wire}), 57 .rdclk(clock), 58 .rdreq((~int_rdempty) & int_rdreq), 59 .wrclk(lvds_fco), 60 .wrreq(~int_wrfull), 61 .q(int_q_wire), 62 .rdempty(int_rdempty), 63 .wrfull(int_wrfull), 64 .aclr(), 65 .rdfull(), 66 .rdusedw(), 67 .wrempty(), 68 .wrusedw()); 69 70 always @ (posedge clock) 71 begin 72 case (state) 73 1'b0: 74 begin 75 int_rdreq <= 1'b1; 76 adc_frame_reg <= 1'b0; 77 state <= 1'b1; 78 end 79 80 1'b1: 81 begin 82 if (~int_rdempty) 83 begin 84 int_rdreq <= 1'b0; 85 adc_frame_reg <= 1'b1; 86 adc_data_reg <= int_q_wire; 87 state <= 1'b0; 88 end 89 end 90 endcase 91 end 92 93 always @ (negedge lvds_dco) 94 begin 95 int_data_l <= lvds_d; 96 end 40 97 41 98 always @ (posedge lvds_dco) 42 99 begin 43 for (i = 0; i < size; i = i + 1) 44 begin 45 int_data_reg[i] <= int_data_next[i]; 46 end 100 int_data_h <= lvds_d; 101 int_data_reg <= int_data_wire; 47 102 end 48 103 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 104 assign adc_frame = adc_frame_reg; 105 assign adc_data = adc_data_reg; 73 106 74 107 endmodule
Note:
See TracChangeset
for help on using the changeset viewer.