|
| 1 | +// *************************************************************************** |
| 2 | +// *************************************************************************** |
| 3 | +// Copyright 2024 (c) 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 responsabilities 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 | + |
| 38 | +package ad57xx_environment_pkg; |
| 39 | + |
| 40 | + import axi_vip_pkg::*; |
| 41 | + import axi4stream_vip_pkg::*; |
| 42 | + import m_axi_sequencer_pkg::*; |
| 43 | + import s_axi_sequencer_pkg::*; |
| 44 | + import s_spi_sequencer_pkg::*; |
| 45 | + import adi_spi_vip_pkg::*; |
| 46 | + import test_harness_env_pkg::*; |
| 47 | + import `PKGIFY(test_harness, mng_axi_vip)::*; |
| 48 | + import `PKGIFY(test_harness, ddr_axi_vip)::*; |
| 49 | + import `PKGIFY(test_harness, spi_s_vip)::*; |
| 50 | + |
| 51 | + class ad57xx_environment extends test_harness_env; |
| 52 | + |
| 53 | + // Agents |
| 54 | + adi_spi_agent #(`SPI_VIP_PARAMS(test_harness, spi_s_vip)) spi_agent; |
| 55 | + |
| 56 | + // Sequencers |
| 57 | + s_spi_sequencer #(`SPI_VIP_PARAMS(test_harness, spi_s_vip)) spi_seq; |
| 58 | + |
| 59 | + //============================================================================ |
| 60 | + // Constructor |
| 61 | + //============================================================================ |
| 62 | + function new( |
| 63 | + virtual interface clk_vip_if #(.C_CLK_CLOCK_PERIOD(10)) sys_clk_vip_if, |
| 64 | + virtual interface clk_vip_if #(.C_CLK_CLOCK_PERIOD(5)) dma_clk_vip_if, |
| 65 | + virtual interface clk_vip_if #(.C_CLK_CLOCK_PERIOD(2.5)) ddr_clk_vip_if, |
| 66 | + |
| 67 | + virtual interface rst_vip_if #(.C_ASYNCHRONOUS(1), .C_RST_POLARITY(1)) sys_rst_vip_if, |
| 68 | + |
| 69 | + virtual interface axi_vip_if #(`AXI_VIP_IF_PARAMS(test_harness, mng_axi_vip)) mng_vip_if, |
| 70 | + virtual interface axi_vip_if #(`AXI_VIP_IF_PARAMS(test_harness, ddr_axi_vip)) ddr_vip_if, |
| 71 | + virtual interface spi_vip_if #(`SPI_VIP_PARAMS(test_harness, spi_s_vip)) spi_s_vip_if |
| 72 | + ); |
| 73 | + |
| 74 | + super.new(sys_clk_vip_if, |
| 75 | + dma_clk_vip_if, |
| 76 | + ddr_clk_vip_if, |
| 77 | + sys_rst_vip_if, |
| 78 | + mng_vip_if, |
| 79 | + ddr_vip_if); |
| 80 | + |
| 81 | + // Creating the agents |
| 82 | + spi_agent = new(spi_s_vip_if); |
| 83 | + |
| 84 | + // Creating the sequencers |
| 85 | + spi_seq = new(spi_agent); |
| 86 | + |
| 87 | + endfunction |
| 88 | + |
| 89 | + //============================================================================ |
| 90 | + // Start environment |
| 91 | + // - Connect all the agents to the scoreboard |
| 92 | + // - Start the agents |
| 93 | + //============================================================================ |
| 94 | + task start(); |
| 95 | + super.start(); |
| 96 | + spi_agent.start(); |
| 97 | + endtask |
| 98 | + |
| 99 | + //============================================================================ |
| 100 | + // Start the test |
| 101 | + // - start the scoreboard |
| 102 | + // - start the sequencers |
| 103 | + //============================================================================ |
| 104 | + task test(); |
| 105 | + super.test(); |
| 106 | + fork |
| 107 | + |
| 108 | + join_none |
| 109 | + endtask |
| 110 | + |
| 111 | + //============================================================================ |
| 112 | + // Post test subroutine |
| 113 | + //============================================================================ |
| 114 | + task post_test(); |
| 115 | + super.post_test(); |
| 116 | + endtask |
| 117 | + |
| 118 | + //============================================================================ |
| 119 | + // Run subroutine |
| 120 | + //============================================================================ |
| 121 | + task run; |
| 122 | + test(); |
| 123 | + post_test(); |
| 124 | + endtask |
| 125 | + |
| 126 | + //============================================================================ |
| 127 | + // Stop subroutine |
| 128 | + //============================================================================ |
| 129 | + task stop; |
| 130 | + spi_agent.stop(); |
| 131 | + super.stop(); |
| 132 | + endtask |
| 133 | + |
| 134 | + endclass |
| 135 | + |
| 136 | +endpackage |
0 commit comments