#define SC_INCLUDE_DYNAMIC_PROCESSES #include "systemc" #include "tlm.h" #include "tlm_utils/simple_initiator_socket.h" #include "tlm_utils/simple_target_socket.h" #include #include "CPU.h" #include "Memory.h" using namespace sc_core; using namespace sc_dt; using namespace std; string filename; SC_MODULE(Top) { //Initiator *initiator; CPU *cpu; Memory *InstrMemory; Memory *DataMemory; sc_signal IRQ; SC_CTOR(Top) { cpu = new CPU("cpu"); InstrMemory = new Memory("InstrMemory", filename); DataMemory = new Memory("Datamemory", false); cpu->instr_bus.bind(InstrMemory->socket); cpu->exec->data_bus.bind(DataMemory->socket); //cpu->interrupt.bind(IRQ); } ~Top() { cout << "Top destructor" << endl; delete cpu; delete InstrMemory; delete DataMemory; } }; Top *top; void intHandler(int dummy) { delete top; //sc_stop(); exit(-1); } int sc_main(int argc, char* argv[]) { signal(SIGINT, intHandler); if (argv[1] == nullptr) { cerr << "Filename needed for hex memory" << endl; return -1; } filename = argv[1]; top = new Top("top"); sc_start(); return 0; }