Skip to content

Commit 1dc8a7e

Browse files
committed
Add compilation option to avoid using prints
1 parent d993d5d commit 1dc8a7e

13 files changed

+181
-91
lines changed

modules/router/Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,36 @@ ifdef IPS_JPG_PV_EN
6767
LFLAGS += -DIPS_JPG_PV_EN
6868
endif # IPS_JPG_PV_EN
6969

70+
ifdef DISABLE_ROUTER_DEBUG
71+
CFLAGS += -DDISABLE_ROUTER_DEBUG
72+
LFLAGS += -DDISABLE_ROUTER_DEBUG
73+
endif # DISABLE_ROUTER_DEBUG
74+
75+
ifdef DISABLE_FILTER_DEBUG
76+
CFLAGS += -DDISABLE_FILTER_DEBUG
77+
LFLAGS += -DDISABLE_FILTER_DEBUG
78+
endif # DISABLE_FILTER_DEBUG
79+
80+
ifdef DISABLE_MEM_DEBUG
81+
CFLAGS += -DDISABLE_MEM_DEBUG
82+
LFLAGS += -DDISABLE_MEM_DEBUG
83+
endif # DISABLE_MEM_DEBUG
84+
85+
ifdef DISABLE_RGB_DEBUG
86+
CFLAGS += -DDISABLE_RGB_DEBUG
87+
LFLAGS += -DDISABLE_RGB_DEBUG
88+
endif # DISABLE_RGB_DEBUG
89+
90+
ifdef DISABLE_SOBEL_DEBUG
91+
CFLAGS += -DDISABLE_SOBEL_DEBUG
92+
LFLAGS += -DDISABLE_SOBEL_DEBUG
93+
endif # DISABLE_SOBEL_DEBUG
94+
95+
ifdef DISABLE_TB_DEBUG
96+
CFLAGS += -DDISABLE_TB_DEBUG
97+
LFLAGS += -DDISABLE_TB_DEBUG
98+
endif # DISABLE_TB_DEBUG
99+
70100
.PHONY: print-all
71101
print-all:
72102
@echo "Incdir is $(INCDIR)"

modules/router/include/common_func.hpp

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,32 @@
22
#define COMMON_FUNC_HPP
33

44
#define dbgprint(FORMAT, ARGS...) \
5-
printf("%s(%0d) @%s: " FORMAT "\n", __FILE__, __LINE__, sc_time_stamp().to_string().c_str(), ##ARGS)
5+
printf("%s(%0d) @%s: " FORMAT "\n", __FILE__, __LINE__, sc_time_stamp().to_string().c_str(), ##ARGS);
66

7-
#define dbgmodprint(FORMAT, ARGS...) \
8-
printf("%s(%0d) [%s] @%s : " FORMAT "\n", __FILE__, __LINE__, this->name(), sc_time_stamp().to_string().c_str(), ##ARGS)
7+
#define dbgmodprint(DBG_ACT, FORMAT, ARGS...) \
8+
if (DBG_ACT) printf("%s(%0d) [%s] @%s : " FORMAT "\n", __FILE__, __LINE__, this->name(), sc_time_stamp().to_string().c_str(), ##ARGS)
99

10-
#define dbgimgtarmodprint(FORMAT, ARGS...) \
11-
printf("%s(%0d) [%s] @%s : " FORMAT "\n", __FILE__, __LINE__, img_target::name(), sc_time_stamp().to_string().c_str(), ##ARGS)
10+
#define dbgimgtarmodprint(DBG_ACT, FORMAT, ARGS...) \
11+
if (DBG_ACT) printf("%s(%0d) [%s] @%s : " FORMAT "\n", __FILE__, __LINE__, img_target::name(), sc_time_stamp().to_string().c_str(), ##ARGS)
12+
13+
#define checkprintenable(DBG_ACT) \
14+
if (DBG_ACT) \
15+
{ \
16+
printf("%s(%0d) [%s] @%s : " "Prints enabled for this module" "\n", __FILE__, __LINE__, this->name(), sc_time_stamp().to_string().c_str()); \
17+
} \
18+
else \
19+
{ \
20+
printf("%s(%0d) [%s] @%s : " "Prints are not enabled for this module" "\n", __FILE__, __LINE__, this->name(), sc_time_stamp().to_string().c_str()); \
21+
}
22+
23+
#define checkprintenableimgtar(DBG_ACT) \
24+
if (DBG_ACT) \
25+
{ \
26+
printf("%s(%0d) [%s] @%s : " "Prints enabled for this module" "\n", __FILE__, __LINE__, img_target::name(), sc_time_stamp().to_string().c_str()); \
27+
} \
28+
else \
29+
{ \
30+
printf("%s(%0d) [%s] @%s : " "Prints are not enabled for this module" "\n", __FILE__, __LINE__, img_target::name(), sc_time_stamp().to_string().c_str()); \
31+
}
1232

1333
#endif // COMMON_FUNC_HPP

modules/router/include/ips_filter_tlm.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ struct ips_filter_tlm : public Filter<IPS_IN_TYPE_TB, IPS_OUT_TYPE_TB, IPS_FILTE
2020
{
2121

2222
ips_filter_tlm(sc_module_name name) : Filter<IPS_IN_TYPE_TB, IPS_OUT_TYPE_TB, IPS_FILTER_KERNEL_SIZE>((std::string(name) + "_HW_block").c_str()), img_target((std::string(name) + "_target").c_str()) {
23+
#ifdef DISABLE_FILTER_DEBUG
24+
this->use_prints = false;
25+
#endif //DISABLE_FILTER_DEBUG
26+
checkprintenableimgtar(use_prints);
2327
}
2428

2529
//Override do_when_transaction functions

modules/router/include/memory_tlm.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ struct memory_tlm : public img_target
1818

1919
memory_tlm(sc_module_name name) : img_target((std::string(name) + "_target").c_str()) {
2020
mem_array = new unsigned char[2764852];
21+
#ifdef DISABLE_MEM_DEBUG
22+
this->use_prints = false;
23+
#endif //DISABLE_MEM_DEBUG
24+
checkprintenableimgtar(use_prints);
2125
}
2226

2327
//Override do_when_transaction functions

modules/router/include/rgb2gray_tlm.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ struct rgb2gray_tlm : public Rgb2Gray, public img_target
1818
{
1919

2020
rgb2gray_tlm(sc_module_name name) : Rgb2Gray((std::string(name) + "_HW_block").c_str()), img_target((std::string(name) + "_target").c_str()) {
21+
#ifdef DISABLE_RGB_DEBUG
22+
this->use_prints = false;
23+
#endif //DISABLE_RGB_DEBUG
24+
checkprintenableimgtar(use_prints);
2125
}
2226

2327
//Override do_when_transaction functions

modules/router/include/sobel_edge_detector_tlm.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ struct sobel_edge_detector_tlm : public Edge_Detector, public img_target
1818
{
1919

2020
sobel_edge_detector_tlm(sc_module_name name) : Edge_Detector((std::string(name) + "_HW_block").c_str()), img_target((std::string(name) + "_target").c_str()) {
21+
#ifdef DISABLE_SOBEL_DEBUG
22+
this->use_prints = false;
23+
#endif //DISABLE_SOBEL_DEBUG
24+
checkprintenableimgtar(use_prints);
2125
}
2226

2327
//Override do_when_transaction functions

modules/router/run_all.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ case $1 in
44
"save_log")
55
make INCLUDE_OPENCV_PKG=1 RGB2GRAY_PV_EN=1 IPS_FILTER_LT_EN=1 EDGE_DETECTOR_AT_EN=1 IMG_UNIFICATE_PV_EN=1 IPS_JPG_PV_EN=1 USING_TLM_TB_EN=1 all > output.log
66
;;
7+
"save_log_no_dbg")
8+
make INCLUDE_OPENCV_PKG=1 RGB2GRAY_PV_EN=1 IPS_FILTER_LT_EN=1 EDGE_DETECTOR_AT_EN=1 IMG_UNIFICATE_PV_EN=1 IPS_JPG_PV_EN=1 USING_TLM_TB_EN=1 DISABLE_ROUTER_DEBUG=1 DISABLE_FILTER_DEBUG=1 DISABLE_MEM_DEBUG=1 DISABLE_RGB_DEBUG=1 DISABLE_SOBEL_DEBUG=1 DISABLE_TB_DEBUG=1 all > output.log
9+
;;
710
"print_all")
811
make INCLUDE_OPENCV_PKG=1 RGB2GRAY_PV_EN=1 IPS_FILTER_LT_EN=1 EDGE_DETECTOR_AT_EN=1 IMG_UNIFICATE_PV_EN=1 IPS_JPG_PV_EN=1 USING_TLM_TB_EN=1 print-all
912
;;

modules/router/src/img_initiator.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,12 @@ struct img_initiator: sc_module
4747
// DEBUG
4848
unsigned int transaction_sent_id = 0;
4949
unsigned int transaction_received_id = 0;
50+
51+
bool use_prints;
5052

5153
//Constructor
5254
SC_CTOR(img_initiator)
53-
: socket("socket"), m_peq(this, &img_initiator::peq_cb) // Construct and name socket
55+
: socket("socket"), m_peq(this, &img_initiator::peq_cb), use_prints(true) // Construct and name socket
5456
{
5557
// Register callbacks for incoming interface method calls
5658
socket.register_nb_transport_bw(this, &img_initiator::nb_transport_bw);

modules/router/src/img_router.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

modules/router/src/img_target.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ struct img_target: sc_module
4242
//DEBUG
4343
unsigned int transaction_in_progress_id = 0;
4444

45+
bool use_prints;
46+
4547
//Constructor
4648
SC_CTOR(img_target)
47-
: socket("socket"), response_transaction(0), m_peq(this, &img_target::peq_cb) // Construct and name socket
49+
: socket("socket"), response_transaction(0), m_peq(this, &img_target::peq_cb), use_prints(true) // Construct and name socket
4850
{
4951
// Register callbacks for incoming interface method calls
5052
socket.register_nb_transport_fw(this, &img_target::nb_transport_fw);

0 commit comments

Comments
 (0)