sc_object.cpp revision 12027
112027Sjungma@eit.uni-kl.de/***************************************************************************** 212027Sjungma@eit.uni-kl.de 312027Sjungma@eit.uni-kl.de Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 412027Sjungma@eit.uni-kl.de more contributor license agreements. See the NOTICE file distributed 512027Sjungma@eit.uni-kl.de with this work for additional information regarding copyright ownership. 612027Sjungma@eit.uni-kl.de Accellera licenses this file to you under the Apache License, Version 2.0 712027Sjungma@eit.uni-kl.de (the "License"); you may not use this file except in compliance with the 812027Sjungma@eit.uni-kl.de License. You may obtain a copy of the License at 912027Sjungma@eit.uni-kl.de 1012027Sjungma@eit.uni-kl.de http://www.apache.org/licenses/LICENSE-2.0 1112027Sjungma@eit.uni-kl.de 1212027Sjungma@eit.uni-kl.de Unless required by applicable law or agreed to in writing, software 1312027Sjungma@eit.uni-kl.de distributed under the License is distributed on an "AS IS" BASIS, 1412027Sjungma@eit.uni-kl.de WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 1512027Sjungma@eit.uni-kl.de implied. See the License for the specific language governing 1612027Sjungma@eit.uni-kl.de permissions and limitations under the License. 1712027Sjungma@eit.uni-kl.de 1812027Sjungma@eit.uni-kl.de *****************************************************************************/ 1912027Sjungma@eit.uni-kl.de 2012027Sjungma@eit.uni-kl.de/***************************************************************************** 2112027Sjungma@eit.uni-kl.de 2212027Sjungma@eit.uni-kl.de sc_object.cpp -- Abstract base class of all SystemC objects. 2312027Sjungma@eit.uni-kl.de 2412027Sjungma@eit.uni-kl.de Original Author: Stan Y. Liao, Synopsys, Inc. 2512027Sjungma@eit.uni-kl.de 2612027Sjungma@eit.uni-kl.de CHANGE LOG AT THE END OF THE FILE 2712027Sjungma@eit.uni-kl.de *****************************************************************************/ 2812027Sjungma@eit.uni-kl.de 2912027Sjungma@eit.uni-kl.de 3012027Sjungma@eit.uni-kl.de#include <cstdlib> 3112027Sjungma@eit.uni-kl.de#include <cassert> 3212027Sjungma@eit.uni-kl.de#include <stddef.h> 3312027Sjungma@eit.uni-kl.de#include <cstdio> 3412027Sjungma@eit.uni-kl.de#include <string.h> 3512027Sjungma@eit.uni-kl.de#include <ctype.h> 3612027Sjungma@eit.uni-kl.de 3712027Sjungma@eit.uni-kl.de#include "sysc/kernel/sc_externs.h" 3812027Sjungma@eit.uni-kl.de#include "sysc/kernel/sc_kernel_ids.h" 3912027Sjungma@eit.uni-kl.de#include "sysc/kernel/sc_module.h" 4012027Sjungma@eit.uni-kl.de#include "sysc/kernel/sc_object.h" 4112027Sjungma@eit.uni-kl.de#include "sysc/kernel/sc_object_manager.h" 4212027Sjungma@eit.uni-kl.de#include "sysc/kernel/sc_phase_callback_registry.h" 4312027Sjungma@eit.uni-kl.de#include "sysc/kernel/sc_process_handle.h" 4412027Sjungma@eit.uni-kl.de#include "sysc/kernel/sc_simcontext.h" 4512027Sjungma@eit.uni-kl.de#include "sysc/kernel/sc_event.h" 4612027Sjungma@eit.uni-kl.de#include "sysc/utils/sc_hash.h" 4712027Sjungma@eit.uni-kl.de#include "sysc/utils/sc_iostream.h" 4812027Sjungma@eit.uni-kl.de#include "sysc/utils/sc_list.h" 4912027Sjungma@eit.uni-kl.de#include "sysc/utils/sc_utils_ids.h" 5012027Sjungma@eit.uni-kl.de#include "sysc/utils/sc_mempool.h" 5112027Sjungma@eit.uni-kl.de 5212027Sjungma@eit.uni-kl.denamespace sc_core { 5312027Sjungma@eit.uni-kl.de 5412027Sjungma@eit.uni-kl.detypedef int (*STRCMP)(const void*, const void*); 5512027Sjungma@eit.uni-kl.de 5612027Sjungma@eit.uni-kl.deconst char SC_HIERARCHY_CHAR = '.'; 5712027Sjungma@eit.uni-kl.de 5812027Sjungma@eit.uni-kl.de/* This will be gotten rid after multiple-processes 5912027Sjungma@eit.uni-kl.de are implemented. This is to fix some regression 6012027Sjungma@eit.uni-kl.de problems. */ 6112027Sjungma@eit.uni-kl.debool sc_enable_name_checking = true; 6212027Sjungma@eit.uni-kl.de 6312027Sjungma@eit.uni-kl.de 6412027Sjungma@eit.uni-kl.de// ---------------------------------------------------------------------------- 6512027Sjungma@eit.uni-kl.de// CLASS : sc_object 6612027Sjungma@eit.uni-kl.de// 6712027Sjungma@eit.uni-kl.de// Abstract base class of all SystemC `simulation' objects. 6812027Sjungma@eit.uni-kl.de// ---------------------------------------------------------------------------- 6912027Sjungma@eit.uni-kl.de 7012027Sjungma@eit.uni-kl.devoid 7112027Sjungma@eit.uni-kl.desc_object::add_child_event( sc_event* event_p ) 7212027Sjungma@eit.uni-kl.de{ 7312027Sjungma@eit.uni-kl.de // no check if event_p is already in the set 7412027Sjungma@eit.uni-kl.de m_child_events.push_back( event_p ); 7512027Sjungma@eit.uni-kl.de} 7612027Sjungma@eit.uni-kl.de 7712027Sjungma@eit.uni-kl.devoid 7812027Sjungma@eit.uni-kl.desc_object::add_child_object( sc_object* object_ ) 7912027Sjungma@eit.uni-kl.de{ 8012027Sjungma@eit.uni-kl.de // no check if object_ is already in the set 8112027Sjungma@eit.uni-kl.de m_child_objects.push_back( object_ ); 8212027Sjungma@eit.uni-kl.de} 8312027Sjungma@eit.uni-kl.de 8412027Sjungma@eit.uni-kl.deconst char* 8512027Sjungma@eit.uni-kl.desc_object::basename() const 8612027Sjungma@eit.uni-kl.de{ 8712027Sjungma@eit.uni-kl.de size_t pos; // position of last SC_HIERARCHY_CHAR. 8812027Sjungma@eit.uni-kl.de pos = m_name.rfind( (char)SC_HIERARCHY_CHAR ); 8912027Sjungma@eit.uni-kl.de return ( pos == m_name.npos ) ? m_name.c_str() : &(m_name.c_str()[pos+1]); 9012027Sjungma@eit.uni-kl.de} 9112027Sjungma@eit.uni-kl.de 9212027Sjungma@eit.uni-kl.devoid 9312027Sjungma@eit.uni-kl.desc_object::print(::std::ostream& os) const 9412027Sjungma@eit.uni-kl.de{ 9512027Sjungma@eit.uni-kl.de os << name(); 9612027Sjungma@eit.uni-kl.de} 9712027Sjungma@eit.uni-kl.de 9812027Sjungma@eit.uni-kl.devoid 9912027Sjungma@eit.uni-kl.desc_object::dump(::std::ostream& os) const 10012027Sjungma@eit.uni-kl.de{ 10112027Sjungma@eit.uni-kl.de os << "name = " << name() << "\n"; 10212027Sjungma@eit.uni-kl.de os << "kind = " << kind() << "\n"; 10312027Sjungma@eit.uni-kl.de} 10412027Sjungma@eit.uni-kl.de 10512027Sjungma@eit.uni-kl.destatic int sc_object_num = 0; 10612027Sjungma@eit.uni-kl.de 10712027Sjungma@eit.uni-kl.destatic std::string 10812027Sjungma@eit.uni-kl.desc_object_newname() 10912027Sjungma@eit.uni-kl.de{ 11012027Sjungma@eit.uni-kl.de char buffer[64]; 11112027Sjungma@eit.uni-kl.de std::string result; 11212027Sjungma@eit.uni-kl.de 11312027Sjungma@eit.uni-kl.de std::sprintf(buffer, "{%d}", sc_object_num); 11412027Sjungma@eit.uni-kl.de sc_object_num++; 11512027Sjungma@eit.uni-kl.de result = buffer; 11612027Sjungma@eit.uni-kl.de 11712027Sjungma@eit.uni-kl.de return result; 11812027Sjungma@eit.uni-kl.de} 11912027Sjungma@eit.uni-kl.de 12012027Sjungma@eit.uni-kl.de// +---------------------------------------------------------------------------- 12112027Sjungma@eit.uni-kl.de// |"sc_object::remove_child_event" 12212027Sjungma@eit.uni-kl.de// | 12312027Sjungma@eit.uni-kl.de// | This virtual method removes the supplied event from the list of child 12412027Sjungma@eit.uni-kl.de// | events if it is present. 12512027Sjungma@eit.uni-kl.de// | 12612027Sjungma@eit.uni-kl.de// | Arguments: 12712027Sjungma@eit.uni-kl.de// | event_p -> event to be removed. 12812027Sjungma@eit.uni-kl.de// | Returns true if the event was present, false if not. 12912027Sjungma@eit.uni-kl.de// +---------------------------------------------------------------------------- 13012027Sjungma@eit.uni-kl.debool 13112027Sjungma@eit.uni-kl.desc_object::remove_child_event( sc_event* event_p ) 13212027Sjungma@eit.uni-kl.de{ 13312027Sjungma@eit.uni-kl.de int size = m_child_events.size(); 13412027Sjungma@eit.uni-kl.de for( int i = 0; i < size; ++ i ) { 13512027Sjungma@eit.uni-kl.de if( event_p == m_child_events[i] ) { 13612027Sjungma@eit.uni-kl.de m_child_events[i] = m_child_events[size - 1]; 13712027Sjungma@eit.uni-kl.de m_child_events.pop_back(); 13812027Sjungma@eit.uni-kl.de return true; 13912027Sjungma@eit.uni-kl.de } 14012027Sjungma@eit.uni-kl.de } 14112027Sjungma@eit.uni-kl.de return false; 14212027Sjungma@eit.uni-kl.de} 14312027Sjungma@eit.uni-kl.de 14412027Sjungma@eit.uni-kl.de// +---------------------------------------------------------------------------- 14512027Sjungma@eit.uni-kl.de// |"sc_object::remove_child_object" 14612027Sjungma@eit.uni-kl.de// | 14712027Sjungma@eit.uni-kl.de// | This virtual method removes the supplied object from the list of child 14812027Sjungma@eit.uni-kl.de// | objects if it is present. 14912027Sjungma@eit.uni-kl.de// | 15012027Sjungma@eit.uni-kl.de// | Arguments: 15112027Sjungma@eit.uni-kl.de// | object_p -> object to be removed. 15212027Sjungma@eit.uni-kl.de// | Returns true if the object was present, false if not. 15312027Sjungma@eit.uni-kl.de// +---------------------------------------------------------------------------- 15412027Sjungma@eit.uni-kl.debool 15512027Sjungma@eit.uni-kl.desc_object::remove_child_object( sc_object* object_p ) 15612027Sjungma@eit.uni-kl.de{ 15712027Sjungma@eit.uni-kl.de int size = m_child_objects.size(); 15812027Sjungma@eit.uni-kl.de for( int i = 0; i < size; ++ i ) { 15912027Sjungma@eit.uni-kl.de if( object_p == m_child_objects[i] ) { 16012027Sjungma@eit.uni-kl.de m_child_objects[i] = m_child_objects[size - 1]; 16112027Sjungma@eit.uni-kl.de m_child_objects.pop_back(); 16212027Sjungma@eit.uni-kl.de object_p->m_parent = NULL; 16312027Sjungma@eit.uni-kl.de return true; 16412027Sjungma@eit.uni-kl.de } 16512027Sjungma@eit.uni-kl.de } 16612027Sjungma@eit.uni-kl.de return false; 16712027Sjungma@eit.uni-kl.de} 16812027Sjungma@eit.uni-kl.de 16912027Sjungma@eit.uni-kl.de// +---------------------------------------------------------------------------- 17012027Sjungma@eit.uni-kl.de// |"sc_object::sc_object_init" 17112027Sjungma@eit.uni-kl.de// | 17212027Sjungma@eit.uni-kl.de// | This method initializes this object instance and places it in to the 17312027Sjungma@eit.uni-kl.de// | object hierarchy if the supplied name is not NULL. 17412027Sjungma@eit.uni-kl.de// | 17512027Sjungma@eit.uni-kl.de// | Arguments: 17612027Sjungma@eit.uni-kl.de// | nm = leaf name for the object. 17712027Sjungma@eit.uni-kl.de// +---------------------------------------------------------------------------- 17812027Sjungma@eit.uni-kl.devoid 17912027Sjungma@eit.uni-kl.desc_object::sc_object_init(const char* nm) 18012027Sjungma@eit.uni-kl.de{ 18112027Sjungma@eit.uni-kl.de // SET UP POINTERS TO OBJECT MANAGER, PARENT, AND SIMULATION CONTEXT: 18212027Sjungma@eit.uni-kl.de // 18312027Sjungma@eit.uni-kl.de // Make the current simcontext the simcontext for this object 18412027Sjungma@eit.uni-kl.de 18512027Sjungma@eit.uni-kl.de m_simc = sc_get_curr_simcontext(); 18612027Sjungma@eit.uni-kl.de m_attr_cltn_p = 0; 18712027Sjungma@eit.uni-kl.de sc_object_manager* object_manager = m_simc->get_object_manager(); 18812027Sjungma@eit.uni-kl.de m_parent = m_simc->active_object(); 18912027Sjungma@eit.uni-kl.de 19012027Sjungma@eit.uni-kl.de // CONSTRUCT PATHNAME TO OBJECT BEING CREATED: 19112027Sjungma@eit.uni-kl.de // 19212027Sjungma@eit.uni-kl.de // If there is not a leaf name generate one. 19312027Sjungma@eit.uni-kl.de 19412027Sjungma@eit.uni-kl.de m_name = object_manager->create_name(nm ? nm : sc_object_newname().c_str()); 19512027Sjungma@eit.uni-kl.de 19612027Sjungma@eit.uni-kl.de 19712027Sjungma@eit.uni-kl.de // PLACE THE OBJECT INTO THE HIERARCHY 19812027Sjungma@eit.uni-kl.de 19912027Sjungma@eit.uni-kl.de object_manager->insert_object(m_name, this); 20012027Sjungma@eit.uni-kl.de if ( m_parent ) 20112027Sjungma@eit.uni-kl.de m_parent->add_child_object( this ); 20212027Sjungma@eit.uni-kl.de else 20312027Sjungma@eit.uni-kl.de m_simc->add_child_object( this ); 20412027Sjungma@eit.uni-kl.de} 20512027Sjungma@eit.uni-kl.de 20612027Sjungma@eit.uni-kl.desc_object::sc_object() : 20712027Sjungma@eit.uni-kl.de m_attr_cltn_p(0), m_child_events(), m_child_objects(), m_name(), 20812027Sjungma@eit.uni-kl.de m_parent(0), m_simc(0) 20912027Sjungma@eit.uni-kl.de{ 21012027Sjungma@eit.uni-kl.de sc_object_init( sc_gen_unique_name("object") ); 21112027Sjungma@eit.uni-kl.de} 21212027Sjungma@eit.uni-kl.de 21312027Sjungma@eit.uni-kl.desc_object::sc_object( const sc_object& that ) : 21412027Sjungma@eit.uni-kl.de m_attr_cltn_p(0), m_child_events(), m_child_objects(), m_name(), 21512027Sjungma@eit.uni-kl.de m_parent(0), m_simc(0) 21612027Sjungma@eit.uni-kl.de{ 21712027Sjungma@eit.uni-kl.de sc_object_init( sc_gen_unique_name( that.basename() ) ); 21812027Sjungma@eit.uni-kl.de} 21912027Sjungma@eit.uni-kl.de 22012027Sjungma@eit.uni-kl.de 22112027Sjungma@eit.uni-kl.destatic bool 22212027Sjungma@eit.uni-kl.deobject_name_illegal_char(char ch) 22312027Sjungma@eit.uni-kl.de{ 22412027Sjungma@eit.uni-kl.de return (ch == SC_HIERARCHY_CHAR) || isspace(ch); 22512027Sjungma@eit.uni-kl.de} 22612027Sjungma@eit.uni-kl.de 22712027Sjungma@eit.uni-kl.desc_object::sc_object(const char* nm) : 22812027Sjungma@eit.uni-kl.de m_attr_cltn_p(0), m_child_events(), m_child_objects(), m_name(), 22912027Sjungma@eit.uni-kl.de m_parent(0), m_simc(0) 23012027Sjungma@eit.uni-kl.de{ 23112027Sjungma@eit.uni-kl.de int namebuf_alloc = 0; 23212027Sjungma@eit.uni-kl.de char* namebuf = 0; 23312027Sjungma@eit.uni-kl.de const char* p; 23412027Sjungma@eit.uni-kl.de 23512027Sjungma@eit.uni-kl.de // null name or "" uses machine generated name. 23612027Sjungma@eit.uni-kl.de 23712027Sjungma@eit.uni-kl.de if ( !nm || !*nm ) 23812027Sjungma@eit.uni-kl.de nm = sc_gen_unique_name("object"); 23912027Sjungma@eit.uni-kl.de p = nm; 24012027Sjungma@eit.uni-kl.de 24112027Sjungma@eit.uni-kl.de if (nm && sc_enable_name_checking) { 24212027Sjungma@eit.uni-kl.de namebuf_alloc = 1 + strlen(nm); 24312027Sjungma@eit.uni-kl.de namebuf = (char*) sc_mempool::allocate(namebuf_alloc); 24412027Sjungma@eit.uni-kl.de char* q = namebuf; 24512027Sjungma@eit.uni-kl.de const char* r = nm; 24612027Sjungma@eit.uni-kl.de bool has_illegal_char = false; 24712027Sjungma@eit.uni-kl.de while (*r) { 24812027Sjungma@eit.uni-kl.de if (object_name_illegal_char(*r)) { 24912027Sjungma@eit.uni-kl.de has_illegal_char = true; 25012027Sjungma@eit.uni-kl.de *q = '_'; 25112027Sjungma@eit.uni-kl.de } else { 25212027Sjungma@eit.uni-kl.de *q = *r; 25312027Sjungma@eit.uni-kl.de } 25412027Sjungma@eit.uni-kl.de r++; 25512027Sjungma@eit.uni-kl.de q++; 25612027Sjungma@eit.uni-kl.de } 25712027Sjungma@eit.uni-kl.de *q = '\0'; 25812027Sjungma@eit.uni-kl.de p = namebuf; 25912027Sjungma@eit.uni-kl.de if (has_illegal_char) 26012027Sjungma@eit.uni-kl.de { 26112027Sjungma@eit.uni-kl.de std::string message = nm; 26212027Sjungma@eit.uni-kl.de message += " substituted by "; 26312027Sjungma@eit.uni-kl.de message += namebuf; 26412027Sjungma@eit.uni-kl.de SC_REPORT_WARNING( SC_ID_ILLEGAL_CHARACTERS_, message.c_str()); 26512027Sjungma@eit.uni-kl.de } 26612027Sjungma@eit.uni-kl.de } 26712027Sjungma@eit.uni-kl.de sc_object_init(p); 26812027Sjungma@eit.uni-kl.de sc_mempool::release( namebuf, namebuf_alloc ); 26912027Sjungma@eit.uni-kl.de} 27012027Sjungma@eit.uni-kl.de 27112027Sjungma@eit.uni-kl.desc_object::~sc_object() 27212027Sjungma@eit.uni-kl.de{ 27312027Sjungma@eit.uni-kl.de#if SC_HAS_PHASE_CALLBACKS_ 27412027Sjungma@eit.uni-kl.de unregister_simulation_phase_callback( SC_STATUS_ANY ); 27512027Sjungma@eit.uni-kl.de#endif 27612027Sjungma@eit.uni-kl.de detach(); 27712027Sjungma@eit.uni-kl.de delete m_attr_cltn_p; 27812027Sjungma@eit.uni-kl.de} 27912027Sjungma@eit.uni-kl.de 28012027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------ 28112027Sjungma@eit.uni-kl.de//"sc_object::detach" 28212027Sjungma@eit.uni-kl.de// 28312027Sjungma@eit.uni-kl.de// This method detaches this object instance from the object hierarchy. 28412027Sjungma@eit.uni-kl.de// It is called in two places: ~sc_object() and sc_process_b::kill_process(). 28512027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------ 28612027Sjungma@eit.uni-kl.devoid sc_object::detach() 28712027Sjungma@eit.uni-kl.de{ 28812027Sjungma@eit.uni-kl.de if (m_simc) { 28912027Sjungma@eit.uni-kl.de 29012027Sjungma@eit.uni-kl.de // REMOVE OBJECT FROM THE OBJECT MANAGER: 29112027Sjungma@eit.uni-kl.de 29212027Sjungma@eit.uni-kl.de sc_object_manager* object_manager = m_simc->get_object_manager(); 29312027Sjungma@eit.uni-kl.de object_manager->remove_object(m_name); 29412027Sjungma@eit.uni-kl.de 29512027Sjungma@eit.uni-kl.de // REMOVE OBJECT FROM PARENT'S LIST OF OBJECTS: 29612027Sjungma@eit.uni-kl.de 29712027Sjungma@eit.uni-kl.de if ( m_parent ) 29812027Sjungma@eit.uni-kl.de m_parent->remove_child_object( this ); 29912027Sjungma@eit.uni-kl.de else 30012027Sjungma@eit.uni-kl.de m_simc->remove_child_object( this ); 30112027Sjungma@eit.uni-kl.de 30212027Sjungma@eit.uni-kl.de // ORPHAN THIS OBJECT'S CHILDREN: 30312027Sjungma@eit.uni-kl.de 30412027Sjungma@eit.uni-kl.de#if 0 // #### 30512027Sjungma@eit.uni-kl.de ::std::<sc_object*> children_p = &get_child_objects(); 30612027Sjungma@eit.uni-kl.de int child_n = children_p->size(); 30712027Sjungma@eit.uni-kl.de sc_object* parent_p; 30812027Sjungma@eit.uni-kl.de 30912027Sjungma@eit.uni-kl.de for ( int child_i = 0; child_i < child_n; child_i++ ) 31012027Sjungma@eit.uni-kl.de { 31112027Sjungma@eit.uni-kl.de (*children_p)[child_i]->m_parent = 0; 31212027Sjungma@eit.uni-kl.de } 31312027Sjungma@eit.uni-kl.de#endif 31412027Sjungma@eit.uni-kl.de 31512027Sjungma@eit.uni-kl.de } 31612027Sjungma@eit.uni-kl.de} 31712027Sjungma@eit.uni-kl.de 31812027Sjungma@eit.uni-kl.de// +---------------------------------------------------------------------------- 31912027Sjungma@eit.uni-kl.de// |"sc_object::orphan_child_events" 32012027Sjungma@eit.uni-kl.de// | 32112027Sjungma@eit.uni-kl.de// | This method moves the children of this object instance to be children 32212027Sjungma@eit.uni-kl.de// | of the simulator. 32312027Sjungma@eit.uni-kl.de// +---------------------------------------------------------------------------- 32412027Sjungma@eit.uni-kl.devoid sc_object::orphan_child_events() 32512027Sjungma@eit.uni-kl.de{ 32612027Sjungma@eit.uni-kl.de std::vector< sc_event* > const & events = get_child_events(); 32712027Sjungma@eit.uni-kl.de 32812027Sjungma@eit.uni-kl.de std::vector< sc_event* >::const_iterator 32912027Sjungma@eit.uni-kl.de it = events.begin(), end = events.end(); 33012027Sjungma@eit.uni-kl.de 33112027Sjungma@eit.uni-kl.de for( ; it != end; ++it ) 33212027Sjungma@eit.uni-kl.de { 33312027Sjungma@eit.uni-kl.de (*it)->m_parent_p = NULL; 33412027Sjungma@eit.uni-kl.de simcontext()->add_child_event(*it); 33512027Sjungma@eit.uni-kl.de } 33612027Sjungma@eit.uni-kl.de} 33712027Sjungma@eit.uni-kl.de 33812027Sjungma@eit.uni-kl.de// +---------------------------------------------------------------------------- 33912027Sjungma@eit.uni-kl.de// |"sc_object::orphan_child_objects" 34012027Sjungma@eit.uni-kl.de// | 34112027Sjungma@eit.uni-kl.de// | This method moves the children of this object instance to be children 34212027Sjungma@eit.uni-kl.de// | of the simulator. 34312027Sjungma@eit.uni-kl.de// +---------------------------------------------------------------------------- 34412027Sjungma@eit.uni-kl.devoid sc_object::orphan_child_objects() 34512027Sjungma@eit.uni-kl.de{ 34612027Sjungma@eit.uni-kl.de std::vector< sc_object* > const & children = get_child_objects(); 34712027Sjungma@eit.uni-kl.de 34812027Sjungma@eit.uni-kl.de std::vector< sc_object* >::const_iterator 34912027Sjungma@eit.uni-kl.de it = children.begin(), end = children.end(); 35012027Sjungma@eit.uni-kl.de 35112027Sjungma@eit.uni-kl.de for( ; it != end; ++it ) 35212027Sjungma@eit.uni-kl.de { 35312027Sjungma@eit.uni-kl.de (*it)->m_parent = NULL; 35412027Sjungma@eit.uni-kl.de simcontext()->add_child_object(*it); 35512027Sjungma@eit.uni-kl.de } 35612027Sjungma@eit.uni-kl.de} 35712027Sjungma@eit.uni-kl.de 35812027Sjungma@eit.uni-kl.devoid 35912027Sjungma@eit.uni-kl.desc_object::trace( sc_trace_file * /* unused */) const 36012027Sjungma@eit.uni-kl.de{ 36112027Sjungma@eit.uni-kl.de /* This space is intentionally left blank */ 36212027Sjungma@eit.uni-kl.de} 36312027Sjungma@eit.uni-kl.de 36412027Sjungma@eit.uni-kl.de 36512027Sjungma@eit.uni-kl.de// add attribute 36612027Sjungma@eit.uni-kl.de 36712027Sjungma@eit.uni-kl.debool 36812027Sjungma@eit.uni-kl.desc_object::add_attribute( sc_attr_base& attribute_ ) 36912027Sjungma@eit.uni-kl.de{ 37012027Sjungma@eit.uni-kl.de if ( !m_attr_cltn_p ) m_attr_cltn_p = new sc_attr_cltn; 37112027Sjungma@eit.uni-kl.de return ( m_attr_cltn_p->push_back( &attribute_ ) ); 37212027Sjungma@eit.uni-kl.de} 37312027Sjungma@eit.uni-kl.de 37412027Sjungma@eit.uni-kl.de 37512027Sjungma@eit.uni-kl.de// get attribute by name 37612027Sjungma@eit.uni-kl.de 37712027Sjungma@eit.uni-kl.desc_attr_base* 37812027Sjungma@eit.uni-kl.desc_object::get_attribute( const std::string& name_ ) 37912027Sjungma@eit.uni-kl.de{ 38012027Sjungma@eit.uni-kl.de if ( !m_attr_cltn_p ) m_attr_cltn_p = new sc_attr_cltn; 38112027Sjungma@eit.uni-kl.de return ( (*m_attr_cltn_p)[name_] ); 38212027Sjungma@eit.uni-kl.de} 38312027Sjungma@eit.uni-kl.de 38412027Sjungma@eit.uni-kl.deconst sc_attr_base* 38512027Sjungma@eit.uni-kl.desc_object::get_attribute( const std::string& name_ ) const 38612027Sjungma@eit.uni-kl.de{ 38712027Sjungma@eit.uni-kl.de if ( !m_attr_cltn_p ) m_attr_cltn_p = new sc_attr_cltn; 38812027Sjungma@eit.uni-kl.de return ( (*m_attr_cltn_p)[name_] ); 38912027Sjungma@eit.uni-kl.de} 39012027Sjungma@eit.uni-kl.de 39112027Sjungma@eit.uni-kl.de 39212027Sjungma@eit.uni-kl.de// remove attribute by name 39312027Sjungma@eit.uni-kl.de 39412027Sjungma@eit.uni-kl.desc_attr_base* 39512027Sjungma@eit.uni-kl.desc_object::remove_attribute( const std::string& name_ ) 39612027Sjungma@eit.uni-kl.de{ 39712027Sjungma@eit.uni-kl.de if ( m_attr_cltn_p ) 39812027Sjungma@eit.uni-kl.de return ( m_attr_cltn_p->remove( name_ ) ); 39912027Sjungma@eit.uni-kl.de else 40012027Sjungma@eit.uni-kl.de return 0; 40112027Sjungma@eit.uni-kl.de} 40212027Sjungma@eit.uni-kl.de 40312027Sjungma@eit.uni-kl.de 40412027Sjungma@eit.uni-kl.de// remove all attributes 40512027Sjungma@eit.uni-kl.de 40612027Sjungma@eit.uni-kl.devoid 40712027Sjungma@eit.uni-kl.desc_object::remove_all_attributes() 40812027Sjungma@eit.uni-kl.de{ 40912027Sjungma@eit.uni-kl.de if ( m_attr_cltn_p ) 41012027Sjungma@eit.uni-kl.de m_attr_cltn_p->remove_all(); 41112027Sjungma@eit.uni-kl.de} 41212027Sjungma@eit.uni-kl.de 41312027Sjungma@eit.uni-kl.de 41412027Sjungma@eit.uni-kl.de// get the number of attributes 41512027Sjungma@eit.uni-kl.de 41612027Sjungma@eit.uni-kl.deint 41712027Sjungma@eit.uni-kl.desc_object::num_attributes() const 41812027Sjungma@eit.uni-kl.de{ 41912027Sjungma@eit.uni-kl.de if ( m_attr_cltn_p ) 42012027Sjungma@eit.uni-kl.de return ( m_attr_cltn_p->size() ); 42112027Sjungma@eit.uni-kl.de else 42212027Sjungma@eit.uni-kl.de return 0; 42312027Sjungma@eit.uni-kl.de} 42412027Sjungma@eit.uni-kl.de 42512027Sjungma@eit.uni-kl.de 42612027Sjungma@eit.uni-kl.de// get the attribute collection 42712027Sjungma@eit.uni-kl.de 42812027Sjungma@eit.uni-kl.desc_attr_cltn& 42912027Sjungma@eit.uni-kl.desc_object::attr_cltn() 43012027Sjungma@eit.uni-kl.de{ 43112027Sjungma@eit.uni-kl.de if ( !m_attr_cltn_p ) m_attr_cltn_p = new sc_attr_cltn; 43212027Sjungma@eit.uni-kl.de return *m_attr_cltn_p; 43312027Sjungma@eit.uni-kl.de} 43412027Sjungma@eit.uni-kl.de 43512027Sjungma@eit.uni-kl.deconst sc_attr_cltn& 43612027Sjungma@eit.uni-kl.desc_object::attr_cltn() const 43712027Sjungma@eit.uni-kl.de{ 43812027Sjungma@eit.uni-kl.de if ( !m_attr_cltn_p ) m_attr_cltn_p = new sc_attr_cltn; 43912027Sjungma@eit.uni-kl.de return *m_attr_cltn_p; 44012027Sjungma@eit.uni-kl.de} 44112027Sjungma@eit.uni-kl.de 44212027Sjungma@eit.uni-kl.desc_object* 44312027Sjungma@eit.uni-kl.desc_object::get_parent() const 44412027Sjungma@eit.uni-kl.de{ 44512027Sjungma@eit.uni-kl.de static bool warn_sc_get_parent_deprecated=true; 44612027Sjungma@eit.uni-kl.de if ( warn_sc_get_parent_deprecated ) 44712027Sjungma@eit.uni-kl.de { 44812027Sjungma@eit.uni-kl.de warn_sc_get_parent_deprecated=false; 44912027Sjungma@eit.uni-kl.de SC_REPORT_INFO(sc_core::SC_ID_IEEE_1666_DEPRECATION_, 45012027Sjungma@eit.uni-kl.de "sc_object::get_parent() is deprecated, " 45112027Sjungma@eit.uni-kl.de "use get_parent_object() instead"); 45212027Sjungma@eit.uni-kl.de } 45312027Sjungma@eit.uni-kl.de return get_parent_object(); 45412027Sjungma@eit.uni-kl.de} 45512027Sjungma@eit.uni-kl.de 45612027Sjungma@eit.uni-kl.de// ---------------------------------------------------------------------------- 45712027Sjungma@eit.uni-kl.de// simulation phase callbacks 45812027Sjungma@eit.uni-kl.de 45912027Sjungma@eit.uni-kl.de 46012027Sjungma@eit.uni-kl.desc_object::phase_cb_mask 46112027Sjungma@eit.uni-kl.desc_object::register_simulation_phase_callback( phase_cb_mask mask ) 46212027Sjungma@eit.uni-kl.de{ 46312027Sjungma@eit.uni-kl.de mask = simcontext()->m_phase_cb_registry 46412027Sjungma@eit.uni-kl.de ->register_callback(*this, mask); 46512027Sjungma@eit.uni-kl.de return mask; 46612027Sjungma@eit.uni-kl.de} 46712027Sjungma@eit.uni-kl.de 46812027Sjungma@eit.uni-kl.de 46912027Sjungma@eit.uni-kl.desc_object::phase_cb_mask 47012027Sjungma@eit.uni-kl.desc_object::unregister_simulation_phase_callback( phase_cb_mask mask ) 47112027Sjungma@eit.uni-kl.de{ 47212027Sjungma@eit.uni-kl.de mask = simcontext()->m_phase_cb_registry 47312027Sjungma@eit.uni-kl.de ->unregister_callback(*this, mask); 47412027Sjungma@eit.uni-kl.de return mask; 47512027Sjungma@eit.uni-kl.de} 47612027Sjungma@eit.uni-kl.de 47712027Sjungma@eit.uni-kl.de 47812027Sjungma@eit.uni-kl.devoid 47912027Sjungma@eit.uni-kl.desc_object::simulation_phase_callback() 48012027Sjungma@eit.uni-kl.de{ 48112027Sjungma@eit.uni-kl.de SC_REPORT_WARNING( SC_ID_PHASE_CALLBACK_NOT_IMPLEMENTED_, name() ); 48212027Sjungma@eit.uni-kl.de} 48312027Sjungma@eit.uni-kl.de 48412027Sjungma@eit.uni-kl.de 48512027Sjungma@eit.uni-kl.de} // namespace sc_core 48612027Sjungma@eit.uni-kl.de 48712027Sjungma@eit.uni-kl.de/***************************************************************************** 48812027Sjungma@eit.uni-kl.de 48912027Sjungma@eit.uni-kl.de MODIFICATION LOG - modifiers, enter your name, affiliation, date and 49012027Sjungma@eit.uni-kl.de changes you are making here. 49112027Sjungma@eit.uni-kl.de 49212027Sjungma@eit.uni-kl.de Name, Affiliation, Date: Bishnupriya Bhattacharya, Cadence Design Systems, 49312027Sjungma@eit.uni-kl.de 25 August, 2003 49412027Sjungma@eit.uni-kl.de Description of Modification: if module name hierarchy is empty, sc_object 49512027Sjungma@eit.uni-kl.de ctor assumes the currently executing process 49612027Sjungma@eit.uni-kl.de as the parent object to support dynamic process 49712027Sjungma@eit.uni-kl.de creation similar to other sc_objects 49812027Sjungma@eit.uni-kl.de 49912027Sjungma@eit.uni-kl.de Name, Affiliation, Date: Andy Goodrich, Forte Design Systems 50012027Sjungma@eit.uni-kl.de 5 September 2003 50112027Sjungma@eit.uni-kl.de Description of Modification: - Made creation of attributes structure 50212027Sjungma@eit.uni-kl.de conditional on its being used. This eliminates 50312027Sjungma@eit.uni-kl.de 100 bytes of storage for each normal sc_object. 50412027Sjungma@eit.uni-kl.de 50512027Sjungma@eit.uni-kl.de *****************************************************************************/ 50612027Sjungma@eit.uni-kl.de 50712027Sjungma@eit.uni-kl.de 50812027Sjungma@eit.uni-kl.de// $Log: sc_object.cpp,v $ 50912027Sjungma@eit.uni-kl.de// Revision 1.16 2011/08/29 18:04:32 acg 51012027Sjungma@eit.uni-kl.de// Philipp A. Hartmann: miscellaneous clean ups. 51112027Sjungma@eit.uni-kl.de// 51212027Sjungma@eit.uni-kl.de// Revision 1.15 2011/08/26 20:46:10 acg 51312027Sjungma@eit.uni-kl.de// Andy Goodrich: moved the modification log to the end of the file to 51412027Sjungma@eit.uni-kl.de// eliminate source line number skew when check-ins are done. 51512027Sjungma@eit.uni-kl.de// 51612027Sjungma@eit.uni-kl.de// Revision 1.14 2011/08/24 22:05:51 acg 51712027Sjungma@eit.uni-kl.de// Torsten Maehne: initialization changes to remove warnings. 51812027Sjungma@eit.uni-kl.de// 51912027Sjungma@eit.uni-kl.de// Revision 1.13 2011/04/01 21:24:57 acg 52012027Sjungma@eit.uni-kl.de// Andy Goodrich: removed unused code. 52112027Sjungma@eit.uni-kl.de// 52212027Sjungma@eit.uni-kl.de// Revision 1.12 2011/03/06 15:55:11 acg 52312027Sjungma@eit.uni-kl.de// Andy Goodrich: Changes for named events. 52412027Sjungma@eit.uni-kl.de// 52512027Sjungma@eit.uni-kl.de// Revision 1.11 2011/03/05 19:44:20 acg 52612027Sjungma@eit.uni-kl.de// Andy Goodrich: changes for object and event naming and structures. 52712027Sjungma@eit.uni-kl.de// 52812027Sjungma@eit.uni-kl.de// Revision 1.10 2011/03/05 04:45:16 acg 52912027Sjungma@eit.uni-kl.de// Andy Goodrich: moved active process calculation to the sc_simcontext class. 53012027Sjungma@eit.uni-kl.de// 53112027Sjungma@eit.uni-kl.de// Revision 1.9 2011/03/05 01:39:21 acg 53212027Sjungma@eit.uni-kl.de// Andy Goodrich: changes for named events. 53312027Sjungma@eit.uni-kl.de// 53412027Sjungma@eit.uni-kl.de// Revision 1.8 2011/02/18 20:27:14 acg 53512027Sjungma@eit.uni-kl.de// Andy Goodrich: Updated Copyrights. 53612027Sjungma@eit.uni-kl.de// 53712027Sjungma@eit.uni-kl.de// Revision 1.7 2011/02/13 21:47:37 acg 53812027Sjungma@eit.uni-kl.de// Andy Goodrich: update copyright notice. 53912027Sjungma@eit.uni-kl.de// 54012027Sjungma@eit.uni-kl.de// Revision 1.6 2011/01/25 20:50:37 acg 54112027Sjungma@eit.uni-kl.de// Andy Goodrich: changes for IEEE 1666 2011. 54212027Sjungma@eit.uni-kl.de// 54312027Sjungma@eit.uni-kl.de// Revision 1.5 2011/01/18 20:10:44 acg 54412027Sjungma@eit.uni-kl.de// Andy Goodrich: changes for IEEE1666_2011 semantics. 54512027Sjungma@eit.uni-kl.de// 54612027Sjungma@eit.uni-kl.de// Revision 1.4 2010/08/03 17:02:39 acg 54712027Sjungma@eit.uni-kl.de// Andy Goodrich: formatting changes. 54812027Sjungma@eit.uni-kl.de// 54912027Sjungma@eit.uni-kl.de// Revision 1.3 2009/02/28 00:26:58 acg 55012027Sjungma@eit.uni-kl.de// Andy Goodrich: changed boost name space to sc_boost to allow use with 55112027Sjungma@eit.uni-kl.de// full boost library applications. 55212027Sjungma@eit.uni-kl.de// 55312027Sjungma@eit.uni-kl.de// Revision 1.2 2008/05/22 17:06:26 acg 55412027Sjungma@eit.uni-kl.de// Andy Goodrich: updated copyright notice to include 2008. 55512027Sjungma@eit.uni-kl.de// 55612027Sjungma@eit.uni-kl.de// Revision 1.1.1.1 2006/12/15 20:20:05 acg 55712027Sjungma@eit.uni-kl.de// SystemC 2.3 55812027Sjungma@eit.uni-kl.de// 55912027Sjungma@eit.uni-kl.de// Revision 1.5 2006/04/20 17:08:17 acg 56012027Sjungma@eit.uni-kl.de// Andy Goodrich: 3.0 style process changes. 56112027Sjungma@eit.uni-kl.de// 56212027Sjungma@eit.uni-kl.de// Revision 1.4 2006/03/21 00:00:34 acg 56312027Sjungma@eit.uni-kl.de// Andy Goodrich: changed name of sc_get_current_process_base() to be 56412027Sjungma@eit.uni-kl.de// sc_get_current_process_b() since its returning an sc_process_b instance. 56512027Sjungma@eit.uni-kl.de// 56612027Sjungma@eit.uni-kl.de// Revision 1.3 2006/01/13 18:44:30 acg 56712027Sjungma@eit.uni-kl.de// Added $Log to record CVS changes into the source. 56812027Sjungma@eit.uni-kl.de// 569