46template <
class T>
class sc_in_opt :
public sc_core::sc_port<sc_core::sc_signal_in_if<T>, 1, sc_core::SC_ZERO_OR_MORE_BOUND> {
49 using if_type = sc_core::sc_signal_in_if<data_type>;
50 using base_type = sc_core::sc_port<if_type, 1, sc_core::SC_ZERO_OR_MORE_BOUND>;
51 using this_type = sc_in_opt<data_type>;
52 using base_port_type =
typename base_type::port_type;
54 using in_if_type = if_type;
55 using in_port_type = base_type;
56 using inout_if_type = sc_core::sc_signal_inout_if<data_type>;
57 using inout_port_type = sc_core::sc_port<inout_if_type, 1, sc_core::SC_ZERO_OR_MORE_BOUND>;
63 explicit sc_in_opt(
const char* name_)
66 explicit sc_in_opt(
const in_if_type& interface_)
67 : base_type(
const_cast<in_if_type&
>(interface_)) {}
69 sc_in_opt(
const char* name_,
const in_if_type& interface_)
70 : base_type(name_,
const_cast<in_if_type&
>(interface_)) {}
72 explicit sc_in_opt(in_port_type& parent_)
73 : base_type(parent_) {}
75 sc_in_opt(
const char* name_, in_port_type& parent_)
76 : base_type(name_, parent_) {}
78 explicit sc_in_opt(inout_port_type& parent_)
80 sc_core::sc_port_base::bind(parent_);
83 sc_in_opt(
const char* name_, inout_port_type& parent_)
85 sc_core::sc_port_base::bind(parent_);
88 sc_in_opt(this_type& parent_)
89 : base_type(parent_) {}
91 sc_in_opt(
const char* name_, this_type& parent_)
92 : base_type(name_, parent_) {}
94 sc_in_opt(
const this_type&) =
delete;
96 virtual ~sc_in_opt() {}
98 this_type& operator=(
const this_type&) =
delete;
100 SCC_VIRT
void bind(
const in_if_type& interface_) { sc_core::sc_port_base::bind(
const_cast<in_if_type&
>(interface_)); }
102 SCC_VIRT
void bind(in_if_type& interface_)
override { this->bind(
const_cast<const in_if_type&
>(interface_)); }
104 void operator()(
const in_if_type& interface_) { this->bind(interface_); }
106 SCC_VIRT
void bind(in_port_type& parent_) { sc_core::sc_port_base::bind(parent_); }
108 void operator()(in_port_type& parent_) { this->bind(parent_); }
110 SCC_VIRT
void bind(sc_core::sc_port<if_type, 1, sc_core::SC_ONE_OR_MORE_BOUND>& parent_) { sc_core::sc_port_base::bind(parent_); }
112 void operator()(sc_core::sc_port<if_type, 1, sc_core::SC_ONE_OR_MORE_BOUND>& parent_) { this->bind(parent_); }
114 SCC_VIRT
void bind(inout_port_type& parent_) { sc_core::sc_port_base::bind(parent_); }
116 void operator()(inout_port_type& parent_) { this->bind(parent_); }
118 SCC_VIRT
void bind(sc_core::sc_port<inout_if_type, 1, sc_core::SC_ONE_OR_MORE_BOUND>& parent_) { sc_core::sc_port_base::bind(parent_); }
120 void operator()(sc_core::sc_port<inout_if_type, 1, sc_core::SC_ONE_OR_MORE_BOUND>& parent_) { this->bind(parent_); }
122 const sc_core::sc_event& default_event()
const {
return (*this)->default_event(); }
124 const sc_core::sc_event& value_changed_event()
const {
return (*this)->value_changed_event(); }
126 const data_type& read()
const {
return (*this)->read(); }
128 operator const data_type&()
const {
return (*this)->read(); }
130 bool event()
const {
return (*this)->event(); }
132 virtual const char* kind()
const override {
return "sc_in"; }
141template <>
class SC_API sc_in_opt<bool> :
public sc_core::sc_port<sc_core::sc_signal_in_if<bool>, 1, sc_core::SC_ZERO_OR_MORE_BOUND> {
143 typedef bool data_type;
145 typedef sc_core::sc_signal_in_if<data_type> if_type;
146 typedef sc_core::sc_port<if_type, 1, sc_core::SC_ZERO_OR_MORE_BOUND> base_type;
147 typedef sc_in_opt<data_type> this_type;
148 typedef base_type::port_type base_port_type;
150 typedef if_type in_if_type;
151 typedef base_type in_port_type;
152 typedef sc_core::sc_signal_inout_if<data_type> inout_if_type;
153 typedef sc_core::sc_port<inout_if_type, 1, sc_core::SC_ZERO_OR_MORE_BOUND> inout_port_type;
159 explicit sc_in_opt(
const char* name_)
160 : base_type(name_) {}
162 explicit sc_in_opt(
const in_if_type& interface_)
163 : base_type(
const_cast<in_if_type&
>(interface_)) {}
165 sc_in_opt(
const char* name_,
const in_if_type& interface_)
166 : base_type(name_,
const_cast<in_if_type&
>(interface_)) {}
168 explicit sc_in_opt(in_port_type& parent_)
169 : base_type(parent_) {}
171 sc_in_opt(
const char* name_, in_port_type& parent_)
172 : base_type(name_, parent_) {}
174 explicit sc_in_opt(inout_port_type& parent_)
176 sc_port_base::bind(parent_);
179 sc_in_opt(
const char* name_, inout_port_type& parent_)
181 sc_port_base::bind(parent_);
184 sc_in_opt(this_type& parent_)
185 : base_type(parent_) {}
187 sc_in_opt(
const char* name_, this_type& parent_)
188 : base_type(name_, parent_) {}
190 sc_in_opt(
const this_type&) =
delete;
192 virtual ~sc_in_opt() =
default;
194 this_type& operator=(
const this_type&) =
delete;
196 SCC_VIRT
void bind(
const in_if_type& interface_) { sc_port_base::bind(
const_cast<in_if_type&
>(interface_)); }
198 SCC_VIRT
void bind(in_if_type& interface_)
override { this->bind(
const_cast<const in_if_type&
>(interface_)); }
200 void operator()(
const in_if_type& interface_) { this->bind(interface_); }
202 SCC_VIRT
void bind(in_port_type& parent_) { sc_port_base::bind(parent_); }
204 void operator()(in_port_type& parent_) { this->bind(parent_); }
206 SCC_VIRT
void bind(inout_port_type& parent_) { sc_port_base::bind(parent_); }
208 void operator()(inout_port_type& parent_) { this->bind(parent_); }
210 const sc_core::sc_event& default_event()
const {
return (*this)->default_event(); }
212 const sc_core::sc_event& value_changed_event()
const {
return (*this)->value_changed_event(); }
214 const sc_core::sc_event& posedge_event()
const {
return (*this)->posedge_event(); }
216 const sc_core::sc_event& negedge_event()
const {
return (*this)->negedge_event(); }
218 const data_type& read()
const {
return (*this)->read(); }
220 operator const data_type&()
const {
return (*this)->read(); }
222 bool event()
const {
return (*this)->event(); }
224 bool posedge()
const {
return (*this)->posedge(); }
226 bool negedge()
const {
return (*this)->negedge(); }
228 virtual const char* kind()
const override {
return "sc_in"; }
237class SC_API sc_in_opt<sc_dt::sc_logic>
238:
public sc_core::sc_port<sc_core::sc_signal_in_if<sc_dt::sc_logic>, 1, sc_core::SC_ZERO_OR_MORE_BOUND> {
240 typedef sc_dt::sc_logic data_type;
242 typedef sc_core::sc_signal_in_if<data_type> if_type;
243 typedef sc_core::sc_port<if_type, 1, sc_core::SC_ZERO_OR_MORE_BOUND> base_type;
244 typedef sc_in_opt<data_type> this_type;
245 typedef base_type::port_type base_port_type;
247 typedef if_type in_if_type;
248 typedef base_type in_port_type;
249 typedef sc_core::sc_signal_inout_if<data_type> inout_if_type;
250 typedef sc_core::sc_port<inout_if_type, 1, sc_core::SC_ZERO_OR_MORE_BOUND> inout_port_type;
256 explicit sc_in_opt(
const char* name_)
257 : base_type(name_) {}
259 explicit sc_in_opt(
const in_if_type& interface_)
260 : base_type(
const_cast<in_if_type&
>(interface_)) {}
262 sc_in_opt(
const char* name_,
const in_if_type& interface_)
263 : base_type(name_,
const_cast<in_if_type&
>(interface_)) {}
265 explicit sc_in_opt(in_port_type& parent_)
266 : base_type(parent_) {}
268 sc_in_opt(
const char* name_, in_port_type& parent_)
269 : base_type(name_, parent_) {}
271 explicit sc_in_opt(inout_port_type& parent_)
273 sc_port_base::bind(parent_);
276 sc_in_opt(
const char* name_, inout_port_type& parent_)
278 sc_port_base::bind(parent_);
281 sc_in_opt(this_type& parent_)
282 : base_type(parent_) {}
284 sc_in_opt(
const char* name_, this_type& parent_)
285 : base_type(name_, parent_) {}
287 sc_in_opt(
const this_type&) =
delete;
289 virtual ~sc_in_opt() =
default;
291 this_type& operator=(
const this_type&) =
delete;
293 SCC_VIRT
void bind(
const in_if_type& interface_) { sc_port_base::bind(
const_cast<in_if_type&
>(interface_)); }
295 SCC_VIRT
void bind(in_if_type& interface_)
override { this->bind(
const_cast<const in_if_type&
>(interface_)); }
297 void operator()(
const in_if_type& interface_) { this->bind(interface_); }
299 SCC_VIRT
void bind(in_port_type& parent_) { sc_port_base::bind(parent_); }
301 void operator()(in_port_type& parent_) { this->bind(parent_); }
303 SCC_VIRT
void bind(inout_port_type& parent_) { sc_port_base::bind(parent_); }
305 void operator()(inout_port_type& parent_) { this->bind(parent_); }
307 const sc_core::sc_event& default_event()
const {
return (*this)->default_event(); }
309 const sc_core::sc_event& value_changed_event()
const {
return (*this)->value_changed_event(); }
311 const sc_core::sc_event& posedge_event()
const {
return (*this)->posedge_event(); }
313 const sc_core::sc_event& negedge_event()
const {
return (*this)->negedge_event(); }
315 const data_type& read()
const {
return (*this)->read(); }
317 operator const data_type&()
const {
return (*this)->read(); }
319 bool event()
const {
return (*this)->event(); }
321 bool posedge()
const {
return (*this)->posedge(); }
323 bool negedge()
const {
return (*this)->negedge(); }
325 virtual const char* kind()
const override {
return "sc_in"; }
335template <
class T>
class sc_inout_opt :
public sc_core::sc_port<sc_core::sc_signal_inout_if<T>, 1, sc_core::SC_ZERO_OR_MORE_BOUND> {
339 typedef sc_core::sc_signal_inout_if<data_type> if_type;
340 typedef sc_core::sc_port<if_type, 1, sc_core::SC_ZERO_OR_MORE_BOUND> base_type;
341 typedef sc_inout_opt<data_type> this_type;
343 typedef sc_core::sc_signal_in_if<data_type> in_if_type;
344 typedef sc_core::sc_port<in_if_type, 1, sc_core::SC_ZERO_OR_MORE_BOUND> in_port_type;
345 typedef if_type inout_if_type;
346 typedef base_type inout_port_type;
353 explicit sc_inout_opt(
const char* name_)
357 explicit sc_inout_opt(inout_if_type& interface_)
358 : base_type(interface_)
361 sc_inout_opt(
const char* name_, inout_if_type& interface_)
362 : base_type(name_, interface_)
365 explicit sc_inout_opt(inout_port_type& parent_)
369 sc_inout_opt(
const char* name_, inout_port_type& parent_)
370 : base_type(name_, parent_)
373 sc_inout_opt(this_type& parent_)
377 sc_inout_opt(
const char* name_, this_type& parent_)
378 : base_type(name_, parent_)
381 sc_inout_opt(
const this_type&) =
delete;
383 virtual ~sc_inout_opt() =
default;
385 const sc_core::sc_event& default_event()
const {
return (*this)->default_event(); }
387 const sc_core::sc_event& value_changed_event()
const {
return (*this)->value_changed_event(); }
389 const data_type& read()
const {
return (*this)->read(); }
391 operator const data_type&()
const {
return (*this)->read(); }
393 bool event()
const {
return (*this)->event(); }
395 void write(
const data_type& value_) { (*this)->write(value_); }
397 this_type& operator=(
const data_type& value_) {
398 (*this)->write(value_);
402 this_type& operator=(
const in_if_type& interface_) {
403 (*this)->write(interface_.read());
407 this_type& operator=(
const in_port_type& port_) {
408 (*this)->write(port_->read());
412 this_type& operator=(
const inout_port_type& port_) {
413 (*this)->write(port_->read());
417 this_type& operator=(
const this_type& port_) {
418 (*this)->write(port_->read());
422 void initialize(
const data_type& value_);
424 void initialize(
const in_if_type& interface_) { initialize(interface_.read()); }
426 void end_of_elaboration()
override;
428 virtual const char* kind()
const override {
return "sc_inout"; }
431 data_type* m_init_val;
463class SC_API sc_inout_opt<bool> :
public sc_core::sc_port<sc_core::sc_signal_inout_if<bool>, 1, sc_core::SC_ZERO_OR_MORE_BOUND> {
465 typedef bool data_type;
467 typedef sc_core::sc_signal_inout_if<data_type> if_type;
468 typedef sc_core::sc_port<if_type, 1, sc_core::SC_ZERO_OR_MORE_BOUND> base_type;
469 typedef sc_inout_opt<data_type> this_type;
471 typedef sc_core::sc_signal_in_if<data_type> in_if_type;
472 typedef sc_core::sc_port<in_if_type, 1, sc_core::SC_ZERO_OR_MORE_BOUND> in_port_type;
473 typedef if_type inout_if_type;
474 typedef base_type inout_port_type;
481 explicit sc_inout_opt(
const char* name_)
485 explicit sc_inout_opt(inout_if_type& interface_)
486 : base_type(interface_)
489 sc_inout_opt(
const char* name_, inout_if_type& interface_)
490 : base_type(name_, interface_)
493 explicit sc_inout_opt(inout_port_type& parent_)
497 sc_inout_opt(
const char* name_, inout_port_type& parent_)
498 : base_type(name_, parent_)
501 sc_inout_opt(this_type& parent_)
505 sc_inout_opt(
const char* name_, this_type& parent_)
506 : base_type(name_, parent_)
509 sc_inout_opt(
const this_type&) =
delete;
511 virtual ~sc_inout_opt() =
default;
513 const sc_core::sc_event& default_event()
const {
return (*this)->default_event(); }
515 const sc_core::sc_event& value_changed_event()
const {
return (*this)->value_changed_event(); }
517 const sc_core::sc_event& posedge_event()
const {
return (*this)->posedge_event(); }
519 const sc_core::sc_event& negedge_event()
const {
return (*this)->negedge_event(); }
521 const data_type& read()
const {
return (*this)->read(); }
523 operator const data_type&()
const {
return (*this)->read(); }
525 bool event()
const {
return (*this)->event(); }
527 bool posedge()
const {
return (*this)->posedge(); }
529 bool negedge()
const {
return (*this)->negedge(); }
531 void write(
const data_type& value_) { (*this)->write(value_); }
533 this_type& operator=(
const data_type& value_) {
534 (*this)->write(value_);
538 this_type& operator=(
const in_if_type& interface_) {
539 (*this)->write(interface_.read());
543 this_type& operator=(
const in_port_type& port_) {
544 (*this)->write(port_->read());
548 this_type& operator=(
const inout_port_type& port_) {
549 (*this)->write(port_->read());
553 this_type& operator=(
const this_type& port_) {
554 (*this)->write(port_->read());
558 void initialize(
const data_type& value_);
560 void initialize(
const in_if_type& interface_) { initialize(interface_.read()); }
562 void end_of_elaboration()
override {
563 if(m_init_val != 0) {
570 virtual const char* kind()
const override {
return "sc_inout"; }
573 data_type* m_init_val;
583class SC_API sc_inout_opt<sc_dt::sc_logic>
584:
public sc_core::sc_port<sc_core::sc_signal_inout_if<sc_dt::sc_logic>, 1, sc_core::SC_ZERO_OR_MORE_BOUND> {
586 typedef sc_dt::sc_logic data_type;
588 typedef sc_core::sc_signal_inout_if<data_type> if_type;
589 typedef sc_core::sc_port<if_type, 1, sc_core::SC_ZERO_OR_MORE_BOUND> base_type;
590 typedef sc_inout_opt<data_type> this_type;
592 typedef sc_core::sc_signal_in_if<data_type> in_if_type;
593 typedef sc_core::sc_port<in_if_type, 1, sc_core::SC_ZERO_OR_MORE_BOUND> in_port_type;
594 typedef if_type inout_if_type;
595 typedef base_type inout_port_type;
602 explicit sc_inout_opt(
const char* name_)
606 explicit sc_inout_opt(inout_if_type& interface_)
607 : base_type(interface_)
610 sc_inout_opt(
const char* name_, inout_if_type& interface_)
611 : base_type(name_, interface_)
614 explicit sc_inout_opt(inout_port_type& parent_)
618 sc_inout_opt(
const char* name_, inout_port_type& parent_)
619 : base_type(name_, parent_)
622 sc_inout_opt(this_type& parent_)
626 sc_inout_opt(
const char* name_, this_type& parent_)
627 : base_type(name_, parent_)
630 sc_inout_opt(
const this_type&) =
delete;
632 virtual ~sc_inout_opt();
634 const sc_core::sc_event& default_event()
const {
return (*this)->default_event(); }
636 const sc_core::sc_event& value_changed_event()
const {
return (*this)->value_changed_event(); }
638 const sc_core::sc_event& posedge_event()
const {
return (*this)->posedge_event(); }
640 const sc_core::sc_event& negedge_event()
const {
return (*this)->negedge_event(); }
642 const data_type& read()
const {
return (*this)->read(); }
644 operator const data_type&()
const {
return (*this)->read(); }
646 bool event()
const {
return (*this)->event(); }
648 bool posedge()
const {
return (*this)->posedge(); }
650 bool negedge()
const {
return (*this)->negedge(); }
652 void write(
const data_type& value_) { (*this)->write(value_); }
654 this_type& operator=(
const data_type& value_) {
655 (*this)->write(value_);
659 this_type& operator=(
const in_if_type& interface_) {
660 (*this)->write(interface_.read());
664 this_type& operator=(
const in_port_type& port_) {
665 (*this)->write(port_->read());
669 this_type& operator=(
const inout_port_type& port_) {
670 (*this)->write(port_->read());
674 this_type& operator=(
const this_type& port_) {
675 (*this)->write(port_->read());
679 void initialize(
const data_type& value_);
681 void initialize(
const in_if_type& interface_) { initialize(interface_.read()); }
684 void end_of_elaboration()
override {
685 if(m_init_val != 0) {
692 virtual const char* kind()
const override {
return "sc_inout"; }
695 data_type* m_init_val;
705template <
class T>
class sc_out_opt :
public sc_inout_opt<T> {
709 typedef sc_out_opt<data_type> this_type;
710 typedef sc_inout_opt<data_type> base_type;
712 typedef typename base_type::in_if_type in_if_type;
713 typedef typename base_type::in_port_type in_port_type;
714 typedef typename base_type::inout_if_type inout_if_type;
715 typedef typename base_type::inout_port_type inout_port_type;
721 explicit sc_out_opt(
const char* name_)
722 : base_type(name_) {}
724 explicit sc_out_opt(inout_if_type& interface_)
725 : base_type(interface_) {}
727 sc_out_opt(
const char* name_, inout_if_type& interface_)
728 : base_type(name_, interface_) {}
730 explicit sc_out_opt(inout_port_type& parent_)
731 : base_type(parent_) {}
733 sc_out_opt(
const char* name_, inout_port_type& parent_)
734 : base_type(name_, parent_) {}
736 sc_out_opt(this_type& parent_)
737 : base_type(parent_) {}
739 sc_out_opt(
const char* name_, this_type& parent_)
740 : base_type(name_, parent_) {}
742 virtual ~sc_out_opt() {}
744 this_type& operator=(
const data_type& value_) {
745 (*this)->write(value_);
749 this_type& operator=(
const in_if_type& interface_) {
750 (*this)->write(interface_.read());
754 this_type& operator=(
const in_port_type& port_) {
755 (*this)->write(port_->read());
759 this_type& operator=(
const inout_port_type& port_) {
760 (*this)->write(port_->read());
764 this_type& operator=(
const this_type& port_) {
765 (*this)->write(port_->read());
769 virtual const char* kind()
const override {
return "sc_out"; }
772 sc_out_opt(
const this_type&) =
delete;