|
| 1 | +// *************************************************************************** |
| 2 | +// *************************************************************************** |
| 3 | +// Copyright (C) 2023-2024 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 | +package spi_environment_pkg; |
| 40 | + |
| 41 | + import logger_pkg::*; |
| 42 | + import adi_environment_pkg::*; |
| 43 | + |
| 44 | + import m_axis_sequencer_pkg::*; |
| 45 | + import adi_axis_agent_pkg::*; |
| 46 | + import adi_spi_vip_pkg::*; |
| 47 | + import adi_spi_vip_if_base_pkg::*; |
| 48 | + |
| 49 | + `ifdef DEF_SDO_STREAMING |
| 50 | + import `PKGIFY(test_harness, sdo_src)::*; |
| 51 | + `endif |
| 52 | + |
| 53 | + class spi_environment extends adi_environment; |
| 54 | + |
| 55 | + // Agents |
| 56 | + adi_spi_agent spi_agent; |
| 57 | + `ifdef DEF_SDO_STREAMING |
| 58 | + adi_axis_master_agent #(`AXIS_VIP_PARAM_ORDER(test_harness_sdo_src_0)) sdo_src_agent; |
| 59 | + `endif |
| 60 | + |
| 61 | + //============================================================================ |
| 62 | + // Constructor |
| 63 | + //============================================================================ |
| 64 | + function new( |
| 65 | + input string name, |
| 66 | + |
| 67 | + `ifdef DEF_SDO_STREAMING |
| 68 | + virtual interface axi4stream_vip_if #(`AXIS_VIP_IF_PARAMS(test_harness_sdo_src_0)) sdo_src_axis_vip_if, |
| 69 | + `endif |
| 70 | + adi_spi_vip_if_base spi_s_vip_if); |
| 71 | + |
| 72 | + super.new(name); |
| 73 | + |
| 74 | + // Creating the agents |
| 75 | + this.spi_agent = new("SPI VIP Agent", spi_s_vip_if, this); |
| 76 | + `ifdef DEF_SDO_STREAMING |
| 77 | + this.sdo_src_agent = new("SDO Source AXI Stream Agent", sdo_src_axis_vip_if); |
| 78 | + `endif |
| 79 | + |
| 80 | + // downgrade reset check: we are currently using a clock generator for the SPI clock, |
| 81 | + // so it will come a bit after the reset and trigger the default error. |
| 82 | + // This is harmless for this test (we don't want to test any reset scheme) |
| 83 | + `ifdef DEF_SDO_STREAMING |
| 84 | + sdo_src_axis_vip_if.set_xilinx_reset_check_to_warn(); |
| 85 | + `endif |
| 86 | + endfunction |
| 87 | + |
| 88 | + //============================================================================ |
| 89 | + // Configure environment |
| 90 | + // - Configure the sequencers with an initial configuration before starting |
| 91 | + //============================================================================ |
| 92 | + task configure(); |
| 93 | + `ifdef DEF_SDO_STREAMING |
| 94 | + this.sdo_src_agent.sequencer.set_stop_policy(STOP_POLICY_PACKET); |
| 95 | + this.sdo_src_agent.sequencer.set_data_gen_mode(DATA_GEN_MODE_TEST_DATA); |
| 96 | + `endif |
| 97 | + endtask |
| 98 | + |
| 99 | + //============================================================================ |
| 100 | + // Start environment |
| 101 | + // - Connect all the agents to the scoreboard |
| 102 | + // - Start the agents |
| 103 | + //============================================================================ |
| 104 | + task start(); |
| 105 | + this.spi_agent.start(); |
| 106 | + `ifdef DEF_SDO_STREAMING |
| 107 | + this.sdo_src_agent.start(); |
| 108 | + `endif |
| 109 | + endtask |
| 110 | + |
| 111 | + //============================================================================ |
| 112 | + // Run subroutine |
| 113 | + //============================================================================ |
| 114 | + task run(); |
| 115 | + fork |
| 116 | + `ifdef DEF_SDO_STREAMING |
| 117 | + this.sdo_src_agent.run(); |
| 118 | + `endif |
| 119 | + join_none |
| 120 | + endtask |
| 121 | + |
| 122 | + //============================================================================ |
| 123 | + // Stop subroutine |
| 124 | + //============================================================================ |
| 125 | + task stop(); |
| 126 | + this.spi_agent.stop(); |
| 127 | + `ifdef DEF_SDO_STREAMING |
| 128 | + this.sdo_src_agent.stop(); |
| 129 | + `endif |
| 130 | + endtask |
| 131 | + |
| 132 | + endclass |
| 133 | + |
| 134 | +endpackage |
0 commit comments