diff options
author | Martin Braun <martin.braun@ettus.com> | 2020-01-23 16:10:22 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2020-01-28 09:35:36 -0800 |
commit | bafa9d95453387814ef25e6b6256ba8db2df612f (patch) | |
tree | 39ba24b5b67072d354775272e687796bb511848d /fpga/usrp3/lib/rfnoc/utils/context_handler_sync.v | |
parent | 3075b981503002df3115d5f1d0b97d2619ba30f2 (diff) | |
download | uhd-bafa9d95453387814ef25e6b6256ba8db2df612f.tar.gz uhd-bafa9d95453387814ef25e6b6256ba8db2df612f.tar.bz2 uhd-bafa9d95453387814ef25e6b6256ba8db2df612f.zip |
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>
Diffstat (limited to 'fpga/usrp3/lib/rfnoc/utils/context_handler_sync.v')
-rw-r--r-- | fpga/usrp3/lib/rfnoc/utils/context_handler_sync.v | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/fpga/usrp3/lib/rfnoc/utils/context_handler_sync.v b/fpga/usrp3/lib/rfnoc/utils/context_handler_sync.v new file mode 100644 index 000000000..c7f899ee9 --- /dev/null +++ b/fpga/usrp3/lib/rfnoc/utils/context_handler_sync.v @@ -0,0 +1,110 @@ +// +// Copyright 2018-2019 Ettus Research, A National Instruments Company +// +// SPDX-License-Identifier: LGPL-3.0-or-later +// +// Module: context_handler_sync +// Description: +// +// Parameters: +// - CHDR_W: Width of the input CHDR bus in bits +// +// Signals: +// + +module context_handler_sync #( + parameter CHDR_W = 256, + parameter ITEM_W = 32, + parameter NIPC = 2 +)( + // Clock and reset + input wire clk, + input wire rst, + // Context stream in (AXI-Stream) + input wire [CHDR_W-1:0] s_axis_context_tdata, + input wire [3:0] s_axis_context_tuser, + input wire s_axis_context_tlast, + input wire s_axis_context_tvalid, + output wire s_axis_context_tready, + // Context stream out (AXI-Stream) + output wire [CHDR_W-1:0] m_axis_context_tdata, + output wire [3:0] m_axis_context_tuser, + output wire m_axis_context_tlast, + output wire m_axis_context_tvalid, + input wire m_axis_context_tready, + // Input payload stream monitor + input wire [NIPC-1:0] in_payload_tkeep, + input wire in_payload_tlast, + input wire in_payload_tvalid, + input wire in_payload_tready, + // Output payload stream monitor + input wire [NIPC-1:0] out_payload_tkeep, + input wire out_payload_tlast, + input wire out_payload_tvalid, + input wire out_payload_tready, + // Status + output reg length_err_stb, + output reg seq_err_stb +); + + `include "../core/rfnoc_chdr_utils.vh" + + // Thermometer to binary decoder + // 4'b0000 => 3'd0 + // 4'b0001 => 3'd1 + // 4'b0011 => 3'd2 + // 4'b0111 => 3'd3 + // 4'b1111 => 3'd4 + function [$clog2(NIPC):0] thermo2bin(input [NIPC-1:0] thermo); + reg [NIPC:0] onehot; + integer i; + begin + onehot = thermo + 1; + thermo2bin = 0; + for (i = 0; i <= NIPC; i=i+1) + if (onehot[i]) + thermo2bin = thermo2bin | i; + end + endfunction + + axi_fifo #(.WIDTH(CHDR_W+4+1), .SIZE(1)) ctxt_pipe_i ( + .clk(clk), .reset(rst), .clear(1'b0), + .i_tdata({s_axis_context_tlast, s_axis_context_tuser, s_axis_context_tdata}), + .i_tvalid(s_axis_context_tvalid), .i_tready(s_axis_context_tready), + .o_tdata({m_axis_context_tlast, m_axis_context_tuser, m_axis_context_tdata}), + .o_tvalid(m_axis_context_tvalid), .o_tready(m_axis_context_tready), + .space(), .occupied() + ); + + wire is_ctxt_hdr = s_axis_context_tvalid && s_axis_context_tready && + (s_axis_context_tuser == CONTEXT_FIELD_HDR || + s_axis_context_tuser == CONTEXT_FIELD_HDR_TS); + + reg [15:0] exp_pkt_len = 16'd0; + reg [15:0] exp_seq_num = 16'd0; + reg check_seq_num = 1'b0; + always @(posedge clk) begin + if (rst) begin + exp_pkt_len <= 16'd0; + check_seq_num <= 1'b0; + end else if (is_ctxt_hdr) begin + check_seq_num <= 1'b1; + exp_pkt_len <= chdr_get_length(s_axis_context_tdata[63:0]); + exp_seq_num <= chdr_get_seq_num(s_axis_context_tdata[63:0]) + 16'd1; + end + seq_err_stb <= is_ctxt_hdr && check_seq_num && + (exp_seq_num != chdr_get_seq_num(s_axis_context_tdata[63:0])); + end + + reg [15:0] pyld_pkt_len = 16'd0; + always @(posedge clk) begin + if (rst) begin + pyld_pkt_len <= 16'd0; + end else if (in_payload_tvalid && in_payload_tready) begin + pyld_pkt_len <= in_payload_tlast ? 16'd0 : (pyld_pkt_len + ((ITEM_W*NIPC)/8)); + end + length_err_stb <= in_payload_tvalid && in_payload_tready && in_payload_tlast && + (pyld_pkt_len + (thermo2bin(in_payload_tkeep)*(ITEM_W/8)) != exp_pkt_len); + end + +endmodule // context_handler_sync |