aboutsummaryrefslogtreecommitdiffstats
path: root/fpga
diff options
context:
space:
mode:
authorWade Fife <wade.fife@ettus.com>2020-03-26 12:47:03 -0500
committerWade Fife <wade.fife@ettus.com>2020-04-14 16:37:43 -0500
commit8c6eabcd86f8e5d1e25cfed441e1acf1a0b6759a (patch)
tree9502766bfda954a07cade43acf454ca0dcb5da4d /fpga
parentfa0f4b2833119d57d331f592028ff9f032895c89 (diff)
downloaduhd-8c6eabcd86f8e5d1e25cfed441e1acf1a0b6759a.tar.gz
uhd-8c6eabcd86f8e5d1e25cfed441e1acf1a0b6759a.tar.bz2
uhd-8c6eabcd86f8e5d1e25cfed441e1acf1a0b6759a.zip
fpga: core: Add chdr_update_length function
Diffstat (limited to 'fpga')
-rw-r--r--fpga/usrp3/lib/rfnoc/core/rfnoc_chdr_utils.vh21
1 files changed, 21 insertions, 0 deletions
diff --git a/fpga/usrp3/lib/rfnoc/core/rfnoc_chdr_utils.vh b/fpga/usrp3/lib/rfnoc/core/rfnoc_chdr_utils.vh
index 047d58bc0..32376d12d 100644
--- a/fpga/usrp3/lib/rfnoc/core/rfnoc_chdr_utils.vh
+++ b/fpga/usrp3/lib/rfnoc/core/rfnoc_chdr_utils.vh
@@ -198,3 +198,24 @@ function [15:0] chdr_calc_payload_length(input [31:0] chdr_w, input [63:0] heade
chdr_calc_payload_length = payload_length;
end
endfunction
+
+// Return a CHDR header with the length field updated, based on the CHDR_W,
+// payload byte length, and current header fields.
+function [63:0] chdr_update_length(
+ input [31:0] chdr_w,
+ input [63:0] base_hdr,
+ input [15:0] payload_length
+);
+ reg [15:0] length, mdata_length, header_length;
+ begin
+ if (chdr_w == 64) begin
+ header_length = chdr_get_has_time(base_hdr) ? 2*(chdr_w/8) : (chdr_w/8);
+ end else begin
+ header_length = chdr_w/8;
+ end
+ mdata_length = chdr_get_num_mdata(base_hdr) * (chdr_w/8);
+ length = header_length + mdata_length + payload_length;
+
+ chdr_update_length = chdr_set_length(chdr_w, length);
+ end
+endfunction