2017-05-17 08:44:52 +00:00
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
// Copyright 2014 - 2017 (c) Analog Devices, Inc. All rights reserved.
|
|
|
|
//
|
2017-05-29 06:55:41 +00:00
|
|
|
// 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.
|
2017-05-17 08:44:52 +00:00
|
|
|
//
|
2017-05-29 06:55:41 +00:00
|
|
|
// 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:
|
2017-05-17 08:44:52 +00:00
|
|
|
//
|
|
|
|
// 1. The GNU General Public License version 2 as published by the
|
2017-05-29 06:55:41 +00:00
|
|
|
// Free Software Foundation, which can be found in the top level directory of
|
|
|
|
// the repository (LICENSE_GPL2), and at: <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
|
2017-05-17 08:44:52 +00:00
|
|
|
//
|
|
|
|
// OR
|
2017-01-31 14:18:58 +00:00
|
|
|
//
|
2017-05-29 06:55:41 +00:00
|
|
|
// 2. An ADI specific BSD license as noted in the top level directory, or 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.
|
2017-01-31 14:18:58 +00:00
|
|
|
//
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
`timescale 1ns/100ps
|
|
|
|
|
|
|
|
module axi_ad9963_if #(
|
|
|
|
|
|
|
|
// this parameter controls the buffer type based on the target device.
|
|
|
|
|
|
|
|
parameter DEVICE_TYPE = 0,
|
2017-04-17 11:12:06 +00:00
|
|
|
parameter ADC_IODELAY_ENABLE = 0,
|
2017-01-31 14:18:58 +00:00
|
|
|
parameter IO_DELAY_GROUP = "dev_if_delay_group") (
|
|
|
|
|
|
|
|
// physical interface (receive)
|
|
|
|
|
|
|
|
input trx_clk,
|
|
|
|
input trx_iq,
|
|
|
|
input [11:0] trx_data,
|
|
|
|
|
|
|
|
// physical interface (transmit)
|
|
|
|
|
2017-03-29 07:28:38 +00:00
|
|
|
input tx_clk,
|
2017-01-31 14:18:58 +00:00
|
|
|
output tx_iq,
|
|
|
|
output [11:0] tx_data,
|
|
|
|
|
|
|
|
// clock (common to both receive and transmit)
|
|
|
|
|
2017-03-29 08:01:44 +00:00
|
|
|
input adc_rst,
|
2017-03-29 07:28:38 +00:00
|
|
|
input dac_rst,
|
2017-03-29 08:01:44 +00:00
|
|
|
output adc_clk,
|
|
|
|
output dac_clk,
|
2017-01-31 14:18:58 +00:00
|
|
|
|
|
|
|
// receive data path interface
|
|
|
|
|
|
|
|
output reg adc_valid,
|
|
|
|
output reg [23:0] adc_data,
|
|
|
|
output reg adc_status,
|
2017-04-18 09:24:42 +00:00
|
|
|
input up_adc_ce,
|
2017-01-31 14:18:58 +00:00
|
|
|
|
|
|
|
// transmit data path interface
|
|
|
|
|
2017-04-18 09:24:42 +00:00
|
|
|
input dac_valid,
|
|
|
|
input [23:0] dac_data,
|
|
|
|
input up_dac_ce,
|
2017-01-31 14:18:58 +00:00
|
|
|
|
|
|
|
// delay interface
|
|
|
|
|
2017-04-18 09:24:42 +00:00
|
|
|
input up_clk,
|
|
|
|
input [12:0] up_adc_dld,
|
|
|
|
input [64:0] up_adc_dwdata,
|
|
|
|
output [64:0] up_adc_drdata,
|
|
|
|
input delay_clk,
|
|
|
|
input delay_rst,
|
|
|
|
output delay_locked);
|
2017-01-31 14:18:58 +00:00
|
|
|
|
|
|
|
// internal registers
|
|
|
|
|
|
|
|
reg [11:0] rx_data_p = 0;
|
|
|
|
reg [11:0] tx_data_p = 'd0;
|
|
|
|
reg [11:0] tx_data_n = 'd0;
|
|
|
|
|
|
|
|
// internal signals
|
|
|
|
|
|
|
|
wire [11:0] rx_data_p_s;
|
|
|
|
wire [11:0] rx_data_n_s;
|
|
|
|
wire rx_iq_p_s;
|
|
|
|
wire rx_iq_n_s;
|
|
|
|
|
2017-03-29 07:28:38 +00:00
|
|
|
wire div_clk;
|
2017-01-31 14:18:58 +00:00
|
|
|
|
|
|
|
genvar l_inst;
|
|
|
|
|
2017-03-29 08:01:44 +00:00
|
|
|
always @(posedge adc_clk) begin
|
2017-01-31 14:18:58 +00:00
|
|
|
if( rx_iq_p_s == 1'b1) begin
|
|
|
|
adc_data <= {rx_data_n_s, rx_data_p_s} ; // data[11:00] I
|
|
|
|
adc_valid <= 1'b1; // data[23:12] Q
|
|
|
|
end else begin
|
|
|
|
rx_data_p <= rx_data_p_s; // if this happens it means that risedge data is sampled on falledge
|
2017-04-18 09:24:42 +00:00
|
|
|
adc_data <= {rx_data_p, rx_data_n_s}; // so we take current N data with previous P data
|
2017-01-31 14:18:58 +00:00
|
|
|
adc_valid <= 1'b1; // in order to have data sampled at the same instance sent to the DMA
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
always @(posedge dac_clk) begin
|
|
|
|
if(dac_valid == 1'b1) begin
|
|
|
|
tx_data_p <= dac_data[11:0] ;
|
|
|
|
tx_data_n <= dac_data[23:12];
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-03-29 08:01:44 +00:00
|
|
|
always @(posedge adc_clk) begin
|
|
|
|
if (adc_rst == 1'b1) begin
|
2017-01-31 14:18:58 +00:00
|
|
|
adc_status <= 1'b0;
|
|
|
|
end else begin
|
|
|
|
adc_status <= 1'b1;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
// device clock interface (receive clock)
|
|
|
|
|
2017-04-18 09:24:42 +00:00
|
|
|
BUFGCTRL #(
|
|
|
|
.INIT_OUT(0),
|
|
|
|
.PRESELECT_I0("FALSE"),
|
|
|
|
.PRESELECT_I1("FALSE")
|
|
|
|
)
|
|
|
|
bufgctrl_adc (
|
|
|
|
.O(adc_clk),
|
|
|
|
.CE0(1'b1),
|
|
|
|
.CE1(1'b0),
|
|
|
|
.I0(trx_clk),
|
|
|
|
.I1(1'b0),
|
|
|
|
.IGNORE0(1'b0),
|
|
|
|
.IGNORE1(1'b0),
|
|
|
|
.S0(up_adc_ce),
|
|
|
|
.S1(1'b0)
|
|
|
|
);
|
2017-01-31 14:18:58 +00:00
|
|
|
|
|
|
|
// receive data interface, ibuf -> idelay -> iddr
|
|
|
|
|
|
|
|
generate
|
|
|
|
for (l_inst = 0; l_inst <= 11; l_inst = l_inst + 1) begin: g_rx_data
|
|
|
|
ad_lvds_in #(
|
|
|
|
.SINGLE_ENDED (1),
|
|
|
|
.DEVICE_TYPE (DEVICE_TYPE),
|
2017-04-17 11:12:06 +00:00
|
|
|
.IODELAY_ENABLE (ADC_IODELAY_ENABLE),
|
2017-01-31 14:18:58 +00:00
|
|
|
.IODELAY_CTRL (0),
|
|
|
|
.IODELAY_GROUP (IO_DELAY_GROUP))
|
|
|
|
i_rx_data (
|
2017-03-29 08:01:44 +00:00
|
|
|
.rx_clk (adc_clk),
|
2017-01-31 14:18:58 +00:00
|
|
|
.rx_data_in_p (trx_data[l_inst]),
|
|
|
|
.rx_data_in_n (1'b0),
|
|
|
|
.rx_data_p (rx_data_p_s[l_inst]),
|
|
|
|
.rx_data_n (rx_data_n_s[l_inst]),
|
|
|
|
.up_clk (up_clk),
|
|
|
|
.up_dld (up_adc_dld[l_inst]),
|
|
|
|
.up_dwdata (up_adc_dwdata[((l_inst*5)+4):(l_inst*5)]),
|
|
|
|
.up_drdata (up_adc_drdata[((l_inst*5)+4):(l_inst*5)]),
|
|
|
|
.delay_clk (delay_clk),
|
|
|
|
.delay_rst (delay_rst),
|
|
|
|
.delay_locked ());
|
|
|
|
end
|
|
|
|
endgenerate
|
|
|
|
|
|
|
|
// receive iq interface, ibuf -> idelay -> iddr
|
|
|
|
|
|
|
|
ad_lvds_in #(
|
|
|
|
.SINGLE_ENDED (1),
|
|
|
|
.DEVICE_TYPE (DEVICE_TYPE),
|
2017-04-17 11:12:06 +00:00
|
|
|
.IODELAY_ENABLE (ADC_IODELAY_ENABLE),
|
2017-01-31 14:18:58 +00:00
|
|
|
.IODELAY_CTRL (1),
|
|
|
|
.IODELAY_GROUP (IO_DELAY_GROUP))
|
|
|
|
i_rx_iq (
|
2017-03-29 08:01:44 +00:00
|
|
|
.rx_clk (adc_clk),
|
2017-01-31 14:18:58 +00:00
|
|
|
.rx_data_in_p (trx_iq),
|
|
|
|
.rx_data_in_n (1'b0),
|
|
|
|
.rx_data_p (rx_iq_p_s),
|
|
|
|
.rx_data_n (rx_iq_n_s),
|
|
|
|
.up_clk (up_clk),
|
|
|
|
.up_dld (up_adc_dld[12]),
|
|
|
|
.up_dwdata (up_adc_dwdata[64:60]),
|
|
|
|
.up_drdata (up_adc_drdata[64:60]),
|
|
|
|
.delay_clk (delay_clk),
|
|
|
|
.delay_rst (delay_rst),
|
|
|
|
.delay_locked (delay_locked));
|
|
|
|
|
2017-03-29 07:28:38 +00:00
|
|
|
// transmit data interface
|
|
|
|
|
2017-03-30 18:12:58 +00:00
|
|
|
BUFR #(.BUFR_DIVIDE(2)) i_div_clk_buf (
|
|
|
|
.CLR (1'b0),
|
|
|
|
.CE (1'b1),
|
|
|
|
.I (tx_clk),
|
|
|
|
.O (div_clk));
|
|
|
|
|
2017-04-18 09:24:42 +00:00
|
|
|
BUFGCTRL #(
|
|
|
|
.INIT_OUT(0),
|
|
|
|
.PRESELECT_I0("FALSE"),
|
|
|
|
.PRESELECT_I1("FALSE")
|
|
|
|
)
|
|
|
|
bufgctrl_dac (
|
|
|
|
.O(dac_clk),
|
|
|
|
.CE0(1'b1),
|
|
|
|
.CE1(1'b0),
|
|
|
|
.I0(div_clk),
|
|
|
|
.I1(1'b0),
|
|
|
|
.IGNORE0(1'b0),
|
|
|
|
.IGNORE1(1'b0),
|
|
|
|
.S0(up_dac_ce),
|
|
|
|
.S1(1'b0)
|
|
|
|
);
|
2017-03-29 07:28:38 +00:00
|
|
|
|
2017-03-30 18:12:58 +00:00
|
|
|
generate
|
|
|
|
for (l_inst = 0; l_inst <= 11; l_inst = l_inst + 1) begin: g_tx_data
|
|
|
|
ODDR #(
|
|
|
|
.DDR_CLK_EDGE ("SAME_EDGE"),
|
|
|
|
.INIT (1'b0),
|
|
|
|
.SRTYPE ("SYNC"))
|
|
|
|
i_tx_data_oddr (
|
|
|
|
.CE (1'b1),
|
|
|
|
.R (dac_rst),
|
|
|
|
.S (1'b0),
|
|
|
|
.C (dac_clk),
|
|
|
|
.D1 (tx_data_p[l_inst]),
|
|
|
|
.D2 (tx_data_n[l_inst]),
|
|
|
|
.Q (tx_data[l_inst]));
|
|
|
|
end
|
|
|
|
endgenerate
|
|
|
|
|
|
|
|
ODDR #(
|
|
|
|
.DDR_CLK_EDGE ("SAME_EDGE"),
|
|
|
|
.INIT (1'b0),
|
|
|
|
.SRTYPE ("SYNC"))
|
|
|
|
i_tx_data_oddr (
|
|
|
|
.CE (1'b1),
|
|
|
|
.R (dac_rst),
|
|
|
|
.S (1'b0),
|
|
|
|
.C (dac_clk),
|
|
|
|
.D1 (1'b1),
|
|
|
|
.D2 (1'b0),
|
|
|
|
.Q (tx_iq));
|
2017-01-31 14:18:58 +00:00
|
|
|
|
|
|
|
endmodule
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|