Skip to content

Commit

Permalink
Merge branch 'isa_avst_speed' into 'main'
Browse files Browse the repository at this point in the history
UVM AVST: [MAITENANCE] Add automatic speed mesurement when UVM_LOW verbosity is set

See merge request ndk/ofm!412
  • Loading branch information
jakubcabal committed Sep 3, 2024
2 parents b93bc49 + 12ee5fc commit bbbae2b
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
6 changes: 6 additions & 0 deletions comp/uvm/avst/agent.sv
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class agent_rx #(int unsigned REGIONS, int unsigned REGION_SIZE, int unsigned BL
sequencer #(REGIONS, REGION_SIZE, BLOCK_SIZE, ITEM_WIDTH, META_WIDTH) m_sequencer;
driver_rx #(REGIONS, REGION_SIZE, BLOCK_SIZE, ITEM_WIDTH, META_WIDTH) m_driver;
monitor #(REGIONS, REGION_SIZE, BLOCK_SIZE, ITEM_WIDTH, META_WIDTH) m_monitor;
statistic #(REGIONS, REGION_SIZE, BLOCK_SIZE, ITEM_WIDTH, META_WIDTH) m_stat;
config_item m_config;

// ------------------------------------------------------------------------
Expand All @@ -46,6 +47,7 @@ class agent_rx #(int unsigned REGIONS, int unsigned REGION_SIZE, int unsigned BL

// Create monitor
m_monitor = monitor #(REGIONS, REGION_SIZE, BLOCK_SIZE, ITEM_WIDTH, META_WIDTH)::type_id::create("m_monitor", this);
m_stat = statistic#(REGIONS, REGION_SIZE, BLOCK_SIZE, ITEM_WIDTH, META_WIDTH)::type_id::create("m_statistic", this);
endfunction

virtual function uvm_active_passive_enum get_is_active();
Expand Down Expand Up @@ -75,6 +77,7 @@ class agent_rx #(int unsigned REGIONS, int unsigned REGION_SIZE, int unsigned BL
// Connect monitor
m_monitor.vif = vif;
analysis_port = m_monitor.analysis_port;
analysis_port.connect(m_stat.analysis_export);
endfunction

endclass
Expand All @@ -95,6 +98,7 @@ class agent_tx #(int unsigned REGIONS, int unsigned REGION_SIZE, int unsigned BL
sequencer #(REGIONS, REGION_SIZE, BLOCK_SIZE, ITEM_WIDTH, META_WIDTH) m_sequencer;
driver_tx #(REGIONS, REGION_SIZE, BLOCK_SIZE, ITEM_WIDTH, META_WIDTH) m_driver;
monitor #(REGIONS, REGION_SIZE, BLOCK_SIZE, ITEM_WIDTH, META_WIDTH) m_monitor;
statistic #(REGIONS, REGION_SIZE, BLOCK_SIZE, ITEM_WIDTH, META_WIDTH) m_stat;
config_item m_config;

// ------------------------------------------------------------------------
Expand All @@ -121,6 +125,7 @@ class agent_tx #(int unsigned REGIONS, int unsigned REGION_SIZE, int unsigned BL

// Create monitor
m_monitor = monitor #(REGIONS, REGION_SIZE, BLOCK_SIZE, ITEM_WIDTH, META_WIDTH)::type_id::create("m_monitor", this);
m_stat = statistic#(REGIONS, REGION_SIZE, BLOCK_SIZE, ITEM_WIDTH, META_WIDTH)::type_id::create("m_statistic", this);
endfunction

virtual function uvm_active_passive_enum get_is_active();
Expand All @@ -142,6 +147,7 @@ class agent_tx #(int unsigned REGIONS, int unsigned REGION_SIZE, int unsigned BL
// Connect driver if the agent is active
m_monitor.vif = vif;
analysis_port = m_monitor.analysis_port;
analysis_port.connect(m_stat.analysis_export);

// Connect monitor
if(get_is_active() == UVM_ACTIVE) begin
Expand Down
2 changes: 2 additions & 0 deletions comp/uvm/avst/pkg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ package uvm_avst;

`include "config.sv"
`include "sequence_item.sv"

`include "statistic.sv"
`include "sequencer.sv"
`include "sequence.sv"
`include "driver.sv"
Expand Down
75 changes: 75 additions & 0 deletions comp/uvm/avst/statistic.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
//-- statistic.sv :
//-- Copyright (C) 2024 CESNET z. s. p. o.
//-- Author(s): Radek Iša <[email protected]>

//-- SPDX-License-Identifier: BSD-3-Clause


class statistic #(int unsigned REGIONS, int unsigned REGION_SIZE, int unsigned BLOCK_SIZE, int unsigned ITEM_WIDTH, int unsigned META_WIDTH) extends uvm_subscriber#(sequence_item #(REGIONS, REGION_SIZE, BLOCK_SIZE, ITEM_WIDTH, META_WIDTH));
`uvm_component_param_utils(uvm_avst::statistic#(REGIONS, REGION_SIZE, BLOCK_SIZE, ITEM_WIDTH, META_WIDTH));


// SPEED mesures
protected uvm_common::stats speed;
protected int unsigned speed_data;

function new(string name, uvm_component parent = null);
super.new(name, parent);
speed_data = 0;
speed = new();
endfunction

function void write(sequence_item #(REGIONS, REGION_SIZE, BLOCK_SIZE, ITEM_WIDTH, META_WIDTH) t);
int unsigned data_size = 0;

for (int unsigned it = 0; it < REGIONS; it++) begin
if (t.valid[it]) begin
data_size += REGION_SIZE*BLOCK_SIZE*ITEM_WIDTH;

if (t.eop[it]) begin
data_size -= t.empty[it]*ITEM_WIDTH;
end
speed_data += data_size;
end
end
endfunction

task run_phase(uvm_phase phase);
time speed_start_time;
time speed_end_time;
const int unsigned mesures = 100;
string msg;

speed_end_time = 0ns;
forever begin
time step_speed_end_time = speed_end_time;
time step_speed_start_time;

for (int unsigned it = 0; it < mesures; it++) begin
step_speed_start_time = step_speed_end_time;

#(10us);
step_speed_end_time = $time();
//if (speed_data == 0) begin
// $write("SPEED 0\n\t%s\n\t%0dns %0dns\n",this.get_full_name(), speed_start_time/1ns, speed_end_time/1ns);
//end
speed.next_val(real'(speed_data)/((step_speed_end_time-step_speed_start_time)/1ns));

speed_data = 0;
end

begin
real min, max, avg, std_dev;

speed_start_time = speed_end_time;
speed_end_time = step_speed_end_time;
speed.count(min, max, avg, std_dev);
msg = $sformatf("\n\tSpeed [%0dns:%0dns]\n\t\tAverage : %0.2fGb/s std_dev %0.2fGb/s\n\t\tmin : %0.2fGb/s max %0.2fGb/s",
speed_start_time/1ns, speed_end_time/1ns, avg, std_dev, min, max);
`uvm_info(this.get_full_name(), msg, UVM_LOW);
speed.reset();
end
end
endtask
endclass

0 comments on commit bbbae2b

Please sign in to comment.