Skip to content

Commit

Permalink
util_axis_fifo_asym: Updated after rebase
Browse files Browse the repository at this point in the history
Signed-off-by: Istvan-Zsolt Szekely <[email protected]>
  • Loading branch information
IstvanZsSzekely committed Jan 22, 2025
1 parent da1c012 commit cc748dc
Show file tree
Hide file tree
Showing 11 changed files with 201 additions and 260 deletions.
2 changes: 1 addition & 1 deletion library/drivers/common/watchdog.sv
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ package watchdog_pkg;
fork
begin
#(this.timer*1ns);
this.error($sformatf("Watchdog timer timed out! %s", this.message));
this.fatal($sformatf("Watchdog timer timed out! %s", this.message));
end
@this.stop_event;
join_any
Expand Down
16 changes: 8 additions & 8 deletions library/utilities/test_harness_env.sv
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ package test_harness_env_pkg;
this.mng.agent.start_master();
this.ddr.agent.start_slave();

this.sys_clk_vip_if.start_clock;
this.dma_clk_vip_if.start_clock;
this.ddr_clk_vip_if.start_clock;
this.sys_clk_vip_if.start_clock();
this.dma_clk_vip_if.start_clock();
this.ddr_clk_vip_if.start_clock();
endtask

//============================================================================
Expand All @@ -103,19 +103,19 @@ package test_harness_env_pkg;
this.mng.agent.stop_master();
this.ddr.agent.stop_slave();

this.sys_clk_vip_if.stop_clock;
this.dma_clk_vip_if.stop_clock;
this.ddr_clk_vip_if.stop_clock;
this.sys_clk_vip_if.stop_clock();
this.dma_clk_vip_if.stop_clock();
this.ddr_clk_vip_if.stop_clock();
endtask

//============================================================================
// System reset routine
//============================================================================
task sys_reset();
//asserts all the resets for 100 ns
this.sys_rst_vip_if.assert_reset;
this.sys_rst_vip_if.assert_reset();
#200;
this.sys_rst_vip_if.deassert_reset;
this.sys_rst_vip_if.deassert_reset();
#800;
endtask

Expand Down
2 changes: 1 addition & 1 deletion testbenches/ip/scoreboard/environment.sv
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package environment_pkg;
import scoreboard_pkg::*;


class scoreboard_environment #(`AXIS_VIP_PARAM_DECL(adc_src), `AXIS_VIP_PARAM_DECL(dac_dst), `AXIS_VIP_PARAM_DECL(adc_dst_pt), `AXIS_VIP_PARAM_DECL(dac_src_pt)) extends adi_environment;
class scoreboard_environment #(`AXIS_VIP_PARAM_DECL(adc_src), `AXIS_VIP_PARAM_DECL(dac_dst), `AXI_VIP_PARAM_DECL(adc_dst_pt), `AXI_VIP_PARAM_DECL(dac_src_pt)) extends adi_environment;

// Agents
adi_axis_master_agent #(`AXIS_VIP_PARAM_ORDER(adc_src)) adc_src_axis_agent;
Expand Down
2 changes: 1 addition & 1 deletion testbenches/ip/scoreboard/tests/test_program.sv
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import `PKGIFY(test_harness, dac_src_axi_pt_1)::*;

`define ADC_TRANSFER_LENGTH 32'h600

program test_program;
program test_program();

// declare the class instances
test_harness_env #(`AXI_VIP_PARAMS(test_harness, mng_axi_vip), `AXI_VIP_PARAMS(test_harness, ddr_axi_vip)) base_env;
Expand Down
30 changes: 7 additions & 23 deletions testbenches/ip/util_axis_fifo_asym/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,14 @@
####################################################################################
####################################################################################

# All test-bench dependencies except test programs
SV_DEPS += ../../../library/utilities/utils.svh
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/utilities/test_harness_env.sv
SV_DEPS += ../../../library/regmaps/adi_peripheral_pkg.sv
SV_DEPS += ../../../library/regmaps/adi_regmap_pkg.sv
SV_DEPS += ../../../library/drivers/common/mailbox.sv
SV_DEPS += ../../../library/drivers/common/x_monitor.sv
SV_DEPS += ../../../library/drivers/common/scoreboard.sv
SV_DEPS += ../../../library/drivers/common/filter.sv
SV_DEPS += ../../../library/drivers/common/interfaces.svh
SV_DEPS += ../../../library/drivers/common/watchdog.sv
SV_DEPS += environment.sv
SV_DEPS += system_tb.sv
# Makeincludes
include ../../../scripts/make_tb_path.mk
include $(TB_LIBRARY_PATH)/includes/Makeinclude_common.mk
include $(TB_LIBRARY_PATH)/includes/Makeinclude_axis.mk
include $(TB_LIBRARY_PATH)/includes/Makeinclude_scoreboard.mk

ENV_DEPS += system_project.tcl
ENV_DEPS += system_bd.tcl
ENV_DEPS += ../../../scripts/adi_sim.tcl
ENV_DEPS += ../../../scripts/run_sim.tcl
# Remaining test-bench dependencies except test programs
SV_DEPS += environment.sv

LIB_DEPS := util_cdc
LIB_DEPS += util_axis_fifo
Expand Down
26 changes: 21 additions & 5 deletions testbenches/ip/util_axis_fifo_asym/cfgs/cfg_rand.tcl
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
global ad_project_params

set async_clk [expr int(rand()*2)]
set ad_project_params(ASYNC_CLK) $async_clk

set tkeep_en [expr int(rand()*2)]
set ad_project_params(TKEEP_EN) $tkeep_en

set tlast_en [expr int(rand()*2)]
set ad_project_params(TLAST_EN) $tlast_en

set random_width [expr int(8*pow(2, int(7.0*rand()+1)))]
set INPUT_WIDTH $random_width
set ad_project_params(INPUT_WIDTH) $INPUT_WIDTH
Expand All @@ -8,10 +17,10 @@ set random_width [expr int(8*pow(2, int(7.0*rand()+1)))]
set OUTPUT_WIDTH $random_width
set ad_project_params(OUTPUT_WIDTH) $OUTPUT_WIDTH

set FIFO_LIMITED [expr int(rand()*2)]
set ad_project_params(FIFO_LIMITED) $FIFO_LIMITED
set fifo_limited [expr int(rand()*2)]
set ad_project_params(FIFO_LIMITED) $fifo_limited

if {$FIFO_LIMITED} {
if {$fifo_limited} {
if {$INPUT_WIDTH > $OUTPUT_WIDTH} {
set RATIO $INPUT_WIDTH/$OUTPUT_WIDTH
} else {
Expand All @@ -24,5 +33,12 @@ if {$FIFO_LIMITED} {
set random_width [expr int(int(log($RATIO)/log(2))+4.0*rand()+1)]
set ad_project_params(ADDRESS_WIDTH) $random_width

set ad_project_params(INPUT_CLK) [expr int(rand()*9000)+1000]
set ad_project_params(OUTPUT_CLK) [expr int(rand()*9000)+1000]
set input_clk [expr int(rand()*9)+1]
set ad_project_params(INPUT_CLK) $input_clk

if {$async_clk} {
set output_clk [expr int(rand()*9)+1]
set ad_project_params(OUTPUT_CLK) $output_clk
} else {
set ad_project_params(OUTPUT_CLK) $input_clk
}
178 changes: 52 additions & 126 deletions testbenches/ip/util_axis_fifo_asym/environment.sv
Original file line number Diff line number Diff line change
@@ -1,112 +1,72 @@
`include "utils.svh"
`include "axis_definitions.svh"

package environment_pkg;

import m_axi_sequencer_pkg::*;
import s_axi_sequencer_pkg::*;
import m_axis_sequencer_pkg::*;
import s_axis_sequencer_pkg::*;
import logger_pkg::*;

import axi_vip_pkg::*;
import adi_common_pkg::*;
import axi4stream_vip_pkg::*;
import test_harness_env_pkg::*;
import m_axis_sequencer_pkg::*;
import s_axis_sequencer_pkg::*;
import adi_axis_agent_pkg::*;
import scoreboard_pkg::*;
import x_monitor_pkg::*;

import `PKGIFY(test_harness, mng_axi_vip)::*;
import `PKGIFY(test_harness, ddr_axi_vip)::*;
class util_axis_fifo_environment #(`AXIS_VIP_PARAM_DECL(input_axis), `AXIS_VIP_PARAM_DECL(output_axis), int INPUT_CLK, int OUTPUT_CLK) extends adi_environment;

import `PKGIFY(test_harness, input_axis)::*;
import `PKGIFY(test_harness, output_axis)::*;
virtual interface clk_vip_if #(.C_CLK_CLOCK_PERIOD(INPUT_CLK)) input_clk_vip_if;
virtual interface clk_vip_if #(.C_CLK_CLOCK_PERIOD(OUTPUT_CLK)) output_clk_vip_if;

class environment extends test_harness_env;
adi_axis_master_agent #(`AXIS_VIP_PARAM_ORDER(input_axis)) input_axis_agent;
adi_axis_slave_agent #(`AXIS_VIP_PARAM_ORDER(output_axis)) output_axis_agent;

virtual interface clk_if input_clk_if;
virtual interface clk_if output_clk_if;

// agents and sequencers
`AGENT(test_harness, input_axis, mst_t) input_axis_agent;
`AGENT(test_harness, output_axis, slv_t) output_axis_agent;

m_axis_sequencer #(`AGENT(test_harness, input_axis, mst_t),
`AXIS_VIP_PARAMS(test_harness, input_axis)
) input_axis_seq;
s_axis_sequencer #(`AGENT(test_harness, output_axis, slv_t)) output_axis_seq;

x_axis_monitor #(`AGENT(test_harness, input_axis, mst_t)) input_axis_mon;
x_axis_monitor #(`AGENT(test_harness, output_axis, slv_t)) output_axis_mon;

scoreboard scoreboard_inst;
scoreboard #(logic [7:0]) scoreboard_inst;

//============================================================================
// Constructor
//============================================================================
function new (
virtual interface clk_vip_if #(.C_CLK_CLOCK_PERIOD(10)) sys_clk_vip_if,
virtual interface clk_vip_if #(.C_CLK_CLOCK_PERIOD(5)) dma_clk_vip_if,
virtual interface clk_vip_if #(.C_CLK_CLOCK_PERIOD(2.5)) ddr_clk_vip_if,

virtual interface rst_vip_if #(.C_ASYNCHRONOUS(1), .C_RST_POLARITY(1)) sys_rst_vip_if,
input string name,

virtual interface axi_vip_if #(`AXI_VIP_IF_PARAMS(test_harness, mng_axi_vip)) mng_vip_if,
virtual interface axi_vip_if #(`AXI_VIP_IF_PARAMS(test_harness, ddr_axi_vip)) ddr_vip_if,
virtual interface clk_vip_if #(.C_CLK_CLOCK_PERIOD(INPUT_CLK)) input_clk_vip_if,
virtual interface clk_vip_if #(.C_CLK_CLOCK_PERIOD(OUTPUT_CLK)) output_clk_vip_if,

virtual interface clk_if input_clk_if,
virtual interface clk_if output_clk_if,

virtual interface axi4stream_vip_if #(`AXIS_VIP_IF_PARAMS(test_harness, input_axis)) input_axis_vip_if,
virtual interface axi4stream_vip_if #(`AXIS_VIP_IF_PARAMS(test_harness, output_axis)) output_axis_vip_if
);
virtual interface axi4stream_vip_if #(`AXIS_VIP_IF_PARAMS(input_axis)) input_axis_vip_if,
virtual interface axi4stream_vip_if #(`AXIS_VIP_IF_PARAMS(output_axis)) output_axis_vip_if);

// creating the agents
super.new(sys_clk_vip_if,
dma_clk_vip_if,
ddr_clk_vip_if,
sys_rst_vip_if,
mng_vip_if,
ddr_vip_if);

this.input_clk_if = input_clk_if;
this.output_clk_if = output_clk_if;

input_axis_agent = new("Input AXI Stream Agent", input_axis_vip_if);
output_axis_agent = new("Output AXI Stream Agent", output_axis_vip_if);
super.new(name);

input_axis_seq = new(input_axis_agent);
output_axis_seq = new(output_axis_agent);
this.input_clk_vip_if = input_clk_vip_if;
this.output_clk_vip_if = output_clk_vip_if;

input_axis_mon = new("Input AXIS Transaction Monitor", input_axis_agent);
output_axis_mon = new("Output AXIS Transaction Monitor", output_axis_agent);

scoreboard_inst = new("Verification Environment Scoreboard");
this.input_axis_agent = new("Input AXI Stream Agent", input_axis_vip_if, this);
this.output_axis_agent = new("Output AXI Stream Agent", output_axis_vip_if, this);

this.scoreboard_inst = new("Util AXIS FIFO Scoreboard", this);
endfunction

//============================================================================
// Configure environment
//============================================================================
task configure();

// configuration for input
this.input_axis_seq.set_stop_policy(STOP_POLICY_PACKET);
this.input_axis_seq.set_data_gen_mode(DATA_GEN_MODE_AUTO_INCR);
this.input_axis_seq.set_descriptor_gen_mode(1);
this.input_axis_seq.set_data_beat_delay(0);
this.input_axis_seq.set_descriptor_delay(0);
this.input_axis_seq.set_inactive_drive_output_0();
this.input_axis_agent.sequencer.set_stop_policy(STOP_POLICY_PACKET);
this.input_axis_agent.sequencer.set_data_gen_mode(DATA_GEN_MODE_AUTO_INCR);
this.input_axis_agent.sequencer.set_descriptor_gen_mode(1);
this.input_axis_agent.sequencer.set_data_beat_delay(0);
this.input_axis_agent.sequencer.set_descriptor_delay(0);
this.input_axis_agent.sequencer.set_inactive_drive_output_0();

// configuration for output
this.output_axis_seq.set_mode(XIL_AXI4STREAM_READY_GEN_NO_BACKPRESSURE);
this.output_axis_agent.sequencer.set_mode(XIL_AXI4STREAM_READY_GEN_NO_BACKPRESSURE);

// this.output_axis_seq.set_use_variable_ranges();
// this.output_axis_seq.set_high_time_range(1,1);
// this.output_axis_seq.set_low_time_range(0,0);

// this.output_axis_seq.clr_use_variable_ranges();
// this.output_axis_seq.set_high_time(1);
// this.output_axis_seq.set_low_time(1);
// this.output_axis_agent.sequencer.set_use_variable_ranges();
// this.output_axis_agent.sequencer.set_high_time_range(1,1);
// this.output_axis_agent.sequencer.set_low_time_range(0,0);

// this.output_axis_agent.sequencer.clr_use_variable_ranges();
// this.output_axis_agent.sequencer.set_high_time(1);
// this.output_axis_agent.sequencer.set_low_time(1);
endtask

//============================================================================
Expand All @@ -115,72 +75,38 @@ package environment_pkg;
// - Start the agents
//============================================================================
task start();
this.input_clk_vip_if.start_clock();
this.output_clk_vip_if.start_clock();

super.start();

input_clk_if.start_clock(`INPUT_CLK);
output_clk_if.start_clock(`OUTPUT_CLK);

input_axis_agent.start_master();
output_axis_agent.start_slave();

scoreboard_inst.set_source_stream(input_axis_mon);
scoreboard_inst.set_sink_stream(output_axis_mon);
this.input_axis_agent.agent.start_master();
this.output_axis_agent.agent.start_slave();

this.input_axis_agent.monitor.publisher.subscribe(this.scoreboard_inst.subscriber_source);
this.output_axis_agent.monitor.publisher.subscribe(this.scoreboard_inst.subscriber_sink);
endtask

//============================================================================
// Start the test
// - start the RX scoreboard and sequencer
// - start the TX scoreboard and sequencer
// - setup the RX DMA
// - setup the TX DMA
// Run subroutine
//============================================================================
task test();

task run();
fork
input_axis_seq.run();
output_axis_seq.run();
this.input_axis_agent.sequencer.run();
this.output_axis_agent.sequencer.run();

input_axis_mon.run();
output_axis_mon.run();
this.input_axis_agent.monitor.run();
this.output_axis_agent.monitor.run();

scoreboard_inst.run();
this.scoreboard_inst.run();
join_none

endtask


//============================================================================
// Post test subroutine
//============================================================================
task post_test();
// Evaluate the scoreboard's results
endtask

//============================================================================
// Run subroutine
//============================================================================
task run;

//pre_test();
test();

endtask

//============================================================================
// Stop subroutine
//============================================================================
task stop;

super.stop();

input_axis_seq.stop();
input_axis_agent.stop_master();
output_axis_agent.stop_slave();

post_test();

task stop();
this.input_axis_agent.sequencer.stop();
this.input_axis_agent.agent.stop_master();
this.output_axis_agent.agent.stop_slave();
endtask

endclass
Expand Down
Loading

0 comments on commit cc748dc

Please sign in to comment.