2015-06-26 09:04:19 +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.
|
2015-06-26 09:04:19 +00:00
|
|
|
//
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
`timescale 1ns/100ps
|
|
|
|
|
2017-04-13 08:45:54 +00:00
|
|
|
module util_upack #(
|
|
|
|
|
2017-07-28 19:25:56 +00:00
|
|
|
parameter CHANNEL_DATA_WIDTH = 32,
|
|
|
|
parameter NUM_OF_CHANNELS = 8) (
|
2015-06-26 09:04:19 +00:00
|
|
|
|
|
|
|
// dac interface
|
|
|
|
|
2017-07-28 19:25:56 +00:00
|
|
|
input dac_clk,
|
|
|
|
input dac_enable_0,
|
|
|
|
input dac_valid_0,
|
|
|
|
output dac_valid_out_0,
|
|
|
|
output [(CHANNEL_DATA_WIDTH-1):0] dac_data_0,
|
|
|
|
input dac_enable_1,
|
|
|
|
input dac_valid_1,
|
|
|
|
output dac_valid_out_1,
|
|
|
|
output [(CHANNEL_DATA_WIDTH-1):0] dac_data_1,
|
|
|
|
input dac_enable_2,
|
|
|
|
input dac_valid_2,
|
|
|
|
output dac_valid_out_2,
|
|
|
|
output [(CHANNEL_DATA_WIDTH-1):0] dac_data_2,
|
|
|
|
input dac_enable_3,
|
|
|
|
input dac_valid_3,
|
|
|
|
output dac_valid_out_3,
|
|
|
|
output [(CHANNEL_DATA_WIDTH-1):0] dac_data_3,
|
|
|
|
input dac_enable_4,
|
|
|
|
input dac_valid_4,
|
|
|
|
output dac_valid_out_4,
|
|
|
|
output [(CHANNEL_DATA_WIDTH-1):0] dac_data_4,
|
|
|
|
input dac_enable_5,
|
|
|
|
input dac_valid_5,
|
|
|
|
output dac_valid_out_5,
|
|
|
|
output [(CHANNEL_DATA_WIDTH-1):0] dac_data_5,
|
|
|
|
input dac_enable_6,
|
|
|
|
input dac_valid_6,
|
|
|
|
output dac_valid_out_6,
|
|
|
|
output [(CHANNEL_DATA_WIDTH-1):0] dac_data_6,
|
|
|
|
input dac_enable_7,
|
|
|
|
input dac_valid_7,
|
|
|
|
output dac_valid_out_7,
|
|
|
|
output [(CHANNEL_DATA_WIDTH-1):0] dac_data_7,
|
2015-06-26 09:04:19 +00:00
|
|
|
|
|
|
|
// fifo interface
|
|
|
|
|
2017-07-28 19:25:56 +00:00
|
|
|
output dac_valid,
|
|
|
|
output dac_sync,
|
|
|
|
input [((NUM_OF_CHANNELS*CHANNEL_DATA_WIDTH)-1):0] dac_data);
|
2015-06-26 09:04:19 +00:00
|
|
|
|
2017-07-28 19:25:56 +00:00
|
|
|
// internal parameters
|
2015-06-26 09:04:19 +00:00
|
|
|
|
2017-07-28 19:25:56 +00:00
|
|
|
localparam MAX_CHANNELS = 8;
|
2015-06-26 09:04:19 +00:00
|
|
|
|
|
|
|
// internal registers
|
|
|
|
|
2017-07-28 19:25:56 +00:00
|
|
|
reg dac_valid_int = 'd0;
|
|
|
|
reg dac_sync_int = 'd0;
|
2015-06-26 09:04:19 +00:00
|
|
|
|
|
|
|
// internal signals
|
|
|
|
|
2017-07-28 19:25:56 +00:00
|
|
|
wire dac_valid_s;
|
|
|
|
wire [ 7:0] dac_enable_s;
|
|
|
|
wire dac_dsf_valid_m_s;
|
|
|
|
wire [((CHANNEL_DATA_WIDTH*MAX_CHANNELS)-1):0] dac_dsf_data_m_s;
|
|
|
|
wire [ 7:0] dac_dmx_enable_m_s;
|
|
|
|
wire [(MAX_CHANNELS-1):0] dac_dsf_req_s;
|
|
|
|
wire [(MAX_CHANNELS-1):0] dac_dsf_sync_s;
|
|
|
|
wire [(MAX_CHANNELS-1):0] dac_dsf_valid_s;
|
|
|
|
wire [((CHANNEL_DATA_WIDTH*MAX_CHANNELS)-1):0] dac_dsf_data_s[(MAX_CHANNELS-1):0];
|
|
|
|
wire [((CHANNEL_DATA_WIDTH/16)-1):0] dac_dmx_valid_s;
|
|
|
|
wire [((CHANNEL_DATA_WIDTH/16)-1):0] dac_dmx_enable_7_s;
|
|
|
|
wire [((CHANNEL_DATA_WIDTH/16)-1):0] dac_dmx_enable_6_s;
|
|
|
|
wire [((CHANNEL_DATA_WIDTH/16)-1):0] dac_dmx_enable_5_s;
|
|
|
|
wire [((CHANNEL_DATA_WIDTH/16)-1):0] dac_dmx_enable_4_s;
|
|
|
|
wire [((CHANNEL_DATA_WIDTH/16)-1):0] dac_dmx_enable_3_s;
|
|
|
|
wire [((CHANNEL_DATA_WIDTH/16)-1):0] dac_dmx_enable_2_s;
|
|
|
|
wire [((CHANNEL_DATA_WIDTH/16)-1):0] dac_dmx_enable_1_s;
|
|
|
|
wire [((CHANNEL_DATA_WIDTH/16)-1):0] dac_dmx_enable_0_s;
|
|
|
|
|
|
|
|
// data interleaving
|
|
|
|
|
|
|
|
assign dac_valid = dac_valid_int;
|
|
|
|
assign dac_sync = dac_sync_int;
|
|
|
|
assign dac_valid_out_0 = dac_dmx_valid_s[0];
|
|
|
|
assign dac_valid_out_1 = dac_dmx_valid_s[0];
|
|
|
|
assign dac_valid_out_2 = dac_dmx_valid_s[0];
|
|
|
|
assign dac_valid_out_3 = dac_dmx_valid_s[0];
|
|
|
|
assign dac_valid_out_4 = dac_dmx_valid_s[0];
|
|
|
|
assign dac_valid_out_5 = dac_dmx_valid_s[0];
|
|
|
|
assign dac_valid_out_6 = dac_dmx_valid_s[0];
|
|
|
|
assign dac_valid_out_7 = dac_dmx_valid_s[0];
|
2015-06-26 09:04:19 +00:00
|
|
|
|
|
|
|
always @(posedge dac_clk) begin
|
2017-07-28 19:25:56 +00:00
|
|
|
dac_valid_int <= | dac_dsf_req_s;
|
|
|
|
dac_sync_int <= | dac_dsf_sync_s;
|
2015-06-26 09:04:19 +00:00
|
|
|
end
|
|
|
|
|
2017-07-28 19:25:56 +00:00
|
|
|
assign dac_valid_s = dac_valid_7 | dac_valid_6 | dac_valid_5 | dac_valid_4 |
|
|
|
|
dac_valid_3 | dac_valid_2 | dac_valid_1 | dac_valid_0;
|
|
|
|
assign dac_enable_s = {dac_enable_7, dac_enable_6, dac_enable_5, dac_enable_4,
|
|
|
|
dac_enable_3, dac_enable_2, dac_enable_1, dac_enable_0};
|
|
|
|
|
|
|
|
assign dac_dsf_valid_m_s = | dac_dsf_valid_s;
|
|
|
|
assign dac_dsf_data_m_s = dac_dsf_data_s[7] | dac_dsf_data_s[6] |
|
|
|
|
dac_dsf_data_s[5] | dac_dsf_data_s[4] | dac_dsf_data_s[3] |
|
|
|
|
dac_dsf_data_s[2] | dac_dsf_data_s[1] | dac_dsf_data_s[0];
|
|
|
|
|
|
|
|
assign dac_dmx_enable_m_s[7] = | dac_dmx_enable_7_s;
|
|
|
|
assign dac_dmx_enable_m_s[6] = | dac_dmx_enable_6_s;
|
|
|
|
assign dac_dmx_enable_m_s[5] = | dac_dmx_enable_5_s;
|
|
|
|
assign dac_dmx_enable_m_s[4] = | dac_dmx_enable_4_s;
|
|
|
|
assign dac_dmx_enable_m_s[3] = | dac_dmx_enable_3_s;
|
|
|
|
assign dac_dmx_enable_m_s[2] = | dac_dmx_enable_2_s;
|
|
|
|
assign dac_dmx_enable_m_s[1] = | dac_dmx_enable_1_s;
|
|
|
|
assign dac_dmx_enable_m_s[0] = | dac_dmx_enable_0_s;
|
|
|
|
|
|
|
|
// instantiations
|
|
|
|
|
|
|
|
genvar n;
|
|
|
|
generate
|
2015-06-26 09:04:19 +00:00
|
|
|
|
2017-07-28 19:25:56 +00:00
|
|
|
// defaults
|
2015-06-26 09:04:19 +00:00
|
|
|
|
2017-07-28 19:25:56 +00:00
|
|
|
for (n = NUM_OF_CHANNELS; n < MAX_CHANNELS; n = n + 1) begin: g_defaults
|
|
|
|
assign dac_dsf_req_s[n] = 'd0;
|
|
|
|
assign dac_dsf_sync_s[n] = 'd0;
|
|
|
|
assign dac_dsf_valid_s[n] = 'd0;
|
|
|
|
assign dac_dsf_data_s[n] = 'd0;
|
2015-06-26 09:04:19 +00:00
|
|
|
end
|
|
|
|
|
2017-07-28 19:25:56 +00:00
|
|
|
// dsf
|
|
|
|
|
|
|
|
for (n = 0; n < NUM_OF_CHANNELS; n = n + 1) begin: g_dsf
|
2015-06-26 09:04:19 +00:00
|
|
|
util_upack_dsf #(
|
2015-08-19 11:11:47 +00:00
|
|
|
.CHANNEL_DATA_WIDTH (CHANNEL_DATA_WIDTH),
|
2017-07-28 19:25:56 +00:00
|
|
|
.NUM_OF_CHANNELS (NUM_OF_CHANNELS),
|
|
|
|
.MAX_CHANNELS (MAX_CHANNELS),
|
|
|
|
.SEL_CHANNELS ((n+1)))
|
2015-06-26 09:04:19 +00:00
|
|
|
i_dsf (
|
|
|
|
.dac_clk (dac_clk),
|
|
|
|
.dac_valid (dac_valid_s),
|
|
|
|
.dac_data (dac_data),
|
2017-07-28 19:25:56 +00:00
|
|
|
.dac_dmx_enable (dac_dmx_enable_m_s[n]),
|
|
|
|
.dac_dsf_req (dac_dsf_req_s[n]),
|
2015-06-26 09:04:19 +00:00
|
|
|
.dac_dsf_sync (dac_dsf_sync_s[n]),
|
2017-07-28 19:25:56 +00:00
|
|
|
.dac_dsf_valid (dac_dsf_valid_s[n]),
|
2015-06-26 09:04:19 +00:00
|
|
|
.dac_dsf_data (dac_dsf_data_s[n]));
|
|
|
|
end
|
|
|
|
|
|
|
|
// demux
|
|
|
|
|
2017-07-28 19:25:56 +00:00
|
|
|
for (n = 0; n < (CHANNEL_DATA_WIDTH/16); n = n + 1) begin: g_dmx
|
2015-06-26 09:04:19 +00:00
|
|
|
util_upack_dmx i_dmx (
|
|
|
|
.dac_clk (dac_clk),
|
2017-07-28 19:25:56 +00:00
|
|
|
.dac_enable (dac_enable_s),
|
|
|
|
.dac_valid (dac_dmx_valid_s[n]),
|
2015-06-26 09:04:19 +00:00
|
|
|
.dac_data_0 (dac_data_0[((16*n)+15):(16*n)]),
|
|
|
|
.dac_data_1 (dac_data_1[((16*n)+15):(16*n)]),
|
|
|
|
.dac_data_2 (dac_data_2[((16*n)+15):(16*n)]),
|
|
|
|
.dac_data_3 (dac_data_3[((16*n)+15):(16*n)]),
|
|
|
|
.dac_data_4 (dac_data_4[((16*n)+15):(16*n)]),
|
|
|
|
.dac_data_5 (dac_data_5[((16*n)+15):(16*n)]),
|
|
|
|
.dac_data_6 (dac_data_6[((16*n)+15):(16*n)]),
|
|
|
|
.dac_data_7 (dac_data_7[((16*n)+15):(16*n)]),
|
|
|
|
.dac_dmx_enable ({dac_dmx_enable_7_s[n], dac_dmx_enable_6_s[n],
|
2017-07-28 19:25:56 +00:00
|
|
|
dac_dmx_enable_5_s[n], dac_dmx_enable_4_s[n], dac_dmx_enable_3_s[n],
|
|
|
|
dac_dmx_enable_2_s[n], dac_dmx_enable_1_s[n], dac_dmx_enable_0_s[n]}),
|
|
|
|
.dac_dsf_valid (dac_dsf_valid_m_s),
|
|
|
|
.dac_dsf_data (dac_dsf_data_m_s[((MAX_CHANNELS*16*(n+1))-1):(MAX_CHANNELS*16*n)]));
|
2015-06-26 09:04:19 +00:00
|
|
|
end
|
2017-07-28 19:25:56 +00:00
|
|
|
|
2015-06-26 09:04:19 +00:00
|
|
|
endgenerate
|
|
|
|
|
|
|
|
endmodule
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|