2015-06-26 09:04:19 +00:00
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
2023-07-06 13:54:40 +00:00
|
|
|
// Copyright (C) 2014-2023 Analog Devices, Inc. All rights reserved.
|
2017-05-17 08:44:52 +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.
|
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:
|
2023-12-13 16:03:34 +00:00
|
|
|
// https://github.com/analogdevicesinc/hdl/blob/main/LICENSE_ADIBSD
|
2017-05-29 06:55:41 +00:00
|
|
|
// This will allow to generate bit files and not release the source code,
|
|
|
|
// as long as it attaches to an ADI device.
|
2015-06-26 09:04:19 +00:00
|
|
|
//
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
`timescale 1ns/100ps
|
|
|
|
|
2016-09-23 20:13:24 +00:00
|
|
|
module up_delay_cntrl #(
|
2015-06-26 09:04:19 +00:00
|
|
|
|
|
|
|
// parameters
|
|
|
|
|
2016-09-23 20:13:24 +00:00
|
|
|
parameter DISABLE = 0,
|
2017-03-13 20:28:24 +00:00
|
|
|
parameter INIT_DELAY = 0,
|
2016-09-23 20:13:24 +00:00
|
|
|
parameter DATA_WIDTH = 8,
|
2019-07-18 06:26:24 +00:00
|
|
|
parameter DRP_WIDTH = 5,
|
2022-04-08 10:21:52 +00:00
|
|
|
parameter BASE_ADDRESS = 6'h02
|
|
|
|
) (
|
2015-06-26 09:04:19 +00:00
|
|
|
|
|
|
|
// delay interface
|
|
|
|
|
2016-09-23 20:13:24 +00:00
|
|
|
input delay_clk,
|
|
|
|
output delay_rst,
|
|
|
|
input delay_locked,
|
2015-06-26 09:04:19 +00:00
|
|
|
|
|
|
|
// io interface
|
|
|
|
|
2016-09-23 20:13:24 +00:00
|
|
|
output [(DATA_WIDTH-1):0] up_dld,
|
2019-07-18 06:26:24 +00:00
|
|
|
output [((DATA_WIDTH*DRP_WIDTH)-1):0] up_dwdata,
|
|
|
|
input [((DATA_WIDTH*DRP_WIDTH)-1):0] up_drdata,
|
2015-06-26 09:04:19 +00:00
|
|
|
|
|
|
|
// processor interface
|
|
|
|
|
2016-09-23 20:13:24 +00:00
|
|
|
input up_rstn,
|
|
|
|
input up_clk,
|
|
|
|
input up_wreq,
|
|
|
|
input [13:0] up_waddr,
|
|
|
|
input [31:0] up_wdata,
|
|
|
|
output up_wack,
|
|
|
|
input up_rreq,
|
|
|
|
input [13:0] up_raddr,
|
|
|
|
output [31:0] up_rdata,
|
2022-04-08 10:21:52 +00:00
|
|
|
output up_rack
|
|
|
|
);
|
2015-06-26 09:04:19 +00:00
|
|
|
|
2018-03-06 08:09:57 +00:00
|
|
|
generate
|
|
|
|
if (DISABLE == 1) begin
|
|
|
|
assign up_wack = 1'd0;
|
|
|
|
assign up_rack = 1'd0;
|
|
|
|
assign up_rdata = 32'd0;
|
|
|
|
|
|
|
|
assign up_dld = 'd0;
|
|
|
|
assign up_dwdata = 'd0;
|
|
|
|
|
|
|
|
assign delay_rst = 1'd0;
|
|
|
|
|
|
|
|
end else begin
|
2015-06-26 09:04:19 +00:00
|
|
|
// internal registers
|
2018-01-23 10:13:05 +00:00
|
|
|
|
2015-08-28 17:16:18 +00:00
|
|
|
reg up_preset = 'd0;
|
2016-09-23 20:13:24 +00:00
|
|
|
reg up_wack_int = 'd0;
|
|
|
|
reg up_rack_int = 'd0;
|
|
|
|
reg [31:0] up_rdata_int = 'd0;
|
2015-08-28 17:16:18 +00:00
|
|
|
reg up_dlocked_m1 = 'd0;
|
2017-03-13 20:28:24 +00:00
|
|
|
reg up_dlocked_m2 = 'd0;
|
|
|
|
reg up_dlocked_m3 = 'd0;
|
2015-08-28 17:16:18 +00:00
|
|
|
reg up_dlocked = 'd0;
|
2016-09-23 20:13:24 +00:00
|
|
|
reg [(DATA_WIDTH-1):0] up_dld_int = 'd0;
|
2019-07-18 06:26:24 +00:00
|
|
|
reg [((DATA_WIDTH*DRP_WIDTH)-1):0] up_dwdata_int = 'd0;
|
2015-06-26 09:04:19 +00:00
|
|
|
|
|
|
|
// internal signals
|
|
|
|
|
2015-08-28 17:16:18 +00:00
|
|
|
wire up_wreq_s;
|
|
|
|
wire up_rreq_s;
|
2019-07-18 06:26:24 +00:00
|
|
|
wire [ DRP_WIDTH-1:0] up_rdata_s;
|
2015-08-19 11:11:47 +00:00
|
|
|
wire [(DATA_WIDTH-1):0] up_drdata4_s;
|
|
|
|
wire [(DATA_WIDTH-1):0] up_drdata3_s;
|
|
|
|
wire [(DATA_WIDTH-1):0] up_drdata2_s;
|
|
|
|
wire [(DATA_WIDTH-1):0] up_drdata1_s;
|
|
|
|
wire [(DATA_WIDTH-1):0] up_drdata0_s;
|
2016-09-22 17:41:18 +00:00
|
|
|
wire [(DATA_WIDTH-1):0] up_dld_s;
|
2019-07-18 06:26:24 +00:00
|
|
|
wire [((DATA_WIDTH*DRP_WIDTH)-1):0] up_dwdata_s;
|
2017-03-13 20:28:24 +00:00
|
|
|
wire [(DATA_WIDTH-1):0] up_dinit_s;
|
2019-07-18 06:26:24 +00:00
|
|
|
wire [((DATA_WIDTH*DRP_WIDTH)-1):0] up_dinitdata_s;
|
2016-09-23 20:13:24 +00:00
|
|
|
wire delay_rst_s;
|
2015-06-26 09:04:19 +00:00
|
|
|
|
|
|
|
// variables
|
|
|
|
|
2015-08-28 17:16:18 +00:00
|
|
|
genvar n;
|
2015-06-26 09:04:19 +00:00
|
|
|
|
|
|
|
// decode block select
|
|
|
|
|
2015-08-19 11:11:47 +00:00
|
|
|
assign up_wreq_s = (up_waddr[13:8] == BASE_ADDRESS) ? up_wreq : 1'b0;
|
|
|
|
assign up_rreq_s = (up_raddr[13:8] == BASE_ADDRESS) ? up_rreq : 1'b0;
|
2019-07-18 06:26:24 +00:00
|
|
|
|
|
|
|
assign up_rdata_s = up_drdata >> (DRP_WIDTH*up_raddr[7:0]);
|
2015-06-26 09:04:19 +00:00
|
|
|
|
|
|
|
// processor interface
|
|
|
|
|
2018-03-06 08:09:57 +00:00
|
|
|
assign up_wack = up_wack_int;
|
|
|
|
assign up_rack = up_rack_int;
|
|
|
|
assign up_rdata = up_rdata_int;
|
2016-09-23 20:13:24 +00:00
|
|
|
|
2018-01-23 10:13:05 +00:00
|
|
|
always @(posedge up_clk) begin
|
2015-06-26 09:04:19 +00:00
|
|
|
if (up_rstn == 0) begin
|
|
|
|
up_preset <= 1'd1;
|
2016-09-23 20:13:24 +00:00
|
|
|
up_wack_int <= 'd0;
|
|
|
|
up_rack_int <= 'd0;
|
|
|
|
up_rdata_int <= 'd0;
|
2015-06-26 09:04:19 +00:00
|
|
|
up_dlocked_m1 <= 'd0;
|
2017-03-13 20:28:24 +00:00
|
|
|
up_dlocked_m2 <= 'd0;
|
|
|
|
up_dlocked_m3 <= 'd0;
|
2015-06-26 09:04:19 +00:00
|
|
|
up_dlocked <= 'd0;
|
|
|
|
end else begin
|
|
|
|
up_preset <= 1'd0;
|
2016-09-23 20:13:24 +00:00
|
|
|
up_wack_int <= up_wreq_s;
|
|
|
|
up_rack_int <= up_rreq_s;
|
2015-06-26 09:04:19 +00:00
|
|
|
if (up_rreq_s == 1'b1) begin
|
|
|
|
if (up_dlocked == 1'b0) begin
|
2016-09-23 20:13:24 +00:00
|
|
|
up_rdata_int <= 32'hffffffff;
|
2015-06-26 09:04:19 +00:00
|
|
|
end else begin
|
2019-07-18 06:26:24 +00:00
|
|
|
up_rdata_int <= {{32-DRP_WIDTH{1'b0}}, up_rdata_s};
|
2015-06-26 09:04:19 +00:00
|
|
|
end
|
|
|
|
end else begin
|
2016-09-23 20:13:24 +00:00
|
|
|
up_rdata_int <= 32'd0;
|
2015-06-26 09:04:19 +00:00
|
|
|
end
|
|
|
|
up_dlocked_m1 <= delay_locked;
|
2017-03-13 20:28:24 +00:00
|
|
|
up_dlocked_m2 <= up_dlocked_m1;
|
|
|
|
up_dlocked_m3 <= up_dlocked_m2;
|
|
|
|
up_dlocked <= up_dlocked_m3;
|
2015-06-26 09:04:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-03-13 20:28:24 +00:00
|
|
|
// init delay values (after delay locked)
|
|
|
|
|
|
|
|
for (n = 0; n < DATA_WIDTH; n = n + 1) begin: g_dinit
|
|
|
|
assign up_dinit_s[n] = up_dlocked_m2 & ~up_dlocked_m3;
|
2019-07-18 06:26:24 +00:00
|
|
|
assign up_dinitdata_s[(n*DRP_WIDTH) +: DRP_WIDTH] = INIT_DELAY;
|
2017-03-13 20:28:24 +00:00
|
|
|
end
|
|
|
|
|
2018-01-23 10:13:05 +00:00
|
|
|
// write does not hold- read back what goes into effect.
|
2015-06-26 09:04:19 +00:00
|
|
|
|
2015-08-19 11:11:47 +00:00
|
|
|
for (n = 0; n < DATA_WIDTH; n = n + 1) begin: g_dwr
|
2016-09-22 17:41:18 +00:00
|
|
|
assign up_dld_s[n] = (up_waddr[7:0] == n) ? up_wreq_s : 1'b0;
|
2019-07-18 06:26:24 +00:00
|
|
|
assign up_dwdata_s[(n*DRP_WIDTH) +: DRP_WIDTH] = (up_waddr[7:0] == n) ?
|
|
|
|
up_wdata[DRP_WIDTH-1:0] : up_dwdata_int[(n*DRP_WIDTH) +: DRP_WIDTH];
|
2016-09-22 17:41:18 +00:00
|
|
|
end
|
|
|
|
|
2018-03-06 08:09:57 +00:00
|
|
|
assign up_dld = up_dld_int;
|
|
|
|
assign up_dwdata = up_dwdata_int;
|
2016-09-23 20:13:24 +00:00
|
|
|
|
2018-01-23 10:13:05 +00:00
|
|
|
always @(posedge up_clk) begin
|
2015-06-26 09:04:19 +00:00
|
|
|
if (up_rstn == 0) begin
|
2016-09-23 20:13:24 +00:00
|
|
|
up_dld_int <= 'd0;
|
|
|
|
up_dwdata_int <= 'd0;
|
2015-06-26 09:04:19 +00:00
|
|
|
end else begin
|
2017-03-13 20:28:24 +00:00
|
|
|
up_dld_int <= up_dld_s | up_dinit_s;
|
|
|
|
if ((up_dlocked_m2 == 1'b1) && (up_dlocked_m3 == 1'b0)) begin
|
|
|
|
up_dwdata_int <= up_dinitdata_s;
|
|
|
|
end else if (up_wreq_s == 1'b1) begin
|
2016-09-23 20:13:24 +00:00
|
|
|
up_dwdata_int <= up_dwdata_s;
|
2015-06-26 09:04:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
// resets
|
|
|
|
|
2018-03-06 08:09:57 +00:00
|
|
|
assign delay_rst = delay_rst_s;
|
2016-09-23 20:13:24 +00:00
|
|
|
|
2015-06-26 09:04:19 +00:00
|
|
|
ad_rst i_delay_rst_reg (
|
2018-07-18 14:21:33 +00:00
|
|
|
.rst_async (up_preset),
|
2015-06-26 09:04:19 +00:00
|
|
|
.clk (delay_clk),
|
2018-07-18 14:21:33 +00:00
|
|
|
.rstn (),
|
2016-09-23 20:13:24 +00:00
|
|
|
.rst (delay_rst_s));
|
2018-03-06 08:09:57 +00:00
|
|
|
end
|
|
|
|
endgenerate
|
2015-06-26 09:04:19 +00:00
|
|
|
|
|
|
|
endmodule
|