Skip to content

Commit 9b3d090

Browse files
authored
ad57xx: add testbench (#122)
add a test for the ad57xx project, and also updates the spi engine tests to include sdo streaming for dac-type scenarios. Signed-off-by: Laez Barbosa <laez.barbosa@analog.com>
1 parent 460926c commit 9b3d090

21 files changed

+1273
-76
lines changed

ad57xx/Makefile

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
####################################################################################
2+
####################################################################################
3+
## Copyright 2024(c) Analog Devices, Inc.
4+
####################################################################################
5+
####################################################################################
6+
7+
# All test-bench dependencies except test programs
8+
SV_DEPS += ../common/sv/utils.svh
9+
SV_DEPS += ../common/sv/logger_pkg.sv
10+
SV_DEPS += ../common/sv/reg_accessor.sv
11+
SV_DEPS += ../common/sv/m_axis_sequencer.sv
12+
SV_DEPS += ../common/sv/s_axis_sequencer.sv
13+
SV_DEPS += ../common/sv/m_axi_sequencer.sv
14+
SV_DEPS += ../common/sv/s_axi_sequencer.sv
15+
SV_DEPS += ../common/sv/s_spi_sequencer.sv
16+
SV_DEPS += ../common/sv/spi_vip/adi_spi_vip_pkg.sv
17+
SV_DEPS += ../common/sv/dmac_api.sv
18+
SV_DEPS += ../common/sv/adi_regmap_pkg.sv
19+
SV_DEPS += ../common/sv/adi_regmap_clkgen_pkg.sv
20+
SV_DEPS += ../common/sv/adi_regmap_dmac_pkg.sv
21+
SV_DEPS += ../common/sv/adi_regmap_spi_engine_pkg.sv
22+
SV_DEPS += ../common/sv/adi_regmap_pwm_gen_pkg.sv
23+
SV_DEPS += ../common/sv/dma_trans.sv
24+
SV_DEPS += ad57xx_environment.sv
25+
SV_DEPS += system_tb.sv
26+
27+
ENV_DEPS += system_project.tcl
28+
ENV_DEPS += system_bd.tcl
29+
ENV_DEPS += ../scripts/adi_sim.tcl
30+
ENV_DEPS += ../scripts/run_sim.tcl
31+
32+
LIB_DEPS += axi_clkgen
33+
LIB_DEPS += axi_pwm_gen
34+
LIB_DEPS += axi_dmac
35+
LIB_DEPS += axi_sysid
36+
LIB_DEPS += util_axis_fifo
37+
LIB_DEPS += spi_engine/axi_spi_engine
38+
LIB_DEPS += spi_engine/spi_engine_execution
39+
LIB_DEPS += spi_engine/spi_engine_interconnect
40+
LIB_DEPS += spi_engine/spi_engine_offload
41+
LIB_DEPS += sysid_rom
42+
43+
SIM_LIB_DEPS += spi_vip
44+
45+
# default test programs
46+
# Format is: <test name>
47+
TP := $(notdir $(basename $(wildcard tests/*.sv)))
48+
49+
# config files should have the following format
50+
# cfg_<param1>_<param2>.tcl
51+
CFG_FILES := $(notdir $(wildcard cfgs/cfg*.tcl))
52+
53+
# List of tests and configuration combinations that has to be run
54+
# Format is: <configuration>:<test name>
55+
TESTS := $(foreach cfg, $(basename $(CFG_FILES)), $(addprefix $(cfg):, $(TP)))
56+
57+
include ../scripts/project-sim.mk
58+
59+
# usage :
60+
#
61+
# run specific test on a specific configuration in gui mode
62+
# make CFG=cfg1 TST=test_program MODE=gui
63+
#
64+
# run all test from a configuration
65+
# make cfg1
66+
67+
####################################################################################
68+
####################################################################################

ad57xx/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Usage :
2+
3+
Run all tests in batch mode:
4+
5+
make
6+
7+
8+
Run all tests in GUI mode:
9+
10+
make MODE=gui
11+
12+
13+
Run specific test on a specific configuration in gui mode:
14+
15+
make CFG=<name of cfg> TST=<name of test> MODE=gui
16+
17+
18+
Run all test from a configuration:
19+
20+
make <name of cfg>
21+
22+
23+
Where:
24+
25+
* <name of cfg> is a file from the cfgs directory without the tcl extension of format cfg\*
26+
* <name of test> is a file from the tests directory without the tcl extension
27+

ad57xx/ad57xx_environment.sv

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
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

ad57xx/cfgs/cfg1.tcl

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
global ad_project_params
2+
3+
# SPI Engine DUT parameters
4+
set ad_project_params(DATA_WIDTH) 32
5+
set ad_project_params(ASYNC_SPI_CLK) 1
6+
set ad_project_params(NUM_OF_CS) 1
7+
set ad_project_params(NUM_OF_SDI) 1
8+
set ad_project_params(NUM_OF_SDO) 1
9+
set ad_project_params(SDI_DELAY) 1
10+
set ad_project_params(ECHO_SCLK) 0
11+
set ad_project_params(CMD_MEM_ADDR_WIDTH) 4
12+
set ad_project_params(DATA_MEM_ADDR_WIDTH) 4
13+
set ad_project_params(SDI_FIFO_ADDR_WIDTH) 5
14+
set ad_project_params(SDO_FIFO_ADDR_WIDTH) 5
15+
set ad_project_params(SYNC_FIFO_ADDR_WIDTH) 4
16+
set ad_project_params(CMD_FIFO_ADDR_WIDTH) 4
17+
18+
# Test parameters
19+
set ad_project_params(DATA_DLENGTH) 24
20+
set ad_project_params(THREE_WIRE) 0
21+
set ad_project_params(CPOL) 0
22+
set ad_project_params(CPHA) 1
23+
set ad_project_params(SDO_IDLE_STATE) 0
24+
set ad_project_params(SLAVE_TIN) 0
25+
set ad_project_params(SLAVE_TOUT) 0
26+
set ad_project_params(MASTER_TIN) 0
27+
set ad_project_params(MASTER_TOUT) 0
28+
set ad_project_params(CS_TO_MISO) 0
29+
set ad_project_params(CLOCK_DIVIDER) 1
30+
set ad_project_params(NUM_OF_WORDS) 1
31+
set ad_project_params(NUM_OF_TRANSFERS) 3
32+
set ad_project_params(CS_ACTIVE_HIGH) 0
33+
set ad_project_params(ECHO_SCLK_DELAY) 0.1
34+
set ad_project_params(PWM_PERIOD) 98
35+
set ad_project_params(TEST_DATA_MODE) DATA_MODE_PATTERN;
36+
37+
set spi_s_vip_cfg [ list \
38+
MODE 0 \
39+
CPOL $ad_project_params(CPOL) \
40+
CPHA $ad_project_params(CPHA) \
41+
INV_CS $ad_project_params(CS_ACTIVE_HIGH) \
42+
SLAVE_TIN $ad_project_params(SLAVE_TIN) \
43+
SLAVE_TOUT $ad_project_params(SLAVE_TOUT) \
44+
MASTER_TIN $ad_project_params(MASTER_TIN) \
45+
MASTER_TOUT $ad_project_params(MASTER_TOUT) \
46+
CS_TO_MISO $ad_project_params(CS_TO_MISO) \
47+
DATA_DLENGTH $ad_project_params(DATA_DLENGTH) \
48+
]
49+
set ad_project_params(spi_s_vip_cfg) $spi_s_vip_cfg

ad57xx/system_bd.tcl

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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 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+
source ../../scripts/adi_env.tcl
37+
source $ad_hdl_dir/library/spi_engine/scripts/spi_engine.tcl
38+
39+
40+
global ad_project_params
41+
42+
adi_project_files [list \
43+
"../../library/common/ad_edge_detect.v" \
44+
"../../library/util_cdc/sync_bits.v" \
45+
"../../library/common/ad_iobuf.v" \
46+
]
47+
48+
#
49+
# Block design under test
50+
#
51+
52+
source ../../projects/ad57xx_ardz/common/ad57xx_ardz_bd.tcl
53+
54+
# Add test-specific VIPs
55+
56+
ad_ip_instance adi_spi_vip spi_s_vip $ad_project_params(spi_s_vip_cfg)
57+
58+
adi_sim_add_define "SPI_S=spi_s_vip"
59+
60+
ad_disconnect ad57xx_spi spi_ad57xx/m_spi
61+
62+
ad_connect spi_s_vip/s_spi spi_ad57xx/m_spi
63+
64+
# Last tasks
65+
create_bd_port -dir O ad57xx_spi_clk
66+
create_bd_port -dir O ad57xx_spi_irq
67+
create_bd_port -dir O ad57xx_spi_sclk
68+
ad_connect ad57xx_spi_clk axi_ad57xx_clkgen/clk_0
69+
ad_connect ad57xx_spi_irq spi_ad57xx/irq
70+
71+
set BA_SPI_REGMAP 0x44A00000
72+
set_property offset $BA_SPI_REGMAP [get_bd_addr_segs {mng_axi_vip/Master_AXI/spi_ad57xx_axi_regmap}]
73+
adi_sim_add_define "SPI_ENGINE_SPI_REGMAP_BA=[format "%d" ${BA_SPI_REGMAP}]"
74+
75+
set BA_TX_DMA 0x44A40000
76+
set_property offset $BA_TX_DMA [get_bd_addr_segs {mng_axi_vip/Master_AXI/SEG_data_ad57xx_dma}]
77+
adi_sim_add_define "SPI_ENGINE_TX_DMA_BA=[format "%d" ${BA_TX_DMA}]"
78+
79+
set BA_CLKGEN 0x44A70000
80+
set_property offset $BA_CLKGEN [get_bd_addr_segs {mng_axi_vip/Master_AXI/SEG_data_axi_ad57xx_clkgen}]
81+
adi_sim_add_define "SPI_ENGINE_AXI_CLKGEN_BA=[format "%d" ${BA_CLKGEN}]"
82+
83+
set BA_PWM 0x44B00000
84+
set_property offset $BA_PWM [get_bd_addr_segs {mng_axi_vip/Master_AXI/SEG_data_trig_gen}]
85+
adi_sim_add_define "SPI_ENGINE_PWM_GEN_BA=[format "%d" ${BA_PWM}]"

0 commit comments

Comments
 (0)