Skip to content

Commit 00982c7

Browse files
jgavillalobosErickOF
authored andcommitted
Add RGB2GRAY module for testing with TLM
1 parent 575daf4 commit 00982c7

15 files changed

+465
-266
lines changed

modules/Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ INCDIR=-I. -I./include -I$(SYSTEMC)/include -Ibasic_protocol -I$(SYSTEMC)/includ
2222
LIBDIR=-L. -L$(SYSTEMC)/lib-linux64
2323

2424
ifdef USING_TLM_TB_EN
25-
SRCDIRS=$(SRCDIR) ../edge-detector/src
26-
INCDIR+=-I../edge-detector/include
25+
EDGE_DIR=../edge-detector
26+
GRAY_DIR=../rgb2gray
27+
28+
SRCDIRS=$(SRCDIR) $(EDGE_DIR)/src $(GRAY_DIR)/src
29+
INCDIR+=-I$(EDGE_DIR)/include -I$(GRAY_DIR)/include
2730
endif # USING_TLM_TB_EN
2831

2932
ifdef INCLUDE_OPENCV

modules/rgb2gray/include/rgb2gray_pv_model.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ SC_MODULE(Rgb2Gray)
2020

2121
void compute_gray_value();
2222

23-
char obtain_gray_value();
23+
unsigned char obtain_gray_value();
2424

2525
};
2626

modules/rgb2gray/src/rgb2gray_pv_model.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ void Rgb2Gray::compute_gray_value()
1616
this->gray_value = 0.299 * this->r + 0.587 * this->g + 0.114 * this->b;
1717
}
1818

19-
char Rgb2Gray::obtain_gray_value()
19+
unsigned char Rgb2Gray::obtain_gray_value()
2020
{
2121
compute_gray_value();
2222

modules/rgb2gray/src/tb_rgb2gray.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#ifndef USING_TLM_TB_EN
12
#define int64 systemc_int64
23
#define uint64 systemc_uint64
34
#include <systemc.h>
@@ -71,3 +72,4 @@ int sc_main(int, char*[])
7172

7273
return 0;
7374
}
75+
#endif USING_TLM_TB_EN

modules/router/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ ifdef TEST_NORMALIZE_MAGNITUDE
2020
endif # TEST_NORMALIZE_MAGNITUDE
2121

2222
# Defining preprocessor directive for using PV model
23+
ifdef RGB2GRAY_PV_EN
24+
CFLAGS += -DRGB2GRAY_PV_EN
25+
LFLAGS += -DRGB2GRAY_PV_EN
26+
endif # RGB2GRAY_PV_EN
27+
2328
ifdef EDGE_DETECTOR_PV_EN
2429
CFLAGS += -DEDGE_DETECTOR_PV_EN
2530
LFLAGS += -DEDGE_DETECTOR_PV_EN

modules/router/include/common_func.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
#define COMMON_FUNC
33

44
#define dbgprint(FORMAT, ARGS...) \
5-
printf("%s -> %0d : " FORMAT "\n", __FILE__, __LINE__, ##ARGS)
5+
printf("%s(%0d) : " FORMAT "\n", __FILE__, __LINE__, ##ARGS)
6+
7+
#define dbgmodprint(FORMAT, ARGS...) \
8+
printf("%s(%0d) [%s] : " FORMAT "\n", __FILE__, __LINE__, this->name(), ##ARGS)
9+
10+
#define dbgimgtarmodprint(FORMAT, ARGS...) \
11+
printf("%s(%0d) [%s] : " FORMAT "\n", __FILE__, __LINE__, img_target::name(), ##ARGS)
612

713
#endif // COMMON_FUNC
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#ifndef IMG_GENERIC_EXTENSION_HPP
2+
#define IMG_GENERIC_EXTENSION_HPP
3+
#include "systemc.h"
4+
using namespace sc_core;
5+
using namespace sc_dt;
6+
using namespace std;
7+
8+
#include "tlm.h"
9+
#include "tlm_utils/simple_initiator_socket.h"
10+
#include "tlm_utils/simple_target_socket.h"
11+
#include "tlm_utils/peq_with_cb_and_phase.h"
12+
13+
struct img_generic_extension : tlm::tlm_extension<img_generic_extension>
14+
{
15+
img_generic_extension() : transaction_number(0) {}
16+
17+
virtual tlm::tlm_extension_base* clone() const;
18+
19+
virtual void copy_from(tlm::tlm_extension_base const &ext);
20+
21+
unsigned int transaction_number;
22+
};
23+
24+
#endif // IMG_GENERIC_EXTENSION_HPP
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#ifndef RGB2GRAY_TLM_HPP
2+
#define RGB2GRAY_TLM_HPP
3+
#include "systemc.h"
4+
using namespace sc_core;
5+
using namespace sc_dt;
6+
using namespace std;
7+
8+
#include "tlm.h"
9+
#include "tlm_utils/simple_initiator_socket.h"
10+
#include "tlm_utils/simple_target_socket.h"
11+
#include "tlm_utils/peq_with_cb_and_phase.h"
12+
13+
#include "rgb2gray_pv_model.hpp"
14+
#include "../src/img_target.cpp"
15+
16+
//Extended Unification TLM
17+
struct rgb2gray_tlm : public Rgb2Gray, public img_target
18+
{
19+
20+
SC_CTOR(rgb2gray_tlm): Rgb2Gray(Rgb2Gray::name()), img_target(img_target::name()) {
21+
}
22+
23+
//Override do_when_transaction functions
24+
virtual void do_when_read_transaction(unsigned char*& data);
25+
virtual void do_when_write_transaction(unsigned char*& data);
26+
27+
};
28+
#endif // RGB2GRAY_TLM_HPP

modules/router/run_all.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
case $1 in
44
"save_log")
5-
make EDGE_DETECTOR_LT_EN=1 USING_TLM_TB_EN=1 all > output.log
5+
make RGB2GRAY_PV_EN=1 EDGE_DETECTOR_LT_EN=1 USING_TLM_TB_EN=1 all > output.log
6+
;;
7+
"print_all")
8+
make RGB2GRAY_PV_EN=1 EDGE_DETECTOR_LT_EN=1 USING_TLM_TB_EN=1 print-all
69
;;
710
*)
8-
make EDGE_DETECTOR_LT_EN=1 USING_TLM_TB_EN=1 all
11+
make RGB2GRAY_PV_EN=1 EDGE_DETECTOR_LT_EN=1 USING_TLM_TB_EN=1 all
912
;;
1013
esac
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#ifndef IMG_GENERIC_EXTENSION_CPP
2+
#define IMG_GENERIC_EXTENSION_CPP
3+
#include "systemc.h"
4+
using namespace sc_core;
5+
using namespace sc_dt;
6+
using namespace std;
7+
8+
#include "tlm.h"
9+
#include "tlm_utils/simple_initiator_socket.h"
10+
#include "tlm_utils/simple_target_socket.h"
11+
#include "tlm_utils/peq_with_cb_and_phase.h"
12+
13+
#include "img_generic_extension.hpp"
14+
15+
tlm::tlm_extension_base* img_generic_extension::clone() const
16+
{
17+
img_generic_extension* t = new img_generic_extension;
18+
t->transaction_number = this->transaction_number;
19+
return t;
20+
}
21+
22+
void img_generic_extension::copy_from(tlm::tlm_extension_base const &ext)
23+
{
24+
transaction_number = static_cast<img_generic_extension const &>(ext).transaction_number;
25+
}
26+
27+
#endif // IMG_GENERIC_EXTENSION_CPP

0 commit comments

Comments
 (0)