@@ -34,10 +34,11 @@ using namespace std;
3434#include " ips_filter_tlm.hpp"
3535#include " sobel_edge_detector_tlm.hpp"
3636#include " unification_pv_model.hpp"
37+ #include " ips_jpg_pv_model.hpp"
3738#include " img_initiator.cpp"
3839
39- #if !defined(RGB2GRAY_PV_EN) || !defined(EDGE_DETECTOR_AT_EN)
40- #error "Not all the required macros (RGB2GRAY_PV_EN and EDGE_DETECTOR_LT_EN ) are defined is defined."
40+ #if !defined(RGB2GRAY_PV_EN) || !defined(IPS_FILTER_LT_EN) || !defined( EDGE_DETECTOR_AT_EN) || !defined(IMG_UNIFICATE_PV_EN) || !defined(IPS_JPG_PV_EN )
41+ #error "Not all the required macros (RGB2GRAY_PV_EN, IPS_FILTER_LT_EN, EDGE_DETECTOR_AT_EN, IMG_UNIFICATE_PV_EN and IPS_JPG_PV_EN ) are defined."
4142#endif
4243
4344SC_MODULE (Tb_top)
@@ -50,6 +51,7 @@ SC_MODULE(Tb_top)
5051 img_initiator *filter_initiator;
5152 ips_filter_tlm *filter_DUT;
5253 img_unification_module* unification_DUT;
54+ jpg_output *jpg_comp_DUT;
5355
5456 SC_CTOR (Tb_top)
5557 {
@@ -61,6 +63,7 @@ SC_MODULE(Tb_top)
6163 filter_initiator = new img_initiator (" filter_initiator" );
6264 filter_DUT = new ips_filter_tlm (" filter_DUT" );
6365 unification_DUT = new img_unification_module (" unification_DUT" );
66+ jpg_comp_DUT = new jpg_output (" jpg_comp_DUT" , IMAG_ROWS, IMAG_COLS);
6467
6568 sobel_initiator->start_img_initiators ();
6669 sobel_initiator->set_delays (sc_time (10 , SC_NS), sc_time (10 , SC_NS));
@@ -96,6 +99,11 @@ SC_MODULE(Tb_top)
9699 int current_number_of_pixels = 0 ;
97100 float next_target_of_completion = 10.0 ;
98101
102+ int local_group_count;
103+ int compression_output_size = 0 ;
104+
105+ signed char * compression_results;
106+
99107 colorImage = imread (" ../../tools/datagen/src/imgs/car.jpg" , IMREAD_UNCHANGED);
100108
101109 if (colorImage.empty ())
@@ -170,7 +178,7 @@ SC_MODULE(Tb_top)
170178
171179 for (int i = 0 ; i < IMAG_ROWS; i++)
172180 {
173- int local_group_count = 0 ;
181+ local_group_count = 0 ;
174182 for (int j = 0 ; j < IMAG_COLS; j++)
175183 {
176184 unsigned char * read_ptr;
@@ -233,7 +241,7 @@ SC_MODULE(Tb_top)
233241
234242 for (int i = 0 ; i < IMAG_ROWS; i++)
235243 {
236- int local_group_count = 0 ;
244+ local_group_count = 0 ;
237245 for (int j = 0 ; j < IMAG_COLS; j++)
238246 {
239247 unsigned char * local_window_ptr = new unsigned char [9 ];
@@ -314,7 +322,7 @@ SC_MODULE(Tb_top)
314322
315323 for (int i = 0 ; i < IMAG_ROWS; i++)
316324 {
317- int local_group_count = 0 ;
325+ local_group_count = 0 ;
318326 for (int j = 0 ; j < IMAG_COLS; j++)
319327 {
320328 unsigned char * local_window_ptr = new unsigned char [16 ];
@@ -398,6 +406,8 @@ SC_MODULE(Tb_top)
398406 }
399407 }
400408
409+ dbgprint (" Finished calculating sobel gradients of the image" );
410+
401411 // Sanity check that the image was written in memory as expected
402412 for (int i = 0 ; i < IMAG_ROWS; i++)
403413 {
@@ -434,9 +444,13 @@ SC_MODULE(Tb_top)
434444 }
435445 }
436446
447+ local_count = 0 ;
448+ current_number_of_pixels = 0 ;
449+ next_target_of_completion = 10.0 ;
450+
437451 for (int i = 0 ; i < IMAG_ROWS; i++)
438452 {
439- int local_group_count = 0 ;
453+ local_group_count = 0 ;
440454 for (int j = 0 ; j < IMAG_COLS; j++)
441455 {
442456 unsigned char * read_ptr;
@@ -495,6 +509,8 @@ SC_MODULE(Tb_top)
495509 }
496510 }
497511
512+ dbgprint (" Finished with the unification of the magnitude of the gradients of the image" );
513+
498514 // Sanity check that the image was written in memory as expected
499515 for (int i = 0 ; i < IMAG_ROWS; i++)
500516 {
@@ -506,6 +522,64 @@ SC_MODULE(Tb_top)
506522 }
507523 }
508524
525+ local_count = 0 ;
526+ current_number_of_pixels = 0 ;
527+ next_target_of_completion = 10.0 ;
528+
529+ for (int i = 0 ; i < IMAG_ROWS; i++)
530+ {
531+ local_group_count = 0 ;
532+ for (int j = 0 ; j < IMAG_COLS; j++)
533+ {
534+ if (local_count == 0 )
535+ {
536+ unsigned char * read_ptr;
537+ local_read = new unsigned char [8 ];
538+
539+ dbgprint (" Before doing a read in TB" );
540+ memory_initiator->read (read_ptr, IMG_INPROCESS_A + ((i * IMAG_COLS) + (local_group_count * 8 * sizeof (char ))), 8 * sizeof (char ));
541+ dbgprint (" After doing a read in TB" );
542+ memcpy (local_read, read_ptr, 8 * sizeof (char ));
543+ }
544+
545+ jpg_comp_DUT->input_pixel ((int )*(local_read + local_count), i, j);
546+
547+ if (local_count == 8 )
548+ {
549+ local_count = 0 ;
550+ local_group_count++;
551+ }
552+ }
553+ }
554+
555+ jpg_comp_DUT->jpeg_compression (&compression_output_size);
556+
557+ local_count = 0 ;
558+ local_group_count = 0 ;
559+ compression_results = new signed char [compression_output_size];
560+ for (int i = 0 ; i < compression_output_size; i++)
561+ {
562+ jpg_comp_DUT->output_byte (compression_results, i);
563+
564+ dbgprint (" Data_returned compression_result: %0d" , *(compression_results + i));
565+
566+ local_count++;
567+
568+ if ((local_count == 8 ))
569+ {
570+ local_results = reinterpret_cast <unsigned char *>(compression_results + (local_group_count * 8 * sizeof (char )));
571+ dbgprint (" Before doing a write in TB" );
572+ sanity_check_address (IMG_COMPRESSED + (local_group_count * 8 * sizeof (char )), IMG_COMPRESSED, IMG_COMPRESSED + IMG_COMPRESSED_SZ);
573+ memory_initiator->write (local_results, IMG_COMPRESSED + (local_group_count * 8 * sizeof (char )), 8 * sizeof (char ));
574+ dbgprint (" After doing a write in TB" );
575+ local_count = 0 ;
576+ local_group_count++;
577+ }
578+
579+ }
580+
581+ dbgprint (" Finished with the compression of the image" );
582+
509583 imwrite (" grayImagePrevMem.jpg" , grayImagePrevMem);
510584 imwrite (" grayImageAfterMem.jpg" , grayImageAfterMem);
511585 imwrite (" filteredImagePrevMem.jpg" , filteredImagePrevMem);
0 commit comments