@@ -77,10 +77,12 @@ struct img_router: sc_module
7777 // DEBUG
7878 unsigned int transaction_in_fw_path_id = 0 ;
7979 unsigned int transaction_in_bw_path_id = 0 ;
80+
81+ bool use_prints;
8082
8183 // Constructor
8284 SC_CTOR (img_router)
83- : target_socket(" socket" ), bw_m_peq(this , &img_router::bw_peq_cb), fw_m_peq(this , &img_router::fw_peq_cb), fw_fifo(10 ), bw_fifo(2 ) // Construct and name socket
85+ : target_socket(" socket" ), bw_m_peq(this , &img_router::bw_peq_cb), fw_m_peq(this , &img_router::fw_peq_cb), fw_fifo(10 ), bw_fifo(2 ), use_prints( true ) // Construct and name socket
8486 {
8587 // Register callbacks for incoming interface method calls
8688 target_socket.register_nb_transport_fw (this , &img_router::nb_transport_fw);
@@ -93,6 +95,11 @@ struct img_router: sc_module
9395
9496 SC_THREAD (fw_thread);
9597 SC_THREAD (bw_thread);
98+
99+ #ifdef DISABLE_ROUTER_DEBUG
100+ this ->use_prints = false ;
101+ #endif // DISABLE_ROUTER_DEBUG
102+ checkprintenable (use_prints);
96103 }
97104
98105 // Address Decoding
@@ -106,25 +113,25 @@ struct img_router: sc_module
106113 switch (address) {
107114 // To Filter
108115 case IMG_FILTER_KERNEL: {
109- dbgmodprint (" Decoded address %016llX corresponds to Filter module." , address);
116+ dbgmodprint (use_prints, " Decoded address %016llX corresponds to Filter module." , address);
110117 return IMG_FILTER_INITIATOR_ID;
111118 }
112119
113120 // To/from Sobel
114121 case SOBEL_INPUT_0:
115122 case SOBEL_INPUT_1:
116123 case SOBEL_OUTPUT: {
117- dbgmodprint (" Decoded address %016llX corresponds to Sobel module." , address);
124+ dbgmodprint (use_prints, " Decoded address %016llX corresponds to Sobel module." , address);
118125 return IMG_SOBEL_INITIATOR_ID;
119126 }
120127
121128 // To/From Memory Valid addresses
122129 case MEM_START ... MEM_FINISH : {
123- dbgmodprint (" Decoded address %016llX corresponds to Memory." , address);
130+ dbgmodprint (use_prints, " Decoded address %016llX corresponds to Memory." , address);
124131 return IMG_MEMORY_INITIATOR_ID;
125132 }
126133 default : {
127- dbgmodprint (" [ERROR] Decoding invalid address %016llX." , address);
134+ dbgmodprint (use_prints, " [ERROR] Decoding invalid address %016llX." , address);
128135 SC_REPORT_FATAL (" [IMG ROUTER]" , " Received address is invalid, does not match any hardware block" );
129136 return INVALID_INITIATOR_ID;
130137 }
@@ -144,12 +151,12 @@ struct img_router: sc_module
144151 item.delay = delay;
145152 trans.get_extension (img_ext);
146153 if (bw_fifo.num_free () == 0 ) {
147- dbgmodprint (" [BW_FIFO] FIFO is FULL. Waiting..." );
154+ dbgmodprint (use_prints, " [BW_FIFO] FIFO is FULL. Waiting..." );
148155 wait (bw_fifo.data_read_event ());
149156 }
150157 bw_fifo.nb_write (item);
151158 wait (bw_fifo.data_written_event ());
152- dbgmodprint (" [BW_FIFO] Pushed transaction #%0d" , img_ext->transaction_number );
159+ dbgmodprint (use_prints, " [BW_FIFO] Pushed transaction #%0d" , img_ext->transaction_number );
153160 return tlm::TLM_ACCEPTED;
154161 }
155162
@@ -166,12 +173,12 @@ struct img_router: sc_module
166173 item.delay = delay;
167174 trans.get_extension (img_ext);
168175 if (fw_fifo.num_free () == 0 ) {
169- dbgmodprint (" [FW_FIFO] FIFO is FULL. Waiting..." );
176+ dbgmodprint (use_prints, " [FW_FIFO] FIFO is FULL. Waiting..." );
170177 wait (fw_fifo.data_read_event ());
171178 }
172179 fw_fifo.nb_write (item);
173180 wait (fw_fifo.data_written_event ());
174- dbgmodprint (" [FW_FIFO] Pushed transaction #%0d" , img_ext->transaction_number );
181+ dbgmodprint (use_prints, " [FW_FIFO] Pushed transaction #%0d" , img_ext->transaction_number );
175182 return tlm::TLM_ACCEPTED;
176183 }
177184
@@ -192,7 +199,7 @@ struct img_router: sc_module
192199 phase = item.phase ;
193200 delay = item.delay ;
194201 (*trans_ptr).get_extension (img_ext);
195- dbgmodprint (" [FW_FIFO] Popped transaction #%0d" , img_ext->transaction_number );
202+ dbgmodprint (use_prints, " [FW_FIFO] Popped transaction #%0d" , img_ext->transaction_number );
196203 fw_m_peq.notify (*trans_ptr, phase, delay);
197204 wait (fw_delay);
198205 }
@@ -215,7 +222,7 @@ struct img_router: sc_module
215222 phase = item.phase ;
216223 delay = item.delay ;
217224 (*trans_ptr).get_extension (img_ext);
218- dbgmodprint (" [BW_FIFO] Popped transaction #%0d" , img_ext->transaction_number );
225+ dbgmodprint (use_prints, " [BW_FIFO] Popped transaction #%0d" , img_ext->transaction_number );
219226 bw_m_peq.notify (*trans_ptr, phase, delay);
220227 wait (bw_delay);
221228 }
@@ -231,7 +238,7 @@ struct img_router: sc_module
231238 sc_dt::uint64 address = trans.get_address ();
232239 this ->transaction_in_bw_path_id = img_ext->transaction_number ;
233240
234- dbgmodprint (" Received transaction #%0d with address %016llX in backward path. Redirecting transaction to CPU" , img_ext->transaction_number , address);
241+ dbgmodprint (use_prints, " Received transaction #%0d with address %016llX in backward path. Redirecting transaction to CPU" , img_ext->transaction_number , address);
235242 target_socket->nb_transport_bw (trans, local_phase, this ->bw_delay );
236243 }
237244
@@ -245,7 +252,7 @@ struct img_router: sc_module
245252 this ->transaction_in_fw_path_id = img_ext->transaction_number ;
246253
247254 unsigned int initiator_id = decode_address (address);
248- dbgmodprint (" Received transaction #%0d with address %016llX in forward path. Redirecting transaction through initiator %d" , img_ext->transaction_number , address, initiator_id);
255+ dbgmodprint (use_prints, " Received transaction #%0d with address %016llX in forward path. Redirecting transaction through initiator %d" , img_ext->transaction_number , address, initiator_id);
249256 (*initiator_socket[initiator_id])->nb_transport_fw (trans, local_phase, this ->fw_delay );
250257 }
251258
0 commit comments