From 6a526f4bb60b1108b740f724d646897e3bde1c9c Mon Sep 17 00:00:00 2001 From: Istvan Csomortani Date: Mon, 18 Jan 2021 15:11:57 +0000 Subject: [PATCH] ad463x_data_capture: Initial commit IP required to support echo and master clock mode --- library/Makefile | 2 + library/ad463x_data_capture/Makefile | 13 + .../ad463x_data_capture/ad463x_data_capture.v | 134 +++++++++ .../ad463x_data_capture_ip.tcl | 26 ++ .../tb/ad463x_data_capture_tb | 10 + .../tb/ad463x_data_capture_tb.sv | 268 ++++++++++++++++++ 6 files changed, 453 insertions(+) create mode 100644 library/ad463x_data_capture/Makefile create mode 100644 library/ad463x_data_capture/ad463x_data_capture.v create mode 100644 library/ad463x_data_capture/ad463x_data_capture_ip.tcl create mode 100755 library/ad463x_data_capture/tb/ad463x_data_capture_tb create mode 100644 library/ad463x_data_capture/tb/ad463x_data_capture_tb.sv diff --git a/library/Makefile b/library/Makefile index ad0a976ee..69e6b2b18 100644 --- a/library/Makefile +++ b/library/Makefile @@ -13,6 +13,7 @@ all: lib clean: + $(MAKE) -C ad463x_data_capture clean $(MAKE) -C axi_ad5766 clean $(MAKE) -C axi_ad6676 clean $(MAKE) -C axi_ad7616 clean @@ -135,6 +136,7 @@ clean-all:clean lib: + $(MAKE) -C ad463x_data_capture $(MAKE) -C axi_ad5766 $(MAKE) -C axi_ad6676 $(MAKE) -C axi_ad7616 diff --git a/library/ad463x_data_capture/Makefile b/library/ad463x_data_capture/Makefile new file mode 100644 index 000000000..f323d2edf --- /dev/null +++ b/library/ad463x_data_capture/Makefile @@ -0,0 +1,13 @@ +#################################################################################### +## Copyright (c) 2018 - 2021 Analog Devices, Inc. +### SPDX short identifier: BSD-1-Clause +## Auto-generated, do not modify! +#################################################################################### + +LIBRARY_NAME := ad463x_data_capture + +GENERIC_DEPS += ad463x_data_capture.v + +XILINX_DEPS += ad463x_data_capture_ip.tcl + +include ../scripts/library.mk diff --git a/library/ad463x_data_capture/ad463x_data_capture.v b/library/ad463x_data_capture/ad463x_data_capture.v new file mode 100644 index 000000000..6a857c009 --- /dev/null +++ b/library/ad463x_data_capture/ad463x_data_capture.v @@ -0,0 +1,134 @@ +// *************************************************************************** +// *************************************************************************** +// 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: +// +// +// 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 + +); + +reg csn_d; + +wire reset; + +always @(posedge clk) begin + csn_d <= csn; +end + +// negative edge resets the shift registers +assign reset = ~csn & csn_d; + +// 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; + +genvar i, j; +generate +if (DDR_EN) // Double Data Rate mode +begin + + for (i=0; i +// +// 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 + +module ad463x_data_capture_tb (); + + parameter VCD_FILE = {`__FILE__,"cd"}; + + // set to one to increase verbosity + localparam DEBUG = 1; + localparam PASSED = 1; + localparam FAILED = 0; + + localparam DDR_EN = 0; + localparam NUM_OF_LANES = 1; + localparam TRANSFER_CYCLE = 120; + localparam TRANSFER_PERIOD = 40; + + reg clk = 1'b0; + reg [NUM_OF_LANES-1:0] data_in = {NUM_OF_LANES{1'b0}}; + reg m_axis_ready = 1'b1; + reg csn_clk = 1; + + wire csn; + wire echo_sclk; + wire m_axis_valid; + wire [(NUM_OF_LANES *32)-1:0] m_axis_data; + + //--------------------------------------------------------------------------- + // test bench regs and wires + //--------------------------------------------------------------------------- + + reg echo_sclk_int = 0; + integer csn_counter = 0; + + //--------------------------------------------------------------------------- + // VCD dump + //--------------------------------------------------------------------------- + + initial begin + $dumpfile (VCD_FILE); + $dumpvars; + end + + //--------------------------------------------------------------------------- + // clock generation + //--------------------------------------------------------------------------- + + always #5 clk = ~clk; + always #10 echo_sclk_int = ~echo_sclk_int; + + //--------------------------------------------------------------------------- + // chis select generation + //--------------------------------------------------------------------------- + + always @(negedge clk) begin + if (csn_counter == TRANSFER_CYCLE-1) + csn_counter = 0; + else + csn_counter++; + end + assign csn = (csn_counter < TRANSFER_CYCLE - TRANSFER_PERIOD) ? 1'b1 : 1'b0; + + assign echo_sclk = ~csn & echo_sclk_int; + + // CSN for DUT must be synchronous to clk + always @(posedge clk) begin + csn_clk <= csn; + end + //--------------------------------------------------------------------------- + // device BFM - MISO (SDO) generation + //--------------------------------------------------------------------------- + + reg csn_d = 0; + always @(posedge clk) begin + csn_d <= csn; + end + + reg [19:0] data_serial[NUM_OF_LANES-1:0]; + + // SDR + initial begin + while (1) begin + @(posedge echo_sclk or negedge csn); + if (csn_d) begin + for (int i=0; iend_of_sim; + #0 + print_status(tb_status); + + $finish; + end + + //-------------------------------------------------------------------------- + // Helper functions + //-------------------------------------------------------------------------- + + function print_queue(string queue_name, bit [31:0] queue[$]); + begin + $display("======================================"); + $display("Printing %s...", queue_name); + for(int i=0; i