Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Util pack #97

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/sv/scoreboard.sv
Expand Up @@ -176,7 +176,7 @@ package scoreboard_pkg;
endtask: get_sink_transaction

// compare the collected data
task compare_transaction();
virtual task compare_transaction();

logic [7:0] source_byte;
logic [7:0] sink_byte;
Expand Down
103 changes: 103 additions & 0 deletions common/sv/scoreboard_pack.sv
@@ -0,0 +1,103 @@
`include "utils.svh"

package scoreboard_pack_pkg;

import xil_common_vip_pkg::*;
import axi4stream_vip_pkg::*;
import axi_vip_pkg::*;
import logger_pkg::*;
import x_monitor_pkg::*;
import mailbox_pkg::*;
import scoreboard_pkg::*;

typedef enum {
CPACK,
UPACK
} pack_type;

class scoreboard_pack extends scoreboard;

protected int channels;
protected int samples;
protected int width;

protected pack_type mode;

// constructor
function new(
input string name,
input int channels,
input int samples,
input int width,
input pack_type mode);

super.new(name);

this.channels = channels;
this.samples = samples;
this.width = width;
this.mode = mode;

endfunction: new

// compare the collected data
virtual task compare_transaction();

logic [7:0] source_byte;
logic [7:0] sink_byte;
logic [7:0] sink_byte_stream_block [int];

int outer_loop = (this.mode == CPACK) ? this.channels : this.samples;
int inner_loop = (this.mode == CPACK) ? this.samples : this.channels;

`INFOV(("Scoreboard started"), 100);

forever begin : tx_path
if (this.enabled == 0)
break;
if ((this.source_byte_stream_size > 0) &&
(this.sink_byte_stream_size >= this.channels*this.samples*this.width/8)) begin
byte_streams_empty_sig = 0;
for (int i=0; i<this.channels*this.samples*this.width/8; i++) begin
sink_byte_stream_block[i] = this.sink_byte_stream.pop_back();
this.sink_byte_stream_size--;
end
for (int i=0; i<outer_loop; i++) begin
for (int j=0; j<inner_loop; j++) begin
for (int k=0; k<this.width/8; k++) begin
source_byte = this.source_byte_stream.pop_back();
if (this.sink_type == CYCLIC)
this.source_byte_stream.push_front(source_byte);
else
this.source_byte_stream_size--;
sink_byte = sink_byte_stream_block[(outer_loop*j+i)*this.width/8+k];
`INFOV(("Scoreboard source-sink data: exp %h - rcv %h", source_byte, sink_byte), 100);
if (source_byte != sink_byte) begin
`ERROR(("Scoreboard failed at: exp %h - rcv %h", source_byte, sink_byte));
end
end
end
end
end else begin
if ((this.source_byte_stream_size == 0) &&
(this.sink_byte_stream_size == 0)) begin
byte_streams_empty_sig = 1;
->>byte_streams_empty;
end
fork begin
fork
@source_transaction_event;
@sink_transaction_event;
@stop_scoreboard;
join_any
byte_streams_empty_sig = 0;
disable fork;
end join
end
end

endtask /* compare_transaction */

endclass

endpackage
67 changes: 67 additions & 0 deletions util_pack/Makefile
@@ -0,0 +1,67 @@
####################################################################################
####################################################################################
## Copyright 2022(c) Analog Devices, Inc.
####################################################################################
####################################################################################

# All test-bench dependencies except test programs
SV_DEPS += ../common/sv/utils.svh
SV_DEPS += ../common/sv/logger_pkg.sv
SV_DEPS += ../common/sv/reg_accessor.sv
SV_DEPS += ../common/sv/m_axis_sequencer.sv
SV_DEPS += ../common/sv/s_axis_sequencer.sv
SV_DEPS += ../common/sv/m_axi_sequencer.sv
SV_DEPS += ../common/sv/s_axi_sequencer.sv
SV_DEPS += ../common/sv/test_harness_env.sv
SV_DEPS += ../common/sv/adi_peripheral_pkg.sv
SV_DEPS += ../common/sv/adi_regmap_pkg.sv
SV_DEPS += ../common/sv/mailbox.sv
SV_DEPS += ../common/sv/x_monitor.sv
SV_DEPS += ../common/sv/scoreboard.sv
SV_DEPS += ../common/sv/scoreboard_pack.sv
SV_DEPS += ../common/sv/dmac_api.sv
SV_DEPS += ../common/sv/dma_trans.sv
SV_DEPS += ../common/sv/adi_regmap_dmac_pkg.sv
SV_DEPS += ../common/sv/watchdog.sv
SV_DEPS += environment.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 := util_cdc
LIB_DEPS += util_axis_fifo
LIB_DEPS += axi_dmac
LIB_DEPS += util_pack/util_cpack2
LIB_DEPS += util_pack/util_upack2

# 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_mm2mm_default:directed_test
#TESTS += cfg1:test_program
#TESTS += cfg2_fsync:test_program
#TESTS += cfg2_fsync:test_frame_delay

include ../scripts/project-sim.mk

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

####################################################################################
####################################################################################
27 changes: 27 additions & 0 deletions util_pack/README.md
@@ -0,0 +1,27 @@
Usage :

Run all tests in batch mode:

make


Run all tests in GUI mode:

make MODE=gui


Run specific test on a specific configuration in gui mode:

make CFG=<name of cfg> TST=<name of test> MODE=gui


Run all test from a configuration:

make <name of cfg>


Where:

* <name of cfg> is a file from the cfgs directory without the tcl extension of format cfg\*
* <name of test> is a file from the tests directory without the tcl extension

5 changes: 5 additions & 0 deletions util_pack/cfgs/cfg1.tcl
@@ -0,0 +1,5 @@
global ad_project_params

set ad_project_params(CHANNELS) 3 ; ##
set ad_project_params(SAMPLES) 2 ; ##
set ad_project_params(WIDTH) 16 ; ##
15 changes: 15 additions & 0 deletions util_pack/cfgs/cfg_rand.tcl
@@ -0,0 +1,15 @@
global ad_project_params

set max_width 4096

while {$max_width > 2048} {
set channels [expr int(15.0*rand()+2)] ; # 2-16
set samples [expr int(pow(2, int(4.0*rand()+1)))] ; # 2-16
set width [expr int(8*pow(2, int(4.0*rand())))] ; # 8-64

set max_width [expr $channels * $samples * $width]
}

set ad_project_params(CHANNELS) $channels
set ad_project_params(SAMPLES) $samples
set ad_project_params(WIDTH) $width