2015-06-26 09:04:19 +00:00
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
2018-04-03 11:58:19 +00:00
|
|
|
// Copyright 2014 - 2018 (c) 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:
|
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.
|
2015-06-26 09:04:19 +00:00
|
|
|
//
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
`timescale 1ns/100ps
|
|
|
|
|
2018-02-07 11:46:08 +00:00
|
|
|
module ad_dds_1 #(
|
|
|
|
|
|
|
|
// parameters
|
|
|
|
|
|
|
|
parameter DDS_TYPE = 1,
|
2018-04-03 11:58:19 +00:00
|
|
|
parameter DDS_D_DW = 16,
|
2022-04-08 10:21:52 +00:00
|
|
|
parameter DDS_P_DW = 16
|
|
|
|
) (
|
2015-06-26 09:04:19 +00:00
|
|
|
|
|
|
|
// interface
|
|
|
|
|
2018-05-31 14:31:30 +00:00
|
|
|
input clk,
|
2018-04-03 11:58:19 +00:00
|
|
|
input [DDS_P_DW-1:0] angle,
|
|
|
|
input [ 15:0] scale,
|
2022-04-08 10:21:52 +00:00
|
|
|
output reg [DDS_D_DW-1:0] dds_data
|
|
|
|
);
|
2015-06-26 09:04:19 +00:00
|
|
|
|
2018-02-07 11:46:08 +00:00
|
|
|
// local parameters
|
|
|
|
|
|
|
|
localparam DDS_CORDIC_TYPE = 1;
|
|
|
|
localparam DDS_POLINOMIAL_TYPE = 2;
|
2015-06-26 09:04:19 +00:00
|
|
|
|
|
|
|
// internal signals
|
|
|
|
|
2018-05-30 15:24:24 +00:00
|
|
|
wire [ DDS_D_DW-1:0] sine_s;
|
2018-04-03 11:58:19 +00:00
|
|
|
wire [DDS_D_DW+17:0] s1_data_s;
|
2018-02-07 11:46:08 +00:00
|
|
|
|
2015-06-26 09:04:19 +00:00
|
|
|
// sine
|
|
|
|
|
2018-02-07 11:46:08 +00:00
|
|
|
generate
|
|
|
|
if (DDS_TYPE == DDS_CORDIC_TYPE) begin
|
|
|
|
|
|
|
|
ad_dds_sine_cordic #(
|
2018-04-03 11:58:19 +00:00
|
|
|
.CORDIC_DW(DDS_D_DW),
|
|
|
|
.PHASE_DW(DDS_P_DW),
|
2022-04-08 10:21:52 +00:00
|
|
|
.DELAY_DW(1)
|
|
|
|
) i_dds_sine (
|
2018-02-07 11:46:08 +00:00
|
|
|
.clk (clk),
|
2018-05-31 14:31:30 +00:00
|
|
|
.angle (angle),
|
2018-02-07 11:46:08 +00:00
|
|
|
.sine (sine_s),
|
2018-02-15 15:14:55 +00:00
|
|
|
.cosine (),
|
2018-02-07 11:46:08 +00:00
|
|
|
.ddata_in (1'b0),
|
|
|
|
.ddata_out ());
|
|
|
|
|
|
|
|
end else begin
|
|
|
|
|
|
|
|
ad_dds_sine i_dds_sine (
|
|
|
|
.clk (clk),
|
|
|
|
.angle (angle),
|
|
|
|
.sine (sine_s),
|
|
|
|
.ddata_in (1'b0),
|
|
|
|
.ddata_out ());
|
|
|
|
end
|
|
|
|
endgenerate
|
2015-06-26 09:04:19 +00:00
|
|
|
|
2018-04-03 11:58:19 +00:00
|
|
|
// scale for a sine generator
|
2015-06-26 09:04:19 +00:00
|
|
|
|
2018-04-03 11:58:19 +00:00
|
|
|
ad_mul #(
|
|
|
|
.A_DATA_WIDTH(DDS_D_DW + 1),
|
|
|
|
.B_DATA_WIDTH(17),
|
2022-04-08 10:21:52 +00:00
|
|
|
.DELAY_DATA_WIDTH(1)
|
|
|
|
) i_dds_scale (
|
2015-06-26 09:04:19 +00:00
|
|
|
.clk (clk),
|
2018-04-03 11:58:19 +00:00
|
|
|
.data_a ({sine_s[DDS_D_DW-1], sine_s}),
|
2015-06-26 09:04:19 +00:00
|
|
|
.data_b ({scale[15], scale}),
|
|
|
|
.data_p (s1_data_s),
|
|
|
|
.ddata_in (1'b0),
|
|
|
|
.ddata_out ());
|
|
|
|
|
|
|
|
// dds data
|
|
|
|
|
|
|
|
always @(posedge clk) begin
|
2018-04-03 11:58:19 +00:00
|
|
|
//15'h8000 is the maximum scale
|
|
|
|
dds_data <= s1_data_s[DDS_D_DW+13:14];
|
2015-06-26 09:04:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
endmodule
|