Skip to content

Commit

Permalink
util_pack: Added scoreboard for UPack and CPack
Browse files Browse the repository at this point in the history
Signed-off-by: Istvan-Zsolt Szekely <istvan.szekely@analog.com>
  • Loading branch information
IstvanZsSzekely committed Apr 18, 2024
1 parent 1b6f876 commit 7a621c7
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 15 deletions.
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
100 changes: 100 additions & 0 deletions common/sv/scoreboard_pack.sv
@@ -0,0 +1,100 @@
`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 pack_type mode;

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

super.new(name);

this.channels = channels;
this.samples = samples;
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);
`INFOV(("Outer loop: %d", outer_loop), 100);
`INFOV(("Inner loop: %d", inner_loop), 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)) begin
byte_streams_empty_sig = 0;
for (int i=0; i<this.channels*this.samples; 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
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];
`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 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
1 change: 1 addition & 0 deletions util_pack/Makefile
Expand Up @@ -18,6 +18,7 @@ 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
Expand Down
2 changes: 1 addition & 1 deletion util_pack/cfgs/cfg1.tcl
@@ -1,5 +1,5 @@
global ad_project_params

set ad_project_params(CHANNELS) 3 ; ##
set ad_project_params(CHANNELS) 4 ; ##
set ad_project_params(SAMPLES) 2 ; ##
set ad_project_params(WIDTH) 8 ; ##
14 changes: 7 additions & 7 deletions util_pack/environment.sv
Expand Up @@ -11,7 +11,7 @@ package environment_pkg;
import axi_vip_pkg::*;
import axi4stream_vip_pkg::*;
import test_harness_env_pkg::*;
import scoreboard_pkg::*;
import scoreboard_pack_pkg::*;
import x_monitor_pkg::*;

import `PKGIFY(test_harness, mng_axi_vip)::*;
Expand Down Expand Up @@ -42,8 +42,8 @@ package environment_pkg;
x_axis_monitor #(`AGENT(test_harness, rx_src_axis, mst_t)) rx_src_axis_mon;
x_axis_monitor #(`AGENT(test_harness, rx_dst_axis, slv_t)) rx_dst_axis_mon;

scoreboard scoreboard_tx;
scoreboard scoreboard_rx;
scoreboard_pack scoreboard_tx;
scoreboard_pack scoreboard_rx;

//============================================================================
// Constructor
Expand Down Expand Up @@ -88,8 +88,8 @@ package environment_pkg;
rx_src_axis_mon = new("RX Source AXIS Transaction Monitor", rx_src_axis_agent);
rx_dst_axis_mon = new("RX Destination AXIS Transaction Monitor", rx_dst_axis_agent);

scoreboard_tx = new("Pack Verification Environment TX Scoreboard");
scoreboard_rx = new("Pack Verification Environment RX Scoreboard");
scoreboard_tx = new("Pack Verification Environment TX Scoreboard", `CHANNELS, `SAMPLES, CPACK);
scoreboard_rx = new("Pack Verification Environment RX Scoreboard", `CHANNELS, `SAMPLES, UPACK);

endfunction

Expand Down Expand Up @@ -155,8 +155,8 @@ package environment_pkg;
rx_src_axis_mon.run();
rx_dst_axis_mon.run();

// scoreboard_tx.run();
// scoreboard_rx.run();
scoreboard_tx.run();
scoreboard_rx.run();
join_none

endtask
Expand Down
1 change: 1 addition & 0 deletions util_pack/system_project.tcl
Expand Up @@ -33,6 +33,7 @@ adi_sim_project_files [list \
"../common/sv/mailbox.sv" \
"../common/sv/x_monitor.sv" \
"../common/sv/scoreboard.sv" \
"../common/sv/scoreboard_pack.sv" \
"../common/sv/dmac_api.sv" \
"../common/sv/dma_trans.sv" \
"../common/sv/adi_regmap_dmac_pkg.sv" \
Expand Down
13 changes: 7 additions & 6 deletions util_pack/tests/test_program.sv
Expand Up @@ -50,6 +50,9 @@ program test_program;

dmac_api dmac_tx;
dmac_api dmac_rx;

int data_length = $urandom_range(5, 10) * `WIDTH * 2**int($clog2(`CHANNELS)) * `CHANNELS * `SAMPLES / 8;
// int data_length = $urandom_range(5, 10) * `WIDTH * `CHANNELS * `SAMPLES / 8;

initial begin

Expand All @@ -76,7 +79,7 @@ program test_program;
env.sys_reset();

// configure environment sequencers
env.configure(128);
env.configure(data_length);

`INFO(("Bring up IPs from reset."));
systemBringUp();
Expand All @@ -87,18 +90,16 @@ program test_program;

// Generate DMA transfers
`INFO(("Start DMAs"));
rx_dma_transfer(128);
tx_dma_transfer(128);

// #5us;
rx_dma_transfer(data_length);
tx_dma_transfer(data_length);

env.tx_src_axis_seq.start();
env.rx_src_axis_seq.start();

// env.scoreboard_rx.wait_until_complete();
// env.scoreboard_tx.wait_until_complete();

#1us;
#5us;

env.stop();

Expand Down

0 comments on commit 7a621c7

Please sign in to comment.