2014-03-06 16:16:02 +00:00
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
2017-05-17 08:44:52 +00:00
|
|
|
// Copyright 2014 - 2017 (c) Analog Devices, Inc. All rights reserved.
|
|
|
|
//
|
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
|
|
|
|
// freedoms and responsabilities 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
|
2017-05-29 06:55:41 +00:00
|
|
|
// 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-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.
|
2014-03-06 16:16:02 +00:00
|
|
|
//
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
module dmac_response_generator (
|
2016-10-01 15:13:42 +00:00
|
|
|
input clk,
|
|
|
|
input resetn,
|
2014-03-06 16:16:02 +00:00
|
|
|
|
2016-10-01 15:13:42 +00:00
|
|
|
input enable,
|
|
|
|
output reg enabled,
|
2014-03-06 16:16:02 +00:00
|
|
|
|
2016-10-01 15:13:42 +00:00
|
|
|
input [ID_WIDTH-1:0] request_id,
|
|
|
|
output reg [ID_WIDTH-1:0] response_id,
|
|
|
|
input sync_id,
|
2014-03-06 16:16:02 +00:00
|
|
|
|
2016-10-01 15:13:42 +00:00
|
|
|
input eot,
|
2014-03-06 16:16:02 +00:00
|
|
|
|
2016-10-01 15:13:42 +00:00
|
|
|
output resp_valid,
|
|
|
|
input resp_ready,
|
|
|
|
output resp_eot,
|
|
|
|
output [1:0] resp_resp
|
2014-03-06 16:16:02 +00:00
|
|
|
);
|
|
|
|
|
2015-08-19 11:11:47 +00:00
|
|
|
parameter ID_WIDTH = 3;
|
2014-03-06 16:16:02 +00:00
|
|
|
|
|
|
|
`include "inc_id.h"
|
|
|
|
`include "resp.h"
|
|
|
|
|
|
|
|
assign resp_resp = RESP_OKAY;
|
|
|
|
assign resp_eot = eot;
|
|
|
|
|
2014-03-18 18:10:33 +00:00
|
|
|
assign resp_valid = request_id != response_id && enabled;
|
2014-03-06 16:16:02 +00:00
|
|
|
|
|
|
|
// We have to wait for all responses before we can disable the response handler
|
|
|
|
always @(posedge clk) begin
|
2016-10-01 15:13:42 +00:00
|
|
|
if (resetn == 1'b0) begin
|
|
|
|
enabled <= 1'b0;
|
|
|
|
end else begin
|
|
|
|
if (enable)
|
|
|
|
enabled <= 1'b1;
|
|
|
|
else if (request_id == response_id)
|
|
|
|
enabled <= 1'b0;
|
|
|
|
end
|
2014-03-06 16:16:02 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
always @(posedge clk) begin
|
2016-10-01 15:13:42 +00:00
|
|
|
if (resetn == 1'b0) begin
|
|
|
|
response_id <= 'h0;
|
|
|
|
end else begin
|
|
|
|
if ((resp_valid && resp_ready) ||
|
|
|
|
(sync_id && response_id != request_id))
|
|
|
|
response_id <= inc_id(response_id);
|
|
|
|
end
|
2014-03-06 16:16:02 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
endmodule
|