scc 2025.09
SystemC components library
sc_clock_ext.h
1/*******************************************************************************
2 * Copyright 2022 MINRES Technologies GmbH
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *******************************************************************************/
16
17#ifndef _SCC_SC_CLOCK_EXT_H_
18#define _SCC_SC_CLOCK_EXT_H_
19
20#include <cci_configuration>
21#include <sysc/communication/sc_clock.h>
22
28namespace scc {
36struct sc_clock_ext : public sc_core::sc_clock {
42 cci::cci_param<sc_core::sc_time> period;
48 cci::cci_param<double> duty_cycle;
54 cci::cci_param<sc_core::sc_time> initial_delay;
55
56 sc_clock_ext(const char* name_, const sc_core::sc_time& period_, double duty_cycle_ = 0.5,
57 const sc_core::sc_time& start_time_ = sc_core::SC_ZERO_TIME, bool posedge_first_ = true)
58 : sc_core::sc_clock(name_, period_, duty_cycle_, start_time_, posedge_first_)
59 , period(get_cci_name(name_, "period"), period_, "The period of the generated clock")
60 , duty_cycle(get_cci_name(name_, "duty_cycle"), duty_cycle_, "The duty cycle of the generated clock")
61 , initial_delay(get_cci_name(name_, "start_time"), start_time_, "The start time of the generated clock") {
62 // period.register_post_write_callback(&sc_clock_ext::period_write_callback,this);
63 }
64
65 virtual ~sc_clock_ext() = default;
66
67protected:
68 void end_of_elaboration() override {
69 init(period.get_value(), duty_cycle.get_value(), initial_delay.get_value(), m_posedge_first);
70 if(initial_delay.get_value() != m_start_time) {
71 if(m_posedge_first) {
72 m_next_posedge_event.cancel();
73 m_next_posedge_event.notify(initial_delay.get_value());
74 } else {
75 m_next_negedge_event.cancel();
76 m_next_negedge_event.notify(initial_delay.get_value());
77 }
78 }
79 }
80 void period_write_callback(const cci::cci_param_write_event<int>& ev) {}
81 static inline std::string get_cci_name(const char* base, const char* name) { return std::string(base) + "_" + name; }
82};
83} // namespace scc // end of scc-sysc
85#endif //
SCC TLM utilities.
A clock source with construction time configurable start delay.
cci::cci_param< sc_core::sc_time > period
The period of the generated clock.
cci::cci_param< double > duty_cycle
The duty cycle of the generated clock.
cci::cci_param< sc_core::sc_time > initial_delay
The start time of the generated clock.