2021-01-18 15:11:57 +00:00
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
// Copyright 2014 - 2021 (c) Analog Devices, Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// In this HDL repository, there are many different and unique modules, consisting
|
|
|
|
// of various HDL (Verilog or VHDL) components. The individual modules are
|
|
|
|
// developed independently, and may be accompanied by separate and unique license
|
|
|
|
// terms.
|
|
|
|
//
|
|
|
|
// The user should read each of these license terms, and understand the
|
|
|
|
// freedoms and responsibilities that he or she has by using this source/core.
|
|
|
|
//
|
|
|
|
// This core is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
|
|
// A PARTICULAR PURPOSE.
|
|
|
|
//
|
|
|
|
// Redistribution and use of source or resulting binaries, with or without modification
|
|
|
|
// of this file, are permitted under one of the following two license terms:
|
|
|
|
//
|
|
|
|
// 1. The GNU General Public License version 2 as published by the
|
|
|
|
// Free Software Foundation, which can be found in the top level directory
|
|
|
|
// of this repository (LICENSE_GPL2), and also online at:
|
|
|
|
// <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
|
|
|
|
//
|
|
|
|
// OR
|
|
|
|
//
|
|
|
|
// 2. An ADI specific BSD license, which can be found in the top level directory
|
|
|
|
// of this repository (LICENSE_ADIBSD), and also on-line at:
|
|
|
|
// https://github.com/analogdevicesinc/hdl/blob/master/LICENSE_ADIBSD
|
|
|
|
// This will allow to generate bit files and not release the source code,
|
|
|
|
// as long as it attaches to an ADI device.
|
|
|
|
//
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
`timescale 1ns/100ps
|
|
|
|
|
|
|
|
// The AD4630-24 device requires this module to capture data in master and
|
|
|
|
// echo clock mode, because the data is clocked by the BUSY/SCLKOUT line,
|
|
|
|
// independent from the SPI interface
|
|
|
|
|
|
|
|
module ad463x_data_capture #(
|
|
|
|
parameter DDR_EN = 0,
|
|
|
|
parameter NUM_OF_LANES = 2,
|
|
|
|
parameter DATA_WIDTH = 32
|
|
|
|
) (
|
|
|
|
input clk, // core clock of the SPIE
|
|
|
|
input csn, // CSN (chip select)
|
|
|
|
input echo_sclk, // BUSY/SCLKOUT
|
|
|
|
input [NUM_OF_LANES-1:0] data_in, // serial data lines
|
|
|
|
|
|
|
|
output [(NUM_OF_LANES * DATA_WIDTH)-1:0] m_axis_data, // parallel data lines
|
|
|
|
output m_axis_valid, // data validation
|
|
|
|
input m_axis_ready // NOTE: back pressure is ignored
|
|
|
|
);
|
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
reg csn_d;
|
2021-01-18 15:11:57 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
wire reset;
|
2021-01-18 15:11:57 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
always @(posedge clk) begin
|
|
|
|
csn_d <= csn;
|
|
|
|
end
|
2021-01-18 15:11:57 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
// negative edge resets the shift registers
|
|
|
|
assign reset = ~csn & csn_d;
|
2021-01-18 15:11:57 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
// CSN positive edge validates the output data
|
|
|
|
// WARNING: there isn't any buffering for data, if the sink module is not
|
|
|
|
// ready, the data will be discarded
|
|
|
|
assign m_axis_valid = csn & ~csn_d & m_axis_ready;
|
2021-01-18 15:11:57 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
genvar i, j;
|
|
|
|
generate
|
|
|
|
if (DDR_EN) // Double Data Rate mode
|
|
|
|
begin
|
2021-01-18 15:11:57 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
for (i=0; i<NUM_OF_LANES; i=i+1) begin
|
2021-01-18 15:11:57 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
reg [DATA_WIDTH-1:0] data_shift_p;
|
|
|
|
reg [DATA_WIDTH-1:0] data_shift_n;
|
2021-01-18 15:11:57 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
// shift register for positive edge
|
|
|
|
always @(negedge echo_sclk or posedge reset) begin
|
|
|
|
if (reset) begin
|
|
|
|
data_shift_n <= 0;
|
|
|
|
end else begin
|
|
|
|
data_shift_n <= {data_shift_n, data_in[i]};
|
|
|
|
end
|
2021-01-18 15:11:57 +00:00
|
|
|
end
|
2022-04-08 10:21:52 +00:00
|
|
|
|
|
|
|
// shift register for positive edge
|
|
|
|
always @(posedge echo_sclk or posedge reset) begin
|
|
|
|
if (reset) begin
|
|
|
|
data_shift_p <= 0;
|
|
|
|
end else begin
|
|
|
|
data_shift_p <= {data_shift_p, data_in[i]};
|
|
|
|
end
|
2021-01-18 15:11:57 +00:00
|
|
|
end
|
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
// DDR output logic - only the first 16 bits are forwarded
|
|
|
|
for (j=0; j<DATA_WIDTH/2; j=j+1) begin
|
|
|
|
assign m_axis_data[DATA_WIDTH*i+(j*2)+:2] = {data_shift_p[j], data_shift_n[j]};
|
|
|
|
end
|
2021-01-18 15:11:57 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
end /* for loop */
|
2021-01-18 15:11:57 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
end else begin // Single Data Rate mode
|
2021-01-18 15:11:57 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
for (i=0; i<NUM_OF_LANES; i=i+1) begin
|
2021-01-18 15:11:57 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
reg [DATA_WIDTH-1:0] data_shift_n;
|
2021-01-18 15:11:57 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
// shift register for positive edge
|
|
|
|
always @(negedge echo_sclk or posedge reset) begin
|
|
|
|
if (reset) begin
|
|
|
|
data_shift_n <= 0;
|
|
|
|
end else begin
|
|
|
|
data_shift_n <= {data_shift_n, data_in[i]};
|
|
|
|
end
|
2021-01-18 15:11:57 +00:00
|
|
|
end
|
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
// SDR output logic
|
|
|
|
assign m_axis_data[DATA_WIDTH*i+:DATA_WIDTH] = data_shift_n;
|
2021-01-18 15:11:57 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
end /* for loop */
|
2021-01-18 15:11:57 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
end
|
|
|
|
endgenerate
|
2021-01-18 15:11:57 +00:00
|
|
|
|
|
|
|
endmodule
|