2015-11-11 08:46:11 +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
|
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:
|
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.
|
2017-05-17 08:44:52 +00:00
|
|
|
//
|
2015-11-11 08:46:11 +00:00
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
2016-02-10 10:43:16 +00:00
|
|
|
//
|
|
|
|
// Simple pulse generator for TDD control
|
|
|
|
// The module has two modes. In function of the state of sync_mode,
|
|
|
|
// the syncronization signal (sync_out) can get its value from an external
|
|
|
|
// source or from its internal generator.
|
|
|
|
//
|
|
|
|
|
2015-11-11 08:46:11 +00:00
|
|
|
`timescale 1ns/1ps
|
|
|
|
|
2017-04-13 08:45:54 +00:00
|
|
|
module util_tdd_sync #(
|
2015-11-11 08:46:11 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
parameter TDD_SYNC_PERIOD = 100000000
|
|
|
|
) (
|
2017-04-13 08:45:54 +00:00
|
|
|
input clk,
|
|
|
|
input rstn,
|
2015-11-11 08:46:11 +00:00
|
|
|
|
2017-04-13 08:45:54 +00:00
|
|
|
input sync_mode,
|
2015-11-11 08:46:11 +00:00
|
|
|
|
2017-04-13 08:45:54 +00:00
|
|
|
input sync_in,
|
2022-04-08 10:21:52 +00:00
|
|
|
output reg sync_out
|
|
|
|
);
|
2015-11-11 08:46:11 +00:00
|
|
|
|
2016-06-09 06:34:06 +00:00
|
|
|
reg sync_mode_d1 = 1'b0;
|
|
|
|
reg sync_mode_d2 = 1'b0;
|
2015-11-11 08:46:11 +00:00
|
|
|
|
2016-02-10 10:43:16 +00:00
|
|
|
wire sync_internal;
|
|
|
|
wire sync_external;
|
2015-11-11 08:46:11 +00:00
|
|
|
|
|
|
|
// pulse generator
|
|
|
|
|
2016-06-09 06:34:06 +00:00
|
|
|
util_pulse_gen #(
|
|
|
|
.PULSE_PERIOD(TDD_SYNC_PERIOD)
|
2022-04-08 10:21:52 +00:00
|
|
|
) i_tdd_sync (
|
2015-11-11 08:46:11 +00:00
|
|
|
.clk (clk),
|
|
|
|
.rstn (rstn),
|
2019-03-21 07:28:18 +00:00
|
|
|
.pulse_width (32'd0),
|
2019-03-19 16:38:32 +00:00
|
|
|
.pulse_period (32'd0),
|
|
|
|
.load_config (1'd0),
|
2022-04-08 10:21:52 +00:00
|
|
|
.pulse (sync_internal));
|
2015-11-11 08:46:11 +00:00
|
|
|
|
|
|
|
// synchronization logic
|
|
|
|
|
|
|
|
always @(posedge clk) begin
|
|
|
|
if(rstn == 1'b0) begin
|
2016-02-10 10:43:16 +00:00
|
|
|
sync_mode_d1 <= 1'b0;
|
|
|
|
sync_mode_d2 <= 1'b0;
|
2015-11-11 08:46:11 +00:00
|
|
|
end else begin
|
2016-02-10 10:43:16 +00:00
|
|
|
sync_mode_d1 <= sync_mode;
|
|
|
|
sync_mode_d2 <= sync_mode_d1;
|
2015-11-11 08:46:11 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
// output logic
|
|
|
|
|
2016-02-10 10:43:16 +00:00
|
|
|
assign sync_external = sync_in;
|
2015-11-11 08:46:11 +00:00
|
|
|
always @(posedge clk) begin
|
|
|
|
if(rstn == 1'b0) begin
|
|
|
|
sync_out <= 1'b0;
|
|
|
|
end else begin
|
2016-02-10 10:43:16 +00:00
|
|
|
sync_out <= (sync_mode_d2 == 1'b0) ? sync_internal : sync_external;
|
2015-11-11 08:46:11 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
endmodule
|