Skip to content

Commit ffc5b74

Browse files
jgavillalobosErickOF
authored andcommitted
Include memory for storing the data using TLM transactions
Preload the image inside the memory and load it from there to use it for RGB2GRAY block, then save the results back into the memory, then load the results from there to use them in the edge detector block and then save the results from the gradients X and Y in the memory for a future use
1 parent 7df8821 commit ffc5b74

File tree

5 files changed

+380
-91
lines changed

5 files changed

+380
-91
lines changed
Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1-
#define SOBEL_INPUT_0 0x00000027u
2-
#define SOBEL_INPUT_1 0x0000002Fu
3-
#define SOBEL_OUTPUT 0x00000030u
1+
#ifndef ADDRESSMAP_H
2+
#define ADDRESSMAP_H
3+
4+
#define IMG_FILTER_KERNEL 0x00000003u
5+
#define SOBEL_INPUT_0 0x00000027u
6+
#define SOBEL_INPUT_1 0x0000002Fu
7+
#define SOBEL_OUTPUT 0x00000030u
8+
#define MEM_START 0x00000034u
9+
#define IMG_INPUT 0x00000034u
10+
#define IMG_INPROCESS_A 0x000E1034u
11+
#define IMG_INPROCESS_B 0x0012C034u
12+
#define IMG_INPROCESS_C 0x001C2034u
13+
#define IMG_COMPRESSED 0x00258034u
14+
15+
#endif // ADDRESSMAP_H
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef IMPORTANTDEFINES_H
2+
#define IMPORTANTDEFINES_H
3+
4+
#include "AddressMap.h"
5+
6+
#define IMAG_ROWS 480
7+
#define IMAG_COLS 640
8+
9+
#endif IMPORTANTDEFINES_H
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#ifndef MEMORY_TLM_HPP
2+
#define MEMORY_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 "../src/img_target.cpp"
14+
15+
//Extended Unification TLM
16+
struct memory_tlm : public img_target
17+
{
18+
19+
SC_CTOR(memory_tlm): img_target(img_target::name()) {
20+
mem_array = new unsigned char[2764852];
21+
}
22+
23+
//Override do_when_transaction functions
24+
virtual void do_when_read_transaction(unsigned char*& data, unsigned int data_length, sc_dt::uint64 address);
25+
virtual void do_when_write_transaction(unsigned char*& data, unsigned int data_length, sc_dt::uint64 address);
26+
27+
void backdoor_write(unsigned char*& data, unsigned int data_length, sc_dt::uint64 address);
28+
29+
unsigned char* mem_array;
30+
31+
sc_uint<64> mem_data;
32+
sc_uint<24> mem_address;
33+
sc_uint<1> mem_we;
34+
35+
};
36+
#endif // MEMORY_TLM_HPP

modules/router/src/memory_tlm.cpp

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#ifndef MEMORY_TLM_CPP
2+
#define MEMORY_TLM_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 "memory_tlm.hpp"
14+
15+
#include "common_func.hpp"
16+
17+
void memory_tlm::do_when_read_transaction(unsigned char*& data, unsigned int data_length, sc_dt::uint64 address)
18+
{
19+
sc_uint<8> local_data[8];
20+
int max_data_length = (data_length > 8) ? 8 : data_length;
21+
22+
for (int i = 0; i < max_data_length; i++)
23+
{
24+
local_data[i] = *(mem_array + address + i);
25+
}
26+
for (int i = max_data_length; i < 8; i++)
27+
{
28+
local_data[i] = 0;
29+
}
30+
mem_data = (local_data[7], local_data[6], local_data[5], local_data[4], local_data[3], local_data[2], local_data[1], local_data[0]);
31+
mem_address = address;
32+
mem_we = 0;
33+
memcpy(data, (mem_array + address), data_length);
34+
}
35+
36+
void memory_tlm::do_when_write_transaction(unsigned char*&data, unsigned int data_length, sc_dt::uint64 address)
37+
{
38+
sc_uint<8> local_data[8];
39+
int max_data_length = (data_length > 8) ? 8 : data_length;
40+
41+
for (int i = 0; i < max_data_length; i++)
42+
{
43+
local_data[i] = *(data + i);
44+
}
45+
for (int i = max_data_length; i < 8; i++)
46+
{
47+
local_data[i] = 0;
48+
}
49+
mem_data = (local_data[7], local_data[6], local_data[5], local_data[4], local_data[3], local_data[2], local_data[1], local_data[0]);
50+
mem_address = address;
51+
mem_we = 1;
52+
memcpy((mem_array + address), data, data_length);
53+
}
54+
55+
void memory_tlm::backdoor_write(unsigned char*&data, unsigned int data_length, sc_dt::uint64 address)
56+
{
57+
memcpy((mem_array + address), data, data_length);
58+
}
59+
60+
#endif // MEMORY_TLM_CPP

0 commit comments

Comments
 (0)