Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding feature TLM router #24

Merged
merged 37 commits into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
92b18fd
Fix/Generalize Initiator
RMorales25 Jul 7, 2024
ed3b320
Fix/Generalize Target
RMorales25 Jul 8, 2024
1036999
Add makefile and other needed files
RMorales25 Jul 8, 2024
1f37f25
Fix compilation issue with missing file
jgavillalobos Jul 9, 2024
a4c31a9
Copy work from communication module
jgavillalobos Jul 9, 2024
c9d2c1b
Delete unrequired files
jgavillalobos Jul 9, 2024
8a8db0e
Change folder for newer version of systemc
jgavillalobos Jul 9, 2024
7100a18
Update Makefile to use other folders for the reused blocks
jgavillalobos Jul 9, 2024
0ae2449
Add new dbgprint function to show file and line from which a print is…
jgavillalobos Jul 9, 2024
575daf4
Add bash script to make easier runs
jgavillalobos Jul 9, 2024
00982c7
Add RGB2GRAY module for testing with TLM
jgavillalobos Jul 11, 2024
a7013da
Use AT model of edge_detector instead of LT
jgavillalobos Jul 11, 2024
4090bfa
Fix wrong values being writen in the jpg files
jgavillalobos Jul 11, 2024
54e27de
Fix bad values assigning to resulting image
jgavillalobos Jul 11, 2024
b561085
Change how the delays of initiator and target are used
jgavillalobos Jul 11, 2024
7df8821
Use normal access to RGB2GRAY module instead of TLM
jgavillalobos Jul 12, 2024
ffc5b74
Include memory for storing the data using TLM transactions
jgavillalobos Jul 12, 2024
ddf95ad
Remove unrequired local references
jgavillalobos Jul 12, 2024
8ca3cf7
Add Filter block to TLM TB
jgavillalobos Jul 13, 2024
82877d0
Add sanity check to ensure that the image is being written as expecte…
jgavillalobos Jul 14, 2024
89a7490
Add unification module to the chain of transactions
jgavillalobos Jul 14, 2024
60b0970
Add img_router and testbench
RMorales25 Jul 14, 2024
da9d700
Fix target to respond using a thread method
RMorales25 Jul 14, 2024
a95d859
Clean and fix initiator to not wait for write responses
RMorales25 Jul 14, 2024
12623bb
clean Here prints
RMorales25 Jul 14, 2024
5c2dbc0
makefile and run_all for router tb
RMorales25 Jul 14, 2024
ebd6ed1
Add compression block to TLM TB
jgavillalobos Jul 14, 2024
8a315e7
Add router to global tb
RMorales25 Jul 14, 2024
af1afba
Add transaction ID tracking
RMorales25 Jul 14, 2024
2607c75
Add transaction ID tracking
RMorales25 Jul 14, 2024
fc430d9
fixes after rebase
RMorales25 Jul 14, 2024
ca4e985
Use RGB noisy image in TB
jgavillalobos Jul 15, 2024
93d2794
Fixing includes + h to hpp + split src from headers
ErickOF Jul 20, 2024
6be6b6e
Fixing python code
ErickOF Jul 21, 2024
46cfcf2
Adding missing name of endif
ErickOF Jul 21, 2024
3bbbff8
Fixing inestability issues in router code
ErickOF Jul 21, 2024
5bd3fd0
Adding memory leakage test commands
ErickOF Jul 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,6 @@ tools/datagen/src/imgs/*_sobel_*

# Ignore VCD files
*.vcd
test
test
*.zst
.vscode
40 changes: 37 additions & 3 deletions modules/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ TARGET?=test

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

ifdef USE_CPP17
CFLAGS+=-std=c++17
endif
endif # USE_CPP17

# Target
LD=g++
LFLAGS=-Wall -I. -lm -g
LFLAGS=-Wall -fsanitize=address -fsanitize=undefined -I. -lm -g
LIBS=-lsystemc -lm

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

ifdef USING_TLM_TB_EN
ErickOF marked this conversation as resolved.
Show resolved Hide resolved
EDGE_DIR=../edge-detector
GRAY_DIR=../rgb2gray
FILTER_DIR=../filter
UNIFICATION_DIR=../unification
COMPRESSION_DIR=../compression

SRCDIRS=$(SRCDIR) $(EDGE_DIR)/src $(GRAY_DIR)/src $(FILTER_DIR)/src $(UNIFICATION_DIR)/src $(COMPRESSION_DIR)/src
INCDIR+=-I$(EDGE_DIR)/include -I$(GRAY_DIR)/include -I$(FILTER_DIR)/include -I$(UNIFICATION_DIR)/include -I$(COMPRESSION_DIR)/include
endif # USING_TLM_TB_EN

ifdef INCLUDE_OPENCV
# Target
LIBS+=-lopencv_imgcodecs -lopencv_core -lopencv_highgui -lopencv_imgproc
Expand All @@ -35,15 +46,38 @@ LFLAGS += $(shell pkg-config --libs opencv4)
endif # INCLUDE_OPENCV_PKG
endif # INCLUDE_OPENCV

ifndef USING_TLM_TB_EN
ErickOF marked this conversation as resolved.
Show resolved Hide resolved
SOURCES := $(wildcard $(SRCDIR)/*.cpp)
INCLUDES := $(wildcard $(INCDIR)/*.hpp)
OBJECTS := $(SOURCES:$(SRCDIR)/%.cpp=$(OBJDIR)/%.o)
else
ErickOF marked this conversation as resolved.
Show resolved Hide resolved
SOURCES = $(wildcard *.cpp) $(foreach DIR, $(SRCDIRS), $(wildcard $(DIR)/*.cpp))
SOURCES_WITHOUT_PATH = $(notdir $(SOURCES))
INCLUDES := $(wildcard $(INCDIR)/*.hpp)
OBJECTS = $(SOURCES_WITHOUT_PATH:%.cpp=$(OBJDIR)/%.o)

VPATH = $(sort $(dir $(SOURCES)))
endif # USING_TLM_TB_EN

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

ifndef USING_TLM_TB_EN
ErickOF marked this conversation as resolved.
Show resolved Hide resolved
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.cpp
@$(CC) $(CFLAGS) $(INCDIR) -c $< -o $@
else
ErickOF marked this conversation as resolved.
Show resolved Hide resolved
$(OBJECTS): $(OBJDIR)/%.o : %.cpp
@$(CC) $(CFLAGS) $(INCDIR) -c $< -o $@
endif # USING_TLM_TB_EN

valgrind:
valgrind --leak-check=full -s ./$(TARGET)

drmemory:
drmemory -- ./$(TARGET)

heaptrack:
heaptrack ./$(TARGET)

.PHONY: clean
clean:
Expand Down
46 changes: 46 additions & 0 deletions modules/communication/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Include common Makefile
include ../Makefile

# Defining preprocessor directive for debug
ifdef IPS_DEBUG_EN
CFLAGS += -DIPS_DEBUG_EN
LFLAGS += -DIPS_DEBUG_EN
endif # IPS_DEBUG_EN

# Defining preprocessor directive for dumping enable
ifdef IPS_DUMP_EN
CFLAGS += -DIPS_DUMP_EN
LFLAGS += -DIPS_DUMP_EN
endif # IPS_DUMP_EN

# Defining preprocessor directive for normalizing the resulting magnitude
ifdef TEST_NORMALIZE_MAGNITUDE
CFLAGS += -DTEST_NORMALIZE_MAGNITUDE
LFLAGS += -DTEST_NORMALIZE_MAGNITUDE
endif # TEST_NORMALIZE_MAGNITUDE

# Defining preprocessor directive for using PV model
ifdef EDGE_DETECTOR_PV_EN
CFLAGS += -DEDGE_DETECTOR_PV_EN
LFLAGS += -DEDGE_DETECTOR_PV_EN
endif # EDGE_DETECTOR_PV_EN

# Defining preprocessor directive for using PV model
ifdef EDGE_DETECTOR_LT_EN
CFLAGS += -DEDGE_DETECTOR_LT_EN
LFLAGS += -DEDGE_DETECTOR_LT_EN
endif # EDGE_DETECTOR_LT_EN

# Defining preprocessor directive for using PV model
ifdef EDGE_DETECTOR_AT_EN
CFLAGS += -DEDGE_DETECTOR_AT_EN
LFLAGS += -DEDGE_DETECTOR_AT_EN
endif # EDGE_DETECTOR_AT_EN

# Run the compiled file
run:
@./test

# Show waveform
waveform:
@gtkwave edge_detector.vcd
ErickOF marked this conversation as resolved.
Show resolved Hide resolved
43 changes: 43 additions & 0 deletions modules/communication/include/sobel_edge_detector_lt_model.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#ifdef EDGE_DETECTOR_LT_EN
#ifndef SOBEL_EDGE_DETECTOR_HPP
#define SOBEL_EDGE_DETECTOR_HPP

#include <systemc.h>

SC_MODULE(Edge_Detector)
{

int localWindow[3][3];

const int sobelGradientX[3][3] = {{-1, 0, 1},
{-2, 0, 2},
{-1, 0, 1}};
const int sobelGradientY[3][3] = {{-1, -2, -1},
{ 0, 0, 0},
{ 1, 2, 1}};

int resultSobelGradientX;
int resultSobelGradientY;

sc_event gotLocalWindow, finishedSobelGradientX, finishedSobelGradientY;

SC_CTOR(Edge_Detector)
{
SC_THREAD(compute_sobel_gradient_x);
SC_THREAD(compute_sobel_gradient_y);
}

void set_local_window(int window[3][3]);

void compute_sobel_gradient_x();

void compute_sobel_gradient_y();

int obtain_sobel_gradient_x();

int obtain_sobel_gradient_y();

};

#endif // SOBEL_EDGE_DETECTOR_HPP
#endif // EDGE_DETECTOR_LT_EN
28 changes: 28 additions & 0 deletions modules/communication/include/sobel_edge_detector_tlm.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef SOBEL_EDGE_DETECTOR_TLM_HPP
#define SOBEL_EDGE_DETECTOR_TLM_HPP
#include <systemc.h>

using namespace sc_core;
using namespace sc_dt;
using namespace std;

#include <tlm.h>
#include <tlm_utils/simple_initiator_socket.h>
#include <tlm_utils/simple_target_socket.h>
#include <tlm_utils/peq_with_cb_and_phase.h>

#include "sobel_edge_detector_lt_model.hpp"
#include "img_target.hpp"

//Extended Unification TLM
struct sobel_edge_detector_tlm : public Edge_Detector, public img_target
{
SC_CTOR(sobel_edge_detector_tlm): Edge_Detector(Edge_Detector::name()), img_target(img_target::name()) {
}

//Override do_when_transaction functions
virtual void do_when_read_transaction(unsigned char*& data);
virtual void do_when_write_transaction(unsigned char*& data);

};
#endif // SOBEL_EDGE_DETECTOR_TLM_HPP
Loading