Skip to content

Commit

Permalink
dmac_flock: Test AXI DMAC Framelock feature
Browse files Browse the repository at this point in the history
Verify the framelock when the writer is faster than the reader and
vice-versa.
Test with delay and in AutoRun mode.

Signed-off-by: Jorge Marques <[email protected]>
  • Loading branch information
gastmaier committed Nov 19, 2024
1 parent 2124530 commit 5813b38
Show file tree
Hide file tree
Showing 18 changed files with 1,802 additions and 13 deletions.
4 changes: 2 additions & 2 deletions library/drivers/dmac/dma_trans.sv
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ package dma_trans_pkg;
int DMA_LENGTH_ALIGN;
int MAX_BYTES_PER_BURST;
int FRAMELOCK;
int MAX_NUM_FRAMES;
int MAX_NUM_FRAMES_WIDTH;
int USE_EXT_SYNC;
int HAS_AUTORUN;
} axi_dmac_params_t;
Expand Down Expand Up @@ -430,7 +430,7 @@ package dma_trans_pkg;
ds.flock_wait_writer = flock_wait_writer;
endfunction

constraint c_buf_num {flock_framenum < p.MAX_NUM_FRAMES;};
constraint c_buf_num {flock_framenum < (p.MAX_NUM_FRAMES_WIDTH-1)**2;};
constraint c_frm_dist {flock_distance < flock_framenum;};

virtual function void print();
Expand Down
6 changes: 3 additions & 3 deletions library/drivers/dmac/dmac_api.sv
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ package dmac_api_pkg;
bpb_width_log2 = `GET_DMAC_INTERFACE_DESCRIPTION_1_BYTES_PER_BURST_WIDTH(val);
p.MAX_BYTES_PER_BURST = 2**bpb_width_log2;
p.DMA_2D_TLAST_MODE = `GET_DMAC_INTERFACE_DESCRIPTION_1_DMA_2D_TLAST_MODE(val);
p.MAX_NUM_FRAMES = `GET_DMAC_INTERFACE_DESCRIPTION_1_MAX_NUM_FRAMES(val);
p.MAX_NUM_FRAMES_WIDTH = $clog2(`GET_DMAC_INTERFACE_DESCRIPTION_1_MAX_NUM_FRAMES(val))+1;
p.USE_EXT_SYNC = `GET_DMAC_INTERFACE_DESCRIPTION_1_USE_EXT_SYNC(val);
p.HAS_AUTORUN = `GET_DMAC_INTERFACE_DESCRIPTION_1_HAS_AUTORUN(val);
if (!p.HAS_AUTORUN) begin
Expand Down Expand Up @@ -341,10 +341,10 @@ package dmac_api_pkg;

if ($cast(t_fl_2d,t)) begin
this.axi_write(GetAddrs(DMAC_FRAMELOCK_CONFIG),
`SET_DMAC_FRAMELOCK_CONFIG_FRAMENUM(t_fl_2d.flock_framenum) |
`SET_DMAC_FRAMELOCK_CONFIG_MODE(t_fl_2d.flock_mode) |
`SET_DMAC_FRAMELOCK_CONFIG_WAIT_WRITER(t_fl_2d.flock_wait_writer ) |
`SET_DMAC_FRAMELOCK_CONFIG_DISTANCE(t_fl_2d.flock_distance-1));
`SET_DMAC_FRAMELOCK_CONFIG_FRAMENUM(t_fl_2d.flock_framenum) |
`SET_DMAC_FRAMELOCK_CONFIG_DISTANCE(t_fl_2d.flock_distance));
this.axi_write(GetAddrs(DMAC_FRAMELOCK_STRIDE),
`SET_DMAC_FRAMELOCK_STRIDE_STRIDE(t_fl_2d.flock_stride));
end
Expand Down
14 changes: 7 additions & 7 deletions library/regmaps/adi_regmap_dmac_pkg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -359,13 +359,17 @@ package adi_regmap_dmac_pkg;

const reg_t DMAC_FRAMELOCK_CONFIG = '{ 'h0458, "FRAMELOCK_CONFIG" , '{
"DISTANCE": '{ 23, 16, RW, 0 },
"WAIT_WRITER": '{ 9, 9, RW, 0 },
"MODE": '{ 8, 8, RW, 0 },
"FRAMENUM": '{ 7, 0, RW, 0 }}};
"FRAMENUM": '{ 15, 8, RW, 0 },
"WAIT_WRITER": '{ 1, 1, RW, 0 },
"MODE": '{ 0, 0, RW, 0 }}};
`define SET_DMAC_FRAMELOCK_CONFIG_DISTANCE(x) SetField(DMAC_FRAMELOCK_CONFIG,"DISTANCE",x)
`define GET_DMAC_FRAMELOCK_CONFIG_DISTANCE(x) GetField(DMAC_FRAMELOCK_CONFIG,"DISTANCE",x)
`define DEFAULT_DMAC_FRAMELOCK_CONFIG_DISTANCE GetResetValue(DMAC_FRAMELOCK_CONFIG,"DISTANCE")
`define UPDATE_DMAC_FRAMELOCK_CONFIG_DISTANCE(x,y) UpdateField(DMAC_FRAMELOCK_CONFIG,"DISTANCE",x,y)
`define SET_DMAC_FRAMELOCK_CONFIG_FRAMENUM(x) SetField(DMAC_FRAMELOCK_CONFIG,"FRAMENUM",x)
`define GET_DMAC_FRAMELOCK_CONFIG_FRAMENUM(x) GetField(DMAC_FRAMELOCK_CONFIG,"FRAMENUM",x)
`define DEFAULT_DMAC_FRAMELOCK_CONFIG_FRAMENUM GetResetValue(DMAC_FRAMELOCK_CONFIG,"FRAMENUM")
`define UPDATE_DMAC_FRAMELOCK_CONFIG_FRAMENUM(x,y) UpdateField(DMAC_FRAMELOCK_CONFIG,"FRAMENUM",x,y)
`define SET_DMAC_FRAMELOCK_CONFIG_WAIT_WRITER(x) SetField(DMAC_FRAMELOCK_CONFIG,"WAIT_WRITER",x)
`define GET_DMAC_FRAMELOCK_CONFIG_WAIT_WRITER(x) GetField(DMAC_FRAMELOCK_CONFIG,"WAIT_WRITER",x)
`define DEFAULT_DMAC_FRAMELOCK_CONFIG_WAIT_WRITER GetResetValue(DMAC_FRAMELOCK_CONFIG,"WAIT_WRITER")
Expand All @@ -374,10 +378,6 @@ package adi_regmap_dmac_pkg;
`define GET_DMAC_FRAMELOCK_CONFIG_MODE(x) GetField(DMAC_FRAMELOCK_CONFIG,"MODE",x)
`define DEFAULT_DMAC_FRAMELOCK_CONFIG_MODE GetResetValue(DMAC_FRAMELOCK_CONFIG,"MODE")
`define UPDATE_DMAC_FRAMELOCK_CONFIG_MODE(x,y) UpdateField(DMAC_FRAMELOCK_CONFIG,"MODE",x,y)
`define SET_DMAC_FRAMELOCK_CONFIG_FRAMENUM(x) SetField(DMAC_FRAMELOCK_CONFIG,"FRAMENUM",x)
`define GET_DMAC_FRAMELOCK_CONFIG_FRAMENUM(x) GetField(DMAC_FRAMELOCK_CONFIG,"FRAMENUM",x)
`define DEFAULT_DMAC_FRAMELOCK_CONFIG_FRAMENUM GetResetValue(DMAC_FRAMELOCK_CONFIG,"FRAMENUM")
`define UPDATE_DMAC_FRAMELOCK_CONFIG_FRAMENUM(x,y) UpdateField(DMAC_FRAMELOCK_CONFIG,"FRAMENUM",x,y)

const reg_t DMAC_FRAMELOCK_STRIDE = '{ 'h045c, "FRAMELOCK_STRIDE" , '{
"STRIDE": '{ 31, 0, RW, 0 }}};
Expand Down
2 changes: 1 addition & 1 deletion library/utilities/utils.svh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
th``_``vip``_0_DISABLE_DEBUG_REGISTERS, \
th``_``vip``_0_ENABLE_DIAGNOSTICS_IF, \
th``_``vip``_0_ENABLE_FRAME_LOCK, \
th``_``vip``_0_MAX_NUM_FRAMES, \
th``_``vip``_0_MAX_NUM_FRAMES_WIDTH, \
th``_``vip``_0_USE_EXT_SYNC, \
th``_``vip``_0_HAS_AUTORUN

Expand Down
63 changes: 63 additions & 0 deletions testbenches/ip/dma_flock/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
####################################################################################
####################################################################################
## Copyright (C) 2024 Analog Devices, Inc.
####################################################################################
####################################################################################

# All test-bench dependencies except test programs
SV_DEPS += ../../../library/utilities/utils.svh
SV_DEPS += ../../../library/drivers/dmac/dma_trans.sv
SV_DEPS += ../../../library/utilities/logger_pkg.sv
SV_DEPS += ../../../library/regmaps/reg_accessor.sv
SV_DEPS += ../../../library/vip/amd/m_axis_sequencer.sv
SV_DEPS += ../../../library/vip/amd/s_axis_sequencer.sv
SV_DEPS += ../../../library/vip/amd/m_axi_sequencer.sv
SV_DEPS += ../../../library/vip/amd/s_axi_sequencer.sv
SV_DEPS += ../../../library/drivers/dmac/dmac_api.sv
SV_DEPS += ../../../library/regmaps/adi_regmap_pkg.sv
SV_DEPS += ../../../library/regmaps/adi_regmap_dmac_pkg.sv
SV_DEPS += ../../../library/drivers/dmac/dma_trans.sv
SV_DEPS += ../../../library/utilities/test_harness_env.sv
SV_DEPS += ../../../library/regmaps/adi_peripheral_pkg.sv
SV_DEPS += environment.sv
SV_DEPS += scoreboard.sv
SV_DEPS += system_tb.sv

ENV_DEPS += system_project.tcl
ENV_DEPS += system_bd.tcl
ENV_DEPS +=../../../scripts/adi_sim.tcl
ENV_DEPS +=../../../scripts/run_sim.tcl

LIB_DEPS := axi_dmac
SIM_LIB_DEPS := io_vip

# default test program
TP := test_program

# config files should have the following format
# cfg_<param1>_<param2>.tcl
CFG_FILES := $(notdir $(wildcard cfgs/cfg*.tcl))
#$(warning $(CFG_FILES))

# List of tests and configuration combinations that has to be run
# Format is: <configuration>:<test name>
#TESTS := $(foreach cfg, $(basename $(CFG_FILES)), $(cfg):$(TP))
TESTS += cfg1:test_program
TESTS += cfg2_fsync:test_program
TESTS += cfg2_fsync:test_program_frame_delay
TESTS += cfg3_fsync_autorun:test_program_frame_delay

include ../../../scripts/project-sim.mk

# usage :
#
# run specific test on a specific configuration in gui mode
# make CFG=cfg2_fsync TST=test_program_frame_delay MODE=gui
#
# run all test from a configuration
# make cfg1_mm2mm_default



####################################################################################
####################################################################################
65 changes: 65 additions & 0 deletions testbenches/ip/dma_flock/cfgs/cfg1.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
set MAX_NUM_FRAMES_WIDTH 4
set AUTORUN 0
set USE_EXT_SYNC 0
set TDATA_NUM_BYTES 8

set ad_project_params(M_DMA_CFG_MAX_NUM_FRAMES) $MAX_NUM_FRAMES_WIDTH
set ad_project_params(M_DMA_CFG_AUTORUN) $AUTORUN
set ad_project_params(S_DMA_CFG_AUTORUN) $AUTORUN
set ad_project_params(M_DMA_CFG_USE_EXT_SYNC) $USE_EXT_SYNC
set ad_project_params(S_DMA_CFG_USE_EXT_SYNC) $USE_EXT_SYNC
set ad_project_params(SRC_AXIS_VIP_CFG_TDATA_NUM_BYTES) $TDATA_NUM_BYTES
set ad_project_params(DST_AXIS_VIP_CFG_TDATA_NUM_BYTES) $TDATA_NUM_BYTES

set m_dma_cfg [list \
DMA_TYPE_SRC 1 \
DMA_TYPE_DEST 0 \
DMA_2D_TRANSFER 1 \
SYNC_TRANSFER_START 0 \
AXIS_TUSER_SYNC 0 \
CYCLIC 1 \
FRAMELOCK 1 \
MAX_NUM_FRAMES_WIDTH $MAX_NUM_FRAMES_WIDTH \
USE_EXT_SYNC $USE_EXT_SYNC \
DMA_2D_TLAST_MODE 1 \
]

set s_dma_cfg [list \
DMA_TYPE_SRC 0 \
DMA_TYPE_DEST 1 \
DMA_2D_TRANSFER 1 \
SYNC_TRANSFER_START 0 \
AXIS_TUSER_SYNC 0 \
CYCLIC 1 \
FRAMELOCK 1 \
MAX_NUM_FRAMES_WIDTH $MAX_NUM_FRAMES_WIDTH \
USE_EXT_SYNC $USE_EXT_SYNC \
DMA_2D_TLAST_MODE 1 \
]

# VDMA config
set vdma_cfg [list \
c_m_axis_mm2s_tdata_width {64} \
c_num_fstores {3} \
c_use_mm2s_fsync {0} \
c_use_s2mm_fsync {0} \
c_enable_vert_flip {0} \
c_mm2s_genlock_mode {3} \
c_s2mm_genlock_mode {2} \
c_mm2s_linebuffer_depth {8192} \
c_s2mm_linebuffer_depth {8192} \
]

# SRC AXIS
set src_axis_vip_cfg [list \
INTERFACE_MODE {MASTER} \
HAS_TLAST {1} \
TDATA_NUM_BYTES $TDATA_NUM_BYTES \
]

# DST AXIS
set dst_axis_vip_cfg [list \
INTERFACE_MODE {SLAVE} \
HAS_TLAST {1} \
TDATA_NUM_BYTES $TDATA_NUM_BYTES \
]
66 changes: 66 additions & 0 deletions testbenches/ip/dma_flock/cfgs/cfg2_fsync.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
set MAX_NUM_FRAMES_WIDTH 4
set AUTORUN 0
set M_USE_EXT_SYNC 0
set S_USE_EXT_SYNC 1
set TDATA_NUM_BYTES 8

set ad_project_params(M_DMA_CFG_MAX_NUM_FRAMES) $MAX_NUM_FRAMES_WIDTH
set ad_project_params(M_DMA_CFG_AUTORUN) $AUTORUN
set ad_project_params(S_DMA_CFG_AUTORUN) $AUTORUN
set ad_project_params(M_DMA_CFG_USE_EXT_SYNC) $M_USE_EXT_SYNC
set ad_project_params(S_DMA_CFG_USE_EXT_SYNC) $S_USE_EXT_SYNC
set ad_project_params(SRC_AXIS_VIP_CFG_TDATA_NUM_BYTES) $TDATA_NUM_BYTES
set ad_project_params(DST_AXIS_VIP_CFG_TDATA_NUM_BYTES) $TDATA_NUM_BYTES

set m_dma_cfg [list \
DMA_TYPE_SRC 1 \
DMA_TYPE_DEST 0 \
DMA_2D_TRANSFER 1 \
SYNC_TRANSFER_START 0 \
AXIS_TUSER_SYNC 0 \
CYCLIC 1 \
FRAMELOCK 1 \
MAX_NUM_FRAMES_WIDTH $MAX_NUM_FRAMES_WIDTH \
USE_EXT_SYNC $M_USE_EXT_SYNC \
SYNC_TRANSFER_START 1 \
DMA_2D_TLAST_MODE 1 \
]

set s_dma_cfg [list \
DMA_TYPE_SRC {0} \
DMA_TYPE_DEST {1} \
DMA_2D_TRANSFER 1 \
SYNC_TRANSFER_START 0 \
AXIS_TUSER_SYNC 0 \
CYCLIC 1 \
FRAMELOCK 1 \
MAX_NUM_FRAMES_WIDTH $MAX_NUM_FRAMES_WIDTH \
USE_EXT_SYNC $S_USE_EXT_SYNC \
DMA_2D_TLAST_MODE 1 \
]

# VDMA config
set vdma_cfg [list \
c_m_axis_mm2s_tdata_width {64} \
c_num_fstores {8} \
c_use_mm2s_fsync {1} \
c_use_s2mm_fsync {2} \
c_enable_vert_flip {0} \
c_mm2s_genlock_mode {1} \
c_s2mm_genlock_mode {0} \
]

# SRC AXIS
set src_axis_vip_cfg [list \
INTERFACE_MODE {MASTER} \
HAS_TLAST {1} \
TUSER_WIDTH {1} \
TDATA_NUM_BYTES $TDATA_NUM_BYTES \
]

# DST AXIS
set dst_axis_vip_cfg [list \
INTERFACE_MODE {SLAVE} \
HAS_TLAST {1} \
TDATA_NUM_BYTES $TDATA_NUM_BYTES \
]
89 changes: 89 additions & 0 deletions testbenches/ip/dma_flock/cfgs/cfg3_fsync_autorun.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
set MAX_NUM_FRAMES_WIDTH 4
set AUTORUN 1
set M_USE_EXT_SYNC 0
set S_USE_EXT_SYNC 1
set TDATA_NUM_BYTES 8

set ad_project_params(M_DMA_CFG_MAX_NUM_FRAMES) $MAX_NUM_FRAMES_WIDTH
set ad_project_params(M_DMA_CFG_AUTORUN) $AUTORUN
set ad_project_params(S_DMA_CFG_AUTORUN) $AUTORUN
set ad_project_params(M_DMA_CFG_USE_EXT_SYNC) $M_USE_EXT_SYNC
set ad_project_params(S_DMA_CFG_USE_EXT_SYNC) $S_USE_EXT_SYNC
set ad_project_params(SRC_AXIS_VIP_CFG_TDATA_NUM_BYTES) $TDATA_NUM_BYTES
set ad_project_params(DST_AXIS_VIP_CFG_TDATA_NUM_BYTES) $TDATA_NUM_BYTES

set m_dma_cfg [list \
DMA_TYPE_SRC 1 \
DMA_TYPE_DEST 0 \
DMA_2D_TRANSFER 1 \
SYNC_TRANSFER_START 0 \
AXIS_TUSER_SYNC 0 \
CYCLIC 1 \
FRAMELOCK 1 \
MAX_NUM_FRAMES_WIDTH $MAX_NUM_FRAMES_WIDTH \
USE_EXT_SYNC $M_USE_EXT_SYNC \
SYNC_TRANSFER_START 1 \
DMA_2D_TLAST_MODE {1} \
\
AUTORUN $AUTORUN \
AUTORUN_FLAGS {0x13} \
AUTORUN_SRC_ADDR {0x00000000} \
AUTORUN_DEST_ADDR {0x00001000} \
AUTORUN_X_LENGTH {0x3FF} \
AUTORUN_Y_LENGTH {0x7} \
AUTORUN_SRC_STRIDE {0x000} \
AUTORUN_DEST_STRIDE {0x400} \
AUTORUN_FRAMELOCK_CONFIG {0x00303} \
AUTORUN_FRAMELOCK_STRIDE {0x2000} \
]

set s_dma_cfg [list \
DMA_TYPE_SRC {0} \
DMA_TYPE_DEST {1} \
DMA_2D_TRANSFER 1 \
SYNC_TRANSFER_START 0 \
AXIS_TUSER_SYNC 0 \
CYCLIC 1 \
FRAMELOCK 1 \
MAX_NUM_FRAMES_WIDTH $MAX_NUM_FRAMES_WIDTH \
USE_EXT_SYNC $S_USE_EXT_SYNC \
DMA_2D_TLAST_MODE {1} \
\
AUTORUN $AUTORUN \
AUTORUN_FLAGS {0x13} \
AUTORUN_SRC_ADDR {0x00001000} \
AUTORUN_DEST_ADDR {0x00000000} \
AUTORUN_X_LENGTH {0x3FF} \
AUTORUN_Y_LENGTH {0x7} \
AUTORUN_SRC_STRIDE {0x000} \
AUTORUN_DEST_STRIDE {0x400} \
AUTORUN_FRAMELOCK_CONFIG {0x00303} \
AUTORUN_FRAMELOCK_STRIDE {0x2000} \
]


# VDMA config
set vdma_cfg [list \
c_m_axis_mm2s_tdata_width {64} \
c_num_fstores {8} \
c_use_mm2s_fsync {1} \
c_use_s2mm_fsync {2} \
c_enable_vert_flip {0} \
c_mm2s_genlock_mode {1} \
c_s2mm_genlock_mode {0} \
]

# SRC AXIS
set src_axis_vip_cfg [list \
INTERFACE_MODE {MASTER} \
HAS_TLAST {1} \
TUSER_WIDTH {1} \
TDATA_NUM_BYTES $TDATA_NUM_BYTES \
]

# DST AXIS
set dst_axis_vip_cfg [list \
INTERFACE_MODE {SLAVE} \
HAS_TLAST {1} \
TDATA_NUM_BYTES $TDATA_NUM_BYTES \
]
Loading

0 comments on commit 5813b38

Please sign in to comment.