@@ -6,51 +6,53 @@ using namespace sc_dt;
66using namespace std ;
77
88#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-
139#include " sobel_edge_detector_tlm.hpp"
10+ #include " address_map.hpp"
1411
1512#include " common_func.hpp"
1613
1714void sobel_edge_detector_tlm::do_when_read_transaction (unsigned char *& data, unsigned int data_length, sc_dt::uint64 address){
1815 short int sobel_results[4 ];
1916 sc_int<16 > local_result;
20-
21- dbgimgtarmodprint (" Calling do_when_read_transaction" );
2217
23- Edge_Detector::address = address;
18+ Edge_Detector::address = (sc_uint< 24 >) address+SOBEL_OUTPUT_ADDRESS_LO ;
2419 read ();
2520
26- for (int i = 0 ; i < 4 ; i++)
21+ for (int i = 0 ; i < data_length ; i++)
2722 {
28- local_result = Edge_Detector::data.range ((i + 1 ) * 16 - 1 , i * 16 ).to_int ();
29- sobel_results[i] = (short int )local_result;
30- dbgimgtarmodprint (" %0d" , sobel_results[i]);
23+ local_result = Edge_Detector::data.range ((address + i + 1 ) * 16 - 1 , (address+i) * 16 ).to_int ();
24+ sobel_results[address+i] = (short int )local_result;
25+ *(data+i) = sobel_results[address+i];
26+ // dbgimgtarmodprint("%0d", sobel_results[address+i]);
3127 }
3228
33- memcpy (data, sobel_results, 4 * sizeof (short int ));
3429}
3530
3631void sobel_edge_detector_tlm::do_when_write_transaction (unsigned char *&data, unsigned int data_length, sc_dt::uint64 address)
3732{
38- sc_uint<8 > values[8 ];
39-
40- dbgimgtarmodprint (" Calling do_when_write_transaction" );
41-
42- for (int i = 0 ; i < 8 ; i++)
43- {
44- values[i] = *(data + i);
33+ if (address < SOBEL_INPUT_0_SIZE) {
34+ for (int i = 0 ; i < data_length; data++) {
35+ this ->sobel_input [address+i] = *(data+i);
36+ }
4537 }
46- Edge_Detector::data = (values[7 ], values[6 ], values[5 ], values[4 ], values[3 ], values[2 ], values[1 ], values[0 ]);
47- Edge_Detector::address = address;
48- write ();
38+ else if (SOBEL_INPUT_0_SIZE <= address && address < SOBEL_INPUT_0_SIZE + SOBEL_INPUT_1_SIZE) {
39+ for (int i = 0 ; i < data_length; data++) {
40+ this ->sobel_input [address+i-SOBEL_INPUT_0_SIZE] = *(data+i-SOBEL_INPUT_0_SIZE);
41+ }
42+ }
43+
44+ Edge_Detector::data = (this ->sobel_input [7 ], this ->sobel_input [6 ], this ->sobel_input [5 ], this ->sobel_input [4 ], this ->sobel_input [3 ], this ->sobel_input [2 ], this ->sobel_input [1 ], this ->sobel_input [0 ]);
45+ Edge_Detector::address = address+SOBEL_INPUT_0_ADDRESS_LO;
46+
47+ if ((address == SOBEL_INPUT_0_SIZE-1 ) || (address == SOBEL_INPUT_0_SIZE+SOBEL_INPUT_1_SIZE-1 )) {
48+ write ();
49+ }
50+
4951}
5052
5153void sobel_edge_detector_tlm::read ()
5254{
53- if ((Edge_Detector::address - SOBEL_OUTPUT ) == 0 )
55+ if ((Edge_Detector::address - SOBEL_OUTPUT_ADDRESS_LO ) == 0 )
5456 {
5557 Edge_Detector::data = (sc_uint<32 >(0 ), resultSobelGradientY, resultSobelGradientX);
5658 }
0 commit comments