Skip to content

Commit 094537e

Browse files
authored
Merge pull request #24 from ErickOF/feature-tlm_router
Adding feature TLM router
2 parents 331ad1b + 5bd3fd0 commit 094537e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+4031
-153
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,4 +231,6 @@ tools/datagen/src/imgs/*_sobel_*
231231

232232
# Ignore VCD files
233233
*.vcd
234-
test
234+
test
235+
*.zst
236+
.vscode

modules/Makefile

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ TARGET?=test
33

44
# Compiler
55
CC=g++
6-
CFLAGS=-Wall -I. -O3 -g -Wextra -Wunused-function
6+
CFLAGS=-Wall -Wextra -fsanitize=address -fsanitize=undefined -I. -O3 -g
77

88
ifdef USE_CPP17
99
CFLAGS+=-std=c++17
10-
endif
10+
endif # USE_CPP17
1111

1212
# Target
1313
LD=g++
14-
LFLAGS=-Wall -I. -lm -g
14+
LFLAGS=-Wall -fsanitize=address -fsanitize=undefined -I. -lm -g
1515
LIBS=-lsystemc -lm
1616

1717
# Source directories
@@ -21,6 +21,17 @@ BINDIR=./
2121
INCDIR=-I. -I./include -I$(SYSTEMC)/include -Ibasic_protocol -I$(SYSTEMC)/include/tlm_core/tlm_2
2222
LIBDIR=-L. -L$(SYSTEMC)/lib-linux64
2323

24+
ifdef USING_TLM_TB_EN
25+
EDGE_DIR=../edge-detector
26+
GRAY_DIR=../rgb2gray
27+
FILTER_DIR=../filter
28+
UNIFICATION_DIR=../unification
29+
COMPRESSION_DIR=../compression
30+
31+
SRCDIRS=$(SRCDIR) $(EDGE_DIR)/src $(GRAY_DIR)/src $(FILTER_DIR)/src $(UNIFICATION_DIR)/src $(COMPRESSION_DIR)/src
32+
INCDIR+=-I$(EDGE_DIR)/include -I$(GRAY_DIR)/include -I$(FILTER_DIR)/include -I$(UNIFICATION_DIR)/include -I$(COMPRESSION_DIR)/include
33+
endif # USING_TLM_TB_EN
34+
2435
ifdef INCLUDE_OPENCV
2536
# Target
2637
LIBS+=-lopencv_imgcodecs -lopencv_core -lopencv_highgui -lopencv_imgproc
@@ -35,15 +46,38 @@ LFLAGS += $(shell pkg-config --libs opencv4)
3546
endif # INCLUDE_OPENCV_PKG
3647
endif # INCLUDE_OPENCV
3748

49+
ifndef USING_TLM_TB_EN
3850
SOURCES := $(wildcard $(SRCDIR)/*.cpp)
3951
INCLUDES := $(wildcard $(INCDIR)/*.hpp)
4052
OBJECTS := $(SOURCES:$(SRCDIR)/%.cpp=$(OBJDIR)/%.o)
53+
else
54+
SOURCES = $(wildcard *.cpp) $(foreach DIR, $(SRCDIRS), $(wildcard $(DIR)/*.cpp))
55+
SOURCES_WITHOUT_PATH = $(notdir $(SOURCES))
56+
INCLUDES := $(wildcard $(INCDIR)/*.hpp)
57+
OBJECTS = $(SOURCES_WITHOUT_PATH:%.cpp=$(OBJDIR)/%.o)
58+
59+
VPATH = $(sort $(dir $(SOURCES)))
60+
endif # USING_TLM_TB_EN
4161

4262
$(BINDIR)/$(TARGET): clean $(OBJECTS)
4363
@$(LD) $(OBJECTS) $(LFLAGS) $(LIBS) $(LIBDIR) -o $@
4464

65+
ifndef USING_TLM_TB_EN
4566
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.cpp
4667
@$(CC) $(CFLAGS) $(INCDIR) -c $< -o $@
68+
else
69+
$(OBJECTS): $(OBJDIR)/%.o : %.cpp
70+
@$(CC) $(CFLAGS) $(INCDIR) -c $< -o $@
71+
endif # USING_TLM_TB_EN
72+
73+
valgrind:
74+
valgrind --leak-check=full -s ./$(TARGET)
75+
76+
drmemory:
77+
drmemory -- ./$(TARGET)
78+
79+
heaptrack:
80+
heaptrack ./$(TARGET)
4781

4882
.PHONY: clean
4983
clean:

modules/communication/Makefile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Include common Makefile
2+
include ../Makefile
3+
4+
# Defining preprocessor directive for debug
5+
ifdef IPS_DEBUG_EN
6+
CFLAGS += -DIPS_DEBUG_EN
7+
LFLAGS += -DIPS_DEBUG_EN
8+
endif # IPS_DEBUG_EN
9+
10+
# Defining preprocessor directive for dumping enable
11+
ifdef IPS_DUMP_EN
12+
CFLAGS += -DIPS_DUMP_EN
13+
LFLAGS += -DIPS_DUMP_EN
14+
endif # IPS_DUMP_EN
15+
16+
# Defining preprocessor directive for normalizing the resulting magnitude
17+
ifdef TEST_NORMALIZE_MAGNITUDE
18+
CFLAGS += -DTEST_NORMALIZE_MAGNITUDE
19+
LFLAGS += -DTEST_NORMALIZE_MAGNITUDE
20+
endif # TEST_NORMALIZE_MAGNITUDE
21+
22+
# Defining preprocessor directive for using PV model
23+
ifdef EDGE_DETECTOR_PV_EN
24+
CFLAGS += -DEDGE_DETECTOR_PV_EN
25+
LFLAGS += -DEDGE_DETECTOR_PV_EN
26+
endif # EDGE_DETECTOR_PV_EN
27+
28+
# Defining preprocessor directive for using PV model
29+
ifdef EDGE_DETECTOR_LT_EN
30+
CFLAGS += -DEDGE_DETECTOR_LT_EN
31+
LFLAGS += -DEDGE_DETECTOR_LT_EN
32+
endif # EDGE_DETECTOR_LT_EN
33+
34+
# Defining preprocessor directive for using PV model
35+
ifdef EDGE_DETECTOR_AT_EN
36+
CFLAGS += -DEDGE_DETECTOR_AT_EN
37+
LFLAGS += -DEDGE_DETECTOR_AT_EN
38+
endif # EDGE_DETECTOR_AT_EN
39+
40+
# Run the compiled file
41+
run:
42+
@./test
43+
44+
# Show waveform
45+
waveform:
46+
@gtkwave edge_detector.vcd
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#ifdef EDGE_DETECTOR_LT_EN
2+
#ifndef SOBEL_EDGE_DETECTOR_HPP
3+
#define SOBEL_EDGE_DETECTOR_HPP
4+
5+
#include <systemc.h>
6+
7+
SC_MODULE(Edge_Detector)
8+
{
9+
10+
int localWindow[3][3];
11+
12+
const int sobelGradientX[3][3] = {{-1, 0, 1},
13+
{-2, 0, 2},
14+
{-1, 0, 1}};
15+
const int sobelGradientY[3][3] = {{-1, -2, -1},
16+
{ 0, 0, 0},
17+
{ 1, 2, 1}};
18+
19+
int resultSobelGradientX;
20+
int resultSobelGradientY;
21+
22+
sc_event gotLocalWindow, finishedSobelGradientX, finishedSobelGradientY;
23+
24+
SC_CTOR(Edge_Detector)
25+
{
26+
SC_THREAD(compute_sobel_gradient_x);
27+
SC_THREAD(compute_sobel_gradient_y);
28+
}
29+
30+
void set_local_window(int window[3][3]);
31+
32+
void compute_sobel_gradient_x();
33+
34+
void compute_sobel_gradient_y();
35+
36+
int obtain_sobel_gradient_x();
37+
38+
int obtain_sobel_gradient_y();
39+
40+
};
41+
42+
#endif // SOBEL_EDGE_DETECTOR_HPP
43+
#endif // EDGE_DETECTOR_LT_EN
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#ifndef SOBEL_EDGE_DETECTOR_TLM_HPP
2+
#define SOBEL_EDGE_DETECTOR_TLM_HPP
3+
#include <systemc.h>
4+
5+
using namespace sc_core;
6+
using namespace sc_dt;
7+
using namespace std;
8+
9+
#include <tlm.h>
10+
#include <tlm_utils/simple_initiator_socket.h>
11+
#include <tlm_utils/simple_target_socket.h>
12+
#include <tlm_utils/peq_with_cb_and_phase.h>
13+
14+
#include "sobel_edge_detector_lt_model.hpp"
15+
#include "img_target.hpp"
16+
17+
//Extended Unification TLM
18+
struct sobel_edge_detector_tlm : public Edge_Detector, public img_target
19+
{
20+
SC_CTOR(sobel_edge_detector_tlm): Edge_Detector(Edge_Detector::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 // SOBEL_EDGE_DETECTOR_TLM_HPP

0 commit comments

Comments
 (0)