2017-04-03 11:27:59 +00:00
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
2017-05-17 08:44:52 +00:00
|
|
|
// Copyright 2014 - 2017 (c) Analog Devices, Inc. All rights reserved.
|
2017-04-03 11:27:59 +00:00
|
|
|
//
|
2017-05-29 06:55:41 +00:00
|
|
|
// This core is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
|
|
// A PARTICULAR PURPOSE.
|
2017-04-03 11:27:59 +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-04-03 11:27:59 +00:00
|
|
|
//
|
2017-05-17 08:44:52 +00:00
|
|
|
// 1. The GNU General Public License version 2 as published by the
|
2017-05-29 06:55:41 +00:00
|
|
|
// Free Software Foundation, which can be found in the top level directory of
|
|
|
|
// the repository (LICENSE_GPL2), and at: <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
|
2017-05-17 08:44:52 +00:00
|
|
|
//
|
|
|
|
// OR
|
|
|
|
//
|
2017-05-29 06:55:41 +00:00
|
|
|
// 2. An ADI specific BSD license as noted in the top level directory, or on-line at:
|
|
|
|
// 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-04-03 11:27:59 +00:00
|
|
|
//
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
module cic_int #(
|
2017-04-04 13:44:20 +00:00
|
|
|
parameter DATA_WIDTH = 12,
|
|
|
|
parameter STAGE_WIDTH = 1,
|
|
|
|
parameter NUM_STAGES = 1
|
2017-04-03 11:27:59 +00:00
|
|
|
) (
|
|
|
|
input clk,
|
2017-04-04 13:44:20 +00:00
|
|
|
input [NUM_STAGES-1:0] ce,
|
2017-04-03 11:27:59 +00:00
|
|
|
input [DATA_WIDTH-1:0] data_in,
|
|
|
|
output [DATA_WIDTH-1:0] data_out
|
|
|
|
);
|
|
|
|
|
|
|
|
reg [DATA_WIDTH-1:0] state = 'h00;
|
|
|
|
wire [DATA_WIDTH-1:0] sum;
|
2017-04-04 13:44:20 +00:00
|
|
|
wire [DATA_WIDTH-1:0] mask;
|
2017-04-03 11:27:59 +00:00
|
|
|
|
|
|
|
assign data_out = state;
|
2017-04-04 13:44:20 +00:00
|
|
|
assign sum = (data_in & mask) + (state & mask);
|
|
|
|
generate
|
|
|
|
genvar i;
|
2017-04-03 11:27:59 +00:00
|
|
|
|
2017-04-04 13:44:20 +00:00
|
|
|
for (i = 0; i < NUM_STAGES; i = i + 1) begin
|
|
|
|
localparam j = NUM_STAGES - i - 1;
|
|
|
|
localparam H = DATA_WIDTH - STAGE_WIDTH * i - 1;
|
|
|
|
localparam L = j == 0 ? 0 : DATA_WIDTH - STAGE_WIDTH * (i+1);
|
|
|
|
|
|
|
|
assign mask[H:L] = {{H-L{1'b1}},j != 0 ? ce[j] : 1'b1};
|
|
|
|
|
|
|
|
always @(posedge clk) begin
|
|
|
|
if (ce[j] == 1'b1) begin
|
|
|
|
state[H:L] <= sum[H:L];
|
|
|
|
end
|
2017-04-03 11:27:59 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-04-04 13:44:20 +00:00
|
|
|
endgenerate
|
|
|
|
|
2017-04-03 11:27:59 +00:00
|
|
|
endmodule
|