Skip to content

Commit ccace94

Browse files
committed
dma_sg: Add testbench for the Scatter-Gather feature
Signed-off-by: Ionut Podgoreanu <ionut.podgoreanu@analog.com>
1 parent 8d23e52 commit ccace94

File tree

12 files changed

+1565
-0
lines changed

12 files changed

+1565
-0
lines changed

dma_sg/Makefile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
####################################################################################
2+
## Copyright (C) 2024 Analog Devices, Inc.
3+
####################################################################################
4+
5+
# All test-bench dependencies except test programs
6+
SV_DEPS += ../common/sv/utils.svh
7+
SV_DEPS += ../common/sv/logger_pkg.sv
8+
SV_DEPS += ../common/sv/reg_accessor.sv
9+
SV_DEPS += ../common/sv/m_axis_sequencer.sv
10+
SV_DEPS += ../common/sv/s_axis_sequencer.sv
11+
SV_DEPS += ../common/sv/m_axi_sequencer.sv
12+
SV_DEPS += ../common/sv/s_axi_sequencer.sv
13+
SV_DEPS += ../common/sv/dmac_api.sv
14+
SV_DEPS += ../common/sv/adi_regmap_pkg.sv
15+
SV_DEPS += ../common/sv/adi_regmap_dmac_pkg.sv
16+
SV_DEPS += ../common/sv/dma_trans.sv
17+
SV_DEPS += ../common/sv/test_harness_env.sv
18+
SV_DEPS += system_tb.sv
19+
20+
ENV_DEPS += system_project.tcl
21+
ENV_DEPS += system_bd.tcl
22+
ENV_DEPS +=../scripts/adi_sim.tcl
23+
ENV_DEPS +=../scripts/run_sim.tcl
24+
25+
LIB_DEPS += axi_dmac
26+
27+
# default test program
28+
TP := test_program_1d
29+
30+
# config files should have the following format
31+
# cfg_<param1>_<param2>.tcl
32+
CFG_FILES := $(notdir $(wildcard cfgs/cfg*.tcl))
33+
#$(warning $(CFG_FILES))
34+
35+
# List of tests and configuration combinations that has to be run
36+
# Format is: <configuration>:<test name>
37+
#TESTS := $(foreach cfg, $(basename $(CFG_FILES)), $(cfg):$(TP))
38+
TESTS += cfg1:test_program_1d
39+
TESTS += cfg2:test_program_2d
40+
TESTS += cfg1:test_program_tr_queue
41+
42+
include ../scripts/project-sim.mk
43+
44+
# usage :
45+
#
46+
# run specific test on a specific configuration in gui mode
47+
# make CFG=cfg2 TST=test_program_2d MODE=gui
48+
#
49+
# run all test from a configuration
50+
# make cfg2
51+
52+
####################################################################################
53+
####################################################################################

dma_sg/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+

dma_sg/cfgs/cfg1.tcl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
global ad_project_params
2+
3+
set rx_dma_cfg [list \
4+
DMA_TYPE_SRC 1 \
5+
DMA_TYPE_DEST 0 \
6+
ID 0 \
7+
AXI_SLICE_SRC 1 \
8+
AXI_SLICE_DEST 1 \
9+
SYNC_TRANSFER_START 0 \
10+
DMA_LENGTH_WIDTH 24 \
11+
DMA_2D_TRANSFER 0 \
12+
DMA_SG_TRANSFER 1 \
13+
MAX_BYTES_PER_BURST 4096 \
14+
CYCLIC 0 \
15+
DMA_DATA_WIDTH_SRC 64 \
16+
DMA_DATA_WIDTH_DEST 64 \
17+
DMA_DATA_WIDTH_SG 64 \
18+
]
19+
20+
set tx_dma_cfg [list \
21+
DMA_TYPE_SRC 0 \
22+
DMA_TYPE_DEST 1 \
23+
ID 0 \
24+
AXI_SLICE_SRC 1 \
25+
AXI_SLICE_DEST 1 \
26+
SYNC_TRANSFER_START 0 \
27+
DMA_LENGTH_WIDTH 24 \
28+
DMA_2D_TRANSFER 0 \
29+
DMA_SG_TRANSFER 1 \
30+
CYCLIC 1 \
31+
DMA_DATA_WIDTH_SRC 64 \
32+
DMA_DATA_WIDTH_DEST 64 \
33+
DMA_DATA_WIDTH_SG 64 \
34+
]
35+

dma_sg/cfgs/cfg2.tcl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
global ad_project_params
2+
3+
set rx_dma_cfg [list \
4+
DMA_TYPE_SRC 1 \
5+
DMA_TYPE_DEST 0 \
6+
ID 0 \
7+
AXI_SLICE_SRC 1 \
8+
AXI_SLICE_DEST 1 \
9+
SYNC_TRANSFER_START 0 \
10+
DMA_LENGTH_WIDTH 24 \
11+
DMA_2D_TRANSFER 1 \
12+
DMA_SG_TRANSFER 1 \
13+
MAX_BYTES_PER_BURST 4096 \
14+
CYCLIC 0 \
15+
DMA_DATA_WIDTH_SRC 64 \
16+
DMA_DATA_WIDTH_DEST 64 \
17+
DMA_DATA_WIDTH_SG 64 \
18+
]
19+
20+
set tx_dma_cfg [list \
21+
DMA_TYPE_SRC 0 \
22+
DMA_TYPE_DEST 1 \
23+
ID 0 \
24+
AXI_SLICE_SRC 1 \
25+
AXI_SLICE_DEST 1 \
26+
SYNC_TRANSFER_START 0 \
27+
DMA_LENGTH_WIDTH 24 \
28+
DMA_2D_TRANSFER 1 \
29+
DMA_SG_TRANSFER 1 \
30+
CYCLIC 1 \
31+
DMA_DATA_WIDTH_SRC 64 \
32+
DMA_DATA_WIDTH_DEST 64 \
33+
DMA_DATA_WIDTH_SG 64 \
34+
]
35+

dma_sg/system_bd.tcl

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# ***************************************************************************
2+
# ***************************************************************************
3+
# Copyright (C) 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/master/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+
38+
# Device clk
39+
ad_ip_instance clk_vip device_clk_vip [ list \
40+
INTERFACE_MODE {MASTER} \
41+
FREQ_HZ 62500000 \
42+
]
43+
adi_sim_add_define "DEVICE_CLK=device_clk_vip"
44+
45+
set device_clk device_clk_vip/clk_out
46+
47+
# ------------------
48+
#
49+
# Blocks under test
50+
#
51+
# ------------------
52+
53+
global rx_dma_cfg
54+
global tx_dma_cfg
55+
56+
ad_ip_instance axi_dmac dut_rx_dma $rx_dma_cfg
57+
ad_ip_instance axi_dmac dut_tx_dma $tx_dma_cfg
58+
59+
ad_connect $device_clk dut_rx_dma/s_axis_aclk
60+
ad_connect $device_clk dut_tx_dma/m_axis_aclk
61+
62+
# connect resets
63+
ad_connect $sys_cpu_resetn dut_rx_dma/m_dest_axi_aresetn
64+
ad_connect $sys_cpu_resetn dut_tx_dma/m_src_axi_aresetn
65+
66+
ad_connect $sys_cpu_resetn dut_rx_dma/m_sg_axi_aresetn
67+
ad_connect $sys_cpu_resetn dut_tx_dma/m_sg_axi_aresetn
68+
69+
# create loopback
70+
ad_connect dut_tx_dma/m_axis dut_rx_dma/s_axis
71+
72+
ad_cpu_interconnect 0x7c420000 dut_rx_dma
73+
ad_cpu_interconnect 0x7c430000 dut_tx_dma
74+
75+
ad_mem_hp0_interconnect $sys_cpu_clk dut_rx_dma/m_dest_axi
76+
ad_mem_hp0_interconnect $sys_cpu_clk dut_tx_dma/m_src_axi
77+
78+
ad_mem_hp0_interconnect $sys_cpu_clk dut_rx_dma/m_sg_axi
79+
ad_mem_hp0_interconnect $sys_cpu_clk dut_tx_dma/m_sg_axi
80+
81+
ad_cpu_interrupt ps-13 mb-12 dut_rx_dma/irq
82+
ad_cpu_interrupt ps-12 mb-13 dut_tx_dma/irq
83+
84+
set RX_DMA 0x7C420000
85+
set_property offset $RX_DMA [get_bd_addr_segs {mng_axi_vip/Master_AXI/SEG_data_dut_rx_dma}]
86+
adi_sim_add_define "RX_DMA_BA=[format "%d" ${RX_DMA}]"
87+
88+
set TX_DMA 0x7C430000
89+
set_property offset $TX_DMA [get_bd_addr_segs {mng_axi_vip/Master_AXI/SEG_data_dut_tx_dma}]
90+
adi_sim_add_define "TX_DMA_BA=[format "%d" ${TX_DMA}]"

dma_sg/system_project.tcl

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
source ../scripts/adi_sim.tcl
2+
source ../../scripts/adi_env.tcl
3+
source $ad_hdl_dir/projects/scripts/adi_board.tcl
4+
5+
if {$argc < 1} {
6+
puts "Expecting at least one argument that specifies the test configuration"
7+
exit 1
8+
} else {
9+
set cfg_file [lindex $argv 0]
10+
}
11+
12+
# Read config file
13+
source "cfgs/${cfg_file}"
14+
15+
# Set the project name
16+
set project_name [file rootname $cfg_file]
17+
18+
# Create the project
19+
adi_sim_project_xilinx $project_name "xcvu9p-flga2104-2L-e"
20+
21+
# Add test files to the project
22+
adi_sim_project_files [list \
23+
"../common/sv/utils.svh" \
24+
"../common/sv/logger_pkg.sv" \
25+
"../common/sv/reg_accessor.sv" \
26+
"../common/sv/m_axis_sequencer.sv" \
27+
"../common/sv/s_axis_sequencer.sv" \
28+
"../common/sv/m_axi_sequencer.sv" \
29+
"../common/sv/s_axi_sequencer.sv" \
30+
"../common/sv/dmac_api.sv" \
31+
"../common/sv/adi_regmap_pkg.sv" \
32+
"../common/sv/adi_regmap_dmac_pkg.sv" \
33+
"../common/sv/dma_trans.sv" \
34+
"../common/sv/adi_peripheral_pkg.sv" \
35+
"../common/sv/test_harness_env.sv" \
36+
"tests/test_program_1d.sv" \
37+
"tests/test_program_2d.sv" \
38+
"tests/test_program_tr_queue.sv" \
39+
"system_tb.sv" \
40+
]
41+
42+
#set a default test program
43+
adi_sim_add_define "TEST_PROGRAM=test_program_1d"
44+
45+
adi_sim_generate $project_name

dma_sg/system_tb.sv

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// ***************************************************************************
2+
// ***************************************************************************
3+
// Copyright (C) 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 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/master/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+
`timescale 1ns/1ps
37+
38+
`include "utils.svh"
39+
40+
module system_tb();
41+
42+
`TEST_PROGRAM test();
43+
44+
test_harness `TH ();
45+
46+
endmodule

0 commit comments

Comments
 (0)