|
| 1 | +// *************************************************************************** |
| 2 | +// *************************************************************************** |
| 3 | +// Copyright (C) 2024-2025 Analog Devices, Inc. All rights reserved. |
| 4 | +// |
| 5 | +// In this HDL repository, there are many different and unique modules, consisting |
| 6 | +// of various HDL (Verilog or VHDL) components. The individual modules are |
| 7 | +// developed independently, and may be accompanied by separate and unique license |
| 8 | +// terms. |
| 9 | +// |
| 10 | +// The user should read each of these license terms, and understand the |
| 11 | +// freedoms and responsibilities that he or she has by using this source/core. |
| 12 | +// |
| 13 | +// This core is distributed in the hope that it will be useful, but WITHOUT ANY |
| 14 | +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
| 15 | +// A PARTICULAR PURPOSE. |
| 16 | +// |
| 17 | +// Redistribution and use of source or resulting binaries, with or without modification |
| 18 | +// of this file, are permitted under one of the following two license terms: |
| 19 | +// |
| 20 | +// 1. The GNU General Public License version 2 as published by the |
| 21 | +// Free Software Foundation, which can be found in the top level directory |
| 22 | +// of this repository (LICENSE_GPL2), and also online at: |
| 23 | +// <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html> |
| 24 | +// |
| 25 | +// OR |
| 26 | +// |
| 27 | +// 2. An ADI specific BSD license, which can be found in the top level directory |
| 28 | +// of this repository (LICENSE_ADIBSD), and also on-line at: |
| 29 | +// https://github.com/analogdevicesinc/hdl/blob/main/LICENSE_ADIBSD |
| 30 | +// This will allow to generate bit files and not release the source code, |
| 31 | +// as long as it attaches to an ADI device. |
| 32 | +// |
| 33 | +// *************************************************************************** |
| 34 | +// *************************************************************************** |
| 35 | + |
| 36 | +`include "utils.svh" |
| 37 | +`include "axis_definitions.svh" |
| 38 | + |
| 39 | +import logger_pkg::*; |
| 40 | +import test_harness_env_pkg::*; |
| 41 | +import environment_pkg::*; |
| 42 | +import watchdog_pkg::*; |
| 43 | +import m_axis_sequencer_pkg::*; |
| 44 | + |
| 45 | +import `PKGIFY(test_harness, mng_axi_vip)::*; |
| 46 | +import `PKGIFY(test_harness, ddr_axi_vip)::*; |
| 47 | + |
| 48 | +import `PKGIFY(test_harness, input_axis)::*; |
| 49 | +import `PKGIFY(test_harness, output_axis)::*; |
| 50 | + |
| 51 | +program test_tkeep (); |
| 52 | + |
| 53 | + timeunit 1ns; |
| 54 | + timeprecision 1ps; |
| 55 | + |
| 56 | + // declare the class instances |
| 57 | + test_harness_env #(`AXI_VIP_PARAMS(test_harness, mng_axi_vip), `AXI_VIP_PARAMS(test_harness, ddr_axi_vip)) base_env; |
| 58 | + util_axis_fifo_environment #(`AXIS_VIP_PARAMS(test_harness, input_axis), `AXIS_VIP_PARAMS(test_harness, output_axis), `INPUT_CLK, `OUTPUT_CLK) uaf_env; |
| 59 | + |
| 60 | + watchdog send_data_wd; |
| 61 | + |
| 62 | + int byte_count, sample_count; |
| 63 | + |
| 64 | + initial begin |
| 65 | + |
| 66 | + // create environment |
| 67 | + base_env = new("Base Environment", |
| 68 | + `TH.`SYS_CLK.inst.IF, |
| 69 | + `TH.`DMA_CLK.inst.IF, |
| 70 | + `TH.`DDR_CLK.inst.IF, |
| 71 | + `TH.`SYS_RST.inst.IF, |
| 72 | + `TH.`MNG_AXI.inst.IF, |
| 73 | + `TH.`DDR_AXI.inst.IF); |
| 74 | + |
| 75 | + uaf_env = new("Util AXIS FIFO Environment", |
| 76 | + `TH.`INPUT_CLK_VIP.inst.IF, |
| 77 | + `TH.`OUTPUT_CLK_VIP.inst.IF, |
| 78 | + `TH.`INPUT_AXIS.inst.IF, |
| 79 | + `TH.`OUTPUT_AXIS.inst.IF); |
| 80 | + |
| 81 | + setLoggerVerbosity(ADI_VERBOSITY_NONE); |
| 82 | + |
| 83 | + base_env.start(); |
| 84 | + uaf_env.start(); |
| 85 | + |
| 86 | + base_env.sys_reset(); |
| 87 | + |
| 88 | + uaf_env.configure(); |
| 89 | + uaf_env.input_axis_agent.sequencer.set_keep_some(); |
| 90 | + uaf_env.input_axis_agent.sequencer.set_data_gen_mode(DATA_GEN_MODE_TEST_DATA_TKEEP); |
| 91 | + uaf_env.input_axis_agent.sequencer.set_descriptor_gen_mode(0); |
| 92 | + |
| 93 | + uaf_env.run(); |
| 94 | + |
| 95 | + send_data_wd = new("Util AXIS FIFO Watchdog", 50000, "Send data"); |
| 96 | + |
| 97 | + send_data_wd.start(); |
| 98 | + |
| 99 | + uaf_env.input_axis_agent.sequencer.start(); |
| 100 | + |
| 101 | + // stimulus |
| 102 | + //repeat($urandom_range(5,10)) begin |
| 103 | + repeat(1) begin |
| 104 | + send_data_wd.reset(); |
| 105 | + |
| 106 | + if ((!`TKEEP_EN || !`TLAST_EN) && `INPUT_WIDTH < `OUTPUT_WIDTH) begin |
| 107 | + `FATAL(("bad parameter case")); |
| 108 | + repeat($urandom_range(1,5)) begin |
| 109 | + sample_count = $urandom_range(1,128); |
| 110 | + repeat(sample_count) begin |
| 111 | + uaf_env.input_axis_agent.sequencer.push_byte_for_stream($urandom_range(0,255)); |
| 112 | + uaf_env.input_axis_agent.sequencer.push_tkeep_for_stream($urandom_range(0,1)); |
| 113 | + end |
| 114 | + uaf_env.input_axis_agent.sequencer.add_xfer_descriptor_sample_count(sample_count*`OUTPUT_WIDTH/`INPUT_WIDTH, `TLAST_EN, 0); |
| 115 | + end |
| 116 | + end else begin |
| 117 | + //repeat($urandom_range(1,5)) begin |
| 118 | + repeat(1) begin |
| 119 | + byte_count = 16;//$urandom_range(1,1024); |
| 120 | + repeat(byte_count) begin |
| 121 | + uaf_env.input_axis_agent.sequencer.push_byte_for_stream($urandom_range(0,255)); |
| 122 | + uaf_env.input_axis_agent.sequencer.push_tkeep_for_stream($urandom_range(0,1)); |
| 123 | + end |
| 124 | + uaf_env.input_axis_agent.sequencer.add_xfer_descriptor_byte_count(byte_count, `TLAST_EN, 0); |
| 125 | + end |
| 126 | + end |
| 127 | + |
| 128 | + |
| 129 | + #($urandom_range(1,10)*1us); |
| 130 | + |
| 131 | + uaf_env.input_axis_agent.sequencer.clear_descriptor_queue(); |
| 132 | + uaf_env.input_axis_agent.sequencer.wait_empty_descriptor_queue(); |
| 133 | + |
| 134 | + uaf_env.scoreboard_inst.wait_until_complete(); |
| 135 | + |
| 136 | + end |
| 137 | + |
| 138 | + send_data_wd.stop(); |
| 139 | + |
| 140 | + #100ns; |
| 141 | + |
| 142 | + uaf_env.stop(); |
| 143 | + base_env.stop(); |
| 144 | + |
| 145 | + `INFO(("Test bench done!"), ADI_VERBOSITY_NONE); |
| 146 | + $finish(); |
| 147 | + |
| 148 | + end |
| 149 | + |
| 150 | +endprogram |
0 commit comments