Skip to content

Commit 5ae4ff0

Browse files
committed
Add filter testing
1 parent 8e14d24 commit 5ae4ff0

File tree

5 files changed

+45
-28
lines changed

5 files changed

+45
-28
lines changed

modules/VirtualPrototype/FreeRTOS/freertos_test.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,30 @@ static void task_test_grayscale(void *pParameter)
313313
convert_to_grayscale();
314314
}
315315

316+
void filter_image()
317+
{
318+
unsigned char *filter_output_ptr = (unsigned char*) IMG_FILTER_OUTPUT_ADDRESS_LO;
319+
unsigned char *output_image_ptr = (unsigned char*) IMG_COMPRESSED_ADDRESS_LO;
320+
321+
printf("Starting filtering of image\n");
322+
323+
for (int i = 0; i < IMAG_ROWS; i++)
324+
{
325+
for (int j = 0; j < IMAG_COLS; j++)
326+
{
327+
transfer_window(i, j, IMG_INPROCESS_A_ADDRESS_LO, IMG_FILTER_KERNEL_ADDRESS_LO);
328+
*(output_image_ptr + ((i * IMAG_COLS) + j)) = *(filter_output_ptr);
329+
}
330+
}
331+
332+
printf("Finished filtering of image\n");
333+
}
334+
335+
static void task_test_filtering(void *pParameter)
336+
{
337+
filter_image();
338+
}
339+
316340
int main( void )
317341
{
318342

@@ -326,7 +350,8 @@ int main( void )
326350
xTaskCreate(task_3, "Task3", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, NULL);
327351

328352
// xTaskCreate(task_test_sobel, "TaskSobel", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, NULL);
329-
xTaskCreate(task_test_grayscale, "TaskGrayscale", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, NULL);
353+
// xTaskCreate(task_test_grayscale, "TaskGrayscale", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, NULL);
354+
xTaskCreate(task_test_filtering, "TaskFiltering", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, NULL);
330355
/* Start the kernel. From here on, only tasks and interrupts will run. */
331356
vTaskStartScheduler();
332357

modules/VirtualPrototype/include/ips_filter_tlm.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ using namespace sc_core;
55
using namespace sc_dt;
66
using namespace std;
77

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>
128

139
#include "ips_filter_lt_model.hpp"
1410
#include "../src/img_target.cpp"
@@ -20,6 +16,7 @@ struct ips_filter_tlm : public Filter<IPS_IN_TYPE_TB, IPS_OUT_TYPE_TB, IPS_FILTE
2016
{
2117

2218
ips_filter_tlm(sc_module_name name) : Filter<IPS_IN_TYPE_TB, IPS_OUT_TYPE_TB, IPS_FILTER_KERNEL_SIZE>((std::string(name) + "_HW_block").c_str()), img_target((std::string(name) + "_target").c_str()) {
19+
set_mem_attributes(IMG_FILTER_KERNEL_ADDRESS_LO, IMG_FILTER_KERNEL_SIZE+IMG_FILTER_OUTPUT_SIZE);
2320
}
2421

2522
//Override do_when_transaction functions

modules/VirtualPrototype/src/img_target.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,28 @@ struct img_target: sc_module
6464
// Generate the appropriate error response
6565
// *********************************************
6666
if (adr >= sc_dt::uint64(mem_size)) {
67+
dbgmodprint("[DEBUG ERROR] TLM transaction is returned with response status TLM_ADDRESS_ERROR_RESPONSE");
6768
trans.set_response_status(tlm::TLM_ADDRESS_ERROR_RESPONSE);
6869
return;
6970
}
7071
if (byt != nullptr) {
72+
dbgmodprint("[DEBUG ERROR] TLM transaction is returned with response status TLM_BYTE_ERROR_RESPONSE");
7173
trans.set_response_status(tlm::TLM_BYTE_ENABLE_ERROR_RESPONSE);
7274
return;
7375
}
7476
if (len > 4 || wid < len) {
77+
dbgmodprint("[DEBUG ERROR] TLM transaction is returned with response status TLM_BURST_ERROR_RESPONSE");
7578
trans.set_response_status(tlm::TLM_BURST_ERROR_RESPONSE);
7679
return;
7780
}
7881

7982
// Obliged to implement read and write commands
8083
if (cmd == tlm::TLM_READ_COMMAND) {
8184
this->do_when_read_transaction(ptr, len, adr);
82-
//dbgmodprint("Read at address %0x, data: %0x", address_offset, *ptr);
85+
// dbgmodprint("Read at address %0x, data: %0x", address_offset, *ptr);
8386
}
8487
else if (cmd == tlm::TLM_WRITE_COMMAND) {
85-
//dbgmodprint("Write at address %0x, data: %0x", address_offset, *ptr);
88+
// dbgmodprint("Write at address %0x, data: %0x", address_offset, *ptr);
8689
this->do_when_write_transaction(ptr, len, adr);
8790
}
8891

modules/VirtualPrototype/src/ips_filter_tlm.cpp

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ using namespace std;
1717

1818
void ips_filter_tlm::do_when_read_transaction(unsigned char*& data, unsigned int data_length, sc_dt::uint64 address)
1919
{
20+
dbgimgtarmodprint("Called do_when_read_transaction with an address %016llX and length %d", address, data_length);
21+
2022
this->img_result = *(Filter<IPS_IN_TYPE_TB, IPS_OUT_TYPE_TB, IPS_FILTER_KERNEL_SIZE>::result_ptr);
2123
*data = (unsigned char) this->img_result;
2224
//memcpy(data, Filter<IPS_IN_TYPE_TB, IPS_OUT_TYPE_TB, IPS_FILTER_KERNEL_SIZE>::result_ptr, sizeof(IPS_OUT_TYPE_TB));
@@ -25,25 +27,15 @@ void ips_filter_tlm::do_when_read_transaction(unsigned char*& data, unsigned int
2527
void ips_filter_tlm::do_when_write_transaction(unsigned char*& data, unsigned int data_length, sc_dt::uint64 address)
2628
{
2729
IPS_OUT_TYPE_TB* result = new IPS_OUT_TYPE_TB;
28-
IPS_IN_TYPE_TB* img_window = new IPS_IN_TYPE_TB[3 * 3];
29-
30-
dbgprint("[DEBUG]: data: %0d, address %0d, data_length %0d, size of char %0d", *data, address, data_length, sizeof(char));
31-
this->img_window[address] = (IPS_IN_TYPE_TB) *data;
32-
dbgprint("[DEBUG]: img_window data: %0f", this->img_window[address]);
33-
34-
// if ((IPS_FILTER_KERNEL_SIZE * IPS_FILTER_KERNEL_SIZE * sizeof(char)) != data_length)
35-
// {
36-
// SC_REPORT_FATAL("IPS_FILTER", "Illegal transaction size");
37-
// }
38-
39-
// for (int i = 0; i < IPS_FILTER_KERNEL_SIZE; i++)
40-
// {
41-
// for (int j = 0; j < IPS_FILTER_KERNEL_SIZE; j++)
42-
// {
43-
// *(img_window + ((i * IPS_FILTER_KERNEL_SIZE) + j)) = (IPS_IN_TYPE_TB)*(data + ((i * IPS_FILTER_KERNEL_SIZE) + j));
44-
// this->img_window[(i * IPS_FILTER_KERNEL_SIZE) + j] = (IPS_IN_TYPE_TB)*(data + ((i * IPS_FILTER_KERNEL_SIZE) + j));
45-
// }
46-
// }
30+
31+
dbgimgtarmodprint("Called do_when_write_transaction with an address %016llX and length %d", address, data_length);
32+
33+
//dbgprint("[DEBUG]: data: %0d, address %0d, data_length %0d, size of char %0d", *data, address, data_length, sizeof(char));
34+
for (int i = 0; i < data_length; i++) {
35+
this->img_window[address + i] = (IPS_IN_TYPE_TB) *(data + i);
36+
}
37+
//dbgprint("[DEBUG]: img_window data: %0f", this->img_window[address]);
38+
4739
if (address == 8) {
4840
filter(this->img_window, result);
4941
}

modules/VirtualPrototype/src/sobel_edge_detector_tlm.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ void sobel_edge_detector_tlm::do_when_read_transaction(unsigned char*& data, uns
1616
unsigned char* sobel_results_ptr;
1717
sc_uint<8> local_result;
1818

19-
dbgimgtarmodprint("Called do_when_read_transaction witha address %016llX and length %d", address, data_length);
19+
dbgimgtarmodprint("Called do_when_read_transaction with an address %016llX and length %d", address, data_length);
2020

2121
if ((address >= (SOBEL_INPUT_0_SIZE + SOBEL_INPUT_1_SIZE)) && (address < (SOBEL_INPUT_0_SIZE + SOBEL_INPUT_1_SIZE + SOBEL_OUTPUT_SIZE)))
2222
{
@@ -48,7 +48,7 @@ void sobel_edge_detector_tlm::do_when_read_transaction(unsigned char*& data, uns
4848

4949
void sobel_edge_detector_tlm::do_when_write_transaction(unsigned char*&data, unsigned int data_length, sc_dt::uint64 address)
5050
{
51-
dbgimgtarmodprint("Called do_when_write_transaction witha address %016llX and length %d", address, data_length);
51+
dbgimgtarmodprint("Called do_when_write_transaction with an address %016llX and length %d", address, data_length);
5252

5353
if (address < (SOBEL_INPUT_0_SIZE + SOBEL_INPUT_1_SIZE))
5454
{

0 commit comments

Comments
 (0)