Skip to content

Commit 1a8e5a3

Browse files
authored
AD738x testbench (#113)
ad738x_testbench Signed-off-by: Pop Ioan Daniel <pop.ioan-daniel@analog.com>
1 parent 72e4ca8 commit 1a8e5a3

File tree

8 files changed

+803
-0
lines changed

8 files changed

+803
-0
lines changed

ad738x/Makefile

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
####################################################################################
2+
####################################################################################
3+
## Copyright 2021(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/dmac_api.sv
16+
SV_DEPS += ../common/sv/adi_regmap_pkg.sv
17+
SV_DEPS += ../common/sv/adi_regmap_clkgen_pkg.sv
18+
SV_DEPS += ../common/sv/adi_regmap_dmac_pkg.sv
19+
SV_DEPS += ../common/sv/adi_regmap_spi_engine_pkg.sv
20+
SV_DEPS += ../common/sv/adi_regmap_pwm_gen_pkg.sv
21+
SV_DEPS += ../common/sv/dma_trans.sv
22+
SV_DEPS += system_tb.sv
23+
24+
ENV_DEPS += system_project.tcl
25+
ENV_DEPS += system_bd.tcl
26+
ENV_DEPS +=../scripts/adi_sim.tcl
27+
ENV_DEPS +=../scripts/run_sim.tcl
28+
29+
LIB_DEPS += axi_clkgen
30+
LIB_DEPS += axi_dmac
31+
LIB_DEPS += axi_i2s_adi
32+
LIB_DEPS += axi_pwm_gen
33+
LIB_DEPS += axi_sysid
34+
LIB_DEPS += spi_engine/axi_spi_engine
35+
LIB_DEPS += spi_engine/spi_engine_execution
36+
LIB_DEPS += spi_engine/spi_engine_interconnect
37+
LIB_DEPS += spi_engine/spi_engine_offload
38+
LIB_DEPS += sysid_rom
39+
LIB_DEPS += util_axis_upscale
40+
LIB_DEPS += util_pulse_gen
41+
42+
# default test programs
43+
# Format is: <test name>
44+
TP := $(notdir $(basename $(wildcard tests/*.sv)))
45+
46+
# config files should have the following format
47+
# cfg_<param1>_<param2>.tcl
48+
CFG_FILES := $(notdir $(wildcard cfgs/cfg*.tcl))
49+
50+
# List of tests and configuration combinations that has to be run
51+
# Format is: <configuration>:<test name>
52+
TESTS := $(foreach cfg, $(basename $(CFG_FILES)), $(addprefix $(cfg):, $(TP)))
53+
54+
include ../scripts/project-sim.mk
55+
56+
# usage :
57+
#
58+
# run specific test on a specific configuration in gui mode
59+
# make CFG=cfg1 TST=test_program MODE=gui
60+
#
61+
# run all test from a configuration
62+
# make cfg1
63+
64+
####################################################################################
65+
####################################################################################

ad738x/README.md

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

ad738x/cfgs/cfg1.tcl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
global ad_project_params
2+
3+
set ad_project_params(ALERT_SPI_N) 0
4+
set ad_project_params(NUM_OF_SDI) 2

ad738x/system_bd.tcl

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. 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+
# system level parameters
39+
40+
global ad_project_params
41+
42+
#
43+
# Block design under test
44+
#
45+
46+
source ../../projects/ad738x_fmc/common/ad738x_bd.tcl
47+
48+
create_bd_port -dir O ad738x_spi_clk
49+
create_bd_port -dir O ad738x_irq
50+
51+
ad_connect ad738x_spi_clk spi_clkgen/clk_0
52+
ad_connect ad738x_irq spi_ad738x_adc/irq
53+
54+
set BA_SPI_REGMAP 0x44A00000
55+
set_property offset $BA_SPI_REGMAP [get_bd_addr_segs {mng_axi_vip/Master_AXI/spi_ad738x_adc_axi_regmap}]
56+
adi_sim_add_define "SPI_AD738x_REGMAP_BA=[format "%d" ${BA_SPI_REGMAP}]"
57+
58+
set BA_DMA 0x44A30000
59+
set_property offset $BA_DMA [get_bd_addr_segs {mng_axi_vip/Master_AXI/SEG_data_axi_ad738x_dma}]
60+
adi_sim_add_define "AD738x_DMA_BA=[format "%d" ${BA_DMA}]"
61+
62+
set BA_PWM 0x44B00000
63+
set_property offset $BA_PWM [get_bd_addr_segs {mng_axi_vip/Master_AXI/SEG_data_spi_trigger_gen}]
64+
adi_sim_add_define "AD738x_PWM_GEN_BA=[format "%d" ${BA_PWM}]"
65+
66+
set BA_CLKGEN 0x44A70000
67+
set_property offset $BA_CLKGEN [get_bd_addr_segs {mng_axi_vip/Master_AXI/SEG_data_spi_clkgen}]
68+
adi_sim_add_define "AD738x_AXI_CLKGEN_BA=[format "%d" ${BA_CLKGEN}]"

ad738x/system_project.tcl

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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 common config file
13+
source "cfgs/${cfg_file}"
14+
15+
# Set the project name
16+
set project_name [file rootname $cfg_file]
17+
18+
# Set project params
19+
#global ad_project_params
20+
21+
#set SER_PAR_N $ad_project_params(SER_PAR_N)
22+
23+
#set a default test program
24+
25+
adi_sim_add_define "TEST_PROGRAM=test_program"
26+
27+
#global mng_axi_cfg
28+
global use_smartconnect
29+
if {[expr {![info exists use_smartconnect]}]} {
30+
set use_smartconnect 1
31+
}
32+
33+
# Create the project
34+
adi_sim_project_xilinx $project_name "xc7z007sclg400-1"
35+
36+
# Add test files to the project
37+
adi_sim_project_files [list \
38+
"../common/sv/utils.svh" \
39+
"../common/sv/logger_pkg.sv" \
40+
"../common/sv/reg_accessor.sv" \
41+
"../common/sv/m_axis_sequencer.sv" \
42+
"../common/sv/s_axis_sequencer.sv" \
43+
"../common/sv/m_axi_sequencer.sv" \
44+
"../common/sv/s_axi_sequencer.sv" \
45+
"../common/sv/dmac_api.sv" \
46+
"../common/sv/adi_regmap_pkg.sv" \
47+
"../common/sv/adi_regmap_clkgen_pkg.sv" \
48+
"../common/sv/adi_regmap_dmac_pkg.sv" \
49+
"../common/sv/adi_regmap_spi_engine_pkg.sv" \
50+
"../common/sv/adi_regmap_pwm_gen_pkg.sv" \
51+
"../common/sv/dma_trans.sv" \
52+
"../common/sv/test_harness_env.sv" \
53+
"tests/test_program.sv" \
54+
"system_tb.sv"]
55+
56+
#set a default test program
57+
adi_sim_add_define "TEST_PROGRAM=test_program"
58+
59+
adi_sim_generate $project_name

ad738x/system_tb.sv

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// ***************************************************************************
2+
// ***************************************************************************
3+
// Copyright 2022 (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/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+
wire ad738x_spi_sclk;
43+
wire ad738x_spi_sdo;
44+
wire [`NUM_OF_SDI-1:0] ad738x_spi_sdi;
45+
wire ad738x_spi_cs;
46+
wire ad738x_spi_clk;
47+
wire ad738x_irq;
48+
49+
`TEST_PROGRAM test(
50+
.ad738x_spi_clk (ad738x_spi_clk),
51+
.ad738x_irq (ad738x_irq),
52+
.ad738x_spi_sdi(ad738x_spi_sdi),
53+
.ad738x_spi_cs (ad738x_spi_cs),
54+
.ad738x_spi_sclk (ad738x_spi_sclk));
55+
56+
test_harness `TH (
57+
.ad738x_spi_clk (ad738x_spi_clk),
58+
.irq (),
59+
.ad738x_irq(ad738x_irq),
60+
.ad738x_spi_sdo (ad738x_spi_sdo),
61+
.ad738x_spi_sdi (ad738x_spi_sdi),
62+
.ad738x_spi_cs (ad738x_spi_cs),
63+
.ad738x_spi_sclk (ad738x_spi_sclk));
64+
65+
endmodule

0 commit comments

Comments
 (0)