Skip to content

Commit fe80709

Browse files
authored
Merge pull request #25 from ErickOF/dev
Project 2 integration
2 parents a83f376 + 094537e commit fe80709

File tree

70 files changed

+4670
-174
lines changed

Some content is hidden

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

70 files changed

+4670
-174
lines changed

.github/workflows/cpp.yml

Lines changed: 55 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,67 @@ on:
44
push:
55
branches:
66
- main
7-
- dev
7+
# - dev
88
pull_request:
99
branches:
1010
- main
11-
- dev
11+
# - dev
1212

1313
jobs:
1414
build:
15-
1615
runs-on: ubuntu-latest
1716

17+
env:
18+
ACTIONS_STEP_DEBUG: true
19+
1820
steps:
19-
- uses: actions/checkout@v4
20-
- name: install dependencies
21-
run: sudo apt-get install -y libopencv-dev
22-
- name: compile compression
23-
working-directory: ./modules/compression
24-
run: make IPS_JPG_AT_EN=1 INCLUDE_OPENCV_PKG=1
25-
- name: compile edge detector
26-
working-directory: ./modules/edge-detector
27-
run: make EDGE_DETECTOR_AT_EN=1 INCLUDE_OPENCV_PKG=1
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
#
24+
# - name: Cache tools
25+
# id: cache-deps
26+
# uses: actions/cache@v2
27+
# with:
28+
# path: |
29+
# /usr/local/systemc-3.0.0
30+
# $HOME/systemc-3.0.0
31+
# key: ${{ runner.os }}-build-${{ hashFiles('**/setup-dependencies.sh') }}
32+
# restore-keys: |
33+
# ${{ runner.os }}-build-
34+
#
35+
# - name: Install Dependencies
36+
# if: steps.cache-deps.outputs.cache-hit != 'true'
37+
# run: |
38+
# set -x
39+
# sudo apt-get install libopencv-dev
40+
# cd $HOME
41+
# rm -rf systemc-3.0.0
42+
# git clone https://github.com/accellera-official/systemc.git systemc-3.0.0
43+
# cd systemc-3.0.0
44+
# ./config/bootstrap
45+
# mkdir -p objdir
46+
# cd objdir
47+
# export CXX=g++
48+
# ../configure --prefix=/usr/local/systemc-3.0.0
49+
# mkdir -p examples/
50+
# cp -r ../examples/* examples/
51+
# make
52+
# sudo make install
53+
# export SYSTEMC_HOME=/usr/local/systemc-3.0.0
54+
# export LD_LIBRARY_PATH=$SYSTEMC_HOME/lib-linux64
55+
# - name: Compile Compression
56+
# working-directory: ./modules/compression
57+
# run: make IPS_JPG_AT_EN=1 INCLUDE_OPENCV_PKG=1
58+
# - name: Compile Edge Detector
59+
# working-directory: ./modules/edge-detector
60+
# run: make EDGE_DETECTOR_AT_EN=1 INCLUDE_OPENCV_PKG=1
61+
# - name: Compile Filter
62+
# working-directory: ./modules/filter
63+
# run: make IPS_FILTER_LT_EN=1 TEST_MODE_IMAGE=1 IPS_DUMP_EN=1 INCLUDE_OPENCV_PKG=1
64+
# - name: Compile RGB2Gray
65+
# working-directory: ./modules/rgb2gray
66+
# run: make RGB2GRAY_PV_EN=1 INCLUDE_OPENCV_PKG=1
67+
# - name: Compile Unification
68+
# working-directory: ./modules/unification
69+
# run: make IMG_UNIFICATE_PV_EN=1
70+
#

.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/adc/Makefile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Include common Makefile
2+
include ../Makefile
3+
4+
SRCDIR+=../../utils/src
5+
INCDIR+=-I$(SYSTEMC_AMS_HOME)/include -I../utils/include
6+
LIBDIR+=-L$(SYSTEMC_AMS_HOME)/lib-linux64
7+
LIBS+=-lsystemc-ams
8+
9+
# Defining preprocessor directive for debug
10+
ifdef IPS_DEBUG_EN
11+
CFLAGS += -DIPS_DEBUG_EN
12+
LFLAGS += -DIPS_DEBUG_EN
13+
endif # IPS_DEBUG_EN
14+
15+
# Defining preprocessor directive for dumping enable
16+
ifdef IPS_DUMP_EN
17+
CFLAGS += -DIPS_DUMP_EN
18+
LFLAGS += -DIPS_DUMP_EN
19+
endif # IPS_DUMP_EN
20+
21+
# Run the compiled file
22+
run:
23+
@./$(TARGET)
24+
25+
# Show waveform
26+
waveform:
27+
@gtkwave ips_adc.vcd

modules/adc/include/adc.hpp

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#ifndef IPS_ADC_MODEL_HPP
2+
#define IPS_ADC_MODEL_HPP
3+
4+
#include <systemc-ams.h>
5+
#include "vunit.hpp"
6+
7+
8+
/**
9+
* @brief Analog to Digital Converter module representation
10+
* This module generates a N-bit digital signal based on the [Vmin, Vmax]
11+
* voltage range
12+
*
13+
* @tparam BITS - the number of output bits of the digital code
14+
* @tparam VMIN - lowest voltage value
15+
* @tparam VMAX - highest voltage value
16+
* @tparam VU - voltage unit based on VUnit
17+
*/
18+
template <unsigned int BITS = 8, int VMIN = 0, int VMAX = 5, VUnit VU = VUnit::v>
19+
SCA_TDF_MODULE(adc)
20+
{
21+
protected:
22+
// Min voltage value based on the voltage units
23+
const double V_MIN = static_cast<double>(VMIN) / static_cast<double>(VU);
24+
// Max voltage value based on the voltage units
25+
const double V_MAX = static_cast<double>(VMAX) / static_cast<double>(VU);
26+
// Max digital output code
27+
const double MAX_DIG = static_cast<double>((1 << BITS) - 1);
28+
public:
29+
// Input analog voltage
30+
sca_tdf::sca_in<double> in;
31+
// Output digital code
32+
sca_tdf::sca_out<sc_dt::sc_uint<BITS> > out;
33+
34+
/**
35+
* @brief Construct a new adc object
36+
*
37+
*/
38+
SCA_CTOR(adc) : in("in"), out("out") {
39+
// Propagation time from input to output
40+
set_timestep(sca_core::sca_time(0.1, sc_core::SC_US));
41+
}
42+
43+
/**
44+
* @brief Convert the analog signal into digital signal
45+
* The analog signal in a range from Vmin to Vmax is converted into a N-bit
46+
* digital signal
47+
*
48+
*/
49+
void processing()
50+
{
51+
52+
double normalized_ana_in = (in.read() - V_MIN) / (V_MAX - V_MIN);
53+
unsigned int dig_code = static_cast<unsigned int>(normalized_ana_in * MAX_DIG);
54+
55+
this->out.write(static_cast<sc_dt::sc_uint<BITS> >(dig_code));
56+
}
57+
};
58+
59+
#endif // IPS_ADC_MODEL_HPP

modules/adc/include/seq_item_adc.hpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#ifndef IPS_SEQ_ITEM_ADC_HPP
2+
#define IPS_SEQ_ITEM_ADC_HPP
3+
4+
#include <cstdlib>
5+
6+
7+
/**
8+
* @brief This class is used to generate the analog signal for the test
9+
*
10+
* @tparam N
11+
*/
12+
template <unsigned int N>
13+
SCA_TDF_MODULE(seq_item_adc)
14+
{
15+
public:
16+
sca_tdf::sca_out<double> o_ana;
17+
const int MAX_CODE = (1 << N);
18+
19+
SCA_CTOR(seq_item_adc)
20+
{
21+
set_timestep(sca_core::sca_time(0.1, sc_core::SC_US));
22+
}
23+
24+
void processing()
25+
{
26+
this->o_ana.write(static_cast<double>(rand() % MAX_CODE) / MAX_CODE);
27+
}
28+
};
29+
30+
#endif // IPS_SEQ_ITEM_ADC_HPP

modules/adc/src/tb_adc.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include <systemc-ams.h>
2+
#include "adc.hpp"
3+
#include "seq_item_adc.hpp"
4+
5+
#define N 8
6+
7+
8+
int sc_main(int, char*[])
9+
{
10+
// Max number of sequence items to test
11+
const int MAX_SEQ_ITEMS = (1 << N) - 1;
12+
13+
// Signals to connect
14+
sca_tdf::sca_signal<double> s_ana;
15+
sca_tdf::sca_signal<sc_dt::sc_uint<N> > s_dig_out;
16+
17+
// DUT
18+
adc<N> ips_adc("ips_adc");
19+
ips_adc.in(s_ana);
20+
ips_adc.out(s_dig_out);
21+
22+
// Sequence item generator for ADC
23+
seq_item_adc<N> ips_seq_item_adc("ips_seq_item_adc");
24+
ips_seq_item_adc.o_ana(s_ana);
25+
26+
// Dump waveform
27+
sca_util::sca_trace_file* tf = sca_util::sca_create_vcd_trace_file("ips_adc");
28+
sca_util::sca_trace(tf, s_ana, "in");
29+
sca_util::sca_trace(tf, s_dig_out, "out");
30+
31+
// Start time
32+
std::cout << "@" << sc_time_stamp() << std::endl;
33+
34+
// Run test
35+
sc_start(MAX_SEQ_ITEMS * 0.1, SC_US);
36+
37+
// End time
38+
std::cout << "@" << sc_time_stamp() << std::endl;
39+
40+
sca_util::sca_close_vcd_trace_file(tf);
41+
42+
return 0;
43+
};

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

0 commit comments

Comments
 (0)