Skip to content

Commit 6b1605e

Browse files
committed
i3c_controller: Add testbench project
Signed-off-by: Jorge Marques <jorge.marques@analog.com>
1 parent ff8402e commit 6b1605e

File tree

8 files changed

+1425
-0
lines changed

8 files changed

+1425
-0
lines changed

i3c_controller/Makefile

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
####################################################################################
2+
####################################################################################
3+
## Copyright (C) 2024 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_dmac_pkg.sv
18+
SV_DEPS += ../common/sv/dma_trans.sv
19+
SV_DEPS += ../common/sv/axi_dmac_pkg.sv
20+
SV_DEPS += system_tb.sv
21+
22+
ENV_DEPS +=../../library/util_cdc/sync_bits.v
23+
ENV_DEPS +=../../library/common/ad_edge_detect.v
24+
25+
ENV_DEPS += system_project.tcl
26+
ENV_DEPS += system_bd.tcl
27+
ENV_DEPS +=../scripts/adi_sim.tcl
28+
ENV_DEPS +=../scripts/run_sim.tcl
29+
30+
LIB_DEPS += axi_dmac
31+
LIB_DEPS += axi_sysid
32+
LIB_DEPS += i3c_controller/i3c_controller_host_interface
33+
LIB_DEPS += i3c_controller/i3c_controller_core
34+
LIB_DEPS += sysid_rom
35+
36+
# default test program
37+
TP := test_program
38+
39+
# config files should have the following format
40+
# cfg_<param1>_<param2>.tcl
41+
CFG_FILES := $(notdir $(wildcard cfgs/cfg*.tcl))
42+
#$(warning $(CFG_FILES))
43+
44+
# List of tests and configuration combinations that has to be run
45+
# Format is: <configuration>:<test name>
46+
TESTS := $(foreach cfg, $(basename $(CFG_FILES)), $(cfg):$(TP))
47+
48+
include ../scripts/project-sim.mk
49+
50+
# usage :
51+
#
52+
# run specific test on a specific configuration in gui mode
53+
# make CFG=cfg1 TST=test_program MODE=gui
54+
#
55+
# run all test from a configuration
56+
# make cfg1
57+
58+
####################################################################################
59+
####################################################################################

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

i3c_controller/cfgs/cfg1.tcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
global ad_project_params

i3c_controller/system_bd.tcl

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
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/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+
38+
global ad_project_params
39+
40+
adi_project_files [list \
41+
"../../library/common/ad_edge_detect.v" \
42+
"../../library/util_cdc/sync_bits.v" \
43+
"../../library/common/ad_iobuf.v" \
44+
]
45+
46+
#
47+
# Block design under test
48+
#
49+
50+
create_bd_intf_port -mode Master -vlnv analog.com:interface:i3c_controller_rtl:1.0 i3c_controller_0
51+
52+
source $ad_hdl_dir/library/i3c_controller/scripts/i3c_controller.tcl
53+
54+
set async_clk 0
55+
set offload 1
56+
set max_devs 16
57+
58+
set hier_i3c_controller i3c_controller_0
59+
60+
i3c_controller_create $hier_i3c_controller $async_clk $offload $max_devs
61+
62+
# pwm to trigger on offload data burst
63+
ad_ip_instance axi_pwm_gen i3c_offload_pwm
64+
ad_ip_parameter i3c_offload_pwm CONFIG.PULSE_0_PERIOD 120
65+
ad_ip_parameter i3c_offload_pwm CONFIG.PULSE_0_WIDTH 1
66+
67+
# dma to receive offload data stream
68+
ad_ip_instance axi_dmac i3c_offload_dma
69+
ad_ip_parameter i3c_offload_dma CONFIG.DMA_TYPE_SRC 1
70+
ad_ip_parameter i3c_offload_dma CONFIG.DMA_TYPE_DEST 0
71+
ad_ip_parameter i3c_offload_dma CONFIG.CYCLIC 0
72+
ad_ip_parameter i3c_offload_dma CONFIG.SYNC_TRANSFER_START 0
73+
ad_ip_parameter i3c_offload_dma CONFIG.AXI_SLICE_SRC 0
74+
ad_ip_parameter i3c_offload_dma CONFIG.AXI_SLICE_DEST 1
75+
ad_ip_parameter i3c_offload_dma CONFIG.DMA_2D_TRANSFER 0
76+
ad_ip_parameter i3c_offload_dma CONFIG.DMA_DATA_WIDTH_SRC 32
77+
ad_ip_parameter i3c_offload_dma CONFIG.DMA_DATA_WIDTH_DEST 64
78+
79+
ad_connect $sys_cpu_clk i3c_offload_pwm/ext_clk
80+
ad_connect $sys_cpu_clk i3c_offload_pwm/s_axi_aclk
81+
ad_connect sys_cpu_resetn i3c_offload_pwm/s_axi_aresetn
82+
ad_connect i3c_offload_pwm/pwm_0 $hier_i3c_controller/trigger
83+
84+
ad_connect i3c_offload_dma/s_axis $hier_i3c_controller/m_offload
85+
ad_connect $hier_i3c_controller/m_i3c i3c_controller_0
86+
87+
ad_connect $sys_cpu_clk $hier_i3c_controller/clk
88+
ad_connect $sys_cpu_clk i3c_offload_dma/s_axis_aclk
89+
ad_connect sys_cpu_resetn $hier_i3c_controller/reset_n
90+
ad_connect sys_cpu_resetn i3c_offload_dma/m_dest_axi_aresetn
91+
92+
ad_cpu_interconnect 0x44a00000 $hier_i3c_controller/host_interface
93+
ad_cpu_interconnect 0x44a30000 i3c_offload_dma
94+
ad_cpu_interconnect 0x44b00000 i3c_offload_pwm
95+
96+
ad_cpu_interrupt "ps-13" "mb-13" i3c_offload_dma/irq
97+
ad_cpu_interrupt "ps-12" "mb-12" /$hier_i3c_controller/irq
98+
99+
ad_mem_hp1_interconnect $sys_cpu_clk sys_ps7/S_AXI_HP1
100+
ad_mem_hp1_interconnect $sys_cpu_clk i3c_offload_dma/m_dest_axi
101+
102+
create_bd_port -dir O i3c_irq
103+
create_bd_port -dir O i3c_clk
104+
105+
ad_connect i3c_irq i3c_controller_0/irq
106+
ad_connect i3c_clk sys_clk_vip/clk_out

i3c_controller/system_project.tcl

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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/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_sim.tcl
37+
source ../../scripts/adi_env.tcl
38+
source $ad_hdl_dir/projects/scripts/adi_board.tcl
39+
40+
if {$argc < 1} {
41+
puts "Expecting at least one argument that specifies the test configuration"
42+
exit 1
43+
} else {
44+
set cfg_file [lindex $argv 0]
45+
}
46+
47+
# Read common config file
48+
source "cfgs/${cfg_file}"
49+
50+
# Set the project name
51+
set project_name [file rootname $cfg_file]
52+
53+
# Create the project
54+
adi_sim_project_xilinx $project_name "xcvu9p-flga2104-2L-e"
55+
56+
# Add test files to the project
57+
adi_sim_project_files [list \
58+
"../common/sv/utils.svh" \
59+
"../common/sv/logger_pkg.sv" \
60+
"../common/sv/reg_accessor.sv" \
61+
"../common/sv/m_axis_sequencer.sv" \
62+
"../common/sv/s_axis_sequencer.sv" \
63+
"../common/sv/m_axi_sequencer.sv" \
64+
"../common/sv/s_axi_sequencer.sv" \
65+
"../common/sv/dmac_api.sv" \
66+
"../common/sv/adi_regmap_pkg.sv" \
67+
"../common/sv/adi_regmap_dmac_pkg.sv" \
68+
"../common/sv/dma_trans.sv" \
69+
"../common/sv/axi_dmac_pkg.sv" \
70+
"../common/sv/test_harness_env.sv" \
71+
"tests/test_program.sv" \
72+
"system_tb.sv" \
73+
]
74+
75+
#set a default test program
76+
adi_sim_add_define "TEST_PROGRAM=test_program"
77+
78+
adi_sim_generate $project_name

i3c_controller/system_tb.sv

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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/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+
`timescale 1ns/1ps
37+
38+
`include "utils.svh"
39+
40+
module system_tb();
41+
wire i3c_irq;
42+
wire i3c_clk;
43+
wire i3c_scl;
44+
wire i3c_sda;
45+
wire i3c_sdi;
46+
wire i3c_sdo;
47+
wire i3c_t;
48+
49+
ad_iobuf #(
50+
.DATA_WIDTH(1)
51+
) i_iobuf_sda (
52+
.dio_t(i3c_t),
53+
.dio_i(i3c_sdo),
54+
.dio_o(i3c_sdi),
55+
.dio_p(i3c_sda));
56+
57+
`TEST_PROGRAM test(
58+
.i3c_irq(i3c_irq),
59+
.i3c_clk(i3c_clk),
60+
.i3c_controller_0_scl(i3c_scl),
61+
.i3c_controller_0_sda(i3c_sda));
62+
63+
test_harness `TH (
64+
.i3c_irq(i3c_irq),
65+
.i3c_clk(i3c_clk),
66+
.i3c_controller_0_scl(i3c_scl),
67+
.i3c_controller_0_sdi(i3c_sdi),
68+
.i3c_controller_0_sdo(i3c_sdo),
69+
.i3c_controller_0_t(i3c_t));
70+
71+
endmodule

0 commit comments

Comments
 (0)