clock.cc

Go to the documentation of this file.
00001 #include "clock.h"
00002 #include "simulator.h"
00003 #include <list>
00004 
00005 using namespace std;
00006 
00007 Clock::Clock(double freq)
00008 {
00009   frequency=freq;
00010   period=1/frequency;
00011   //schedule first rising edge event
00012   Simulator::Schedule(Simulator::Now()+(period/2), 
00013                       &Clock::risingEdge, this);
00014   //schedule first falling edge event
00015   Simulator::Schedule(Simulator::Now()+period, &Clock::fallingEdge, this);
00016 }
00017 
00018 void Clock::risingEdge()
00019 {
00020   //schedule next risingEdge
00021   Simulator::Schedule(Simulator::Now()+period, &Clock::risingEdge, this);
00022   //call handler for each component registered for rising
00023   list<tickObjBase*>::iterator iter;
00024   for(iter=risingObjs.begin(); iter!=risingObjs.end(); iter++)
00025     {
00026       (*iter)->CallTick();
00027     } 
00028 }
00029 
00030 void Clock::fallingEdge()
00031 {
00032   //schedule next fallingEdge
00033   Simulator::Schedule(Simulator::Now()+period, &Clock::fallingEdge, this);
00034   //call handler for each component registered for falling
00035   list<tickObjBase*>::iterator iter;
00036   for(iter=fallingObjs.begin(); iter!=fallingObjs.end(); iter++)
00037     {
00038       (*iter)->CallTick();
00039     } 
00040 }

Generated on Tue Oct 19 17:22:00 2010 for IRIS by  doxygen 1.5.8