Skip to content

Commit 1036999

Browse files
RMorales25ErickOF
authored andcommitted
Add makefile and other needed files
1 parent ed3b320 commit 1036999

File tree

4 files changed

+238
-0
lines changed

4 files changed

+238
-0
lines changed

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: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#ifdef EDGE_DETECTOR_LT_EN
2+
#ifndef SOBEL_EDGE_DETECTOR_CPP
3+
#define SOBEL_EDGE_DETECTOR_CPP
4+
5+
#include "sobel_edge_detector_lt_model.hpp"
6+
7+
void Edge_Detector::set_local_window(int window[3][3])
8+
{
9+
for (int i = 0; i < 3; i++)
10+
{
11+
for (int j = 0; j < 3; j++)
12+
{
13+
this->localWindow[i][j] = window[i][j];
14+
}
15+
}
16+
gotLocalWindow.notify(10, SC_NS);
17+
}
18+
19+
void Edge_Detector::compute_sobel_gradient_x()
20+
{
21+
while (true)
22+
{
23+
wait(gotLocalWindow);
24+
this->resultSobelGradientX = 0;
25+
26+
for (int i = 0; i < 3; i++)
27+
{
28+
for (int j = 0; j < 3; j++)
29+
{
30+
this->resultSobelGradientX += this->localWindow[i][j] * this->sobelGradientX[i][j];
31+
}
32+
}
33+
finishedSobelGradientX.notify(5, SC_NS);
34+
}
35+
}
36+
37+
void Edge_Detector::compute_sobel_gradient_y()
38+
{
39+
while (true)
40+
{
41+
wait(gotLocalWindow);
42+
this->resultSobelGradientY = 0;
43+
44+
for (int i = 0; i < 3; i++)
45+
{
46+
for (int j = 0; j < 3; j++)
47+
{
48+
this->resultSobelGradientY += this->localWindow[i][j] * this->sobelGradientY[i][j];
49+
}
50+
}
51+
finishedSobelGradientY.notify(5, SC_NS);
52+
}
53+
}
54+
55+
int Edge_Detector::obtain_sobel_gradient_x()
56+
{
57+
return this->resultSobelGradientX;
58+
}
59+
60+
int Edge_Detector::obtain_sobel_gradient_y()
61+
{
62+
return this->resultSobelGradientY;
63+
}
64+
65+
#endif // SOBEL_EDGE_DETECTOR_CPP
66+
#endif // EDGE_DETECTOR_LT_EN
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// **************************************************************************************
2+
// User-defined memory manager, which maintains a pool of transactions
3+
// From TLM Duolos tutorials
4+
// **************************************************************************************
5+
#ifndef TRANSACTION_MEMORY_MANAGER_CPP
6+
#define TRANSACTION_MEMORY_MANAGER_CPP
7+
8+
#include "systemc.h"
9+
using namespace sc_core;
10+
using namespace sc_dt;
11+
using namespace std;
12+
13+
#include "tlm.h"
14+
#include "tlm_utils/simple_initiator_socket.h"
15+
#include "tlm_utils/simple_target_socket.h"
16+
#include "tlm_utils/peq_with_cb_and_phase.h"
17+
18+
class mm: public tlm::tlm_mm_interface
19+
{
20+
typedef tlm::tlm_generic_payload gp_t;
21+
22+
public:
23+
mm() : free_list(0), empties(0)
24+
#ifdef DEBUG
25+
, count(0)
26+
#endif
27+
{}
28+
29+
gp_t* allocate()
30+
{
31+
#ifdef DEBUG
32+
cout << "----------------------------- Called allocate(), #trans = " << ++count << endl;
33+
#endif
34+
gp_t* ptr;
35+
if (free_list)
36+
{
37+
ptr = free_list->trans;
38+
empties = free_list;
39+
free_list = free_list->next;
40+
}
41+
else
42+
{
43+
ptr = new gp_t(this);
44+
}
45+
return ptr;
46+
}
47+
48+
void free(gp_t* trans)
49+
{
50+
#ifdef DEBUG
51+
cout << "----------------------------- Called free(), #trans = " << --count << endl;
52+
#endif
53+
if (!empties)
54+
{
55+
empties = new access;
56+
empties->next = free_list;
57+
empties->prev = 0;
58+
if (free_list)
59+
free_list->prev = empties;
60+
}
61+
free_list = empties;
62+
free_list->trans = trans;
63+
empties = free_list->prev;
64+
}
65+
66+
private:
67+
struct access
68+
{
69+
gp_t* trans;
70+
access* next;
71+
access* prev;
72+
};
73+
74+
access* free_list;
75+
access* empties;
76+
77+
#ifdef DEBUG
78+
int count;
79+
#endif
80+
};
81+
82+
83+
#endif

0 commit comments

Comments
 (0)