Skip to content

Commit

Permalink
util_axis_fifo_asym: Updates and fixes
Browse files Browse the repository at this point in the history
- Extended the ADI agent with additional functions
- Fixes issues with the AXIS VIP sequencer
- Updated the testbench

Signed-off-by: Istvan-Zsolt Szekely <istvan.szekely@analog.com>
  • Loading branch information
IstvanZsSzekely committed Feb 3, 2025
1 parent fc60809 commit 2693a75
Show file tree
Hide file tree
Showing 6 changed files with 193 additions and 178 deletions.
48 changes: 48 additions & 0 deletions library/vip/amd/axis/adi_axis_agent.sv
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@ package adi_axis_agent_pkg;
this.monitor = new("Monitor", this.agent.monitor, this);
endfunction: new

task start();
this.agent.start_master();
endtask: start

task run();
this.sequencer.run();
this.monitor.run();
endtask: run

task stop();
this.monitor.stop();
this.sequencer.stop();
this.agent.stop_master();
endtask: stop

endclass: adi_axis_master_agent


Expand All @@ -85,12 +100,28 @@ package adi_axis_agent_pkg;
this.monitor = new("Monitor", this.agent.monitor, this);
endfunction: new

task start();
this.agent.start_slave();
endtask: start

task run();
this.sequencer.run();
this.monitor.run();
endtask: run

task stop();
this.monitor.stop();
this.agent.stop_slave();
endtask: stop

endclass: adi_axis_slave_agent


class adi_axis_passthrough_mem_agent #(`AXIS_VIP_PARAM_DECL(passthrough)) extends adi_agent;

axi4stream_passthrough_agent #(`AXIS_VIP_IF_PARAMS(passthrough)) agent;
m_axis_sequencer #(`AXIS_VIP_PARAM_ORDER(passthrough)) master_sequencer;
s_axis_sequencer #(`AXIS_VIP_PARAM_ORDER(passthrough)) slave_sequencer;
adi_axis_monitor #(`AXIS_VIP_PARAM_ORDER(passthrough)) monitor;

function new(
Expand All @@ -104,6 +135,23 @@ package adi_axis_agent_pkg;
this.monitor = new("Monitor", this.agent.monitor, this);
endfunction: new

task start();
this.warning($sformatf("Start must called manually in the test program or environment"));
endtask: start

task run();
this.master_sequencer.run();
this.slave_sequencer.run();
this.monitor.run();
endtask: run

task stop();
this.monitor.stop();
this.master_sequencer.stop();
this.agent.stop_slave();
this.agent.stop_master();
endtask: stop

endclass: adi_axis_passthrough_mem_agent

endpackage
22 changes: 18 additions & 4 deletions library/vip/amd/axis/adi_axis_monitor.sv
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package adi_axis_monitor_pkg;
adi_publisher #(logic [7:0]) publisher;

protected bit enabled;
protected event enable_ev;

// constructor
function new(
Expand All @@ -37,14 +38,27 @@ package adi_axis_monitor_pkg;
return;
end

fork
this.get_transaction();
join_none

this.enabled = 1;
this.info($sformatf("Monitor enabled"), ADI_VERBOSITY_MEDIUM);

fork
begin
this.get_transaction();
end
begin
if (this.enabled == 1) begin
@enable_ev;
end
disable fork;
end
join_none
endtask: run

function void stop();
this.enabled = 0;
-> enable_ev;
endfunction: stop

// collect data from the AXI4Strean interface of the stub, this task
// handles both ONESHOT and CYCLIC scenarios
task get_transaction();
Expand Down
72 changes: 46 additions & 26 deletions library/vip/amd/axis/m_axis_sequencer.sv
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ package m_axis_sequencer_pkg;
} data_gen_mode_t;

typedef enum bit [1:0] {
STOP_POLICY_IMMEDIATE = 2'h0, // disable as soon as possible
STOP_POLICY_DATA_BEAT = 2'h1, // disable after the data beat has been transferred
STOP_POLICY_PACKET = 2'h2, // disable after the packet has been transferred
STOP_POLICY_DESCRIPTOR_QUEUE = 2'h3 // disable after the packet queue has been transferred
Expand Down Expand Up @@ -117,30 +116,47 @@ package m_axis_sequencer_pkg;

// set vif proxy to drive outputs with 0 when inactive
virtual task set_inactive_drive_output_0();
this.fatal($sformatf("Base class was instantiated instead of the inherited class!"));
endtask: set_inactive_drive_output_0

// check if ready is asserted
virtual function bit check_ready_asserted();
this.fatal($sformatf("Base class was instantiated instead of the inherited class!"));
endfunction: check_ready_asserted

// wait for set amount of clock cycles
virtual task wait_clk_count(input int wait_clocks);
this.fatal($sformatf("Base class was instantiated instead of the inherited class!"));
endtask: wait_clk_count

// pack the byte stream into transfers(beats) then in packets by setting the tlast
virtual protected task packetize();
this.fatal($sformatf("Base class was instantiated instead of the inherited class!"));
endtask: packetize

virtual protected task sender();
this.fatal($sformatf("Base class was instantiated instead of the inherited class!"));
endtask: sender

// create transfer based on data beats per packet
virtual function void add_xfer_descriptor_packet_size(
input int data_beats_per_packet,
input int gen_tlast = 1,
input int gen_sync = 1);

this.fatal($sformatf("Base class was instantiated instead of the inherited class!"));
endfunction: add_xfer_descriptor_packet_size

// wait until data beat is sent
virtual task beat_sent();
this.fatal($sformatf("Base class was instantiated instead of the inherited class!"));
endtask: beat_sent

// wait until packet is sent
virtual task packet_sent();
this.fatal($sformatf("Base class was instantiated instead of the inherited class!"));
endtask: packet_sent


// set disable policy
function void set_stop_policy(input stop_policy_t stop_policy);
Expand Down Expand Up @@ -216,16 +232,6 @@ package m_axis_sequencer_pkg;
wait_clk_count(descriptor_delay);
endtask: descriptor_delay_subroutine

// wait until data beat is sent
task beat_sent();
@beat_done;
endtask: beat_sent

// wait until packet is sent
task packet_sent();
@packet_done;
endtask: packet_sent

// wait until queue is empty
task wait_empty_descriptor_queue();
if (this.queue_empty_sig)
Expand All @@ -249,13 +255,11 @@ package m_axis_sequencer_pkg;
fork
begin
@disable_ev;
if (this.queue_empty_sig == 0)
case (stop_policy)
STOP_POLICY_DESCRIPTOR_QUEUE: @queue_empty;
STOP_POLICY_PACKET: @packet_done;
STOP_POLICY_DATA_BEAT: @beat_done;
STOP_POLICY_IMMEDIATE: ;
endcase
case (stop_policy)
STOP_POLICY_DESCRIPTOR_QUEUE: wait_empty_descriptor_queue();
STOP_POLICY_PACKET: packet_sent();
STOP_POLICY_DATA_BEAT: beat_sent();
endcase
end
forever begin
if (descriptor_q.size() > 0) begin
Expand Down Expand Up @@ -330,6 +334,22 @@ package m_axis_sequencer_pkg;
endfunction: new


// wait until data beat is sent
virtual task beat_sent();
if (this.driver.is_driver_idle()) begin
return;
end
@beat_done;
endtask: beat_sent

// wait until packet is sent
virtual task packet_sent();
if (this.driver.is_driver_idle() && this.trans.get_last()) begin
return;
end
@packet_done;
endtask: packet_sent

// create transfer based on data beats per packet
virtual function void add_xfer_descriptor_packet_size(
input int data_beats_per_packet,
Expand Down Expand Up @@ -443,7 +463,6 @@ package m_axis_sequencer_pkg;
this.info($sformatf("waiting transfer to complete"), ADI_VERBOSITY_HIGH);
@beat_done;
end
->> packet_done;
endtask: packetize

// packet sender function
Expand All @@ -457,19 +476,20 @@ package m_axis_sequencer_pkg;
fork
begin
@disable_ev;
if (this.queue_empty_sig == 0)
case (stop_policy)
STOP_POLICY_DESCRIPTOR_QUEUE: @queue_empty;
STOP_POLICY_PACKET: @packet_done;
STOP_POLICY_DATA_BEAT: @beat_done;
STOP_POLICY_IMMEDIATE: ;
endcase
case (stop_policy)
STOP_POLICY_DESCRIPTOR_QUEUE: wait_empty_descriptor_queue();
STOP_POLICY_PACKET: packet_sent();
STOP_POLICY_DATA_BEAT: beat_sent();
endcase
end
forever begin
@data_av_ev;
this.info($sformatf("sending axis transaction"), ADI_VERBOSITY_HIGH);
this.driver.send(trans);
->> beat_done;
if (this.trans.get_last()) begin
->> packet_done;
end
end
join_any
disable fork;
Expand Down
16 changes: 6 additions & 10 deletions testbenches/ip/util_axis_fifo_asym/environment.sv
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ package environment_pkg;
this.input_clk_vip_if.start_clock();
this.output_clk_vip_if.start_clock();

this.input_axis_agent.agent.start_master();
this.output_axis_agent.agent.start_slave();
this.input_axis_agent.start();
this.output_axis_agent.start();

this.input_axis_agent.monitor.publisher.subscribe(this.scoreboard_inst.subscriber_source);
this.output_axis_agent.monitor.publisher.subscribe(this.scoreboard_inst.subscriber_sink);
Expand All @@ -90,11 +90,8 @@ package environment_pkg;
//============================================================================
task run();
fork
this.input_axis_agent.sequencer.run();
this.output_axis_agent.sequencer.run();

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

this.scoreboard_inst.run();
join_none
Expand All @@ -104,9 +101,8 @@ package environment_pkg;
// Stop subroutine
//============================================================================
task stop();
this.input_axis_agent.sequencer.stop();
this.input_axis_agent.agent.stop_master();
this.output_axis_agent.agent.stop_slave();
this.input_axis_agent.stop();
this.output_axis_agent.stop();
endtask

endclass
Expand Down
3 changes: 1 addition & 2 deletions testbenches/ip/util_axis_fifo_asym/tests/test_program.sv
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ program test_program ();
#($urandom_range(1,10)*1us);

uaf_env.input_axis_agent.sequencer.clear_descriptor_queue();

#1us;
uaf_env.input_axis_agent.sequencer.wait_empty_descriptor_queue();

uaf_env.scoreboard_inst.wait_until_complete();

Expand Down
Loading

0 comments on commit 2693a75

Please sign in to comment.