Files
b210-k7-fpga/top/n3xx/sim/dram_fifo/dram_fifo_tb.sv
T
+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

164 lines
5.5 KiB
Systemverilog

//
// Copyright 2016 Ettus Research
//
`timescale 1ns/1ps
`define SIM_TIMEOUT_US 120
`define NS_PER_TICK 1
`define NUM_TEST_CASES 7
`include "sim_clks_rsts.vh"
`include "sim_exec_report.vh"
`include "sim_cvita_lib.svh"
`include "sim_axi4_lib.svh"
`include "sim_set_rb_lib.svh"
module dram_fifo_tb();
`TEST_BENCH_INIT("dram_fifo_tb",`NUM_TEST_CASES,`NS_PER_TICK)
// Define all clocks and resets
`DEFINE_DIFF_CLK(sys_clk_p, sys_clk_n, 10, 50) //100MHz differential sys_clk to generate DDR3 clocking
`DEFINE_CLK(bus_clk, 1000/200, 50) //200MHz bus_clk
`DEFINE_CLK(dma_engine_clk, 1000.0/305.0, 50) //305MHz dma_engine_clk
`DEFINE_RESET(bus_rst, 0, 100) //100ns for GSR to deassert
`DEFINE_RESET_N(sys_rst_n, 0, 100) //100ns for GSR to deassert
settings_bus_master #(.SR_AWIDTH(8),.SR_DWIDTH(32)) tst_set (.clk(bus_clk));
cvita_master chdr_i (.clk(bus_clk));
cvita_slave chdr_o (.clk(bus_clk));
// Initialize DUT
wire calib_complete;
axis_dram_fifo_single dut_single (
.bus_clk(bus_clk),
.bus_rst(bus_rst),
.sys_clk_p(sys_clk_p),//use differential clock on N310
.sys_clk_n(sys_clk_n),
.sys_rst_n(sys_rst_n),
.dma_engine_clk(dma_engine_clk),
.i_tdata(chdr_i.axis.tdata),
.i_tlast(chdr_i.axis.tlast),
.i_tvalid(chdr_i.axis.tvalid),
.i_tready(chdr_i.axis.tready),
.o_tdata(chdr_o.axis.tdata),
.o_tlast(chdr_o.axis.tlast),
.o_tvalid(chdr_o.axis.tvalid),
.o_tready(chdr_o.axis.tready),
.set_stb(tst_set.settings_bus.set_stb),
.set_addr(tst_set.settings_bus.set_addr),
.set_data(tst_set.settings_bus.set_data),
.rb_data(),
.forced_bit_err(64'h0),
.init_calib_complete(calib_complete)
);
//Testbench variables
cvita_hdr_t header;
cvita_pkt_t pkt_out;
integer i;
//------------------------------------------
//Main thread for testbench execution
//------------------------------------------
initial begin : tb_main
string s;
`TEST_CASE_START("Wait for reset");
while (bus_rst) @(posedge bus_clk);
while (~sys_rst_n) @(posedge sys_clk_p);
`TEST_CASE_DONE((~bus_rst & sys_rst_n));
`TEST_CASE_START("Wait for initial calibration to complete");
while (calib_complete !== 1'b1) @(posedge bus_clk);
`TEST_CASE_DONE(calib_complete);
`TEST_CASE_START("Clear FIFO");
tst_set.write(1, {16'h0, 12'd280, 2'b00, 1'b0, 1'b1});
repeat (200) @(posedge bus_clk);
tst_set.write(1, {16'h0, 12'd280, 2'b00, 1'b0, 1'b0});
repeat (200) @(posedge bus_clk);
`TEST_CASE_DONE(1);
header = '{
pkt_type:DATA, has_time:0, eob:0, seqnum:12'h666,
length:0, src_sid:$random, dst_sid:$random, timestamp:64'h0};
`TEST_CASE_START("Fill up empty FIFO then drain (short packet)");
chdr_i.push_ramp_pkt(16, 64'd0, 64'h100, header);
chdr_o.pull_pkt(pkt_out);
$sformat(s, "Bad packet: Length mismatch. Expected: %0d, Actual: %0d",16,pkt_out.payload.size());
`ASSERT_ERROR(pkt_out.payload.size()==16, s);
$sformat(s, "Bad packet: Wrong SID. Expected: %08x, Actual: %08x",
{header.src_sid,header.dst_sid},{pkt_out.hdr.src_sid,pkt_out.hdr.dst_sid});
`ASSERT_ERROR({header.src_sid,header.dst_sid}=={pkt_out.hdr.src_sid,pkt_out.hdr.dst_sid}, s);
`TEST_CASE_DONE(1);
`TEST_CASE_START("Fill up empty FIFO then drain (long packet)");
chdr_i.push_ramp_pkt(1024, 64'd0, 64'h100, header);
chdr_o.pull_pkt(pkt_out);
$sformat(s, "Bad packet: Length mismatch. Expected: %0d, Actual: %0d",1024,pkt_out.payload.size());
`ASSERT_ERROR(pkt_out.payload.size()==1024, s);
$sformat(s, "Bad packet: Wrong SID. Expected: %08x, Actual: %08x",
{header.src_sid,header.dst_sid},{pkt_out.hdr.src_sid,pkt_out.hdr.dst_sid});
`ASSERT_ERROR({header.src_sid,header.dst_sid}=={pkt_out.hdr.src_sid,pkt_out.hdr.dst_sid}, s);
`TEST_CASE_DONE(1);
header = '{
pkt_type:DATA, has_time:0, eob:0, seqnum:12'h666,
length:0, src_sid:$random, dst_sid:$random, timestamp:64'h0};
`TEST_CASE_START("Concurrent read and write (single packet)");
fork
begin
chdr_i.push_ramp_pkt(20, 64'd0, 64'h100, header);
end
begin
chdr_o.pull_pkt(pkt_out);
end
join
$sformat(s, "Bad packet: Length mismatch. Expected: %0d, Actual: %0d",20,pkt_out.payload.size());
`ASSERT_ERROR(pkt_out.payload.size()==20, s);
i = 0;
repeat (20) begin
$sformat(s, "Bad packet: Wrong payload. Index: %d, Expected: %08x, Actual: %08x",
i,(i * 64'h100),pkt_out.payload[i]);
`ASSERT_ERROR(pkt_out.payload[i]==(i * 64'h100), s);
end
`TEST_CASE_DONE(1);
`TEST_CASE_START("Concurrent read and write (multiple packets)");
fork
begin
repeat (10) begin
chdr_i.push_ramp_pkt(20, 64'd0, 64'h100, header);
repeat (30) @(posedge bus_clk);
end
end
begin
repeat (10) begin
chdr_o.pull_pkt(pkt_out);
$sformat(s, "Bad packet: Length mismatch. Expected: %0d, Actual: %0d",20,pkt_out.payload.size());
`ASSERT_ERROR(pkt_out.payload.size()==20, s);
i = 0;
repeat (20) begin
$sformat(s, "Bad packet: Wrong payload. Index: %d, Expected: %08x, Actual: %08x",
i,(i * 64'h100),pkt_out.payload[i]);
`ASSERT_ERROR(pkt_out.payload[i]==(i * 64'h100), s);
end
end
end
join
`TEST_CASE_DONE(1);
`TEST_BENCH_DONE;
end
endmodule