49 lines
1.6 KiB
Systemverilog
49 lines
1.6 KiB
Systemverilog
`timescale 1ns/1ps
|
|
// One physical AD9216, cores A and B in one forwarded-clock domain.
|
|
// Raw pad registers have no reset or clock enable to permit IOB placement.
|
|
// Offset binary, right aligned: [15:10]=0, [31:26]=0.
|
|
// ADC wake-up/reference settling is external; ready must mean already settled.
|
|
module adc_capture (
|
|
input wire adc_clk,
|
|
input wire arst_n,
|
|
input wire ready_async,
|
|
input wire [9:0] adc_data_a,
|
|
input wire [9:0] adc_data_b,
|
|
output reg [31:0] sample_word,
|
|
output reg sample_valid,
|
|
output reg [63:0] sample_index
|
|
);
|
|
wire rst;
|
|
reset_sync reset_i (.clk(adc_clk), .arst_n(arst_n), .rst(rst));
|
|
(* IOB = "TRUE" *) reg [9:0] input_a, input_b;
|
|
(* ASYNC_REG = "TRUE", SHREG_EXTRACT = "NO" *) reg [1:0] ready_pipe;
|
|
reg warm;
|
|
reg [63:0] next_index;
|
|
always @(posedge adc_clk) begin
|
|
input_a <= adc_data_a;
|
|
input_b <= adc_data_b;
|
|
end
|
|
always @(posedge adc_clk or negedge arst_n) begin
|
|
if (!arst_n) ready_pipe <= 0;
|
|
else if (rst) ready_pipe <= 0;
|
|
else ready_pipe <= {ready_pipe[0], ready_async};
|
|
end
|
|
always @(posedge adc_clk) begin
|
|
if (rst) begin
|
|
sample_word <= 0;
|
|
sample_valid <= 0;
|
|
sample_index <= 0;
|
|
next_index <= 0;
|
|
warm <= 0;
|
|
end else begin
|
|
sample_word <= {6'b0, input_b, 6'b0, input_a};
|
|
warm <= ready_pipe[1];
|
|
sample_valid <= ready_pipe[1] && warm;
|
|
if (ready_pipe[1] && warm) begin
|
|
sample_index <= next_index;
|
|
next_index <= next_index + 1'b1;
|
|
end
|
|
end
|
|
end
|
|
endmodule
|