module.cc (13091:81fceed26e1e) | module.cc (13191:a2254693aa5b) |
---|---|
1/* 2 * Copyright 2018 Google, Inc. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer; 8 * redistributions in binary form must reproduce the above copyright --- 18 unchanged lines hidden (view full) --- 27 * Authors: Gabe Black 28 */ 29 30#include "systemc/core/module.hh" 31 32#include <cassert> 33 34#include "base/logging.hh" | 1/* 2 * Copyright 2018 Google, Inc. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer; 8 * redistributions in binary form must reproduce the above copyright --- 18 unchanged lines hidden (view full) --- 27 * Authors: Gabe Black 28 */ 29 30#include "systemc/core/module.hh" 31 32#include <cassert> 33 34#include "base/logging.hh" |
35#include "systemc/ext/core/sc_export.hh" |
|
35#include "systemc/ext/core/sc_port.hh" 36#include "systemc/ext/utils/sc_report_handler.hh" 37 38namespace sc_gem5 39{ 40 41namespace 42{ 43 44std::list<Module *> _modules; 45Module *_new_module; 46 47Module *_callbackModule = nullptr; 48 49} // anonymous namespace 50 | 36#include "systemc/ext/core/sc_port.hh" 37#include "systemc/ext/utils/sc_report_handler.hh" 38 39namespace sc_gem5 40{ 41 42namespace 43{ 44 45std::list<Module *> _modules; 46Module *_new_module; 47 48Module *_callbackModule = nullptr; 49 50} // anonymous namespace 51 |
51Module::Module(const char *name) : _name(name), _sc_mod(nullptr), _obj(nullptr) | 52Module::Module(const char *name) : 53 _name(name), _sc_mod(nullptr), _obj(nullptr), _ended(false), 54 _deprecatedConstructor(false) |
52{ 53 panic_if(_new_module, "Previous module not finished.\n"); 54 _new_module = this; 55} 56 57Module::~Module() 58{ 59 if (_new_module == this) { --- 40 unchanged lines hidden (view full) --- 100 auto port = *portIt; 101 if (proxy->interface()) 102 port->vbind(*proxy->interface()); 103 else 104 port->vbind(*proxy->port()); 105 } 106} 107 | 55{ 56 panic_if(_new_module, "Previous module not finished.\n"); 57 _new_module = this; 58} 59 60Module::~Module() 61{ 62 if (_new_module == this) { --- 40 unchanged lines hidden (view full) --- 103 auto port = *portIt; 104 if (proxy->interface()) 105 port->vbind(*proxy->interface()); 106 else 107 port->vbind(*proxy->port()); 108 } 109} 110 |
111void 112Module::beforeEndOfElaboration() 113{ 114 callbackModule(this); 115 _sc_mod->before_end_of_elaboration(); 116 for (auto p: ports) 117 p->before_end_of_elaboration(); 118 for (auto e: exports) 119 e->before_end_of_elaboration(); 120 callbackModule(nullptr); 121} 122 123void 124Module::endOfElaboration() 125{ 126 if (_deprecatedConstructor && !_ended) { 127 std::string msg = csprintf("module '%s'", name()); 128 SC_REPORT_WARNING("(W509) module construction not properly completed: " 129 "did you forget to add a sc_module_name parameter to " 130 "your module constructor?", msg.c_str()); 131 } 132 callbackModule(this); 133 _sc_mod->end_of_elaboration(); 134 for (auto p: ports) 135 p->end_of_elaboration(); 136 for (auto e: exports) 137 e->end_of_elaboration(); 138 callbackModule(nullptr); 139} 140 141void 142Module::startOfSimulation() 143{ 144 callbackModule(this); 145 _sc_mod->start_of_simulation(); 146 for (auto p: ports) 147 p->start_of_simulation(); 148 for (auto e: exports) 149 e->start_of_simulation(); 150 callbackModule(nullptr); 151} 152 153void 154Module::endOfSimulation() 155{ 156 callbackModule(this); 157 _sc_mod->end_of_simulation(); 158 for (auto p: ports) 159 p->end_of_simulation(); 160 for (auto e: exports) 161 e->end_of_simulation(); 162 callbackModule(nullptr); 163} 164 |
|
108Module * 109currentModule() 110{ 111 if (_modules.empty()) 112 return nullptr; 113 return _modules.back(); 114} 115 --- 23 unchanged lines hidden --- | 165Module * 166currentModule() 167{ 168 if (_modules.empty()) 169 return nullptr; 170 return _modules.back(); 171} 172 --- 23 unchanged lines hidden --- |