sc_clock.cc (13180:79e680f62779) | sc_clock.cc (13190:81aeb0a8947c) |
---|---|
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 --- 32 unchanged lines hidden (view full) --- 41namespace sc_gem5 42{ 43 44class ClockTick : public ScEvent 45{ 46 private: 47 ::sc_core::sc_clock *clock; 48 ::sc_core::sc_time _period; | 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 --- 32 unchanged lines hidden (view full) --- 41namespace sc_gem5 42{ 43 44class ClockTick : public ScEvent 45{ 46 private: 47 ::sc_core::sc_clock *clock; 48 ::sc_core::sc_time _period; |
49 std::string _name; | 49 std::string name; |
50 Process *p; 51 ProcessMemberFuncWrapper<::sc_core::sc_clock> funcWrapper; | 50 Process *p; 51 ProcessMemberFuncWrapper<::sc_core::sc_clock> funcWrapper; |
52 std::string _procName; | |
53 54 public: 55 ClockTick(::sc_core::sc_clock *clock, bool to, 56 ::sc_core::sc_time _period) : 57 ScEvent([this]() { tick(); }), | 52 53 public: 54 ClockTick(::sc_core::sc_clock *clock, bool to, 55 ::sc_core::sc_time _period) : 56 ScEvent([this]() { tick(); }), |
58 clock(clock), _period(_period), _name(clock->name()), | 57 clock(clock), _period(_period), name(clock->basename()), p(nullptr), |
59 funcWrapper(clock, to ? &::sc_core::sc_clock::tickUp : 60 &::sc_core::sc_clock::tickDown) 61 { | 58 funcWrapper(clock, to ? &::sc_core::sc_clock::tickUp : 59 &::sc_core::sc_clock::tickDown) 60 { |
62 _name += (to ? ".up_tick" : ".down_tick"); 63 _procName = _name + ".p"; 64 p = new Method(_procName.c_str(), &funcWrapper, true); | 61 name += std::string(to ? "_posedge_action" : "_negedge_action"); 62 name = ::sc_core::sc_gen_unique_name(name.c_str()); 63 } 64 65 void 66 createProcess() 67 { 68 p = new Method(name.c_str(), &funcWrapper, true); |
65 scheduler.reg(p); 66 scheduler.dontInitialize(p); 67 } 68 69 ~ClockTick() 70 { 71 if (scheduled()) 72 scheduler.deschedule(this); | 69 scheduler.reg(p); 70 scheduler.dontInitialize(p); 71 } 72 73 ~ClockTick() 74 { 75 if (scheduled()) 76 scheduler.deschedule(this); |
73 p->popListNode(); | 77 if (p) 78 p->popListNode(); |
74 } 75 76 void 77 tick() 78 { 79 scheduler.schedule(this, _period); 80 p->ready(); 81 } --- 69 unchanged lines hidden (view full) --- 151{ 152 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 153 return *(const sc_time *)nullptr; 154} 155 156void 157sc_clock::before_end_of_elaboration() 158{ | 79 } 80 81 void 82 tick() 83 { 84 scheduler.schedule(this, _period); 85 p->ready(); 86 } --- 69 unchanged lines hidden (view full) --- 156{ 157 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 158 return *(const sc_time *)nullptr; 159} 160 161void 162sc_clock::before_end_of_elaboration() 163{ |
164 _gem5UpEdge->createProcess(); 165 _gem5DownEdge->createProcess(); |
|
159 if (_posedgeFirst) { 160 ::sc_gem5::scheduler.schedule(_gem5UpEdge, _startTime); 161 ::sc_gem5::scheduler.schedule(_gem5DownEdge, 162 _startTime + _period * _dutyCycle); 163 } else { 164 ::sc_gem5::scheduler.schedule(_gem5DownEdge, _startTime); 165 ::sc_gem5::scheduler.schedule(_gem5UpEdge, 166 _startTime + _period * (1.0 - _dutyCycle)); 167 } 168} 169 170} // namespace sc_core | 166 if (_posedgeFirst) { 167 ::sc_gem5::scheduler.schedule(_gem5UpEdge, _startTime); 168 ::sc_gem5::scheduler.schedule(_gem5DownEdge, 169 _startTime + _period * _dutyCycle); 170 } else { 171 ::sc_gem5::scheduler.schedule(_gem5DownEdge, _startTime); 172 ::sc_gem5::scheduler.schedule(_gem5UpEdge, 173 _startTime + _period * (1.0 - _dutyCycle)); 174 } 175} 176 177} // namespace sc_core |