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/noc_traffic_counter.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/noc_traffic_counter.v')
-rw-r--r-- | fpga/usrp3/lib/rfnoc/noc_traffic_counter.v | 128 |
1 files changed, 128 insertions, 0 deletions
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 |