@@ -85,17 +85,10 @@ package x_monitor_pkg;
8585 virtual task get_transaction ();
8686 endtask
8787
88- endclass
88+ endclass : x_monitor
8989
9090
91- typedef enum bit {
92- READ_OP = 1'b0 ,
93- WRITE_OP = 1'b1
94- } operation_type_t ;
95-
96- class x_axi_monitor # ( type T , operation_type_t operation_type ) extends x_monitor ;
97- // operation type: 1 - write
98- // 0 - read
91+ class x_axi_monitor # ( type T , xil_axi_cmd_t operation_type ) extends x_monitor ;
9992
10093 // analysis port from the monitor
10194 protected xil_analysis_port # (axi_monitor_transaction) axi_ap;
@@ -124,38 +117,45 @@ package x_monitor_pkg;
124117 xil_axi_strb_beat strb_beat;
125118 int transaction_length;
126119 int num_bytes;
127- logic [ 7 : 0 ] axi_byte ;
120+ int valid_bytes ;
128121 logic [7 : 0 ] axi_packet [];
129122
130123 forever begin
131124 this .get_key ();
132125 this .axi_ap.get (transaction);
133- if (bit '( transaction.get_cmd_type () ) == operation_type) begin
126+ if (transaction.get_cmd_type () == operation_type) begin
134127 this .put_key ();
135128 num_bytes = transaction.get_data_width ()/ 8 ;
136129 transaction_length = transaction.get_len ()+ 1 ;
137- axi_packet = new [transaction_length * num_bytes];
130+
138131 for (int i= 0 ; i< transaction_length; i++ ) begin
139132 data_beat = transaction.get_data_beat (i);
140133 strb_beat = transaction.get_strb_beat (i);
141- for (int j= 0 ; j< num_bytes; j++ ) begin
142- axi_byte = data_beat[j* 8 + : 8 ];
143- if (operation_type == READ_OP )
144- axi_packet[i* num_bytes+ j] = axi_byte;
145- else if (strb_beat[j] || ! this .agent.vif_proxy.C_AXI_HAS_WSTRB )
146- axi_packet[i* num_bytes+ j] = axi_byte;
147- end
134+
135+ valid_bytes = 0 ;
136+ if (this .agent.vif_proxy.C_AXI_HAS_WSTRB && transaction.get_cmd_type () == XIL_AXI_WRITE ) begin
137+ for (int j= 0 ; j< num_bytes; j++ )
138+ if (strb_beat[j])
139+ valid_bytes++ ;
140+ end else
141+ valid_bytes = num_bytes;
142+ axi_packet = new [axi_packet.size ()+ valid_bytes] (axi_packet);
143+
144+ for (int j= 0 ; j< valid_bytes; j++ )
145+ axi_packet[axi_packet.size ()- valid_bytes+ j] = data_beat[j* 8 + : 8 ];
148146 end
147+
149148 if (this .filter_enabled)
150149 this .filter_tree.apply_filter (axi_packet);
150+
151151 if (! this .filter_enabled || this .filter_tree.result) begin
152152 for (int i= 0 ; i< transaction_length* num_bytes; i++ )
153153 this .mailbox.put (axi_packet[i]);
154154 this .transaction_captured ();
155155 # 1step;
156156 this .mailbox.flush ();
157157 end else
158- `INFOV ((" Packet filtered" ), 100 );
158+ `INFOV ((" Packet filtered out " ), 100 );
159159 end else begin
160160 this .axi_ap.write (transaction);
161161 this .put_key ();
@@ -194,7 +194,7 @@ package x_monitor_pkg;
194194 xil_axi4stream_data_beat data_beat;
195195 xil_axi4stream_strb_beat keep_beat;
196196 int num_bytes;
197- logic [ 7 : 0 ] axi_byte ;
197+ int valid_bytes ;
198198 logic [7 : 0 ] axi_packet [];
199199
200200 if (this .filter_enabled && ! this .agent.vif_proxy.C_XIL_AXI4STREAM_SIGNAL_SET [XIL_AXI4STREAM_SIGSET_POS_LAST ])
@@ -206,23 +206,32 @@ package x_monitor_pkg;
206206 num_bytes = transaction.get_data_width ()/ 8 ;
207207 data_beat = transaction.get_data_beat ();
208208 keep_beat = transaction.get_keep_beat ();
209- axi_packet = new [axi_packet.size ()+ num_bytes] (axi_packet);
210- for (int i= 0 ; i< num_bytes; i++ ) begin
211- axi_byte = data_beat[i* 8 + : 8 ];
212- if (keep_beat[i+ : 1 ] || ! this .agent.vif_proxy.C_XIL_AXI4STREAM_SIGNAL_SET [XIL_AXI4STREAM_SIGSET_POS_KEEP ])
213- axi_packet[axi_packet.size ()- num_bytes+ i] = axi_byte;
214- end
209+
210+ valid_bytes = 0 ;
211+ if (this .agent.vif_proxy.C_XIL_AXI4STREAM_SIGNAL_SET [XIL_AXI4STREAM_SIGSET_POS_KEEP ]) begin
212+ for (int i= 0 ; i< num_bytes; i++ )
213+ if (keep_beat[i])
214+ valid_bytes++ ;
215+ end else
216+ valid_bytes = num_bytes;
217+ axi_packet = new [axi_packet.size ()+ valid_bytes] (axi_packet);
218+
219+ for (int i= 0 ; i< valid_bytes; i++ )
220+ axi_packet[axi_packet.size ()- valid_bytes+ i] = data_beat[i* 8 + : 8 ];
221+
215222 if (this .filter_enabled && transaction.get_last ())
216223 this .filter_tree.apply_filter (axi_packet);
217- if (transaction.get_last () && (! this .filter_enabled || this .filter_tree.result)) begin
218- for (int i= 0 ; i< axi_packet.size (); i++ )
219- this .mailbox.put (axi_packet[i]);
220- axi_packet = new [0 ];
221- this .transaction_captured ();
222- # 1step;
223- this .mailbox.flush ();
224- end else
225- `INFOV ((" Packet filtered" ), 100 );
224+
225+ if (transaction.get_last ())
226+ if ((! this .filter_enabled || this .filter_tree.result)) begin
227+ for (int i= 0 ; i< axi_packet.size (); i++ )
228+ this .mailbox.put (axi_packet[i]);
229+ axi_packet = new [0 ];
230+ this .transaction_captured ();
231+ # 1step;
232+ this .mailbox.flush ();
233+ end else
234+ `INFOV ((" Packet filtered out" ), 100 );
226235 end
227236
228237 endtask : get_transaction
0 commit comments