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-17 08:44:52 +00:00
|
|
|
// Each core or library found in this collection may have its own licensing terms.
|
|
|
|
// The user should keep this in in mind while exploring these cores.
|
2016-04-19 08:28:33 +00:00
|
|
|
//
|
2017-05-17 08:44:52 +00:00
|
|
|
// Redistribution and use in source and binary forms,
|
|
|
|
// with or without modification of this file, are permitted under the terms of either
|
|
|
|
// (at the option of the user):
|
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
|
|
|
|
// Free Software Foundation, which can be found in the top level directory, or at:
|
|
|
|
// https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html
|
|
|
|
//
|
|
|
|
// OR
|
|
|
|
//
|
|
|
|
// 2. An ADI specific BSD license as noted in the top level directory, or on-line at:
|
|
|
|
// https://github.com/analogdevicesinc/hdl/blob/dev/LICENSE
|
2016-04-19 08:28:33 +00:00
|
|
|
//
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
`timescale 1ns/100ps
|
|
|
|
|
2017-04-13 08:45:54 +00:00
|
|
|
module axi_dacfifo_rd #(
|
|
|
|
|
|
|
|
parameter AXI_DATA_WIDTH = 512,
|
|
|
|
parameter AXI_SIZE = 2,
|
|
|
|
parameter AXI_LENGTH = 15,
|
|
|
|
parameter AXI_ADDRESS = 32'h00000000) (
|
2016-04-19 08:28:33 +00:00
|
|
|
|
|
|
|
// xfer last for read/write synchronization
|
|
|
|
|
2017-04-13 08:45:54 +00:00
|
|
|
input axi_xfer_req,
|
|
|
|
input [31:0] axi_last_raddr,
|
|
|
|
input [ 3:0] axi_last_beats,
|
2016-04-19 08:28:33 +00:00
|
|
|
|
|
|
|
// axi read address and read data channels
|
|
|
|
|
2017-04-13 08:45:54 +00:00
|
|
|
input axi_clk,
|
|
|
|
input axi_resetn,
|
|
|
|
output reg 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 [ 3:0] axi_aruser,
|
|
|
|
output [ 7:0] axi_arlen,
|
|
|
|
output [ 2:0] axi_arsize,
|
|
|
|
output reg [31:0] axi_araddr,
|
|
|
|
input axi_arready,
|
|
|
|
input axi_rvalid,
|
|
|
|
input [ 3:0] axi_rid,
|
|
|
|
input [ 3:0] axi_ruser,
|
|
|
|
input [ 1:0] axi_rresp,
|
|
|
|
input axi_rlast,
|
|
|
|
input [(AXI_DATA_WIDTH-1):0] axi_rdata,
|
|
|
|
output reg axi_rready,
|
2016-04-19 08:28:33 +00:00
|
|
|
|
|
|
|
// axi status
|
|
|
|
|
2017-04-13 08:45:54 +00:00
|
|
|
output reg axi_rerror,
|
2016-04-19 08:28:33 +00:00
|
|
|
|
|
|
|
// fifo interface
|
|
|
|
|
2017-04-13 08:45:54 +00:00
|
|
|
output reg axi_dvalid,
|
|
|
|
output reg [(AXI_DATA_WIDTH-1):0] axi_ddata,
|
|
|
|
input axi_dready,
|
|
|
|
output reg axi_dlast);
|
2016-04-19 08:28:33 +00:00
|
|
|
|
|
|
|
localparam AXI_BYTE_WIDTH = AXI_DATA_WIDTH/8;
|
|
|
|
localparam AXI_AWINCR = (AXI_LENGTH + 1) * AXI_BYTE_WIDTH;
|
|
|
|
|
|
|
|
// internal registers
|
|
|
|
|
2016-07-20 08:13:04 +00:00
|
|
|
reg axi_rnext = 1'b0;
|
|
|
|
reg axi_ractive = 1'b0;
|
2016-07-20 08:27:06 +00:00
|
|
|
reg [ 31:0] axi_araddr_prev = 32'b0;
|
2016-04-19 08:28:33 +00:00
|
|
|
reg [ 1:0] axi_xfer_req_m = 2'b0;
|
2016-07-20 08:27:06 +00:00
|
|
|
reg [ 4:0] axi_last_beats_cntr = 16'b0;
|
2016-04-19 08:28:33 +00:00
|
|
|
|
|
|
|
// internal signals
|
|
|
|
|
|
|
|
wire axi_ready_s;
|
|
|
|
wire axi_xfer_req_init;
|
|
|
|
wire axi_dvalid_s;
|
2016-07-20 08:27:06 +00:00
|
|
|
wire axi_dlast_s;
|
|
|
|
wire [ 4:0] axi_last_beats_s;
|
2016-04-19 08:28:33 +00:00
|
|
|
|
|
|
|
assign axi_ready_s = (~axi_arvalid | axi_arready) & axi_dready;
|
|
|
|
|
|
|
|
always @(posedge axi_clk) begin
|
|
|
|
if (axi_resetn == 1'b0) begin
|
2016-07-20 08:13:04 +00:00
|
|
|
axi_rnext <= 1'b0;
|
|
|
|
axi_ractive <= 1'b0;
|
2016-04-19 08:28:33 +00:00
|
|
|
axi_xfer_req_m <= 2'b0;
|
|
|
|
end else begin
|
2016-07-20 08:13:04 +00:00
|
|
|
if (axi_ractive == 1'b1) begin
|
|
|
|
axi_rnext <= 1'b0;
|
2016-04-19 08:28:33 +00:00
|
|
|
if ((axi_rvalid == 1'b1) && (axi_rlast == 1'b1)) begin
|
2016-07-20 08:13:04 +00:00
|
|
|
axi_ractive <= 1'b0;
|
2016-04-19 08:28:33 +00:00
|
|
|
end
|
|
|
|
end else if ((axi_ready_s == 1'b1)) begin
|
2016-07-20 08:13:04 +00:00
|
|
|
axi_rnext <= axi_xfer_req;
|
|
|
|
axi_ractive <= axi_xfer_req;
|
2016-04-19 08:28:33 +00:00
|
|
|
end
|
|
|
|
axi_xfer_req_m <= {axi_xfer_req_m[0], axi_xfer_req};
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
assign axi_xfer_req_init = axi_xfer_req_m[0] & ~axi_xfer_req_m[1];
|
|
|
|
|
2016-07-20 08:27:06 +00:00
|
|
|
always @(posedge axi_clk) begin
|
|
|
|
if ((axi_resetn == 1'b0) || (axi_xfer_req == 1'b0)) begin
|
|
|
|
axi_last_beats_cntr <= 0;
|
|
|
|
end else begin
|
|
|
|
if ((axi_rready == 1'b1) && (axi_rvalid == 1'b1)) begin
|
|
|
|
axi_last_beats_cntr <= (axi_rlast == 1'b1) ? 0 : axi_last_beats_cntr + 1;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-04-19 08:28:33 +00:00
|
|
|
// address channel
|
|
|
|
|
|
|
|
assign axi_arid = 4'b0000;
|
|
|
|
assign axi_arburst = 2'b01;
|
|
|
|
assign axi_arlock = 1'b0;
|
|
|
|
assign axi_arcache = 4'b0010;
|
|
|
|
assign axi_arprot = 3'b000;
|
|
|
|
assign axi_arqos = 4'b0000;
|
|
|
|
assign axi_aruser = 4'b0001;
|
|
|
|
assign axi_arlen = AXI_LENGTH;
|
|
|
|
assign axi_arsize = AXI_SIZE;
|
|
|
|
|
|
|
|
always @(posedge axi_clk) begin
|
|
|
|
if (axi_resetn == 1'b0) begin
|
|
|
|
axi_arvalid <= 'd0;
|
2016-07-20 08:27:06 +00:00
|
|
|
axi_araddr <= AXI_ADDRESS;
|
|
|
|
axi_araddr_prev <= AXI_ADDRESS;
|
2016-04-19 08:28:33 +00:00
|
|
|
end else begin
|
|
|
|
if (axi_arvalid == 1'b1) begin
|
|
|
|
if (axi_arready == 1'b1) begin
|
|
|
|
axi_arvalid <= 1'b0;
|
|
|
|
end
|
|
|
|
end else begin
|
2016-07-20 08:13:04 +00:00
|
|
|
if (axi_rnext == 1'b1) begin
|
2016-04-19 08:28:33 +00:00
|
|
|
axi_arvalid <= 1'b1;
|
|
|
|
end
|
|
|
|
end
|
2016-07-20 08:27:06 +00:00
|
|
|
if ((axi_xfer_req == 1'b1) &&
|
|
|
|
(axi_arvalid == 1'b1) &&
|
|
|
|
(axi_arready == 1'b1)) begin
|
|
|
|
axi_araddr <= (axi_araddr >= axi_last_raddr) ? AXI_ADDRESS : axi_araddr + AXI_AWINCR;
|
|
|
|
axi_araddr_prev <= axi_araddr;
|
2016-04-19 08:28:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
// read data channel
|
|
|
|
|
2016-07-20 08:27:06 +00:00
|
|
|
assign axi_last_beats_s = {1'b0, axi_last_beats} - 1;
|
|
|
|
assign axi_dvalid_s = ((axi_last_beats_cntr > axi_last_beats_s) && (axi_araddr_prev == axi_last_raddr)) ? 0 : axi_rvalid & axi_rready;
|
|
|
|
assign axi_dlast_s = (axi_araddr_prev == axi_last_raddr) ? 1 : 0;
|
2016-04-19 08:28:33 +00:00
|
|
|
|
|
|
|
always @(posedge axi_clk) begin
|
|
|
|
if (axi_resetn == 1'b0) begin
|
|
|
|
axi_ddata <= 'd0;
|
|
|
|
axi_rready <= 1'b0;
|
|
|
|
axi_dvalid <= 1'b0;
|
|
|
|
end else begin
|
|
|
|
axi_ddata <= axi_rdata;
|
|
|
|
axi_dvalid <= axi_dvalid_s;
|
2016-07-20 08:27:06 +00:00
|
|
|
axi_dlast <= axi_dlast_s;
|
2016-05-26 11:25:36 +00:00
|
|
|
if (axi_xfer_req == 1'b1) begin
|
2016-04-19 08:28:33 +00:00
|
|
|
axi_rready <= axi_rvalid;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
always @(posedge axi_clk) begin
|
|
|
|
if (axi_resetn == 1'b0) begin
|
|
|
|
axi_rerror <= 'd0;
|
|
|
|
end else begin
|
|
|
|
axi_rerror <= axi_rvalid & axi_rresp[1];
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
endmodule
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
|