1515#include < csignal>
1616#include < unistd.h>
1717#include < chrono>
18-
19- #include " address_map.hpp"
2018#include " CPU.h"
2119#include " Memory.h"
2220#include " BusCtrl.h"
3129#include " inc/stb_image_write.h"
3230
3331// Our modules
32+ #include " address_map.hpp"
3433#include " ips_filter_tlm.hpp"
35- #include " sobel_edge_detector_tlm.cpp"
34+ #include " sobel_edge_detector_tlm.hpp"
35+ #include " img_receiver_tlm.hpp"
36+ #include " img_transmiter_tlm.hpp"
3637
3738std::string filename;
3839bool debug_session = false ;
@@ -53,6 +54,9 @@ SC_MODULE(Simulator) {
5354
5455 // Our modules
5556 ips_filter_tlm *filter_DUT;
57+ sobel_edge_detector_tlm *sobel_edge_detector_DUT;
58+ img_receiver_tlm *receiver_DUT;
59+ img_transmiter_tlm *transmiter_DUT;
5660
5761
5862 SC_CTOR (Simulator) {
@@ -69,7 +73,9 @@ SC_MODULE(Simulator) {
6973
7074 // Our modules
7175 filter_DUT = new ips_filter_tlm (" filter_DUT" );
72-
76+ sobel_edge_detector_DUT = new sobel_edge_detector_tlm (" sobel_edge_detector_DUT" );
77+ receiver_DUT = new img_receiver_tlm (" receiver_DUT" );
78+ transmiter_DUT = new img_transmiter_tlm (" transmiter_DUT" );
7379
7480 cpu->instr_bus .bind (Bus->cpu_instr_socket );
7581 cpu->mem_intf ->data_bus .bind (Bus->cpu_data_socket );
@@ -81,13 +87,15 @@ SC_MODULE(Simulator) {
8187 timer->irq_line .bind (cpu->irq_line_socket );
8288
8389 // Our modules
84- Bus->filter_socket .bind (filter_DUT->socket );
90+ Bus->filter_socket .bind (filter_DUT->socket );
91+ Bus->sobel_edge_detector_socket .bind (sobel_edge_detector_DUT->socket );
92+
93+ Bus->receiver_socket .bind (receiver_DUT->socket );
94+ Bus->transmiter_socket .bind (transmiter_DUT->socket );
8595
8696 if (debug_session) {
8797 Debug debug (cpu, MainMemory);
8898 }
89-
90- pre_load_memory ();
9199 }
92100
93101 ~Simulator () {
@@ -98,19 +106,16 @@ SC_MODULE(Simulator) {
98106 delete timer;
99107 }
100108
101- void pre_load_memory ()
109+ void load_img_from_memory ()
102110 {
103111 int width, height, channels, pixel_count;
104112 unsigned char *noisy_img, *noisy_img2;
105113
106114 noisy_img = stbi_load (" inputs/car_noisy_image.png" , &width, &height, &channels, 0 );
107115 pixel_count = width * height * channels;
108116 printf (" Pixel Count %0d, Width: %0d, Height: %0d \n " , pixel_count, width, height);
109-
110- noisy_img2 = new unsigned char [pixel_count];
111117
112- MainMemory->backdoor_write (noisy_img, pixel_count, INPUT_IMG_MEMORY_LO);
113- // stbi_write_png("outputs/car_filtered_image.png", width, height, channels, noisy_img, width*channels);
118+ receiver_DUT->backdoor_write (noisy_img, pixel_count, IMG_INPUT_ADDRESS_LO);
114119 }
115120
116121 void save_img_from_memory ()
@@ -122,7 +127,7 @@ SC_MODULE(Simulator) {
122127 width = 640 ;
123128 height = 452 ;
124129 pixel_count = width * height * channels;
125- MainMemory ->backdoor_read (img_ptr, pixel_count, OUTPUT_IMG_MEMORY_LO );
130+ transmiter_DUT ->backdoor_read (img_ptr, pixel_count, IMG_OUTPUT_ADDRESS_LO );
126131
127132 stbi_write_png (" outputs/car_filtered_image.png" , width, height, channels, img_ptr, width*channels);
128133 }
@@ -209,6 +214,8 @@ int sc_main(int argc, char *argv[]) {
209214
210215 top = new Simulator (" top" );
211216
217+ top->load_img_from_memory ();
218+
212219 auto start = std::chrono::steady_clock::now ();
213220 sc_core::sc_start ();
214221 auto end = std::chrono::steady_clock::now ();
0 commit comments