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_clock.cpp -- The clock channel. 2312027Sjungma@eit.uni-kl.de 2412027Sjungma@eit.uni-kl.de Original Author: Martin Janssen, Synopsys, Inc., 2001-05-21 2512027Sjungma@eit.uni-kl.de 2612027Sjungma@eit.uni-kl.de CHANGE LOG IS AT THE END OF THE FILE 2712027Sjungma@eit.uni-kl.de *****************************************************************************/ 2812027Sjungma@eit.uni-kl.de 2912027Sjungma@eit.uni-kl.de// using notify_delayed(). 3012027Sjungma@eit.uni-kl.de// 3112027Sjungma@eit.uni-kl.de// Revision 1.4 2006/01/18 21:42:26 acg 3212027Sjungma@eit.uni-kl.de// Andy Goodrich: Changes for check writer support, and tightening up sc_clock 3312027Sjungma@eit.uni-kl.de// port usage. 3412027Sjungma@eit.uni-kl.de// 3512027Sjungma@eit.uni-kl.de// Revision 1.3 2006/01/13 18:47:41 acg 3612027Sjungma@eit.uni-kl.de// Added $Log command so that CVS comments are reproduced in the source. 3712027Sjungma@eit.uni-kl.de// 3812027Sjungma@eit.uni-kl.de 3912027Sjungma@eit.uni-kl.de#include "sysc/communication/sc_clock.h" 4012027Sjungma@eit.uni-kl.de#include "sysc/communication/sc_communication_ids.h" 4112027Sjungma@eit.uni-kl.de#include "sysc/kernel/sc_simcontext.h" 4212027Sjungma@eit.uni-kl.de#include "sysc/kernel/sc_process.h" 4312027Sjungma@eit.uni-kl.de#include "sysc/kernel/sc_spawn.h" 4412027Sjungma@eit.uni-kl.de#include "sysc/utils/sc_utils_ids.h" 4512027Sjungma@eit.uni-kl.de 4612027Sjungma@eit.uni-kl.denamespace sc_core { 4712027Sjungma@eit.uni-kl.de 4812027Sjungma@eit.uni-kl.de// ---------------------------------------------------------------------------- 4912027Sjungma@eit.uni-kl.de// CLASS : sc_clock 5012027Sjungma@eit.uni-kl.de// 5112027Sjungma@eit.uni-kl.de// The clock channel. 5212027Sjungma@eit.uni-kl.de// ---------------------------------------------------------------------------- 5312027Sjungma@eit.uni-kl.de 5412027Sjungma@eit.uni-kl.de// constructors 5512027Sjungma@eit.uni-kl.de 5612027Sjungma@eit.uni-kl.desc_clock::sc_clock() : 5712027Sjungma@eit.uni-kl.de base_type( sc_gen_unique_name( "clock" ) ), 5812027Sjungma@eit.uni-kl.de m_period(), m_duty_cycle(), m_start_time(), m_posedge_first(), 5912027Sjungma@eit.uni-kl.de m_posedge_time(), m_negedge_time(), 6012027Sjungma@eit.uni-kl.de m_next_posedge_event( (std::string(SC_KERNEL_EVENT_PREFIX) + 6112027Sjungma@eit.uni-kl.de "_next_posedge_event").c_str()), 6212027Sjungma@eit.uni-kl.de m_next_negedge_event( (std::string(SC_KERNEL_EVENT_PREFIX) + 6312027Sjungma@eit.uni-kl.de "_next_negedge_event").c_str()) 6412027Sjungma@eit.uni-kl.de 6512027Sjungma@eit.uni-kl.de{ 6612027Sjungma@eit.uni-kl.de init( sc_time::from_value(simcontext()->m_time_params->default_time_unit), 6712027Sjungma@eit.uni-kl.de 0.5, 6812027Sjungma@eit.uni-kl.de SC_ZERO_TIME, 6912027Sjungma@eit.uni-kl.de true ); 7012027Sjungma@eit.uni-kl.de 7112027Sjungma@eit.uni-kl.de m_next_posedge_event.notify_internal( m_start_time ); 7212027Sjungma@eit.uni-kl.de} 7312027Sjungma@eit.uni-kl.de 7412027Sjungma@eit.uni-kl.desc_clock::sc_clock( const char* name_ ) : 7512027Sjungma@eit.uni-kl.de base_type( name_ ), 7612027Sjungma@eit.uni-kl.de m_period(), m_duty_cycle(), m_start_time(), m_posedge_first(), 7712027Sjungma@eit.uni-kl.de m_posedge_time(), m_negedge_time(), 7812027Sjungma@eit.uni-kl.de m_next_posedge_event( (std::string(SC_KERNEL_EVENT_PREFIX) + 7912027Sjungma@eit.uni-kl.de std::string(name_) + "_next_posedge_event").c_str()), 8012027Sjungma@eit.uni-kl.de m_next_negedge_event( (std::string(SC_KERNEL_EVENT_PREFIX) + 8112027Sjungma@eit.uni-kl.de std::string(name_) + "_next_negedge_event").c_str()) 8212027Sjungma@eit.uni-kl.de{ 8312027Sjungma@eit.uni-kl.de init( sc_time::from_value(simcontext()->m_time_params->default_time_unit), 8412027Sjungma@eit.uni-kl.de 0.5, 8512027Sjungma@eit.uni-kl.de SC_ZERO_TIME, 8612027Sjungma@eit.uni-kl.de true ); 8712027Sjungma@eit.uni-kl.de 8812027Sjungma@eit.uni-kl.de m_next_posedge_event.notify_internal( m_start_time ); 8912027Sjungma@eit.uni-kl.de} 9012027Sjungma@eit.uni-kl.de 9112027Sjungma@eit.uni-kl.desc_clock::sc_clock( const char* name_, 9212027Sjungma@eit.uni-kl.de const sc_time& period_, 9312027Sjungma@eit.uni-kl.de double duty_cycle_, 9412027Sjungma@eit.uni-kl.de const sc_time& start_time_, 9512027Sjungma@eit.uni-kl.de bool posedge_first_ ) : 9612027Sjungma@eit.uni-kl.de base_type( name_ ), 9712027Sjungma@eit.uni-kl.de m_period(), m_duty_cycle(), m_start_time(), m_posedge_first(), 9812027Sjungma@eit.uni-kl.de m_posedge_time(), m_negedge_time(), 9912027Sjungma@eit.uni-kl.de m_next_posedge_event( (std::string(SC_KERNEL_EVENT_PREFIX) + 10012027Sjungma@eit.uni-kl.de std::string(name_) + "_next_posedge_event").c_str()), 10112027Sjungma@eit.uni-kl.de m_next_negedge_event( (std::string(SC_KERNEL_EVENT_PREFIX) + 10212027Sjungma@eit.uni-kl.de std::string(name_) + "_next_negedge_event").c_str()) 10312027Sjungma@eit.uni-kl.de{ 10412027Sjungma@eit.uni-kl.de init( period_, 10512027Sjungma@eit.uni-kl.de duty_cycle_, 10612027Sjungma@eit.uni-kl.de start_time_, 10712027Sjungma@eit.uni-kl.de posedge_first_ ); 10812027Sjungma@eit.uni-kl.de 10912027Sjungma@eit.uni-kl.de if( posedge_first_ ) { 11012027Sjungma@eit.uni-kl.de // posedge first 11112027Sjungma@eit.uni-kl.de m_next_posedge_event.notify_internal( m_start_time ); 11212027Sjungma@eit.uni-kl.de } else { 11312027Sjungma@eit.uni-kl.de // negedge first 11412027Sjungma@eit.uni-kl.de m_next_negedge_event.notify_internal( m_start_time ); 11512027Sjungma@eit.uni-kl.de } 11612027Sjungma@eit.uni-kl.de} 11712027Sjungma@eit.uni-kl.de 11812027Sjungma@eit.uni-kl.desc_clock::sc_clock( const char* name_, 11912027Sjungma@eit.uni-kl.de double period_v_, 12012027Sjungma@eit.uni-kl.de sc_time_unit period_tu_, 12112027Sjungma@eit.uni-kl.de double duty_cycle_ ) : 12212027Sjungma@eit.uni-kl.de base_type( name_ ), 12312027Sjungma@eit.uni-kl.de m_period(), m_duty_cycle(), m_start_time(), m_posedge_first(), 12412027Sjungma@eit.uni-kl.de m_posedge_time(), m_negedge_time(), 12512027Sjungma@eit.uni-kl.de m_next_posedge_event( (std::string(SC_KERNEL_EVENT_PREFIX) + 12612027Sjungma@eit.uni-kl.de std::string(name_) + "_next_posedge_event").c_str()), 12712027Sjungma@eit.uni-kl.de m_next_negedge_event( (std::string(SC_KERNEL_EVENT_PREFIX) + 12812027Sjungma@eit.uni-kl.de std::string(name_) + "_next_negedge_event").c_str()) 12912027Sjungma@eit.uni-kl.de{ 13012027Sjungma@eit.uni-kl.de init( sc_time( period_v_, period_tu_, simcontext() ), 13112027Sjungma@eit.uni-kl.de duty_cycle_, 13212027Sjungma@eit.uni-kl.de SC_ZERO_TIME, 13312027Sjungma@eit.uni-kl.de true ); 13412027Sjungma@eit.uni-kl.de 13512027Sjungma@eit.uni-kl.de // posedge first 13612027Sjungma@eit.uni-kl.de m_next_posedge_event.notify_internal( m_start_time ); 13712027Sjungma@eit.uni-kl.de} 13812027Sjungma@eit.uni-kl.de 13912027Sjungma@eit.uni-kl.desc_clock::sc_clock( const char* name_, 14012027Sjungma@eit.uni-kl.de double period_v_, 14112027Sjungma@eit.uni-kl.de sc_time_unit period_tu_, 14212027Sjungma@eit.uni-kl.de double duty_cycle_, 14312027Sjungma@eit.uni-kl.de double start_time_v_, 14412027Sjungma@eit.uni-kl.de sc_time_unit start_time_tu_, 14512027Sjungma@eit.uni-kl.de bool posedge_first_ ) : 14612027Sjungma@eit.uni-kl.de base_type( name_ ), 14712027Sjungma@eit.uni-kl.de m_period(), m_duty_cycle(), m_start_time(), m_posedge_first(), 14812027Sjungma@eit.uni-kl.de m_posedge_time(), m_negedge_time(), 14912027Sjungma@eit.uni-kl.de m_next_posedge_event( (std::string(SC_KERNEL_EVENT_PREFIX) + 15012027Sjungma@eit.uni-kl.de std::string(name_) + "_next_posedge_event").c_str()), 15112027Sjungma@eit.uni-kl.de m_next_negedge_event( (std::string(SC_KERNEL_EVENT_PREFIX) + 15212027Sjungma@eit.uni-kl.de std::string(name_) + "_next_negedge_event").c_str()) 15312027Sjungma@eit.uni-kl.de{ 15412027Sjungma@eit.uni-kl.de init( sc_time( period_v_, period_tu_, simcontext() ), 15512027Sjungma@eit.uni-kl.de duty_cycle_, 15612027Sjungma@eit.uni-kl.de sc_time( start_time_v_, start_time_tu_, simcontext() ), 15712027Sjungma@eit.uni-kl.de posedge_first_ ); 15812027Sjungma@eit.uni-kl.de 15912027Sjungma@eit.uni-kl.de if( posedge_first_ ) { 16012027Sjungma@eit.uni-kl.de // posedge first 16112027Sjungma@eit.uni-kl.de m_next_posedge_event.notify_internal( m_start_time ); 16212027Sjungma@eit.uni-kl.de } else { 16312027Sjungma@eit.uni-kl.de // negedge first 16412027Sjungma@eit.uni-kl.de m_next_negedge_event.notify_internal( m_start_time ); 16512027Sjungma@eit.uni-kl.de } 16612027Sjungma@eit.uni-kl.de} 16712027Sjungma@eit.uni-kl.de 16812027Sjungma@eit.uni-kl.de// for backward compatibility with 1.0 16912027Sjungma@eit.uni-kl.desc_clock::sc_clock( const char* name_, 17012027Sjungma@eit.uni-kl.de double period_, // in default time units 17112027Sjungma@eit.uni-kl.de double duty_cycle_, 17212027Sjungma@eit.uni-kl.de double start_time_, // in default time units 17312027Sjungma@eit.uni-kl.de bool posedge_first_ ) : 17412027Sjungma@eit.uni-kl.de base_type( name_ ), 17512027Sjungma@eit.uni-kl.de m_period(), m_duty_cycle(), m_start_time(), m_posedge_first(), 17612027Sjungma@eit.uni-kl.de m_posedge_time(), m_negedge_time(), 17712027Sjungma@eit.uni-kl.de m_next_posedge_event( (std::string(SC_KERNEL_EVENT_PREFIX) + 17812027Sjungma@eit.uni-kl.de std::string(name_) + "_next_posedge_event").c_str()), 17912027Sjungma@eit.uni-kl.de m_next_negedge_event( (std::string(SC_KERNEL_EVENT_PREFIX) + 18012027Sjungma@eit.uni-kl.de std::string(name_) + "_next_negedge_event").c_str()) 18112027Sjungma@eit.uni-kl.de{ 18212027Sjungma@eit.uni-kl.de static bool warn_sc_clock=true; 18312027Sjungma@eit.uni-kl.de if ( warn_sc_clock ) 18412027Sjungma@eit.uni-kl.de { 18512027Sjungma@eit.uni-kl.de warn_sc_clock = false; 18612027Sjungma@eit.uni-kl.de SC_REPORT_INFO(SC_ID_IEEE_1666_DEPRECATION_, 18712027Sjungma@eit.uni-kl.de "\n sc_clock(const char*, double, double, double, bool)\n" 18812027Sjungma@eit.uni-kl.de " is deprecated use a form that includes sc_time or\n" 18912027Sjungma@eit.uni-kl.de " sc_time_unit"); 19012027Sjungma@eit.uni-kl.de } 19112027Sjungma@eit.uni-kl.de 19212027Sjungma@eit.uni-kl.de sc_time default_time = 19312027Sjungma@eit.uni-kl.de sc_time::from_value( simcontext()->m_time_params->default_time_unit ); 19412027Sjungma@eit.uni-kl.de 19512027Sjungma@eit.uni-kl.de init( ( period_ * default_time ), 19612027Sjungma@eit.uni-kl.de duty_cycle_, 19712027Sjungma@eit.uni-kl.de ( start_time_ * default_time ), 19812027Sjungma@eit.uni-kl.de posedge_first_ ); 19912027Sjungma@eit.uni-kl.de 20012027Sjungma@eit.uni-kl.de if( posedge_first_ ) { 20112027Sjungma@eit.uni-kl.de // posedge first 20212027Sjungma@eit.uni-kl.de m_next_posedge_event.notify_internal( m_start_time ); 20312027Sjungma@eit.uni-kl.de } else { 20412027Sjungma@eit.uni-kl.de // negedge first 20512027Sjungma@eit.uni-kl.de m_next_negedge_event.notify_internal( m_start_time ); 20612027Sjungma@eit.uni-kl.de } 20712027Sjungma@eit.uni-kl.de} 20812027Sjungma@eit.uni-kl.de 20912027Sjungma@eit.uni-kl.de 21012027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------ 21112027Sjungma@eit.uni-kl.de//"sc_clock::before_end_of_elaboration" 21212027Sjungma@eit.uni-kl.de// 21312027Sjungma@eit.uni-kl.de// This callback is used to spawn the edge processes for this object instance. 21412027Sjungma@eit.uni-kl.de// The processes are created here rather than the constructor for the object 21512027Sjungma@eit.uni-kl.de// so that the processes are registered with the global simcontext rather 21612027Sjungma@eit.uni-kl.de// than the scope of the clock's parent. 21712027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------ 21812027Sjungma@eit.uni-kl.de#if ( defined(_MSC_VER) && _MSC_VER < 1300 ) //VC++6.0 doesn't support sc_spawn with functor. 21912027Sjungma@eit.uni-kl.de# define sc_clock_posedge_callback(ptr) sc_clock_posedge_callback 22012027Sjungma@eit.uni-kl.de 22112027Sjungma@eit.uni-kl.de# define sc_clock_negedge_callback(ptr) sc_clock_negedge_callback 22212027Sjungma@eit.uni-kl.de 22312027Sjungma@eit.uni-kl.de# define sc_spawn(a,b,c) { \ 22412027Sjungma@eit.uni-kl.de sc_process_handle result(new sc_spawn_object<a>(a(this),b,c)); \ 22512027Sjungma@eit.uni-kl.de } 22612027Sjungma@eit.uni-kl.de#endif // ( defined(_MSC_VER) && _MSC_VER < 1300 ) 22712027Sjungma@eit.uni-kl.de 22812027Sjungma@eit.uni-kl.devoid sc_clock::before_end_of_elaboration() 22912027Sjungma@eit.uni-kl.de{ 23012027Sjungma@eit.uni-kl.de std::string gen_base; 23112027Sjungma@eit.uni-kl.de sc_spawn_options posedge_options; // Options for posedge process. 23212027Sjungma@eit.uni-kl.de sc_spawn_options negedge_options; // Options for negedge process. 23312027Sjungma@eit.uni-kl.de 23412027Sjungma@eit.uni-kl.de posedge_options.spawn_method(); 23512027Sjungma@eit.uni-kl.de posedge_options.dont_initialize(); 23612027Sjungma@eit.uni-kl.de posedge_options.set_sensitivity(&m_next_posedge_event); 23712027Sjungma@eit.uni-kl.de gen_base = basename(); 23812027Sjungma@eit.uni-kl.de gen_base += "_posedge_action"; 23912027Sjungma@eit.uni-kl.de sc_spawn(sc_clock_posedge_callback(this), 24012027Sjungma@eit.uni-kl.de sc_gen_unique_name( gen_base.c_str() ), &posedge_options); 24112027Sjungma@eit.uni-kl.de 24212027Sjungma@eit.uni-kl.de negedge_options.spawn_method(); 24312027Sjungma@eit.uni-kl.de negedge_options.dont_initialize(); 24412027Sjungma@eit.uni-kl.de negedge_options.set_sensitivity(&m_next_negedge_event); 24512027Sjungma@eit.uni-kl.de gen_base = basename(); 24612027Sjungma@eit.uni-kl.de gen_base += "_negedge_action"; 24712027Sjungma@eit.uni-kl.de sc_spawn( sc_clock_negedge_callback(this), 24812027Sjungma@eit.uni-kl.de sc_gen_unique_name( gen_base.c_str() ), &negedge_options ); 24912027Sjungma@eit.uni-kl.de} 25012027Sjungma@eit.uni-kl.de 25112027Sjungma@eit.uni-kl.de//clear VC++6.0 macros 25212027Sjungma@eit.uni-kl.de#undef sc_clock_posedge_callback 25312027Sjungma@eit.uni-kl.de#undef sc_clock_negedge_callback 25412027Sjungma@eit.uni-kl.de#undef sc_spawn 25512027Sjungma@eit.uni-kl.de 25612027Sjungma@eit.uni-kl.de// destructor (does nothing) 25712027Sjungma@eit.uni-kl.de 25812027Sjungma@eit.uni-kl.desc_clock::~sc_clock() 25912027Sjungma@eit.uni-kl.de{} 26012027Sjungma@eit.uni-kl.de 26112027Sjungma@eit.uni-kl.devoid sc_clock::register_port( sc_port_base& /*port*/, const char* if_typename_ ) 26212027Sjungma@eit.uni-kl.de{ 26312027Sjungma@eit.uni-kl.de std::string nm( if_typename_ ); 26412027Sjungma@eit.uni-kl.de if( nm == typeid( sc_signal_inout_if<bool> ).name() ) { 26512027Sjungma@eit.uni-kl.de SC_REPORT_ERROR(SC_ID_ATTEMPT_TO_BIND_CLOCK_TO_OUTPUT_, ""); 26612027Sjungma@eit.uni-kl.de } 26712027Sjungma@eit.uni-kl.de} 26812027Sjungma@eit.uni-kl.de 26912027Sjungma@eit.uni-kl.devoid 27012027Sjungma@eit.uni-kl.desc_clock::write( const bool& /* value */ ) 27112027Sjungma@eit.uni-kl.de{ 27212027Sjungma@eit.uni-kl.de SC_REPORT_ERROR(SC_ID_ATTEMPT_TO_WRITE_TO_CLOCK_, ""); 27312027Sjungma@eit.uni-kl.de} 27412027Sjungma@eit.uni-kl.de 27512027Sjungma@eit.uni-kl.de// interface methods 27612027Sjungma@eit.uni-kl.de 27712027Sjungma@eit.uni-kl.de// get the current time 27812027Sjungma@eit.uni-kl.de 27912027Sjungma@eit.uni-kl.deconst sc_time& 28012027Sjungma@eit.uni-kl.desc_clock::time_stamp() 28112027Sjungma@eit.uni-kl.de{ 28212027Sjungma@eit.uni-kl.de return sc_time_stamp(); 28312027Sjungma@eit.uni-kl.de} 28412027Sjungma@eit.uni-kl.de 28512027Sjungma@eit.uni-kl.de 28612027Sjungma@eit.uni-kl.de// error reporting 28712027Sjungma@eit.uni-kl.de 28812027Sjungma@eit.uni-kl.devoid 28912027Sjungma@eit.uni-kl.desc_clock::report_error( const char* id, const char* add_msg ) const 29012027Sjungma@eit.uni-kl.de{ 29112027Sjungma@eit.uni-kl.de char msg[BUFSIZ]; 29212027Sjungma@eit.uni-kl.de if( add_msg != 0 ) { 29312027Sjungma@eit.uni-kl.de std::sprintf( msg, "%s: clock '%s'", add_msg, name() ); 29412027Sjungma@eit.uni-kl.de } else { 29512027Sjungma@eit.uni-kl.de std::sprintf( msg, "clock '%s'", name() ); 29612027Sjungma@eit.uni-kl.de } 29712027Sjungma@eit.uni-kl.de SC_REPORT_ERROR( id, msg ); 29812027Sjungma@eit.uni-kl.de} 29912027Sjungma@eit.uni-kl.de 30012027Sjungma@eit.uni-kl.de 30112027Sjungma@eit.uni-kl.devoid 30212027Sjungma@eit.uni-kl.desc_clock::init( const sc_time& period_, 30312027Sjungma@eit.uni-kl.de double duty_cycle_, 30412027Sjungma@eit.uni-kl.de const sc_time& start_time_, 30512027Sjungma@eit.uni-kl.de bool posedge_first_ ) 30612027Sjungma@eit.uni-kl.de{ 30712027Sjungma@eit.uni-kl.de if( period_ == SC_ZERO_TIME ) { 30812027Sjungma@eit.uni-kl.de report_error( SC_ID_CLOCK_PERIOD_ZERO_, 30912027Sjungma@eit.uni-kl.de "increase the period" ); 31012027Sjungma@eit.uni-kl.de } 31112027Sjungma@eit.uni-kl.de m_period = period_; 31212027Sjungma@eit.uni-kl.de m_posedge_first = posedge_first_; 31312027Sjungma@eit.uni-kl.de 31412027Sjungma@eit.uni-kl.de if( duty_cycle_ <= 0.0 || duty_cycle_ >= 1.0 ) { 31512027Sjungma@eit.uni-kl.de m_duty_cycle = 0.5; 31612027Sjungma@eit.uni-kl.de } else { 31712027Sjungma@eit.uni-kl.de m_duty_cycle = duty_cycle_; 31812027Sjungma@eit.uni-kl.de } 31912027Sjungma@eit.uni-kl.de 32012027Sjungma@eit.uni-kl.de m_negedge_time = m_period * m_duty_cycle; 32112027Sjungma@eit.uni-kl.de m_posedge_time = m_period - m_negedge_time; 32212027Sjungma@eit.uni-kl.de 32312027Sjungma@eit.uni-kl.de if( m_negedge_time == SC_ZERO_TIME ) { 32412027Sjungma@eit.uni-kl.de report_error( SC_ID_CLOCK_HIGH_TIME_ZERO_, 32512027Sjungma@eit.uni-kl.de "increase the period or increase the duty cycle" ); 32612027Sjungma@eit.uni-kl.de } 32712027Sjungma@eit.uni-kl.de if( m_posedge_time == SC_ZERO_TIME ) { 32812027Sjungma@eit.uni-kl.de report_error( SC_ID_CLOCK_LOW_TIME_ZERO_, 32912027Sjungma@eit.uni-kl.de "increase the period or decrease the duty cycle" ); 33012027Sjungma@eit.uni-kl.de } 33112027Sjungma@eit.uni-kl.de 33212027Sjungma@eit.uni-kl.de if( posedge_first_ ) { 33312027Sjungma@eit.uni-kl.de this->m_cur_val = false; 33412027Sjungma@eit.uni-kl.de this->m_new_val = false; 33512027Sjungma@eit.uni-kl.de } else { 33612027Sjungma@eit.uni-kl.de this->m_cur_val = true; 33712027Sjungma@eit.uni-kl.de this->m_new_val = true; 33812027Sjungma@eit.uni-kl.de } 33912027Sjungma@eit.uni-kl.de 34012027Sjungma@eit.uni-kl.de m_start_time = start_time_; 34112027Sjungma@eit.uni-kl.de 34212027Sjungma@eit.uni-kl.de} 34312027Sjungma@eit.uni-kl.de 34412027Sjungma@eit.uni-kl.de} // namespace sc_core 34512027Sjungma@eit.uni-kl.de 34612027Sjungma@eit.uni-kl.de/***************************************************************************** 34712027Sjungma@eit.uni-kl.de 34812027Sjungma@eit.uni-kl.de MODIFICATION LOG - modifiers, enter your name, affiliation, date and 34912027Sjungma@eit.uni-kl.de changes you are making here. 35012027Sjungma@eit.uni-kl.de 35112027Sjungma@eit.uni-kl.de Name, Affiliation, Date: Bishnupriya Bhattacharya, Cadence Design Systems, 35212027Sjungma@eit.uni-kl.de Andy Goodrich, Forte Design Systems, 35312027Sjungma@eit.uni-kl.de 3 October, 2003 35412027Sjungma@eit.uni-kl.de Description of Modification: sc_clock inherits from sc_signal<bool> only 35512027Sjungma@eit.uni-kl.de instead of sc_signal_in_if<bool> and sc_module. 35612027Sjungma@eit.uni-kl.de The 2 methods posedge_action() and 35712027Sjungma@eit.uni-kl.de negedge_action() are created using sc_spawn(). 35812027Sjungma@eit.uni-kl.de boost::bind() is not required, instead a local 35912027Sjungma@eit.uni-kl.de bind function can be used since the signatures 36012027Sjungma@eit.uni-kl.de of the spawned functions are statically known. 36112027Sjungma@eit.uni-kl.de 36212027Sjungma@eit.uni-kl.de Name, Affiliation, Date: 36312027Sjungma@eit.uni-kl.de Description of Modification: 36412027Sjungma@eit.uni-kl.de 36512027Sjungma@eit.uni-kl.de *****************************************************************************/ 36612027Sjungma@eit.uni-kl.de 36712027Sjungma@eit.uni-kl.de// $Log: sc_clock.cpp,v $ 36812027Sjungma@eit.uni-kl.de// Revision 1.7 2011/08/26 20:45:39 acg 36912027Sjungma@eit.uni-kl.de// Andy Goodrich: moved the modification log to the end of the file to 37012027Sjungma@eit.uni-kl.de// eliminate source line number skew when check-ins are done. 37112027Sjungma@eit.uni-kl.de// 37212027Sjungma@eit.uni-kl.de// Revision 1.6 2011/08/24 22:05:35 acg 37312027Sjungma@eit.uni-kl.de// Torsten Maehne: initialization changes to remove warnings. 37412027Sjungma@eit.uni-kl.de// 37512027Sjungma@eit.uni-kl.de// Revision 1.5 2011/08/15 16:43:24 acg 37612027Sjungma@eit.uni-kl.de// Torsten Maehne: changes to remove unused argument warnings. 37712027Sjungma@eit.uni-kl.de// 37812027Sjungma@eit.uni-kl.de// Revision 1.4 2011/03/12 21:07:42 acg 37912027Sjungma@eit.uni-kl.de// Andy Goodrich: changes to kernel generated event support. 38012027Sjungma@eit.uni-kl.de// 38112027Sjungma@eit.uni-kl.de// Revision 1.3 2011/03/06 15:55:08 acg 38212027Sjungma@eit.uni-kl.de// Andy Goodrich: Changes for named events. 38312027Sjungma@eit.uni-kl.de// 38412027Sjungma@eit.uni-kl.de// Revision 1.2 2011/02/18 20:23:45 acg 38512027Sjungma@eit.uni-kl.de// Andy Goodrich: Copyright update. 38612027Sjungma@eit.uni-kl.de// 38712027Sjungma@eit.uni-kl.de// Revision 1.1.1.1 2006/12/15 20:20:04 acg 38812027Sjungma@eit.uni-kl.de// SystemC 2.3 38912027Sjungma@eit.uni-kl.de// 39012027Sjungma@eit.uni-kl.de// Revision 1.8 2006/04/18 23:36:50 acg 39112027Sjungma@eit.uni-kl.de// Andy Goodrich: made add_trace_internal public until I can figure out 39212027Sjungma@eit.uni-kl.de// how to do a friend specification for sc_trace in an environment where 39312027Sjungma@eit.uni-kl.de// there are partial template and full template specifications for its 39412027Sjungma@eit.uni-kl.de// arguments. 39512027Sjungma@eit.uni-kl.de// 39612027Sjungma@eit.uni-kl.de// Revision 1.7 2006/04/17 16:38:42 acg 39712027Sjungma@eit.uni-kl.de// Andy Goodrich: added more context to the deprecation message for the 39812027Sjungma@eit.uni-kl.de// sc_clock constructor. 39912027Sjungma@eit.uni-kl.de// 40012027Sjungma@eit.uni-kl.de// Revision 1.6 2006/01/25 00:31:11 acg 40112027Sjungma@eit.uni-kl.de// Andy Goodrich: Changed over to use a standard message id of 40212027Sjungma@eit.uni-kl.de// SC_ID_IEEE_1666_DEPRECATION for all deprecation messages. 40312027Sjungma@eit.uni-kl.de// 40412027Sjungma@eit.uni-kl.de// Revision 1.5 2006/01/24 20:43:24 acg 40512027Sjungma@eit.uni-kl.de// Andy Goodrich: convert notify_delayed() calls into notify_internal() calls. 40612027Sjungma@eit.uni-kl.de// notify_internal() is an implementation dependent version of notify_delayed() 40712027Sjungma@eit.uni-kl.de// that is simpler, and does not trigger the deprecation warning one would get 40812027Sjungma@eit.uni-kl.de 40912027Sjungma@eit.uni-kl.de// Taf! 410