File tree Expand file tree Collapse file tree 2 files changed +98
-0
lines changed Expand file tree Collapse file tree 2 files changed +98
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * mvb_speed.sv : Speed meter of Multi-Value bus
3
+ * Author(s): Radek Iša <[email protected] >
4
+ * Copyright (C) 2025 CESNET z. s. p. o.
5
+ * SPDX-License-Identifier: BSD-3-Clause
6
+ */
7
+
8
+
9
+ class mvb_speed_data ;
10
+ int unsigned data;
11
+
12
+ function new ();
13
+ this .reset ();
14
+ endfunction
15
+
16
+ function int unsigned data_get ();
17
+ return data;
18
+ endfunction
19
+
20
+ function void reset ();
21
+ data = 0 ;
22
+ endfunction
23
+
24
+ function void add ();
25
+ data + = 1 ;
26
+ endfunction
27
+ endclass
28
+
29
+ class mvb_speed_cbs_rx # (ITEM_WIDTH ) extends sv_common_pkg :: DriverCbs;
30
+
31
+ mvb_speed_data data;
32
+
33
+ function new (mvb_speed_data data);
34
+ this .data = data;
35
+ endfunction
36
+
37
+ virtual task post_tx (sv_common_pkg :: Transaction transaction, string inst);
38
+ MvbTransaction # (ITEM_WIDTH ) tr;
39
+ $cast (tr, transaction);
40
+
41
+ data.add ();
42
+ endtask
43
+ endclass
44
+
45
+ class mvb_speed_cbs_tx # (ITEM_WIDTH ) extends sv_common_pkg :: MonitorCbs;
46
+
47
+ mvb_speed_data data;
48
+
49
+ function new (mvb_speed_data data);
50
+ this .data = data;
51
+ endfunction
52
+
53
+ virtual task post_rx (sv_common_pkg :: Transaction transaction, string inst);
54
+ MvbTransaction # (ITEM_WIDTH ) tr;
55
+ $cast (tr, transaction);
56
+
57
+ data.add ();
58
+ endtask
59
+ endclass
60
+
61
+ class mvb_speed # (type T_CBS );
62
+
63
+ string inst;
64
+ bit enabled;
65
+ mvb_speed_data data;
66
+ real speed = 0 ;
67
+ T_CBS cbs;
68
+ time delay = 10000ns ;
69
+
70
+ function new (string inst = " " );
71
+ data = new ();
72
+ cbs = new (data);
73
+ this .inst = inst;
74
+ endfunction
75
+
76
+ virtual task setEnabled ();
77
+ enabled = 1 ;
78
+ fork
79
+ this .run ();
80
+ join_none ;
81
+ endtask
82
+
83
+ virtual task setDisabled ();
84
+ enabled = 0 ;
85
+ endtask
86
+
87
+ virtual task run ();
88
+ const int unsigned const_tns_to_mts = (1s / 1ns )/ 1_000_000 ; // Transactions per ns to M transactions per second
89
+ while (enabled) begin
90
+ # (delay);
91
+
92
+ speed = real '(data.data_get ())* const_tns_to_mts/ (delay/ 1ns );
93
+ $write (" %s speed %4.2f Mts (Mega transaction per seconds)\n " , inst, speed);
94
+ data.reset ();
95
+ end
96
+ endtask
97
+ endclass
Original file line number Diff line number Diff line change @@ -27,5 +27,6 @@ package sv_mvb_pkg;
27
27
`include " mvb_responder.sv"
28
28
`include " mvb_driver.sv"
29
29
`include " mvb_coverage.sv"
30
+ `include " mvb_speed.sv"
30
31
31
32
endpackage
You can’t perform that action at this time.
0 commit comments