Skip to content

Commit aae26e1

Browse files
Util pack (#97)
* util_pack: Upack and Cpack combined testbench Signed-off-by: Istvan-Zsolt Szekely <istvan.szekely@analog.com>
1 parent 51e772b commit aae26e1

File tree

13 files changed

+1623
-1
lines changed

13 files changed

+1623
-1
lines changed

common/sv/scoreboard.sv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ package scoreboard_pkg;
176176
endtask: get_sink_transaction
177177

178178
// compare the collected data
179-
task compare_transaction();
179+
virtual task compare_transaction();
180180

181181
logic [7:0] source_byte;
182182
logic [7:0] sink_byte;

common/sv/scoreboard_pack.sv

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
`include "utils.svh"
2+
3+
package scoreboard_pack_pkg;
4+
5+
import xil_common_vip_pkg::*;
6+
import axi4stream_vip_pkg::*;
7+
import axi_vip_pkg::*;
8+
import logger_pkg::*;
9+
import x_monitor_pkg::*;
10+
import mailbox_pkg::*;
11+
import scoreboard_pkg::*;
12+
13+
typedef enum {
14+
CPACK,
15+
UPACK
16+
} pack_type;
17+
18+
class scoreboard_pack extends scoreboard;
19+
20+
protected int channels;
21+
protected int samples;
22+
protected int width;
23+
24+
protected pack_type mode;
25+
26+
// constructor
27+
function new(
28+
input string name,
29+
input int channels,
30+
input int samples,
31+
input int width,
32+
input pack_type mode);
33+
34+
super.new(name);
35+
36+
this.channels = channels;
37+
this.samples = samples;
38+
this.width = width;
39+
this.mode = mode;
40+
41+
endfunction: new
42+
43+
// compare the collected data
44+
virtual task compare_transaction();
45+
46+
logic [7:0] source_byte;
47+
logic [7:0] sink_byte;
48+
logic [7:0] sink_byte_stream_block [int];
49+
50+
int outer_loop = (this.mode == CPACK) ? this.channels : this.samples;
51+
int inner_loop = (this.mode == CPACK) ? this.samples : this.channels;
52+
53+
`INFOV(("Scoreboard started"), 100);
54+
55+
forever begin : tx_path
56+
if (this.enabled == 0)
57+
break;
58+
if ((this.source_byte_stream_size > 0) &&
59+
(this.sink_byte_stream_size >= this.channels*this.samples*this.width/8)) begin
60+
byte_streams_empty_sig = 0;
61+
for (int i=0; i<this.channels*this.samples*this.width/8; i++) begin
62+
sink_byte_stream_block[i] = this.sink_byte_stream.pop_back();
63+
this.sink_byte_stream_size--;
64+
end
65+
for (int i=0; i<outer_loop; i++) begin
66+
for (int j=0; j<inner_loop; j++) begin
67+
for (int k=0; k<this.width/8; k++) begin
68+
source_byte = this.source_byte_stream.pop_back();
69+
if (this.sink_type == CYCLIC)
70+
this.source_byte_stream.push_front(source_byte);
71+
else
72+
this.source_byte_stream_size--;
73+
sink_byte = sink_byte_stream_block[(outer_loop*j+i)*this.width/8+k];
74+
`INFOV(("Scoreboard source-sink data: exp %h - rcv %h", source_byte, sink_byte), 100);
75+
if (source_byte != sink_byte) begin
76+
`ERROR(("Scoreboard failed at: exp %h - rcv %h", source_byte, sink_byte));
77+
end
78+
end
79+
end
80+
end
81+
end else begin
82+
if ((this.source_byte_stream_size == 0) &&
83+
(this.sink_byte_stream_size == 0)) begin
84+
byte_streams_empty_sig = 1;
85+
->>byte_streams_empty;
86+
end
87+
fork begin
88+
fork
89+
@source_transaction_event;
90+
@sink_transaction_event;
91+
@stop_scoreboard;
92+
join_any
93+
byte_streams_empty_sig = 0;
94+
disable fork;
95+
end join
96+
end
97+
end
98+
99+
endtask /* compare_transaction */
100+
101+
endclass
102+
103+
endpackage

util_pack/Makefile

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

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

util_pack/cfgs/cfg1.tcl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
global ad_project_params
2+
3+
set ad_project_params(CHANNELS) 3 ; ##
4+
set ad_project_params(SAMPLES) 2 ; ##
5+
set ad_project_params(WIDTH) 16 ; ##

util_pack/cfgs/cfg_rand.tcl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
global ad_project_params
2+
3+
set max_width 4096
4+
5+
while {$max_width > 2048} {
6+
set channels [expr int(15.0*rand()+2)] ; # 2-16
7+
set samples [expr int(pow(2, int(4.0*rand()+1)))] ; # 2-16
8+
set width [expr int(8*pow(2, int(4.0*rand())))] ; # 8-64
9+
10+
set max_width [expr $channels * $samples * $width]
11+
}
12+
13+
set ad_project_params(CHANNELS) $channels
14+
set ad_project_params(SAMPLES) $samples
15+
set ad_project_params(WIDTH) $width

0 commit comments

Comments
 (0)