From bafa9d95453387814ef25e6b6256ba8db2df612f Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Thu, 23 Jan 2020 16:10:22 -0800 Subject: Merge FPGA repository back into UHD repository MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Co-authored-by: Andrej Rode Co-authored-by: Ashish Chaudhari Co-authored-by: Ben Hilburn Co-authored-by: Ciro Nishiguchi Co-authored-by: Daniel Jepson Co-authored-by: Derek Kozel Co-authored-by: EJ Kreinar Co-authored-by: Humberto Jimenez Co-authored-by: Ian Buckley Co-authored-by: Jörg Hofrichter Co-authored-by: Jon Kiser Co-authored-by: Josh Blum Co-authored-by: Jonathon Pendlum Co-authored-by: Martin Braun Co-authored-by: Matt Ettus Co-authored-by: Michael West Co-authored-by: Moritz Fischer Co-authored-by: Nick Foster Co-authored-by: Nicolas Cuervo Co-authored-by: Paul Butler Co-authored-by: Paul David Co-authored-by: Ryan Marlow Co-authored-by: Sugandha Gupta Co-authored-by: Sylvain Munaut Co-authored-by: Trung Tran Co-authored-by: Vidush Vishwanath Co-authored-by: Wade Fife --- fpga/usrp3/lib/rfnoc/noc_traffic_counter.v | 128 +++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 fpga/usrp3/lib/rfnoc/noc_traffic_counter.v (limited to 'fpga/usrp3/lib/rfnoc/noc_traffic_counter.v') diff --git a/fpga/usrp3/lib/rfnoc/noc_traffic_counter.v b/fpga/usrp3/lib/rfnoc/noc_traffic_counter.v new file mode 100644 index 000000000..5ac2ff44e --- /dev/null +++ b/fpga/usrp3/lib/rfnoc/noc_traffic_counter.v @@ -0,0 +1,128 @@ +// +// Copyright 2018 Ettus Research, a National Instruments Company +// +// SPDX-License-Identifier: LGPL-3.0-or-later +// + +module noc_traffic_counter #( + parameter SR_REG_BASE = 128, + parameter RB_REG_BASE = 0) +( + input bus_clk, input bus_rst, + input ce_clk, input ce_rst, + + // Control sink + input [31:0] set_data, input [7:0] set_addr, input set_stb, + output rb_stb, input [7:0] rb_addr, output [63:0] rb_data, + + // Traffic signals to count + input i_tlast, input i_tvalid, input i_tready, + input o_tlast, input o_tvalid, input o_tready, + input str_sink_tlast, input str_sink_tvalid, input str_sink_tready, + input str_src_tlast, input str_src_tvalid, input str_src_tready +); + wire en, counter_enable_changed; + + wire [31:0] set_data_bclk; + wire [7:0] set_addr_bclk; + wire set_stb_bclk; + + reg [63:0] rb_data_bclk; + wire [7:0] rb_addr_bclk; + reg rb_stb_bclk; + + reg [63:0] tick_cnt_noc_shell; + + wire [63:0] xbar_to_shell_xfer_cnt; + wire [63:0] xbar_to_shell_pkt_cnt; + + wire [63:0] shell_to_xbar_xfer_cnt; + wire [63:0] shell_to_xbar_pkt_cnt; + + wire [63:0] shell_to_ce_xfer_cnt; + wire [63:0] shell_to_ce_pkt_cnt; + + wire [63:0] ce_to_shell_xfer_cnt; + wire [63:0] ce_to_shell_pkt_cnt; + + localparam SR_COUNTER_ENABLE = SR_REG_BASE + 0; + + localparam RB_SIGNATURE = RB_REG_BASE + 0; + localparam RB_BUS_CLK_TICKS = RB_REG_BASE + 1; + localparam RB_XBAR_TO_SHELL_XFER_CNT = RB_REG_BASE + 2; + localparam RB_XBAR_TO_SHELL_PKT_CNT = RB_REG_BASE + 3; + localparam RB_SHELL_TO_XBAR_XFER_CNT = RB_REG_BASE + 4; + localparam RB_SHELL_TO_XBAR_PKT_CNT = RB_REG_BASE + 5; + localparam RB_SHELL_TO_CE_XFER_CNT = RB_REG_BASE + 6; + localparam RB_SHELL_TO_CE_PKT_CNT = RB_REG_BASE + 7; + localparam RB_CE_TO_SHELL_XFER_CNT = RB_REG_BASE + 8; + localparam RB_CE_TO_SHELL_PKT_CNT = RB_REG_BASE + 9; + + // Registers are implemented on bus clock + axi_fifo_2clk #(.WIDTH(8+8+32), .SIZE(2)) reg_write_to_bclk ( + .reset(ce_rst), .i_aclk(ce_clk), + .i_tdata({set_addr, rb_addr, set_data}), .i_tvalid(set_stb), .i_tready(), + .o_aclk(bus_clk), + .o_tdata({set_addr_bclk, rb_addr_bclk, set_data_bclk}), .o_tvalid(set_stb_bclk), .o_tready(1'b1)); + + axi_fifo_2clk #(.WIDTH(64), .SIZE(2)) reg_rb_from_bclk ( + .reset(bus_rst), .i_aclk(bus_clk), + .i_tdata(rb_data_bclk), .i_tvalid(rb_stb_bclk), .i_tready(), + .o_aclk(ce_clk), + .o_tdata(rb_data), .o_tvalid(rb_stb), .o_tready(1'b1)); + + setting_reg #(.my_addr(SR_COUNTER_ENABLE), .width(1)) enable_measurement_reg ( + .clk(bus_clk), .rst(bus_rst), .strobe(set_stb_bclk), .addr(set_addr_bclk), + .in(set_data_bclk), .out(en), .changed(counter_enable_changed)); + + always @(posedge bus_clk) + if (set_stb_bclk) begin + case(rb_addr_bclk) + RB_SIGNATURE : rb_data_bclk <= 64'h712AFF1C00000000; + RB_BUS_CLK_TICKS : rb_data_bclk <= tick_cnt_noc_shell; + RB_XBAR_TO_SHELL_XFER_CNT : rb_data_bclk <= xbar_to_shell_xfer_cnt; + RB_XBAR_TO_SHELL_PKT_CNT : rb_data_bclk <= xbar_to_shell_pkt_cnt; + RB_SHELL_TO_XBAR_XFER_CNT : rb_data_bclk <= shell_to_xbar_xfer_cnt; + RB_SHELL_TO_XBAR_PKT_CNT : rb_data_bclk <= shell_to_xbar_pkt_cnt; + RB_SHELL_TO_CE_XFER_CNT : rb_data_bclk <= shell_to_ce_xfer_cnt; + RB_SHELL_TO_CE_PKT_CNT : rb_data_bclk <= shell_to_ce_pkt_cnt; + RB_CE_TO_SHELL_XFER_CNT : rb_data_bclk <= ce_to_shell_xfer_cnt; + RB_CE_TO_SHELL_PKT_CNT : rb_data_bclk <= ce_to_shell_pkt_cnt; + default : rb_data_bclk <= 64'h0BADC0DE0BADC0DE; + endcase + end + + always @(posedge bus_clk) + rb_stb_bclk <= set_stb_bclk; + + assign counter_rst = en & counter_enable_changed; + + axis_strm_monitor #(.COUNT_W(64), .PKT_COUNT_EN(1), .XFER_COUNT_EN(1)) xbar_to_shell ( + .clk(bus_clk), .reset(counter_rst), + .axis_tdata(), .axis_tlast(i_tlast & en), .axis_tvalid(i_tvalid & en), .axis_tready(i_tready & en), + .xfer_count(xbar_to_shell_xfer_cnt), .pkt_count(xbar_to_shell_pkt_cnt)); + + axis_strm_monitor #(.COUNT_W(64), .PKT_COUNT_EN(1), .XFER_COUNT_EN(1)) shell_to_xbar ( + .clk(bus_clk), .reset(counter_rst), + .axis_tdata(), .axis_tlast(o_tlast & en), .axis_tvalid(o_tvalid & en), .axis_tready(o_tready & en), + .xfer_count(shell_to_xbar_xfer_cnt), .pkt_count(shell_to_xbar_pkt_cnt)); + + axis_strm_monitor #(.COUNT_W(64), .PKT_COUNT_EN(1), .XFER_COUNT_EN(1)) shell_to_ce ( + .clk(bus_clk), .reset(counter_rst), + .axis_tdata(), .axis_tlast(str_sink_tlast & en), .axis_tvalid(str_sink_tvalid & en), .axis_tready(str_sink_tready & en), + .xfer_count(shell_to_ce_xfer_cnt), .pkt_count(shell_to_ce_pkt_cnt)); + + axis_strm_monitor #(.COUNT_W(64), .PKT_COUNT_EN(1), .XFER_COUNT_EN(1)) ce_to_shell ( + .clk(bus_clk), .reset(counter_rst), + .axis_tdata(), .axis_tlast(str_src_tlast & en), .axis_tvalid(str_src_tvalid & en), .axis_tready(str_src_tready & en), + .xfer_count(ce_to_shell_xfer_cnt), .pkt_count(ce_to_shell_pkt_cnt)); + + // Count clock ticks + always @(posedge bus_clk) + if (counter_rst) + tick_cnt_noc_shell <= 0; + else + if (en) + tick_cnt_noc_shell <= tick_cnt_noc_shell + 1; + +endmodule -- cgit v1.2.3