Skip to content

Commit

Permalink
Merge branch 'isa_mvb_meter' into 'devel'
Browse files Browse the repository at this point in the history
Isa mvb meter

See merge request ndk/ndk-fpga!145
  • Loading branch information
radek-isa committed Feb 5, 2025
2 parents ba2d59a + c39b789 commit bf427ad
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 1 deletion.
97 changes: 97 additions & 0 deletions comp/mvb_tools/ver/mvb_speed.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* mvb_speed.sv : Speed meter of Multi-Value bus
* Author(s): Radek Iša <[email protected]>
* Copyright (C) 2025 CESNET z. s. p. o.
* SPDX-License-Identifier: BSD-3-Clause
*/


class mvb_speed_data;
int unsigned data;

function new ();
this.reset();
endfunction

function int unsigned data_get();
return data;
endfunction

function void reset();
data = 0;
endfunction

function void add();
data += 1;
endfunction
endclass

class mvb_speed_cbs_rx #(ITEM_WIDTH) extends sv_common_pkg::DriverCbs;

mvb_speed_data data;

function new (mvb_speed_data data);
this.data = data;
endfunction

virtual task post_tx(sv_common_pkg::Transaction transaction, string inst);
MvbTransaction #(ITEM_WIDTH) tr;
$cast(tr, transaction);

data.add();
endtask
endclass

class mvb_speed_cbs_tx #(ITEM_WIDTH) extends sv_common_pkg::MonitorCbs;

mvb_speed_data data;

function new (mvb_speed_data data);
this.data = data;
endfunction

virtual task post_rx(sv_common_pkg::Transaction transaction, string inst);
MvbTransaction #(ITEM_WIDTH) tr;
$cast(tr, transaction);

data.add();
endtask
endclass

class mvb_speed #(type T_CBS);

string inst;
bit enabled;
mvb_speed_data data;
real speed = 0;
T_CBS cbs;
time delay = 10000ns;

function new(string inst = "");
data = new();
cbs = new(data);
this.inst = inst;
endfunction

virtual task setEnabled();
enabled = 1;
fork
this.run();
join_none;
endtask

virtual task setDisabled();
enabled = 0;
endtask

virtual task run();
const int unsigned const_tns_to_mts = (1s/1ns)/1_000_000; //Transactions per ns to M transactions per second
while(enabled) begin
#(delay);

speed = real'(data.data_get())*const_tns_to_mts/(delay/1ns);
$write("%s speed %4.2f Mts (Mega transaction per seconds)\n", inst, speed);
data.reset();
end
endtask
endclass
1 change: 1 addition & 0 deletions comp/mvb_tools/ver/sv_mvb_pkg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ package sv_mvb_pkg;
`include "mvb_responder.sv"
`include "mvb_driver.sv"
`include "mvb_coverage.sv"
`include "mvb_speed.sv"

endpackage
2 changes: 1 addition & 1 deletion comp/ver/pcie/ram.sv
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class ram #(ADDR_WIDTH, MPS, MRRS) extends sv_common_pkg::Driver;
end
endtask

function data_display(string dir, byte unsigned data[], logic [ADDR_WIDTH-1:0] addr, int unsigned tag);
function void data_display(string dir, byte unsigned data[], logic [ADDR_WIDTH-1:0] addr, int unsigned tag);
$timeformat(-9, 3, " ns", 8);
$write("Time: %t: ", $time);
$write("PCIe %s %s : %6d B <= %x (tag %x)\n", inst, dir, data.size(), addr, tag);
Expand Down

0 comments on commit bf427ad

Please sign in to comment.