Skip to content

Commit 42488d6

Browse files
committed
pwm_gen: Initial commit
1 parent c8cac8a commit 42488d6

File tree

8 files changed

+588
-0
lines changed

8 files changed

+588
-0
lines changed

pwm_gen/Makefile

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

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

pwm_gen/cfgs/cfg1.tcl

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

pwm_gen/system_bd.tcl

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# ***************************************************************************
2+
# ***************************************************************************
3+
# Copyright 2018 (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+
# common zed-based bd for test
39+
#source ../../projects/common/zed/zed_system_bd.tcl
40+
41+
# ------------------
42+
#
43+
# Block under test
44+
#
45+
# ------------------
46+
47+
create_bd_port -dir O pwm_gen_o_0
48+
create_bd_port -dir O pwm_gen_o_1
49+
create_bd_port -dir O pwm_gen_o_2
50+
create_bd_port -dir O pwm_gen_o_3
51+
create_bd_port -dir O pwm_gen_o_4
52+
create_bd_port -dir O pwm_gen_o_5
53+
create_bd_port -dir O pwm_gen_o_6
54+
create_bd_port -dir O pwm_gen_o_7
55+
create_bd_port -dir O pwm_gen_o_8
56+
create_bd_port -dir O pwm_gen_o_9
57+
create_bd_port -dir O pwm_gen_o_10
58+
create_bd_port -dir O pwm_gen_o_11
59+
create_bd_port -dir O pwm_gen_o_12
60+
create_bd_port -dir O pwm_gen_o_13
61+
create_bd_port -dir O pwm_gen_o_14
62+
create_bd_port -dir O pwm_gen_o_15
63+
64+
ad_ip_instance axi_pwm_gen dut_pwm_gen
65+
ad_ip_parameter dut_pwm_gen CONFIG.ASYNC_CLK_EN 1
66+
ad_ip_parameter dut_pwm_gen CONFIG.N_PWMS 16
67+
68+
69+
ad_connect ddr_clk_vip/clk_out dut_pwm_gen/ext_clk
70+
adi_project_files [list \
71+
"../../library/common/ad_edge_detect.v" \
72+
"../../library/util_cdc/sync_bits.v"]
73+
74+
ad_connect pwm_gen_o_0 dut_pwm_gen/pwm_0
75+
ad_connect pwm_gen_o_1 dut_pwm_gen/pwm_1
76+
ad_connect pwm_gen_o_2 dut_pwm_gen/pwm_2
77+
ad_connect pwm_gen_o_3 dut_pwm_gen/pwm_3
78+
ad_connect pwm_gen_o_4 dut_pwm_gen/pwm_4
79+
ad_connect pwm_gen_o_5 dut_pwm_gen/pwm_5
80+
ad_connect pwm_gen_o_6 dut_pwm_gen/pwm_6
81+
ad_connect pwm_gen_o_7 dut_pwm_gen/pwm_7
82+
ad_connect pwm_gen_o_8 dut_pwm_gen/pwm_8
83+
ad_connect pwm_gen_o_9 dut_pwm_gen/pwm_9
84+
ad_connect pwm_gen_o_10 dut_pwm_gen/pwm_10
85+
ad_connect pwm_gen_o_11 dut_pwm_gen/pwm_11
86+
ad_connect pwm_gen_o_12 dut_pwm_gen/pwm_12
87+
ad_connect pwm_gen_o_13 dut_pwm_gen/pwm_13
88+
ad_connect pwm_gen_o_14 dut_pwm_gen/pwm_14
89+
ad_connect pwm_gen_o_15 dut_pwm_gen/pwm_15
90+
91+
# connect resets
92+
93+
ad_cpu_interconnect 0x7c000000 dut_pwm_gen
94+
95+
create_bd_port -dir O sys_clk
96+
97+
ad_connect sys_clk sys_cpu_clk

pwm_gen/system_project.tcl

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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 "xc7z020clg484-1"
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/adi_regmap_pkg.sv" \
31+
"../common/sv/adi_regmap_common_pkg.sv" \
32+
"../common/sv/adi_regmap_pwm_gen_pkg.sv" \
33+
"../common/sv/adi_peripheral_pkg.sv" \
34+
"../common/sv/test_harness_env.sv" \
35+
"tests/test_program.sv" \
36+
"system_tb.sv" \
37+
]
38+
39+
#set a default test program
40+
adi_sim_add_define "TEST_PROGRAM=test_program"
41+
42+
adi_sim_generate $project_name

pwm_gen/system_tb.sv

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// ***************************************************************************
2+
// ***************************************************************************
3+
// Copyright 2014 - 2018 (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+
wire pwm_gen_o_0;
42+
wire pwm_gen_o_1;
43+
wire pwm_gen_o_2;
44+
wire pwm_gen_o_3;
45+
wire pwm_gen_o_4;
46+
wire pwm_gen_o_5;
47+
wire pwm_gen_o_6;
48+
wire pwm_gen_o_7;
49+
wire pwm_gen_o_8;
50+
wire pwm_gen_o_9;
51+
wire pwm_gen_o_10;
52+
wire pwm_gen_o_11;
53+
wire pwm_gen_o_12;
54+
wire pwm_gen_o_13;
55+
wire pwm_gen_o_14;
56+
wire pwm_gen_o_15;
57+
58+
wire sys_clk;
59+
60+
`TEST_PROGRAM test(
61+
.pwm_gen_o_0 (pwm_gen_o_0),
62+
.pwm_gen_o_1 (pwn_gen_o_1),
63+
.pwm_gen_o_2 (pwm_gen_o_2),
64+
.pwm_gen_o_3 (pwm_gen_o_3),
65+
.pwm_gen_o_4 (pwm_gen_o_4),
66+
.pwm_gen_o_5 (pwm_gen_o_5),
67+
.pwm_gen_o_6 (pwm_gen_o_6),
68+
.pwm_gen_o_7 (pwm_gen_o_7),
69+
.pwm_gen_o_8 (pwm_gen_o_8),
70+
.pwm_gen_o_9 (pwn_gen_o_9),
71+
.pwm_gen_o_10 (pwm_gen_o_10),
72+
.pwm_gen_o_11 (pwm_gen_o_11),
73+
.pwm_gen_o_12 (pwm_gen_o_12),
74+
.pwm_gen_o_13 (pwm_gen_o_13),
75+
.pwm_gen_o_14 (pwm_gen_o_14),
76+
.pwm_gen_o_15 (pwm_gen_o_15),
77+
78+
.sys_clk (sys_clk));
79+
80+
test_harness `TH (
81+
.pwm_gen_o_0 (pwm_gen_o_0),
82+
.pwm_gen_o_1 (pwn_gen_o_1),
83+
.pwm_gen_o_2 (pwm_gen_o_2),
84+
.pwm_gen_o_3 (pwm_gen_o_3),
85+
.pwm_gen_o_4 (pwm_gen_o_4),
86+
.pwm_gen_o_5 (pwm_gen_o_5),
87+
.pwm_gen_o_6 (pwm_gen_o_6),
88+
.pwm_gen_o_7 (pwm_gen_o_7),
89+
.pwm_gen_o_8 (pwm_gen_o_8),
90+
.pwm_gen_o_9 (pwn_gen_o_9),
91+
.pwm_gen_o_10 (pwm_gen_o_10),
92+
.pwm_gen_o_11 (pwm_gen_o_11),
93+
.pwm_gen_o_12 (pwm_gen_o_12),
94+
.pwm_gen_o_13 (pwm_gen_o_13),
95+
.pwm_gen_o_14 (pwm_gen_o_14),
96+
.pwm_gen_o_15 (pwm_gen_o_15),
97+
.sys_clk (sys_clk));
98+
99+
endmodule

0 commit comments

Comments
 (0)