2016-04-19 08:28:33 +00:00
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
2017-05-17 08:44:52 +00:00
|
|
|
// Copyright 2014 - 2017 (c) Analog Devices, Inc. All rights reserved.
|
2016-04-19 08:28:33 +00:00
|
|
|
//
|
2017-05-31 15:15:24 +00:00
|
|
|
// 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
|
2018-03-14 14:45:47 +00:00
|
|
|
// freedoms and responsibilities that he or she has by using this source/core.
|
2017-05-31 15:15:24 +00:00
|
|
|
//
|
|
|
|
// This core is distributed in the hope that it will be useful, but WITHOUT ANY
|
2017-05-29 06:55:41 +00:00
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
|
|
// A PARTICULAR PURPOSE.
|
2016-04-19 08:28:33 +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:
|
2016-04-19 08:28:33 +00:00
|
|
|
//
|
2017-05-17 08:44:52 +00:00
|
|
|
// 1. The GNU General Public License version 2 as published by the
|
2017-05-31 15:15:24 +00:00
|
|
|
// 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>
|
2017-05-17 08:44:52 +00:00
|
|
|
//
|
|
|
|
// OR
|
|
|
|
//
|
2017-05-31 15:15:24 +00:00
|
|
|
// 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:
|
2017-05-29 06:55:41 +00:00
|
|
|
// 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.
|
2016-04-19 08:28:33 +00:00
|
|
|
//
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
`timescale 1ns/100ps
|
|
|
|
|
2017-04-13 08:45:54 +00:00
|
|
|
module axi_dacfifo #(
|
|
|
|
|
|
|
|
parameter DAC_DATA_WIDTH = 64,
|
|
|
|
parameter DMA_DATA_WIDTH = 64,
|
|
|
|
parameter AXI_DATA_WIDTH = 512,
|
|
|
|
parameter AXI_SIZE = 2,
|
|
|
|
parameter AXI_LENGTH = 15,
|
|
|
|
parameter AXI_ADDRESS = 32'h00000000,
|
2022-04-08 10:21:52 +00:00
|
|
|
parameter AXI_ADDRESS_LIMIT = 32'hffffffff
|
|
|
|
) (
|
2016-04-19 08:28:33 +00:00
|
|
|
|
|
|
|
// dma interface (AXI Stream)
|
|
|
|
|
2017-04-13 08:45:54 +00:00
|
|
|
input dma_clk,
|
|
|
|
input dma_rst,
|
|
|
|
input dma_valid,
|
|
|
|
input [(DMA_DATA_WIDTH-1):0] dma_data,
|
|
|
|
output reg dma_ready,
|
|
|
|
input dma_xfer_req,
|
|
|
|
input dma_xfer_last,
|
2016-04-19 08:28:33 +00:00
|
|
|
|
|
|
|
// dac interface
|
|
|
|
|
2017-04-13 08:45:54 +00:00
|
|
|
input dac_clk,
|
|
|
|
input dac_rst,
|
|
|
|
input dac_valid,
|
|
|
|
output reg [(DAC_DATA_WIDTH-1):0] dac_data,
|
|
|
|
output reg dac_dunf,
|
|
|
|
output reg dac_xfer_out,
|
2016-04-19 08:28:33 +00:00
|
|
|
|
2017-04-13 08:45:54 +00:00
|
|
|
input bypass,
|
2016-05-17 08:04:21 +00:00
|
|
|
|
2016-04-19 08:28:33 +00:00
|
|
|
// axi interface
|
|
|
|
|
2017-04-13 08:45:54 +00:00
|
|
|
input axi_clk,
|
|
|
|
input axi_resetn,
|
|
|
|
output axi_awvalid,
|
|
|
|
output [ 3:0] axi_awid,
|
|
|
|
output [ 1:0] axi_awburst,
|
|
|
|
output axi_awlock,
|
|
|
|
output [ 3:0] axi_awcache,
|
|
|
|
output [ 2:0] axi_awprot,
|
|
|
|
output [ 3:0] axi_awqos,
|
|
|
|
output [ 7:0] axi_awlen,
|
|
|
|
output [ 2:0] axi_awsize,
|
|
|
|
output [ 31:0] axi_awaddr,
|
|
|
|
input axi_awready,
|
|
|
|
output axi_wvalid,
|
|
|
|
output [(AXI_DATA_WIDTH-1):0] axi_wdata,
|
|
|
|
output [(AXI_DATA_WIDTH/8-1):0] axi_wstrb,
|
|
|
|
output axi_wlast,
|
|
|
|
input axi_wready,
|
|
|
|
input axi_bvalid,
|
|
|
|
input [ 3:0] axi_bid,
|
|
|
|
input [ 1:0] axi_bresp,
|
|
|
|
output axi_bready,
|
|
|
|
output axi_arvalid,
|
|
|
|
output [ 3:0] axi_arid,
|
|
|
|
output [ 1:0] axi_arburst,
|
|
|
|
output axi_arlock,
|
|
|
|
output [ 3:0] axi_arcache,
|
|
|
|
output [ 2:0] axi_arprot,
|
|
|
|
output [ 3:0] axi_arqos,
|
|
|
|
output [ 7:0] axi_arlen,
|
|
|
|
output [ 2:0] axi_arsize,
|
|
|
|
output [ 31:0] axi_araddr,
|
|
|
|
input axi_arready,
|
|
|
|
input axi_rvalid,
|
|
|
|
input [ 3:0] axi_rid,
|
|
|
|
input [ 1:0] axi_rresp,
|
|
|
|
input axi_rlast,
|
|
|
|
input [(AXI_DATA_WIDTH-1):0] axi_rdata,
|
2022-04-08 10:21:52 +00:00
|
|
|
output axi_rready
|
|
|
|
);
|
2016-04-19 08:28:33 +00:00
|
|
|
|
2017-02-24 10:35:42 +00:00
|
|
|
localparam FIFO_BYPASS = (DAC_DATA_WIDTH == DMA_DATA_WIDTH) ? 1 : 0;
|
|
|
|
|
2017-02-23 15:32:31 +00:00
|
|
|
reg dma_bypass_m1 = 1'b0;
|
|
|
|
reg dma_bypass = 1'b0;
|
|
|
|
reg dac_bypass_m1 = 1'b0;
|
|
|
|
reg dac_bypass = 1'b0;
|
|
|
|
reg dac_xfer_out_m1 = 1'b0;
|
|
|
|
reg dac_xfer_out_bypass = 1'b0;
|
|
|
|
|
2016-04-19 08:28:33 +00:00
|
|
|
wire axi_xfer_req_s;
|
2017-08-04 09:19:12 +00:00
|
|
|
(* dont_touch = "true" *) wire [31:0] axi_last_addr_s;
|
|
|
|
(* dont_touch = "true" *) wire [ 7:0] axi_last_beats_s;
|
2016-07-20 08:27:06 +00:00
|
|
|
wire [ 3:0] dma_last_beats_s;
|
2017-02-23 15:32:31 +00:00
|
|
|
wire [(DAC_DATA_WIDTH-1):0] dac_data_fifo_s;
|
|
|
|
wire [(DAC_DATA_WIDTH-1):0] dac_data_bypass_s;
|
|
|
|
wire dac_xfer_fifo_out_s;
|
|
|
|
wire dac_dunf_fifo_s;
|
|
|
|
wire dac_dunf_bypass_s;
|
|
|
|
wire dma_ready_wr_s;
|
2016-04-19 08:28:33 +00:00
|
|
|
|
|
|
|
axi_dacfifo_wr #(
|
|
|
|
.AXI_DATA_WIDTH (AXI_DATA_WIDTH),
|
|
|
|
.DMA_DATA_WIDTH (DMA_DATA_WIDTH),
|
2016-05-17 14:07:18 +00:00
|
|
|
.AXI_SIZE (AXI_SIZE),
|
|
|
|
.AXI_LENGTH (AXI_LENGTH),
|
2016-04-19 08:28:33 +00:00
|
|
|
.AXI_ADDRESS (AXI_ADDRESS),
|
2017-07-06 09:11:50 +00:00
|
|
|
.AXI_ADDRESS_LIMIT (AXI_ADDRESS_LIMIT),
|
2017-08-04 09:19:12 +00:00
|
|
|
.DMA_MEM_ADDRESS_WIDTH (12)
|
2016-04-19 08:28:33 +00:00
|
|
|
) i_wr (
|
|
|
|
.dma_clk (dma_clk),
|
2017-08-04 09:19:12 +00:00
|
|
|
.dma_rst (dma_rst),
|
2016-04-19 08:28:33 +00:00
|
|
|
.dma_data (dma_data),
|
2017-02-23 15:32:31 +00:00
|
|
|
.dma_ready (dma_ready),
|
|
|
|
.dma_ready_out (dma_ready_wr_s),
|
2016-04-19 08:28:33 +00:00
|
|
|
.dma_valid (dma_valid),
|
|
|
|
.dma_xfer_req (dma_xfer_req),
|
|
|
|
.dma_xfer_last (dma_xfer_last),
|
2016-07-20 08:27:06 +00:00
|
|
|
.dma_last_beats (dma_last_beats_s),
|
2016-05-26 11:25:36 +00:00
|
|
|
.axi_last_addr (axi_last_addr_s),
|
2016-07-20 08:27:06 +00:00
|
|
|
.axi_last_beats (axi_last_beats_s),
|
2016-04-19 08:28:33 +00:00
|
|
|
.axi_xfer_out (axi_xfer_req_s),
|
|
|
|
.axi_clk (axi_clk),
|
|
|
|
.axi_resetn (axi_resetn),
|
|
|
|
.axi_awvalid (axi_awvalid),
|
|
|
|
.axi_awid (axi_awid),
|
|
|
|
.axi_awburst (axi_awburst),
|
|
|
|
.axi_awlock (axi_awlock),
|
|
|
|
.axi_awcache (axi_awcache),
|
|
|
|
.axi_awprot (axi_awprot),
|
|
|
|
.axi_awqos (axi_awqos),
|
|
|
|
.axi_awlen (axi_awlen),
|
|
|
|
.axi_awsize (axi_awsize),
|
|
|
|
.axi_awaddr (axi_awaddr),
|
|
|
|
.axi_awready (axi_awready),
|
|
|
|
.axi_wvalid (axi_wvalid),
|
|
|
|
.axi_wdata (axi_wdata),
|
|
|
|
.axi_wstrb (axi_wstrb),
|
|
|
|
.axi_wlast (axi_wlast),
|
|
|
|
.axi_wready (axi_wready),
|
|
|
|
.axi_bvalid (axi_bvalid),
|
|
|
|
.axi_bid (axi_bid),
|
|
|
|
.axi_bresp (axi_bresp),
|
|
|
|
.axi_bready (axi_bready),
|
|
|
|
.axi_werror (axi_werror));
|
|
|
|
|
|
|
|
axi_dacfifo_rd #(
|
|
|
|
.AXI_DATA_WIDTH (AXI_DATA_WIDTH),
|
2016-05-17 14:07:18 +00:00
|
|
|
.AXI_SIZE (AXI_SIZE),
|
|
|
|
.AXI_LENGTH (AXI_LENGTH),
|
2017-08-04 09:19:12 +00:00
|
|
|
.AXI_ADDRESS (AXI_ADDRESS),
|
|
|
|
.DAC_DATA_WIDTH (DAC_DATA_WIDTH),
|
|
|
|
.DAC_MEM_ADDRESS_WIDTH (12)
|
2016-04-19 08:28:33 +00:00
|
|
|
) i_rd (
|
|
|
|
.axi_xfer_req (axi_xfer_req_s),
|
2016-07-20 08:27:06 +00:00
|
|
|
.axi_last_raddr (axi_last_addr_s),
|
|
|
|
.axi_last_beats (axi_last_beats_s),
|
2016-04-19 08:28:33 +00:00
|
|
|
.axi_clk (axi_clk),
|
|
|
|
.axi_resetn (axi_resetn),
|
|
|
|
.axi_arvalid (axi_arvalid),
|
|
|
|
.axi_arid (axi_arid),
|
|
|
|
.axi_arburst (axi_arburst),
|
|
|
|
.axi_arlock (axi_arlock),
|
|
|
|
.axi_arcache (axi_arcache),
|
|
|
|
.axi_arprot (axi_arprot),
|
|
|
|
.axi_arqos (axi_arqos),
|
|
|
|
.axi_arlen (axi_arlen),
|
|
|
|
.axi_arsize (axi_arsize),
|
|
|
|
.axi_araddr (axi_araddr),
|
|
|
|
.axi_arready (axi_arready),
|
|
|
|
.axi_rvalid (axi_rvalid),
|
|
|
|
.axi_rid (axi_rid),
|
|
|
|
.axi_rresp (axi_rresp),
|
|
|
|
.axi_rlast (axi_rlast),
|
|
|
|
.axi_rdata (axi_rdata),
|
|
|
|
.axi_rready (axi_rready),
|
|
|
|
.axi_rerror (axi_rerror),
|
2016-07-20 08:27:06 +00:00
|
|
|
.dma_last_beats (dma_last_beats_s),
|
2016-04-19 08:28:33 +00:00
|
|
|
.dac_clk (dac_clk),
|
2016-05-17 08:30:41 +00:00
|
|
|
.dac_rst (dac_rst),
|
2016-04-19 08:28:33 +00:00
|
|
|
.dac_valid (dac_valid),
|
2017-02-23 15:32:31 +00:00
|
|
|
.dac_data (dac_data_fifo_s),
|
|
|
|
.dac_xfer_out (dac_xfer_fifo_out_s),
|
|
|
|
.dac_dunf (dac_dunf_fifo_s));
|
2016-04-19 08:28:33 +00:00
|
|
|
|
2017-02-24 10:35:42 +00:00
|
|
|
// bypass logic -- supported if DAC_DATA_WIDTH == DMA_DATA_WIDTH
|
|
|
|
|
|
|
|
generate
|
|
|
|
if (FIFO_BYPASS) begin
|
|
|
|
|
2017-04-21 10:23:03 +00:00
|
|
|
util_dacfifo_bypass #(
|
2017-02-24 10:35:42 +00:00
|
|
|
.DAC_DATA_WIDTH (DAC_DATA_WIDTH),
|
|
|
|
.DMA_DATA_WIDTH (DMA_DATA_WIDTH)
|
|
|
|
) i_dacfifo_bypass (
|
|
|
|
.dma_clk(dma_clk),
|
|
|
|
.dma_data(dma_data),
|
|
|
|
.dma_ready(dma_ready),
|
|
|
|
.dma_ready_out(dma_ready_bypass_s),
|
|
|
|
.dma_valid(dma_valid),
|
|
|
|
.dma_xfer_req(dma_xfer_req),
|
|
|
|
.dac_clk(dac_clk),
|
|
|
|
.dac_rst(dac_rst),
|
|
|
|
.dac_valid(dac_valid),
|
|
|
|
.dac_data(dac_data_bypass_s),
|
2022-04-08 10:21:52 +00:00
|
|
|
.dac_dunf(dac_dunf_bypass_s));
|
2017-02-24 10:35:42 +00:00
|
|
|
|
|
|
|
always @(posedge dma_clk) begin
|
|
|
|
dma_bypass_m1 <= bypass;
|
|
|
|
dma_bypass <= dma_bypass_m1;
|
|
|
|
end
|
|
|
|
|
|
|
|
always @(posedge dac_clk) begin
|
|
|
|
dac_bypass_m1 <= bypass;
|
|
|
|
dac_bypass <= dac_bypass_m1;
|
|
|
|
dac_xfer_out_m1 <= dma_xfer_req;
|
|
|
|
dac_xfer_out_bypass <= dac_xfer_out_m1;
|
|
|
|
end
|
|
|
|
|
|
|
|
// mux for the dma_ready
|
|
|
|
|
|
|
|
always @(posedge dma_clk) begin
|
2017-07-06 07:31:51 +00:00
|
|
|
dma_ready <= (dma_bypass) ? dma_ready_bypass_s : dma_ready_wr_s;
|
2017-02-24 10:35:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
// mux for dac data
|
|
|
|
|
|
|
|
always @(posedge dac_clk) begin
|
|
|
|
if (dac_valid) begin
|
|
|
|
dac_data <= (dac_bypass) ? dac_data_bypass_s : dac_data_fifo_s;
|
|
|
|
end
|
|
|
|
dac_xfer_out <= (dac_bypass) ? dac_xfer_out_bypass : dac_xfer_fifo_out_s;
|
|
|
|
dac_dunf <= (dac_bypass) ? dac_dunf_bypass_s : dac_dunf_fifo_s;
|
|
|
|
end
|
|
|
|
|
|
|
|
end else begin /* if (~FIFO_BYPASS) */
|
|
|
|
|
|
|
|
always @(posedge dma_clk) begin
|
|
|
|
dma_ready <= dma_ready_wr_s;
|
|
|
|
end
|
|
|
|
always @(posedge dac_clk) begin
|
|
|
|
if (dac_valid) begin
|
|
|
|
dac_data <= dac_data_fifo_s;
|
|
|
|
end
|
|
|
|
dac_xfer_out <= dac_xfer_fifo_out_s;
|
|
|
|
dac_dunf <= dac_dunf_fifo_s;
|
|
|
|
end
|
2017-02-23 15:32:31 +00:00
|
|
|
|
|
|
|
end
|
2017-02-24 10:35:42 +00:00
|
|
|
endgenerate
|
2016-05-17 08:04:21 +00:00
|
|
|
|
2016-04-19 08:28:33 +00:00
|
|
|
endmodule
|