Files
b210-k7-fpga/lib/rfnoc/cic_interpolate.v
+18 6b67702ad7 Merge FPGA repository back into UHD repository
The FPGA codebase was removed from the UHD repository in 2014 to reduce
the size of the repository. However, over the last half-decade, the
split between the repositories has proven more burdensome than it has
been helpful. By merging the FPGA code back, it will be possible to
create atomic commits that touch both FPGA and UHD codebases. Continuous
integration testing is also simplified by merging the repositories,
because it was previously difficult to automatically derive the correct
UHD branch when testing a feature branch on the FPGA repository.

This commit also updates the license files and paths therein.

We are therefore merging the repositories again. Future development for
FPGA code will happen in the same repository as the UHD host code and
MPM code.

== Original Codebase and Rebasing ==

The original FPGA repository will be hosted for the foreseeable future
at its original local location: https://github.com/EttusResearch/fpga/

It can be used for bisecting, reference, and a more detailed history.

The final commit from said repository to be merged here is
05003794e2da61cabf64dd278c45685a7abad7ec. This commit is tagged as
v4.0.0.0-pre-uhd-merge.

If you have changes in the FPGA repository that you want to rebase onto
the UHD repository, simply run the following commands:

- Create a directory to store patches (this should be an empty
  directory):

    mkdir ~/patches

- Now make sure that your FPGA codebase is based on the same state as
  the code that was merged:

    cd src/fpga # Or wherever your FPGA code is stored
    git rebase v4.0.0.0-pre-uhd-merge

  Note: The rebase command may look slightly different depending on what
  exactly you're trying to rebase.

- Create a patch set for your changes versus v4.0.0.0-pre-uhd-merge:

    git format-patch v4.0.0.0-pre-uhd-merge -o ~/patches

  Note: Make sure that only patches are stored in your output directory.
  It should otherwise be empty. Make sure that you picked the correct
  range of commits, and only commits you wanted to rebase were exported
  as patch files.

- Go to the UHD repository and apply the patches:

    cd src/uhd # Or wherever your UHD repository is stored
    git am --directory fpga ~/patches/*
    rm -rf ~/patches # This is for cleanup

== Contributors ==

The following people have contributed mainly to these files (this list
is not complete):

Co-authored-by: Alex Williams <alex.williams@ni.com>
Co-authored-by: Andrej Rode <andrej.rode@ettus.com>
Co-authored-by: Ashish Chaudhari <ashish@ettus.com>
Co-authored-by: Ben Hilburn <ben.hilburn@ettus.com>
Co-authored-by: Ciro Nishiguchi <ciro.nishiguchi@ni.com>
Co-authored-by: Daniel Jepson <daniel.jepson@ni.com>
Co-authored-by: Derek Kozel <derek.kozel@ettus.com>
Co-authored-by: EJ Kreinar <ej@he360.com>
Co-authored-by: Humberto Jimenez <humberto.jimenez@ni.com>
Co-authored-by: Ian Buckley <ian.buckley@gmail.com>
Co-authored-by: Jörg Hofrichter <joerg.hofrichter@ni.com>
Co-authored-by: Jon Kiser <jon.kiser@ni.com>
Co-authored-by: Josh Blum <josh@joshknows.com>
Co-authored-by: Jonathon Pendlum <jonathan.pendlum@ettus.com>
Co-authored-by: Martin Braun <martin.braun@ettus.com>
Co-authored-by: Matt Ettus <matt@ettus.com>
Co-authored-by: Michael West <michael.west@ettus.com>
Co-authored-by: Moritz Fischer <moritz.fischer@ettus.com>
Co-authored-by: Nick Foster <nick@ettus.com>
Co-authored-by: Nicolas Cuervo <nicolas.cuervo@ettus.com>
Co-authored-by: Paul Butler <paul.butler@ni.com>
Co-authored-by: Paul David <paul.david@ettus.com>
Co-authored-by: Ryan Marlow <ryan.marlow@ettus.com>
Co-authored-by: Sugandha Gupta <sugandha.gupta@ettus.com>
Co-authored-by: Sylvain Munaut <tnt@246tNt.com>
Co-authored-by: Trung Tran <trung.tran@ettus.com>
Co-authored-by: Vidush Vishwanath <vidush.vishwanath@ettus.com>
Co-authored-by: Wade Fife <wade.fife@ettus.com>


Original-commit: bafa9d95453387814ef25e6b6256ba8db2df612f
2020-01-28 09:35:36 -08:00

133 lines
3.7 KiB
Verilog

//
// Copyright 2016 Ettus Research
// Copyright 2018 Ettus Research, a National Instruments Company
//
// SPDX-License-Identifier: LGPL-3.0-or-later
//
module cic_interpolate #(
parameter WIDTH = 16,
parameter N = 4,
parameter MAX_RATE = 128
)(
input clk,
input reset,
input rate_stb,
input [$clog2(MAX_RATE+1)-1:0] rate, // +1 due to $clog2() rounding
input strobe_in,
output reg strobe_out,
input [WIDTH-1:0] signal_in,
output reg [WIDTH-1:0] signal_out
);
wire [WIDTH+$clog2(MAX_RATE**(N-1))-1:0] signal_in_ext;
reg [WIDTH+$clog2(MAX_RATE**(N-1))-1:0] integrator [0:N-1];
reg [WIDTH+$clog2(MAX_RATE**(N-1))-1:0] differentiator [0:N-1];
reg [WIDTH+$clog2(MAX_RATE**(N-1))-1:0] pipeline [0:N-1];
reg [WIDTH+$clog2(MAX_RATE**(N-1))-1:0] sampler;
reg [N-1:0] strobe_diff;
reg [N-1:0] strobe_integ;
reg strobe_sampler;
integer i;
sign_extend #(WIDTH,WIDTH+$clog2(MAX_RATE**(N-1))) ext_input (.in(signal_in),.out(signal_in_ext));
// Differentiate
always @(posedge clk) begin
if (reset) begin
strobe_diff <= 'd0;
for (i = 0; i < N; i = i + 1) begin
differentiator[i] <= 0;
pipeline[i] <= 0;
end
end else begin
strobe_diff <= {strobe_diff[N-2:0], strobe_in};
if (strobe_in) begin
differentiator[0] <= signal_in_ext;
pipeline[0] <= signal_in_ext - differentiator[0];
end
for (i = 1; i < N; i = i + 1) begin
if (strobe_diff[i-1]) begin
differentiator[i] <= pipeline[i-1];
pipeline[i] <= pipeline[i-1] - differentiator[i];
end
end
end
end
// Strober
reg [$clog2(MAX_RATE+1)-1:0] counter;
wire strobe_out_int;
always @(posedge clk) begin
if (reset | rate_stb) begin
counter <= rate;
end else if (strobe_diff[N-1]) begin
counter <= rate - 1;
end else begin
if (counter == 0) begin
counter <= rate;
end else if (counter < rate) begin
counter <= counter - 1;
end
end
end
assign strobe_out_int = (counter < rate) & ~rate_stb;
// Integrate
always @(posedge clk) begin
if (reset) begin
strobe_sampler <= 1'b0;
strobe_integ <= 'd0;
for (i = 0; i < N; i = i + 1) begin
integrator[i] <= 0;
end
end else begin
strobe_sampler <= strobe_diff[N-1];
if (strobe_diff[N-1]) begin
sampler <= pipeline[N-1];
end
strobe_integ <= {strobe_integ[N-2:0],strobe_out_int};
if (strobe_sampler) begin
integrator[0] <= integrator[0] + sampler;
end
for (i = 1; i < N; i = i + 1) begin
if (strobe_integ[i-1]) begin
integrator[i] <= integrator[i] + integrator[i-1];
end
end
end
end
genvar l;
wire [WIDTH-1:0] signal_out_shifted[0:MAX_RATE];
wire signal_out_shifted_strobe[0:MAX_RATE];
generate
for (l = 0; l <= MAX_RATE; l = l + 1) begin
axi_round #(
.WIDTH_IN((l == 0 || l == 1) ? WIDTH : $clog2(l**(N-1))+WIDTH),
.WIDTH_OUT(WIDTH))
axi_round (
.clk(clk), .reset(reset),
.i_tdata((l == 0 || l == 1) ? integrator[N-1][WIDTH-1:0] : integrator[N-1][$clog2(l**(N-1))+WIDTH-1:0]),
.i_tlast(1'b0), .i_tvalid(strobe_integ[N-1]), .i_tready(),
.o_tdata(signal_out_shifted[l]), .o_tlast(), .o_tvalid(signal_out_shifted_strobe[l]), .o_tready(1'b1));
end
endgenerate
// Output register
always @(posedge clk) begin
if (reset) begin
strobe_out <= 1'b0;
signal_out <= 'd0;
end else begin
strobe_out <= signal_out_shifted_strobe[0]; // Any of the strobes will work here
signal_out <= signal_out_shifted[rate];
end
end
endmodule