sy_process_constructors.hpp
Go to the documentation of this file.
1 /**********************************************************************
2  * sy_process_constructors.hpp -- Process constructors in the SY *
3  * MOC *
4  * *
5  * Author: Hosein Attarzadeh (shan2@kth.se) *
6  * *
7  * Purpose: Providing basic process constructors for modeling *
8  * synchronous systems in ForSyDe-SystemC *
9  * *
10  * Usage: This file is included automatically *
11  * *
12  * License: BSD3 *
13  *******************************************************************/
14 
15 #ifndef SY_PROCESS_CONSTRUCTORS_HPP
16 #define SY_PROCESS_CONSTRUCTORS_HPP
17 
25 #include <functional>
26 #include <tuple>
27 #include <array>
28 #include <algorithm>
29 
30 #include "abst_ext.hpp"
31 #include "sy_process.hpp"
32 
33 namespace ForSyDe
34 {
35 
36 namespace SY
37 {
38 
39 using namespace sc_core;
40 
42 
46 template <typename T0, typename T1>
47 class comb : public sy_process
48 {
49 public:
52 
54  typedef std::function<void(abst_ext<T0>&,const abst_ext<T1>&)> functype;
55 
57 
61  comb(const sc_module_name& _name,
62  const functype& _func
63  ) : sy_process(_name), iport1("iport1"), oport1("oport1"),
64  _func(_func)
65  {
66 #ifdef FORSYDE_INTROSPECTION
67  std::string func_name = std::string(basename());
68  func_name = func_name.substr(0, func_name.find_last_not_of("0123456789")+1);
69  arg_vec.push_back(std::make_tuple("_func",func_name+std::string("_func")));
70 #endif
71  }
72 
74  std::string forsyde_kind() const {return "SY::comb";}
75 
76 private:
77  // Inputs and output variables
78  abst_ext<T0>* oval;
79  abst_ext<T1>* ival1;
80 
82  functype _func;
83 
84  //Implementing the abstract semantics
85  void init()
86  {
87  oval = new abst_ext<T0>;
88  ival1 = new abst_ext<T1>;
89  }
90 
91  void prep()
92  {
93  *ival1 = iport1.read();
94  }
95 
96  void exec()
97  {
98  _func(*oval, *ival1);
99  }
100 
101  void prod()
102  {
103  WRITE_MULTIPORT(oport1, *oval)
104  }
105 
106  void clean()
107  {
108  delete ival1;
109  delete oval;
110  }
111 
112 #ifdef FORSYDE_INTROSPECTION
113  void bindInfo()
114  {
115  boundInChans.resize(1); // only one input port
116  boundInChans[0].port = &iport1;
117  boundOutChans.resize(1); // only one output port
118  boundOutChans[0].port = &oport1;
119  }
120 #endif
121 };
122 
124 
126 template <typename T0, typename T1, typename T2>
127 class comb2 : public sy_process
128 {
129 public:
133 
135  typedef std::function<void(abst_ext<T0>&, const abst_ext<T1>&,
137 
139 
143  comb2(const sc_module_name& _name,
144  const functype& _func
145  ) : sy_process(_name), iport1("iport1"), iport2("iport2"), oport1("oport1"),
146  _func(_func)
147  {
148 #ifdef FORSYDE_INTROSPECTION
149  std::string func_name = std::string(basename());
150  func_name = func_name.substr(0, func_name.find_last_not_of("0123456789")+1);
151  arg_vec.push_back(std::make_tuple("_func",func_name+std::string("_func")));
152 #endif
153  }
154 
156  std::string forsyde_kind() const {return "SY::comb2";}
157 private:
158  // Inputs and output variables
159  abst_ext<T0>* oval;
160  abst_ext<T1>* ival1;
161  abst_ext<T2>* ival2;
162 
164  functype _func;
165 
166  //Implementing the abstract semantics
167  void init()
168  {
169  oval = new abst_ext<T0>;
170  ival1 = new abst_ext<T1>;
171  ival2 = new abst_ext<T2>;
172  }
173 
174  void prep()
175  {
176  *ival1 = iport1.read();
177  *ival2 = iport2.read();
178  }
179 
180  void exec()
181  {
182  _func(*oval, *ival1, *ival2);
183  }
184 
185  void prod()
186  {
187  WRITE_MULTIPORT(oport1, *oval)
188  }
189 
190  void clean()
191  {
192  delete ival2;
193  delete ival1;
194  delete oval;
195  }
196 
197 #ifdef FORSYDE_INTROSPECTION
198  void bindInfo()
199  {
200  boundInChans.resize(2); // only one input port
201  boundInChans[0].port = &iport1;
202  boundInChans[1].port = &iport2;
203  boundOutChans.resize(1); // only one output port
204  boundOutChans[0].port = &oport1;
205  }
206 #endif
207 };
208 
210 
212 template <typename T0, typename T1, typename T2, typename T3>
213 class comb3 : public sy_process
214 {
215 public:
220 
222  typedef std::function<void(abst_ext<T0>&, const abst_ext<T1>&,
223  const abst_ext<T2>&,
225 
227 
231  comb3(const sc_module_name& _name,
232  const functype& _func
233  ) : sy_process(_name), iport1("iport1"), iport2("iport2"), iport3("iport3"),
234  oport1("oport1"), _func(_func)
235  {
236 #ifdef FORSYDE_INTROSPECTION
237  std::string func_name = std::string(basename());
238  func_name = func_name.substr(0, func_name.find_last_not_of("0123456789")+1);
239  arg_vec.push_back(std::make_tuple("_func",func_name+std::string("_func")));
240 #endif
241  }
242 
244  std::string forsyde_kind() const {return "SY::comb3";}
245 
246 private:
247  // Inputs and output variables
248  abst_ext<T0>* oval;
249  abst_ext<T1>* ival1;
250  abst_ext<T2>* ival2;
251  abst_ext<T3>* ival3;
252 
254  functype _func;
255 
256  //Implementing the abstract semantics
257  void init()
258  {
259  oval = new abst_ext<T0>;
260  ival1 = new abst_ext<T1>;
261  ival2 = new abst_ext<T2>;
262  ival3 = new abst_ext<T3>;
263  }
264 
265  void prep()
266  {
267  *ival1 = iport1.read();
268  *ival2 = iport2.read();
269  *ival3 = iport3.read();
270  }
271 
272  void exec()
273  {
274  _func(*oval, *ival1, *ival2, *ival3);
275  }
276 
277  void prod()
278  {
279  WRITE_MULTIPORT(oport1, *oval)
280  }
281 
282  void clean()
283  {
284  delete ival3;
285  delete ival2;
286  delete ival1;
287  delete oval;
288  }
289 
290 #ifdef FORSYDE_INTROSPECTION
291  void bindInfo()
292  {
293  boundInChans.resize(3); // only one input port
294  boundInChans[0].port = &iport1;
295  boundInChans[1].port = &iport2;
296  boundInChans[2].port = &iport3;
297  boundOutChans.resize(1); // only one output port
298  boundOutChans[0].port = &oport1;
299  }
300 #endif
301 };
302 
304 
306 template <typename T0, typename T1, typename T2, typename T3, typename T4>
307 class comb4 : public sy_process
308 {
309 public:
315 
317  typedef std::function<void(abst_ext<T0>&, const abst_ext<T1>&,
318  const abst_ext<T2>&,
319  const abst_ext<T3>&,
321 
323 
327  comb4(const sc_module_name& _name,
328  const functype& _func
329  ) : sy_process(_name), iport1("iport1"), iport2("iport2"),
330  iport3("iport3"), iport4("iport4"), _func(_func)
331  {
332 #ifdef FORSYDE_INTROSPECTION
333  std::string func_name = std::string(basename());
334  func_name = func_name.substr(0, func_name.find_last_not_of("0123456789")+1);
335  arg_vec.push_back(std::make_tuple("_func",func_name+std::string("_func")));
336 #endif
337  }
338 
340  std::string forsyde_kind() const{return "SY::comb4";}
341 
342 private:
343  // Inputs and output variables
344  abst_ext<T0>* oval;
345  abst_ext<T1>* ival1;
346  abst_ext<T2>* ival2;
347  abst_ext<T3>* ival3;
348  abst_ext<T4>* ival4;
349 
351  functype _func;
352 
353  //Implementing the abstract semantics
354  void init()
355  {
356  oval = new abst_ext<T0>;
357  ival1 = new abst_ext<T1>;
358  ival2 = new abst_ext<T2>;
359  ival3 = new abst_ext<T3>;
360  ival4 = new abst_ext<T4>;
361  }
362 
363  void prep()
364  {
365  *ival1 = iport1.read();
366  *ival2 = iport2.read();
367  *ival3 = iport3.read();
368  *ival4 = iport4.read();
369  }
370 
371  void exec()
372  {
373  _func(*oval, *ival1, *ival2, *ival3, *ival4);
374  }
375 
376  void prod()
377  {
378  WRITE_MULTIPORT(oport1, *oval)
379  }
380 
381  void clean()
382  {
383  delete ival4;
384  delete ival3;
385  delete ival2;
386  delete ival1;
387  delete oval;
388  }
389 
390 #ifdef FORSYDE_INTROSPECTION
391  void bindInfo()
392  {
393  boundInChans.resize(4); // only one input port
394  boundInChans[0].port = &iport1;
395  boundInChans[1].port = &iport2;
396  boundInChans[2].port = &iport3;
397  boundInChans[3].port = &iport4;
398  boundOutChans.resize(1); // only one output port
399  boundOutChans[0].port = &oport1;
400  }
401 #endif
402 };
403 
405 
407 template <typename T0, typename T1, std::size_t N>
408 class combX : public sy_process
409 {
410 public:
411  std::array<SY_in<T1>,N> iport;
413 
415  typedef std::function<void(abst_ext<T0>&, const std::array<abst_ext<T1>,N>&)> functype;
416 
418 
422  combX(const sc_module_name& _name,
423  const functype& _func
424  ) : sy_process(_name), _func(_func)
425  {
426 #ifdef FORSYDE_INTROSPECTION
427  std::string func_name = std::string(basename());
428  func_name = func_name.substr(0, func_name.find_last_not_of("0123456789")+1);
429  arg_vec.push_back(std::make_tuple("_func",func_name+std::string("_func")));
430 #endif
431  }
432 
434  std::string forsyde_kind() const{return "SY::combX";}
435 
436 private:
437  // Inputs and output variables
438  abst_ext<T0>* oval;
439  std::array<abst_ext<T1>,N> ival;
440 
442  functype _func;
443 
444  //Implementing the abstract semantics
445  void init()
446  {
447  oval = new abst_ext<T0>;
448  }
449 
450  void prep()
451  {
452  for (size_t i=0; i<N; i++)
453  ival[i] = iport[i].read();
454  }
455 
456  void exec()
457  {
458  _func(*oval, ival);
459  }
460 
461  void prod()
462  {
463  WRITE_MULTIPORT(oport1, *oval)
464  }
465 
466  void clean()
467  {
468  delete oval;
469  }
470 
471 #ifdef FORSYDE_INTROSPECTION
472  void bindInfo()
473  {
474  boundInChans.resize(N); // only one input port
475  for (size_t i=0; i<N; i++)
476  boundInChans[i].port = &iport[i];
477  boundOutChans.resize(1); // only one output port
478  boundOutChans[0].port = &oport1;
479  }
480 #endif
481 };
482 
484 
493 template <class T>
494 class delay : public sy_process
495 {
496 public:
499 
501 
505  delay(const sc_module_name& _name,
506  const abst_ext<T>& init_val
507  ) : sy_process(_name), iport1("iport1"), oport1("oport1"),
508  init_val(init_val)
509  {
510 #ifdef FORSYDE_INTROSPECTION
511  std::stringstream ss;
512  ss << init_val;
513  arg_vec.push_back(std::make_tuple("init_val", ss.str()));
514 #endif
515  }
516 
518  std::string forsyde_kind() const {return "SY::delay";}
519 
520 private:
521  // Initial value
522  abst_ext<T> init_val;
523 
524  // Inputs and output variables
525  abst_ext<T>* val;
526 
527  //Implementing the abstract semantics
528  void init()
529  {
530  val = new abst_ext<T>;
531  WRITE_MULTIPORT(oport1, init_val)
532  }
533 
534  void prep()
535  {
536  *val = iport1.read();
537  }
538 
539  void exec() {}
540 
541  void prod()
542  {
543  WRITE_MULTIPORT(oport1, *val)
544  }
545 
546  void clean()
547  {
548  delete val;
549  }
550 #ifdef FORSYDE_INTROSPECTION
551  void bindInfo()
552  {
553  boundInChans.resize(1); // only one input port
554  boundInChans[0].port = &iport1;
555  boundOutChans.resize(1); // only one output port
556  boundOutChans[0].port = &oport1;
557  }
558 #endif
559 };
560 
562 
569 template <class T>
570 class delayn : public sy_process
571 {
572 public:
575 
577 
581  delayn(const sc_module_name& _name,
582  const abst_ext<T>& init_val,
583  const unsigned int& n
584  ) : sy_process(_name), iport1("iport1"), oport1("oport1"),
585  init_val(init_val), ns(n)
586  {
587 #ifdef FORSYDE_INTROSPECTION
588  std::stringstream ss;
589  ss << init_val;
590  arg_vec.push_back(std::make_tuple("init_val", ss.str()));
591  ss.str("");
592  ss << n;
593  arg_vec.push_back(std::make_tuple("n", ss.str()));
594 #endif
595  }
596 
598  std::string forsyde_kind() const {return "SY::delayn";}
599 
600 private:
601  // Initial value
602  abst_ext<T> init_val;
603  unsigned int ns;
604 
605  // Inputs and output variables
606  abst_ext<T>* val;
607 
608  //Implementing the abstract semantics
609  void init()
610  {
611  val = new abst_ext<T>;
612  for (int i=0; i<ns; i++)
613  WRITE_MULTIPORT(oport1, init_val)
614  }
615 
616  void prep()
617  {
618  *val = iport1.read();
619  }
620 
621  void exec() {}
622 
623  void prod()
624  {
625  WRITE_MULTIPORT(oport1, *val)
626  }
627 
628  void clean()
629  {
630  delete val;
631  }
632 #ifdef FORSYDE_INTROSPECTION
633  void bindInfo()
634  {
635  boundInChans.resize(1); // only one input port
636  boundInChans[0].port = &iport1;
637  boundOutChans.resize(1); // only one output port
638  boundOutChans[0].port = &oport1;
639  }
640 #endif
641 };
642 
644 
648 template <class IT, class ST, class OT>
649 class moore : public sy_process
650 {
651 public:
654 
656  typedef std::function<void(ST&, const ST&, const abst_ext<IT>&)> ns_functype;
657 
659  typedef std::function<void(abst_ext<OT>&, const ST&)> od_functype;
660 
662 
666  moore(const sc_module_name& _name,
667  const ns_functype& _ns_func,
668  const od_functype& _od_func,
669  const ST& init_st
670  ) : sy_process(_name), _ns_func(_ns_func), _od_func(_od_func),
671  init_st(init_st)
672  {
673 #ifdef FORSYDE_INTROSPECTION
674  std::string func_name = std::string(basename());
675  func_name = func_name.substr(0, func_name.find_last_not_of("0123456789")+1);
676  arg_vec.push_back(std::make_tuple("_ns_func",func_name+std::string("_ns_func")));
677  arg_vec.push_back(std::make_tuple("_od_func",func_name+std::string("_od_func")));
678  std::stringstream ss;
679  ss << init_st;
680  arg_vec.push_back(std::make_tuple("init_st",ss.str()));
681 #endif
682  }
683 
685  std::string forsyde_kind() const{return "SY::moore";}
686 
687 private:
689  ns_functype _ns_func;
690  od_functype _od_func;
691  // Initial value
692  ST init_st;
693 
694  bool first_run;
695 
696  // Input, output, current state, and next state variables
697  abst_ext<IT>* ival;
698  ST* stval;
699  ST* nsval;
700  abst_ext<OT>* oval;
701 
702  //Implementing the abstract semantics
703  void init()
704  {
705  ival = new abst_ext<IT>;
706  stval = new ST;
707  *stval = init_st;
708  nsval = new ST;
709  oval = new abst_ext<OT>;
710  // First evaluation cycle
711  first_run = true;
712  }
713 
714  void prep()
715  {
716  if (!first_run)
717  *ival = iport1.read();
718  }
719 
720  void exec()
721  {
722  if (first_run)
723  first_run = false;
724  else
725  {
726  _ns_func(*nsval, *stval, *ival);
727  *stval = *nsval;
728  }
729  _od_func(*oval, *stval);
730  }
731 
732  void prod()
733  {
734  WRITE_MULTIPORT(oport1, *oval)
735  }
736 
737  void clean()
738  {
739  delete ival;
740  delete stval;
741  delete nsval;
742  delete oval;
743  }
744 #ifdef FORSYDE_INTROSPECTION
745  void bindInfo()
746  {
747  boundInChans.resize(1); // only one input port
748  boundInChans[0].port = &iport1;
749  boundOutChans.resize(1); // only one output port
750  boundOutChans[0].port = &oport1;
751  }
752 #endif
753 };
754 
756 
760 template <class IT, class ST, class OT>
761 class mealy : public sy_process
762 {
763 public:
766 
768  typedef std::function<void(ST&, const ST&,
770 
772  typedef std::function<void(abst_ext<OT>&, const ST&,
774 
776 
780  mealy(const sc_module_name& _name,
781  const ns_functype& _ns_func,
782  const od_functype& _od_func,
783  const ST& init_st
784  ) : sy_process(_name), _ns_func(_ns_func), _od_func(_od_func),
785  init_st(init_st)
786  {
787 #ifdef FORSYDE_INTROSPECTION
788  std::string func_name = std::string(basename());
789  func_name = func_name.substr(0, func_name.find_last_not_of("0123456789")+1);
790  arg_vec.push_back(std::make_tuple("_ns_func",func_name+std::string("_ns_func")));
791  arg_vec.push_back(std::make_tuple("_od_func",func_name+std::string("_od_func")));
792  std::stringstream ss;
793  ss << init_st;
794  arg_vec.push_back(std::make_tuple("init_st",ss.str()));
795 #endif
796  }
797 
799  std::string forsyde_kind() const{return "SY::mealy";}
800 
801 private:
803  ns_functype _ns_func;
804  od_functype _od_func;
805  // Initial value
806  ST init_st;
807 
808  // Input, output, current state, and next state variables
809  abst_ext<IT>* ival;
810  ST* stval;
811  ST* nsval;
812  abst_ext<OT>* oval;
813 
814  //Implementing the abstract semantics
815  void init()
816  {
817  ival = new abst_ext<IT>;
818  stval = new ST;
819  *stval = init_st;
820  nsval = new ST;
821  oval = new abst_ext<OT>;
822  }
823 
824  void prep()
825  {
826  *ival = iport1.read();
827  }
828 
829  void exec()
830  {
831  _od_func(*oval, *stval, *ival);
832  _ns_func(*nsval, *stval, *ival);
833  *stval = *nsval;
834  }
835 
836  void prod()
837  {
838  WRITE_MULTIPORT(oport1, *oval)
839  }
840 
841  void clean()
842  {
843  delete ival;
844  delete stval;
845  delete nsval;
846  delete oval;
847  }
848 #ifdef FORSYDE_INTROSPECTION
849  void bindInfo()
850  {
851  boundInChans.resize(1); // only one input port
852  boundInChans[0].port = &iport1;
853  boundOutChans.resize(1); // only one output port
854  boundOutChans[0].port = &oport1;
855  }
856 #endif
857 };
858 
860 
864 template <class T>
865 class fill : public sy_process
866 {
867 public:
870 
872 
875  fill(const sc_module_name& _name,
876  const T& def_val
877  ) : sy_process(_name), def_val(def_val)
878  {
879 #ifdef FORSYDE_INTROSPECTION
880  std::stringstream ss;
881  ss << def_val;
882  arg_vec.push_back(std::make_tuple("def_val", ss.str()));
883 #endif
884  }
885 
887  std::string forsyde_kind() const {return "SY::fill";}
888 
889 private:
890  // The default value
891  T def_val;
892 
893  // Inputs and output variables
894  abst_ext<T>* ival;
895  abst_ext<T>* oval;
896 
897  //Implementing the abstract semantics
898  void init()
899  {
900  ival = new abst_ext<T>;
901  oval = new abst_ext<T>;
902  }
903 
904  void prep()
905  {
906  *ival = iport1.read();
907  }
908 
909  void exec()
910  {
911  *oval = abst_ext<T>(ival->from_abst_ext(def_val));
912  }
913 
914  void prod()
915  {
916  WRITE_MULTIPORT(oport1, *oval)
917  }
918 
919  void clean()
920  {
921  delete ival;
922  delete oval;
923  }
924 #ifdef FORSYDE_INTROSPECTION
925  void bindInfo()
926  {
927  boundInChans.resize(1); // only one input port
928  boundInChans[0].port = &iport1;
929  boundOutChans.resize(1); // only one output port
930  boundOutChans[0].port = &oport1;
931  }
932 #endif
933 };
934 
936 
941 template <class T>
942 class hold : public sy_process
943 {
944 public:
947 
949 
952  hold(const sc_module_name& _name,
953  const T& def_val
954  ) : sy_process(_name), def_val(def_val)
955  {
956 #ifdef FORSYDE_INTROSPECTION
957  std::stringstream ss;
958  ss << def_val;
959  arg_vec.push_back(std::make_tuple("def_val", ss.str()));
960 #endif
961  }
962 
964  std::string forsyde_kind() const {return "SY::hold";}
965 
966 private:
967  // The efault value
968  T def_val;
969 
970  // Input and default output variables
971  abst_ext<T>* ival;
972  abst_ext<T>* oval;
973 
974  //Implementing the abstract semantics
975  void init()
976  {
977  ival = new abst_ext<T>;
978  oval = new abst_ext<T>;
979  *oval = abst_ext<T>(def_val);
980  }
981 
982  void prep()
983  {
984  *ival = iport1.read();
985  }
986 
987  void exec()
988  {
989  *oval = ival->is_present() ? *ival : *oval;
990  }
991 
992  void prod()
993  {
994  WRITE_MULTIPORT(oport1, *oval)
995  }
996 
997  void clean()
998  {
999  delete ival;
1000  delete oval;
1001  }
1002 #ifdef FORSYDE_INTROSPECTION
1003  void bindInfo()
1004  {
1005  boundInChans.resize(1); // only one input port
1006  boundInChans[0].port = &iport1;
1007  boundOutChans.resize(1); // only one output port
1008  boundOutChans[0].port = &oport1;
1009  }
1010 #endif
1011 };
1012 
1014 
1019 template <class T>
1020 class constant : public sy_process
1021 {
1022 public:
1024 
1026 
1029  constant(const sc_module_name& _name,
1030  const abst_ext<T>& init_val,
1031  const unsigned long long& take=0
1032  ) : sy_process(_name), oport1("oport1"),
1033  init_val(init_val), take(take)
1034 
1035  {
1036 #ifdef FORSYDE_INTROSPECTION
1037  std::stringstream ss;
1038  ss << init_val;
1039  arg_vec.push_back(std::make_tuple("init_val", ss.str()));
1040  ss.str("");
1041  ss << take;
1042  arg_vec.push_back(std::make_tuple("take", ss.str()));
1043 #endif
1044  }
1045 
1047  std::string forsyde_kind() const {return "SY::constant";}
1048 
1049 private:
1050  abst_ext<T> init_val;
1051  unsigned long long take; // Number of tokens produced
1052 
1053  unsigned long long tok_cnt;
1054  bool infinite;
1055 
1056  //Implementing the abstract semantics
1057  void init()
1058  {
1059  infinite = take==0 ? true : false;
1060  tok_cnt = 0;
1061  }
1062 
1063  void prep() {}
1064 
1065  void exec() {}
1066 
1067  void prod()
1068  {
1069  if (tok_cnt++ < take || infinite)
1070  WRITE_MULTIPORT(oport1, init_val)
1071  else wait();
1072  }
1073 
1074  void clean() {}
1075 
1076 #ifdef FORSYDE_INTROSPECTION
1077  void bindInfo()
1078  {
1079  boundOutChans.resize(1); // only one output port
1080  boundOutChans[0].port = &oport1;
1081  }
1082 #endif
1083 };
1084 
1086 
1091 template <class T>
1092 class source : public sy_process
1093 {
1094 public:
1096 
1098  typedef std::function<void(abst_ext<T>&, const abst_ext<T>&)> functype;
1099 
1101 
1104  source(const sc_module_name& _name,
1105  const functype& _func,
1106  const abst_ext<T>& init_val,
1107  const unsigned long long& take=0
1108  ) : sy_process(_name), oport1("oport1"),
1109  init_st(init_val), take(take), _func(_func)
1110  {
1111 #ifdef FORSYDE_INTROSPECTION
1112  std::string func_name = std::string(basename());
1113  func_name = func_name.substr(0, func_name.find_last_not_of("0123456789")+1);
1114  arg_vec.push_back(std::make_tuple("_func",func_name+std::string("_func")));
1115  std::stringstream ss;
1116  ss << init_val;
1117  arg_vec.push_back(std::make_tuple("init_val", ss.str()));
1118  ss.str("");
1119  ss << take;
1120  arg_vec.push_back(std::make_tuple("take", ss.str()));
1121 #endif
1122  }
1123 
1125  std::string forsyde_kind() const {return "SY::source";}
1126 
1127 private:
1128  abst_ext<T> init_st; // The current state
1129  unsigned long long take; // Number of tokens produced
1130 
1131  abst_ext<T>* cur_st; // The current state of the process
1132  unsigned long long tok_cnt;
1133  bool infinite;
1134 
1136  functype _func;
1137 
1138  //Implementing the abstract semantics
1139  void init()
1140  {
1141  cur_st = new abst_ext<T>;
1142  *cur_st = init_st;
1143  WRITE_MULTIPORT(oport1, *cur_st)
1144  infinite = take==0 ? true : false;
1145  tok_cnt = 1;
1146  }
1147 
1148  void prep() {}
1149 
1150  void exec()
1151  {
1152  _func(*cur_st, *cur_st);
1153  }
1154 
1155  void prod()
1156  {
1157  if (tok_cnt++ < take || infinite)
1158  WRITE_MULTIPORT(oport1, *cur_st)
1159  else wait();
1160  }
1161 
1162  void clean()
1163  {
1164  delete cur_st;
1165  }
1166 
1167 #ifdef FORSYDE_INTROSPECTION
1168  void bindInfo()
1169  {
1170  boundOutChans.resize(1); // only one output port
1171  boundOutChans[0].port = &oport1;
1172  }
1173 #endif
1174 };
1175 
1177 
1183 template <class T>
1184 class file_source : public sy_process
1185 {
1186 public:
1188 
1190  typedef std::function<void(abst_ext<T>&, const std::string&)> functype;
1191 
1193 
1196  file_source(sc_module_name _name,
1197  functype _func,
1198  std::string file_name
1199  ) : sy_process(_name), oport1("oport1"),
1200  file_name(file_name), _func(_func)
1201  {
1202 #ifdef FORSYDE_INTROSPECTION
1203  std::string func_name = std::string(basename());
1204  func_name = func_name.substr(0, func_name.find_last_not_of("0123456789")+1);
1205  arg_vec.push_back(std::make_tuple("_func",func_name+std::string("_func")));
1206  arg_vec.push_back(std::make_tuple("file_name", file_name));
1207 #endif
1208  }
1209 
1211  std::string forsyde_kind() const {return "SY::file_source";}
1212 
1213 private:
1214  std::string file_name;
1215 
1216  std::string cur_str; // The current string read from the input
1217  std::ifstream ifs;
1218  abst_ext<T>* cur_val;
1219 
1221  functype _func;
1222 
1223  //Implementing the abstract semantics
1224  void init()
1225  {
1226  cur_val = new abst_ext<T>;
1227  ifs.open(file_name);
1228  if (!ifs.is_open())
1229  {
1230  SC_REPORT_ERROR(name(),"cannot open the file.");
1231  }
1232  }
1233 
1234  void prep()
1235  {
1236  if (!getline(ifs,cur_str))
1237  {
1238  wait();
1239  }
1240  }
1241 
1242  void exec()
1243  {
1244  _func(*cur_val, cur_str);
1245  }
1246 
1247  void prod()
1248  {
1249  WRITE_MULTIPORT(oport1, *cur_val)
1250  }
1251 
1252  void clean()
1253  {
1254  ifs.close();
1255  delete cur_val;
1256  }
1257 
1258 #ifdef FORSYDE_INTROSPECTION
1259  void bindInfo()
1260  {
1261  boundOutChans.resize(1); // only one output port
1262  boundOutChans[0].port = &oport1;
1263  }
1264 #endif
1265 };
1266 
1268 
1272 template <class T>
1273 class vsource : public sy_process
1274 {
1275 public:
1277 
1279 
1282  vsource(const sc_module_name& _name,
1283  const std::vector<abst_ext<T>>& in_vec
1284  ) : sy_process(_name), in_vec(in_vec)
1285  {
1286 #ifdef FORSYDE_INTROSPECTION
1287  std::stringstream ss;
1288  ss << in_vec;
1289  arg_vec.push_back(std::make_tuple("in_vec", ss.str()));
1290 #endif
1291  }
1292 
1294  std::string forsyde_kind() const {return "SY::vsource";}
1295 
1296 private:
1297  std::vector<abst_ext<T>> in_vec;
1298 
1299  unsigned long tok_cnt;
1300 
1301  //Implementing the abstract semantics
1302  void init()
1303  {
1304  tok_cnt = 0;
1305  }
1306 
1307  void prep() {}
1308 
1309  void exec() {}
1310 
1311  void prod()
1312  {
1313  if (tok_cnt < in_vec.size())
1314  {
1315  WRITE_MULTIPORT(oport1, in_vec[tok_cnt])
1316  tok_cnt++;
1317  }
1318  else
1319  wait();
1320  }
1321 
1322  void clean() {}
1323 
1324 #ifdef FORSYDE_INTROSPECTION
1325  void bindInfo()
1326  {
1327  boundOutChans.resize(1); // only one output port
1328  boundOutChans[0].port = &oport1;
1329  }
1330 #endif
1331 };
1332 
1334 
1338 template <class T>
1339 class sink : public sy_process
1340 {
1341 public:
1343 
1345  typedef std::function<void(const abst_ext<T>&)> functype;
1346 
1348 
1351  sink(const sc_module_name& _name,
1352  const functype& _func
1353  ) : sy_process(_name), iport1("iport1"), _func(_func)
1354 
1355  {
1356 #ifdef FORSYDE_INTROSPECTION
1357  std::string func_name = std::string(basename());
1358  func_name = func_name.substr(0, func_name.find_last_not_of("0123456789")+1);
1359  arg_vec.push_back(std::make_tuple("_func",func_name+std::string("_func")));
1360 #endif
1361  }
1362 
1364  std::string forsyde_kind() const {return "SY::sink";}
1365 
1366 private:
1367  abst_ext<T>* val; // The current state of the process
1368 
1370  functype _func;
1371 
1372  //Implementing the abstract semantics
1373  void init()
1374  {
1375  val = new abst_ext<T>;
1376  }
1377 
1378  void prep()
1379  {
1380  *val = iport1.read();
1381  }
1382 
1383  void exec()
1384  {
1385  _func(*val);
1386  }
1387 
1388  void prod() {}
1389 
1390  void clean()
1391  {
1392  delete val;
1393  }
1394 
1395 #ifdef FORSYDE_INTROSPECTION
1396  void bindInfo()
1397  {
1398  boundInChans.resize(1); // only one output port
1399  boundInChans[0].port = &iport1;
1400  }
1401 #endif
1402 };
1403 
1405 
1410 template <class T>
1411 class file_sink : public sy_process
1412 {
1413 public:
1415 
1417  typedef std::function<void(std::string&, const abst_ext<T>&)> functype;
1418 
1420 
1423  file_sink(sc_module_name _name,
1424  functype _func,
1425  std::string file_name
1426  ) : sy_process(_name), iport1("iport1"), file_name(file_name),
1427  _func(_func)
1428 
1429  {
1430 #ifdef FORSYDE_INTROSPECTION
1431  std::string func_name = std::string(basename());
1432  func_name = func_name.substr(0, func_name.find_last_not_of("0123456789")+1);
1433  arg_vec.push_back(std::make_tuple("_func",func_name+std::string("_func")));
1434  arg_vec.push_back(std::make_tuple("file_name", file_name));
1435 #endif
1436  }
1437 
1439  std::string forsyde_kind() const {return "SY::file_sink";}
1440 
1441 private:
1442  std::string file_name;
1443 
1444  std::string ostr; // The current string to be written to the output
1445  std::ofstream ofs;
1446  abst_ext<T>* cur_val; // The current state of the process
1447 
1449  functype _func;
1450 
1451  //Implementing the abstract semantics
1452  void init()
1453  {
1454  cur_val = new abst_ext<T>;
1455  ofs.open(file_name);
1456  if (!ofs.is_open())
1457  {
1458  SC_REPORT_ERROR(name(),"cannot open the file.");
1459  }
1460  }
1461 
1462  void prep()
1463  {
1464  *cur_val = iport1.read();
1465  }
1466 
1467  void exec()
1468  {
1469  _func(ostr, *cur_val);
1470  }
1471 
1472  void prod()
1473  {
1474  ofs << ostr << std::endl;
1475  }
1476 
1477  void clean()
1478  {
1479  ofs.close();
1480  delete cur_val;
1481  }
1482 
1483 #ifdef FORSYDE_INTROSPECTION
1484  void bindInfo()
1485  {
1486  boundInChans.resize(1); // only one output port
1487  boundInChans[0].port = &iport1;
1488  }
1489 #endif
1490 };
1491 
1493 
1495 template <class T1, class T2>
1496 class zip : public sy_process
1497 {
1498 public:
1502 
1504 
1507  zip(const sc_module_name& _name
1508  )
1509  :sy_process(_name), iport1("iport1"), iport2("iport2"), oport1("oport1")
1510  { }
1511 
1513  std::string forsyde_kind() const {return "SY::zip";}
1514 
1515 private:
1516  // intermediate values
1517  abst_ext<T1>* ival1;
1518  abst_ext<T2>* ival2;
1519 
1520  void init()
1521  {
1522  ival1 = new abst_ext<T1>;
1523  ival2 = new abst_ext<T2>;
1524  }
1525 
1526  void prep()
1527  {
1528  *ival1 = iport1.read();
1529  *ival2 = iport2.read();
1530  }
1531 
1532  void exec() {}
1533 
1534  void prod()
1535  {
1536  typedef std::tuple<abst_ext<T1>,abst_ext<T2>> TT;
1537  if (ival1->is_absent() && ival2->is_absent())
1538  {
1539 
1540  WRITE_MULTIPORT(oport1,abst_ext<TT>()) // write to the output 1
1541  }
1542  else
1543  {
1544  abst_ext<TT> oval(std::make_tuple(*ival1,*ival2));
1545  WRITE_MULTIPORT(oport1,oval) // write to the output
1546  }
1547  }
1548 
1549  void clean()
1550  {
1551  delete ival1;
1552  delete ival2;
1553  }
1554 
1555 #ifdef FORSYDE_INTROSPECTION
1556  void bindInfo()
1557  {
1558  boundInChans.resize(2); // two input ports
1559  boundInChans[0].port = &iport1;
1560  boundInChans[1].port = &iport2;
1561  boundOutChans.resize(1); // only one output port
1562  boundOutChans[0].port = &oport1;
1563  }
1564 #endif
1565 };
1566 
1568 
1570 template <class T1, std::size_t N>
1571 class zipX : public sy_process
1572 {
1573 public:
1574  std::array<SY_in<T1>,N> iport;
1576 
1578 
1581  zipX(const sc_module_name& _name
1582  )
1583  :sy_process(_name), oport1("oport1")
1584  { }
1585 
1587  std::string forsyde_kind() const {return "SY::zipX";}
1588 
1589 private:
1590  // intermediate values
1591  std::array<abst_ext<T1>,N> ival;
1592 
1593  void init() {}
1594 
1595  void prep()
1596  {
1597  for (size_t i=0; i<N; i++)
1598  ival[i] = iport[i].read();
1599  }
1600 
1601  void exec() {}
1602 
1603  void prod()
1604  {
1605  typedef std::array<abst_ext<T1>,N> TT;
1606  if (std::all_of(ival.begin(), ival.end(), [](abst_ext<T1> ivalx){return ivalx.is_absent();}))
1607  {
1608  WRITE_MULTIPORT(oport1,abst_ext<TT>()) // write to the output 1
1609  }
1610  else
1611  {
1612  WRITE_MULTIPORT(oport1,abst_ext<TT>(ival)) // write to the output
1613  }
1614  }
1615 
1616  void clean() {}
1617 
1618 #ifdef FORSYDE_INTROSPECTION
1619  void bindInfo()
1620  {
1621  boundInChans.resize(N); // N input ports
1622  for (size_t i=0;i<N;i++)
1623  boundInChans[i].port = &iport[i];
1624  boundOutChans.resize(1); // only one output port
1625  boundOutChans[0].port = &oport1;
1626  }
1627 #endif
1628 };
1629 
1631 
1633 template <class... Ts>
1634 class zipN : public sy_process
1635 {
1636 public:
1637  std::tuple <SY_in<Ts>...> iport;
1639 
1641 
1644  zipN(const sc_module_name& _name
1645  )
1646  : sy_process(_name), oport1("oport1")
1647  { }
1648 
1650  std::string forsyde_kind() const {return "SY::zipN";}
1651 private:
1652  // intermediate values
1653  std::tuple<abst_ext<Ts>...>* in_vals;
1654 
1655  void init()
1656  {
1657  in_vals = new std::tuple<abst_ext<Ts>...>;
1658  }
1659 
1660  void prep()
1661  {
1662  *in_vals = sc_fifo_tuple_read<Ts...>(iport);
1663  }
1664 
1665  void exec() {}
1666 
1667  void prod()
1668  {
1669  WRITE_MULTIPORT(oport1,abst_ext<std::tuple<abst_ext<Ts>...>>(*in_vals)) // write to the output
1670  }
1671 
1672  void clean()
1673  {
1674  delete in_vals;
1675  }
1676 
1677  template<size_t N,class R, class T>
1678  struct fifo_read_helper
1679  {
1680  static void read(R& ret, T& t)
1681  {
1682  fifo_read_helper<N-1,R,T>::read(ret,t);
1683  std::get<N>(ret) = std::get<N>(t).read();
1684  }
1685  };
1686 
1687  template<class R, class T>
1688  struct fifo_read_helper<0,R,T>
1689  {
1690  static void read(R& ret, T& t)
1691  {
1692  std::get<0>(ret) = std::get<0>(t).read();
1693  }
1694  };
1695 
1696  template<class... T>
1697  std::tuple<abst_ext<T>...> sc_fifo_tuple_read(std::tuple<SY_in<T>...>& ports)
1698  {
1699  std::tuple<abst_ext<T>...> ret;
1700  fifo_read_helper<sizeof...(T)-1,
1701  std::tuple<abst_ext<T>...>,
1702  std::tuple<SY_in<T>...>>::read(ret,ports);
1703  return ret;
1704  }
1705 
1706 };
1707 
1709 
1711 template <class T1, class T2>
1712 class unzip : public sy_process
1713 {
1714 public:
1718 
1720 
1723  unzip(const sc_module_name& _name
1724  )
1725  :sy_process(_name), iport1("iport1"), oport1("oport1"), oport2("oport2")
1726  {}
1727 
1729  std::string forsyde_kind() const {return "SY::unzip";}
1730 private:
1731  // intermediate values
1733 
1734  void init()
1735  {
1737  }
1738 
1739  void prep()
1740  {
1741  *in_val = iport1.read();
1742  }
1743 
1744  void exec() {}
1745 
1746  void prod()
1747  {
1748  if (in_val->is_absent())
1749  {
1750  WRITE_MULTIPORT(oport1,abst_ext<T1>()) // write to the output 1
1751  WRITE_MULTIPORT(oport2,abst_ext<T2>()) // write to the output 2
1752  }
1753  else
1754  {
1755  WRITE_MULTIPORT(oport1,abst_ext<T1>(std::get<0>(in_val->unsafe_from_abst_ext()))) // write to the output 1
1756  WRITE_MULTIPORT(oport2,abst_ext<T2>(std::get<1>(in_val->unsafe_from_abst_ext()))) // write to the output 2
1757  }
1758  }
1759 
1760  void clean()
1761  {
1762  delete in_val;
1763  }
1764 
1765 #ifdef FORSYDE_INTROSPECTION
1766  void bindInfo()
1767  {
1768  boundInChans.resize(1); // only one input port
1769  boundInChans[0].port = &iport1;
1770  boundOutChans.resize(2); // two output ports
1771  boundOutChans[0].port = &oport1;
1772  boundOutChans[1].port = &oport2;
1773  }
1774 #endif
1775 };
1776 
1778 
1780 template <class T1, std::size_t N>
1781 class unzipX : public sy_process
1782 {
1783 public:
1785  std::array<SY_out<T1>,N> oport;
1786 
1788 
1791  unzipX(const sc_module_name& _name
1792  )
1793  :sy_process(_name), iport1("iport1")
1794  {}
1795 
1797  std::string forsyde_kind() const {return "SY::unzipX";}
1798 private:
1799  // intermediate values
1801 
1802  void init()
1803  {
1804  in_val = new abst_ext<std::array<abst_ext<T1>,N>>;
1805  }
1806 
1807  void prep()
1808  {
1809  *in_val = iport1.read();
1810  }
1811 
1812  void exec() {}
1813 
1814  void prod()
1815  {
1816  if (in_val->is_absent())
1817  {
1818  for (size_t i=0; i<N; i++)
1819  WRITE_MULTIPORT(oport[i],abst_ext<T1>()) // write to the output i
1820  }
1821  else
1822  {
1823  for (size_t i=0; i<N; i++)
1824  WRITE_MULTIPORT(oport[i],abst_ext<T1>(in_val->unsafe_from_abst_ext()[i])) // write to the output i
1825  }
1826  }
1827 
1828  void clean()
1829  {
1830  delete in_val;
1831  }
1832 
1833 #ifdef FORSYDE_INTROSPECTION
1834  void bindInfo()
1835  {
1836  boundInChans.resize(1); // only one input port
1837  boundInChans[0].port = &iport1;
1838  boundOutChans.resize(N); // output ports
1839  for (size_t i=0;i<N;i++)
1840  boundOutChans[i].port = &oport[i];
1841  }
1842 #endif
1843 };
1844 
1846 
1848 template <class... Ts>
1849 class unzipN : public sy_process
1850 {
1851 public:
1853  std::tuple<SY_out<Ts>...> oport;
1854 
1856 
1859  unzipN(const sc_module_name& _name
1860  )
1861  :sy_process(_name), iport1("iport1")
1862  { }
1863 
1865  std::string forsyde_kind() const {return "SY::unzipN";}
1866 private:
1867  // intermediate values
1868  abst_ext<std::tuple<abst_ext<Ts>...>>* in_val;
1869 
1870  void init()
1871  {
1872  in_val = new abst_ext<std::tuple<abst_ext<Ts>...>>;
1873  }
1874 
1875  void prep()
1876  {
1877  *in_val = iport1.read();
1878  }
1879 
1880  void exec() {}
1881 
1882  void prod()
1883  {
1884  if (in_val->is_absent())
1885  {
1886  std::tuple<abst_ext<Ts>...> all_abs;
1887  fifo_tuple_write<Ts...>(all_abs, oport);
1888  }
1889  else
1890  {
1891  fifo_tuple_write<Ts...>(in_val->unsafe_from_abst_ext(), oport);
1892  }
1893  }
1894 
1895  void clean()
1896  {
1897  delete in_val;
1898  }
1899 
1900  template<size_t N,class R, class T>
1901  struct fifo_write_helper
1902  {
1903  static void write(const R& vals, T& t)
1904  {
1905  fifo_write_helper<N-1,R,T>::write(vals,t);
1906  std::get<N>(t).write(std::get<N>(vals));
1907  }
1908  };
1909 
1910  template<class R, class T>
1911  struct fifo_write_helper<0,R,T>
1912  {
1913  static void write(const R& vals, T& t)
1914  {
1915  std::get<0>(t).write(std::get<0>(vals));
1916  }
1917  };
1918 
1919  template<class... T>
1920  void fifo_tuple_write(const std::tuple<abst_ext<T>...>& vals,
1921  std::tuple<SY_out<T>...>& ports)
1922  {
1923  fifo_write_helper<sizeof...(T)-1,
1924  std::tuple<abst_ext<T>...>,
1925  std::tuple<SY_out<T>...>>::write(vals,ports);
1926  }
1927 
1928 #ifdef FORSYDE_INTROSPECTION
1929  void bindInfo()
1930  {
1931  boundInChans.resize(1); // only one input port
1932  boundInChans[0].port = &iport1;
1933  boundOutChans.resize(sizeof...(Ts)); // two output ports
1934  register_ports(boundOutChans, oport);
1935  }
1936 
1937  template<size_t N, class T>
1938  struct register_ports_helper
1939  {
1940  static void reg_port(std::vector<PortInfo>& boundChans, T& t)
1941  {
1942  register_ports_helper<N-1,T>::reg_port(boundChans,t);
1943  boundChans[N].port = &std::get<N>(t);
1944  }
1945  };
1946 
1947  template<class T>
1948  struct register_ports_helper<0,T>
1949  {
1950  static void reg_port(std::vector<PortInfo>& boundChans, T& t)
1951  {
1952  boundChans[0].port = &std::get<0>(t);
1953  }
1954  };
1955 
1956  template<class... T>
1957  void register_ports(std::vector<PortInfo>& boundChans,
1958  std::tuple<SY_out<T>...>& ports)
1959  {
1960  register_ports_helper<sizeof...(T)-1,
1961  std::tuple<SY_out<T>...>&>::reg_port(boundChans,ports);
1962  }
1963 #endif
1964 
1965 };
1966 
1968 
1972 template <class T>
1973 class group : public sy_process
1974 {
1975 public:
1978 
1980 
1984  group(const sc_module_name& _name,
1985  const unsigned long& samples
1986  )
1987  :sy_process(_name), samples(samples)
1988  {
1989 #ifdef FORSYDE_INTROSPECTION
1990  std::stringstream ss;
1991  ss << samples;
1992  arg_vec.push_back(std::make_tuple("samples", ss.str()));
1993 #endif
1994  }
1995 
1997  std::string forsyde_kind() const {return "SY::group";}
1998 
1999 private:
2000  // Number of samples in each group
2001  unsigned long samples;
2002 
2003  unsigned long samples_took;
2004 
2005  // The output vector
2006  std::vector<abst_ext<T>>* oval;
2007 
2008  //Implementing the abstract semantics
2009  void init()
2010  {
2011  oval = new std::vector<abst_ext<T>>;
2012  oval->resize(samples);
2013  samples_took = 0;
2014  }
2015 
2016  void prep()
2017  {
2018  (*oval)[samples_took] = iport1.read();
2019  samples_took++;
2020  }
2021 
2022  void exec() {}
2023 
2024  void prod()
2025  {
2026  if (samples_took==samples)
2027  {
2028  WRITE_MULTIPORT(oport1, abst_ext<std::vector<abst_ext<T>>>(*oval))
2029  samples_took = 0;
2030  }
2031  else
2032  WRITE_MULTIPORT(oport1, abst_ext<std::vector<abst_ext<T>>>())
2033  }
2034 
2035  void clean()
2036  {
2037  delete oval;
2038  }
2039 #ifdef FORSYDE_INTROSPECTION
2040  void bindInfo()
2041  {
2042  boundInChans.resize(1); // only one input port
2043  boundInChans[0].port = &iport1;
2044  boundOutChans.resize(1); // only one output port
2045  boundOutChans[0].port = &oport1;
2046  }
2047 #endif
2048 };
2049 
2051 
2060 template <class T>
2061 class fanout : public sy_process
2062 {
2063 public:
2066 
2068 
2071  fanout(const sc_module_name& _name
2072  )
2073  : sy_process(_name) { }
2074 
2076  std::string forsyde_kind() const {return "SY::fanout";}
2077 
2078 private:
2079  // Inputs and output variables
2080  abst_ext<T>* val;
2081 
2082  //Implementing the abstract semantics
2083  void init()
2084  {
2085  val = new abst_ext<T>;
2086  }
2087 
2088  void prep()
2089  {
2090  *val = iport1.read();
2091  }
2092 
2093  void exec() {}
2094 
2095  void prod()
2096  {
2097  WRITE_MULTIPORT(oport1, *val)
2098  }
2099 
2100  void clean()
2101  {
2102  delete val;
2103  }
2104 #ifdef FORSYDE_INTROSPECTION
2105  void bindInfo()
2106  {
2107  boundInChans.resize(1); // only one input port
2108  boundInChans[0].port = &iport1;
2109  boundOutChans.resize(1); // only one output port
2110  boundOutChans[0].port = &oport1;
2111  }
2112 #endif
2113 };
2114 
2115 }
2116 }
2117 
2118 #endif
SY_in< std::tuple< abst_ext< Ts >... > > iport1
port for the input channel
Definition: sy_process_constructors.hpp:1852
Process constructor for a hold process.
Definition: sy_process_constructors.hpp:942
SY_out< T > oport1
port for the output channel
Definition: sy_process_constructors.hpp:946
T unsafe_from_abst_ext() const
Unsafely converts a value from an extended value assuming it is present.
Definition: abst_ext.hpp:54
std::string forsyde_kind() const
Specifying from which process constructor is the module built.
Definition: sy_process_constructors.hpp:1865
SY_out< T2 > oport2
port for the output channel 2
Definition: sy_process_constructors.hpp:1717
SY_in< T > iport1
port for the input channel
Definition: sy_process_constructors.hpp:1976
SY_out< OT > oport1
port for the output channel
Definition: sy_process_constructors.hpp:653
SY_in< T > iport1
port for the input channel
Definition: sy_process_constructors.hpp:1342
SY_in< T1 > iport1
port for the input channel 1
Definition: sy_process_constructors.hpp:130
comb(const sc_module_name &_name, const functype &_func)
The constructor requires the module name.
Definition: sy_process_constructors.hpp:61
SY_in< T > iport1
port for the input channel
Definition: sy_process_constructors.hpp:868
SY_out< T > oport1
port for the output channel
Definition: sy_process_constructors.hpp:498
std::function< void(std::string &, const abst_ext< T > &)> functype
Type of the function to be passed to the process constructor.
Definition: sy_process_constructors.hpp:1417
The group process with one input and one absent-extended output.
Definition: sy_process_constructors.hpp:1973
SY_in< T > iport1
port for the input channel
Definition: sy_process_constructors.hpp:945
std::array< SY_out< T1 >, N > oport
port array for the output channels
Definition: sy_process_constructors.hpp:1785
SY_in< T > iport1
port for the input channel
Definition: sy_process_constructors.hpp:1414
The namespace for ForSyDe.
Definition: abssemantics.hpp:30
SY_in< T2 > iport2
port for the input channel 2
Definition: sy_process_constructors.hpp:217
fanout(const sc_module_name &_name)
The constructor requires the module name.
Definition: sy_process_constructors.hpp:2071
std::tuple< SY_in< Ts >... > iport
tuple of ports for the input channels
Definition: sy_process_constructors.hpp:1637
Process constructor for a file_sink process.
Definition: sy_process_constructors.hpp:1411
std::function< void(abst_ext< T > &, const std::string &)> functype
Type of the function to be passed to the process constructor.
Definition: sy_process_constructors.hpp:1190
std::function< void(abst_ext< double > &, const abst_ext< double > &)> functype
Type of the function to be passed to the process constructor.
Definition: sy_process_constructors.hpp:1098
Process constructor for a fill process.
Definition: sy_process_constructors.hpp:865
Implements the Absent-extended values.
comb3(const sc_module_name &_name, const functype &_func)
The constructor requires the module name.
Definition: sy_process_constructors.hpp:231
std::string forsyde_kind() const
Specifying from which process constructor is the module built.
Definition: sy_process_constructors.hpp:518
sink(const sc_module_name &_name, const functype &_func)
The constructor requires the module name.
Definition: sy_process_constructors.hpp:1351
Process constructor for a delay element.
Definition: sy_process_constructors.hpp:494
SY_out< T0 > oport1
port for the output channel
Definition: sy_process_constructors.hpp:132
SY_out< std::tuple< abst_ext< T1 >, abst_ext< T2 > > > oport1
port for the output channel
Definition: sy_process_constructors.hpp:1501
std::string forsyde_kind() const
Specifying from which process constructor is the module built.
Definition: sy_process_constructors.hpp:340
SY_in< T1 > iport1
port for the input channel 1
Definition: sy_process_constructors.hpp:216
Process constructor for a n-delay element.
Definition: sy_process_constructors.hpp:570
std::string forsyde_kind() const
Specifying from which process constructor is the module built.
Definition: sy_process_constructors.hpp:1047
SY_in< T1 > iport1
port for the input channel 1
Definition: sy_process_constructors.hpp:310
Process constructor for a combinational process with four inputs and one output.
Definition: sy_process_constructors.hpp:307
SY_in< T4 > iport4
port for the input channel 4
Definition: sy_process_constructors.hpp:313
group(const sc_module_name &_name, const unsigned long &samples)
The constructor requires the module name.
Definition: sy_process_constructors.hpp:1984
Process constructor for a constant source process.
Definition: sy_process_constructors.hpp:1020
std::string forsyde_kind() const
Specifying from which process constructor is the module built.
Definition: sy_process_constructors.hpp:1997
SY_in< T1 > iport1
port for the input channel 1
Definition: sy_process_constructors.hpp:1499
Process constructor for a combinational process with an array of inputs and one output.
Definition: sy_process_constructors.hpp:408
SY_out< T > oport1
port for the output channel
Definition: sy_process_constructors.hpp:1187
moore(const sc_module_name &_name, const ns_functype &_ns_func, const od_functype &_od_func, const ST &init_st)
The constructor requires the module name.
Definition: sy_process_constructors.hpp:666
file_source(sc_module_name _name, functype _func, std::string file_name)
The constructor requires the module name.
Definition: sy_process_constructors.hpp:1196
Process constructor for a Mealy machine.
Definition: sy_process_constructors.hpp:761
std::string forsyde_kind() const
Specifying from which process constructor is the module built.
Definition: sy_process_constructors.hpp:1513
Implements the abstract process in the synchronous Model of Computation.
SY_out< T > oport1
port for the output channel
Definition: sy_process_constructors.hpp:1023
std::string forsyde_kind() const
Specifying from which process constructor is the module built.
Definition: sy_process_constructors.hpp:2076
SY_in< T > iport1
port for the input channel
Definition: sy_process_constructors.hpp:2064
std::array< SY_in< T1 >, N > iport
port for the input channel 1
Definition: sy_process_constructors.hpp:411
bool is_present() const
Checks for the presence of a value.
Definition: abst_ext.hpp:85
SY_out< T > oport1
port for the output channel
Definition: sy_process_constructors.hpp:869
std::string forsyde_kind() const
Specifying from which process constructor is the module built.
Definition: sy_process_constructors.hpp:887
std::tuple< SY_out< Ts >... > oport
tuple of ports for the output channels
Definition: sy_process_constructors.hpp:1853
std::string forsyde_kind() const
Specifying from which process constructor is the module built.
Definition: sy_process_constructors.hpp:598
std::function< void(abst_ext< OT > &, const ST &)> od_functype
Type of the output-decoding function to be passed to the process constructor.
Definition: sy_process_constructors.hpp:659
SY_out< T1 > oport1
port for the output channel 1
Definition: sy_process_constructors.hpp:1716
std::string forsyde_kind() const
Specifying from which process constructor is the module built.
Definition: sy_process_constructors.hpp:1439
source(const sc_module_name &_name, const functype &_func, const abst_ext< T > &init_val, const unsigned long long &take=0)
The constructor requires the module name.
Definition: sy_process_constructors.hpp:1104
std::function< void(abst_ext< T0 > &, const abst_ext< T1 > &, const abst_ext< T2 > &, const abst_ext< T3 > &)> functype
Type of the function to be passed to the process constructor.
Definition: sy_process_constructors.hpp:224
std::function< void(abst_ext< T0 > &, const abst_ext< T1 > &, const abst_ext< T2 > &, const abst_ext< T3 > &, const abst_ext< T4 > &)> functype
Type of the function to be passed to the process constructor.
Definition: sy_process_constructors.hpp:320
SY_in< T2 > iport2
port for the input channel 2
Definition: sy_process_constructors.hpp:1500
SY_in< IT > iport1
port for the input channel
Definition: sy_process_constructors.hpp:764
SY_out< T > oport1
port for the output channel
Definition: sy_process_constructors.hpp:574
Process constructor for a source process.
Definition: sy_process_constructors.hpp:1092
SY_out< T0 > oport1
port for the output channel
Definition: sy_process_constructors.hpp:314
std::array< SY_in< T1 >, N > iport
port array for the input channels
Definition: sy_process_constructors.hpp:1574
Process constructor for a combinational process with three inputs and one output. ...
Definition: sy_process_constructors.hpp:213
SY_in< std::tuple< abst_ext< T1 >, abst_ext< T2 > > > iport1
port for the input channel
Definition: sy_process_constructors.hpp:1715
std::string forsyde_kind() const
Specifying from which process constructor is the module built.
Definition: sy_process_constructors.hpp:1294
std::string forsyde_kind() const
Specifying from which process constructor is the module built.
Definition: sy_process_constructors.hpp:244
SY_out< T0 > oport1
port for the output channel
Definition: sy_process_constructors.hpp:412
std::function< void(abst_ext< T0 > &, const abst_ext< T1 > &)> functype
Type of the function to be passed to the process constructor.
Definition: sy_process_constructors.hpp:54
unzipN(const sc_module_name &_name)
The constructor requires the module name.
Definition: sy_process_constructors.hpp:1859
hold(const sc_module_name &_name, const T &def_val)
The constructor requires the process name and a default value.
Definition: sy_process_constructors.hpp:952
std::string forsyde_kind() const
Specifying from which process constructor is the module built.
Definition: sy_process_constructors.hpp:1364
Process constructor for a sink process.
Definition: sy_process_constructors.hpp:1339
bool is_absent() const
Checks for the absence of a value.
Definition: abst_ext.hpp:79
SY_out< T0 > oport1
port for the output channel
Definition: sy_process_constructors.hpp:51
Process constructor for a fan-out process with one input and one output.
Definition: sy_process_constructors.hpp:2061
Process constructor for a source process with vector input.
Definition: sy_process_constructors.hpp:1273
Process constructor for a Moore machine.
Definition: sy_process_constructors.hpp:649
zipN(const sc_module_name &_name)
The constructor requires the module name.
Definition: sy_process_constructors.hpp:1644
Process constructor for a combinational process with two inputs and one output.
Definition: sy_process_constructors.hpp:127
std::function< void(abst_ext< T0 > &, const abst_ext< T1 > &, const abst_ext< T2 > &)> functype
Type of the function to be passed to the process constructor.
Definition: sy_process_constructors.hpp:136
std::string forsyde_kind() const
Specifying from which process constructor is the module built.
Definition: sy_process_constructors.hpp:1650
std::string forsyde_kind() const
Specifying from which process constructor is the module built.
Definition: sy_process_constructors.hpp:156
delayn(const sc_module_name &_name, const abst_ext< T > &init_val, const unsigned int &n)
The constructor requires the module name.
Definition: sy_process_constructors.hpp:581
unzip(const sc_module_name &_name)
The constructor requires the module name.
Definition: sy_process_constructors.hpp:1723
std::string forsyde_kind() const
Specifying from which process constructor is the module built.
Definition: sy_process_constructors.hpp:1729
std::string forsyde_kind() const
Specifying from which process constructor is the module built.
Definition: sy_process_constructors.hpp:1587
The unzip process with one input and variable number of outputs.
Definition: sy_process_constructors.hpp:1849
The zip process with two inputs and one output.
Definition: sy_process_constructors.hpp:1496
SY_in< T2 > iport2
port for the input channel 2
Definition: sy_process_constructors.hpp:131
comb2(const sc_module_name &_name, const functype &_func)
The constructor requires the module name.
Definition: sy_process_constructors.hpp:143
The unzip process with one input and two outputs.
Definition: sy_process_constructors.hpp:1712
The process constructor which defines the abstract semantics of execution.
Definition: abssemantics.hpp:212
std::function< void(const abst_ext< T > &)> functype
Type of the function to be passed to the process constructor.
Definition: sy_process_constructors.hpp:1345
SY_in< T3 > iport3
port for the input channel 3
Definition: sy_process_constructors.hpp:218
SY_in< std::array< abst_ext< T1 >, N > > iport1
port for the input channel
Definition: sy_process_constructors.hpp:1784
SY_in< T3 > iport3
port for the input channel 3
Definition: sy_process_constructors.hpp:312
std::function< void(ST &, const ST &, const abst_ext< IT > &)> ns_functype
Type of the next-state function to be passed to the process constructor.
Definition: sy_process_constructors.hpp:769
std::function< void(abst_ext< OT > &, const ST &, const abst_ext< IT > &)> od_functype
Type of the output-decoding function to be passed to the process constructor.
Definition: sy_process_constructors.hpp:773
T from_abst_ext(const T &defval) const
Converts a value from an extended value, returning a default value if absent.
Definition: abst_ext.hpp:42
SY_out< std::array< abst_ext< T1 >, N > > oport1
port for the output channel
Definition: sy_process_constructors.hpp:1575
combX(const sc_module_name &_name, const functype &_func)
The constructor requires the module name.
Definition: sy_process_constructors.hpp:422
std::string forsyde_kind() const
Specifying from which process constructor is the module built.
Definition: sy_process_constructors.hpp:434
SY_out< T0 > oport1
port for the output channel
Definition: sy_process_constructors.hpp:219
SY_in< T > iport1
port for the input channel
Definition: sy_process_constructors.hpp:573
delay(const sc_module_name &_name, const abst_ext< T > &init_val)
The constructor requires the module name.
Definition: sy_process_constructors.hpp:505
SY_out< std::vector< abst_ext< T > > > oport1
port for the output channel
Definition: sy_process_constructors.hpp:1977
SY_in< IT > iport1
port for the input channel
Definition: sy_process_constructors.hpp:652
constant(const sc_module_name &_name, const abst_ext< T > &init_val, const unsigned long long &take=0)
The constructor requires the module name.
Definition: sy_process_constructors.hpp:1029
std::string forsyde_kind() const
Specifying from which process constructor is the module built.
Definition: sy_process_constructors.hpp:685
SY_in< T1 > iport1
port for the input channel
Definition: sy_process_constructors.hpp:50
std::string forsyde_kind() const
Specifying from which process constructor is the module built.
Definition: sy_process_constructors.hpp:1797
SY_out< T > oport1
port for the output channel
Definition: sy_process_constructors.hpp:2065
vsource(const sc_module_name &_name, const std::vector< abst_ext< T >> &in_vec)
The constructor requires the module name.
Definition: sy_process_constructors.hpp:1282
std::string forsyde_kind() const
Specifying from which process constructor is the module built.
Definition: sy_process_constructors.hpp:799
std::string forsyde_kind() const
Specifying from which process constructor is the module built.
Definition: sy_process_constructors.hpp:964
SY_in< T > iport1
port for the input channel
Definition: sy_process_constructors.hpp:497
std::string forsyde_kind() const
Specifying from which process constructor is the module built.
Definition: sy_process_constructors.hpp:1125
Process constructor for a file_source process.
Definition: sy_process_constructors.hpp:1184
SY_out< T > oport1
port for the output channel
Definition: sy_process_constructors.hpp:1095
std::function< void(ST &, const ST &, const abst_ext< IT > &)> ns_functype
Type of the next-state function to be passed to the process constructor.
Definition: sy_process_constructors.hpp:656
file_sink(sc_module_name _name, functype _func, std::string file_name)
The constructor requires the module name.
Definition: sy_process_constructors.hpp:1423
std::string forsyde_kind() const
Specifying from which process constructor is the module built.
Definition: sy_process_constructors.hpp:74
SY_out< std::tuple< abst_ext< Ts >... > > oport1
port for the output channel
Definition: sy_process_constructors.hpp:1638
unzipX(const sc_module_name &_name)
The constructor requires the module name.
Definition: sy_process_constructors.hpp:1791
SY_out< OT > oport1
port for the output channel
Definition: sy_process_constructors.hpp:765
Process constructor for a combinational process with one input and one output.
Definition: sy_process_constructors.hpp:47
mealy(const sc_module_name &_name, const ns_functype &_ns_func, const od_functype &_od_func, const ST &init_st)
The constructor requires the module name.
Definition: sy_process_constructors.hpp:780
The unzipX process with one input and an array of outputs.
Definition: sy_process_constructors.hpp:1781
comb4(const sc_module_name &_name, const functype &_func)
The constructor requires the module name.
Definition: sy_process_constructors.hpp:327
SY_in< T2 > iport2
port for the input channel 2
Definition: sy_process_constructors.hpp:311
std::string forsyde_kind() const
Specifying from which process constructor is the module built.
Definition: sy_process_constructors.hpp:1211
SY_out< T > oport1
port for the output channel
Definition: sy_process_constructors.hpp:1276
zipX(const sc_module_name &_name)
The constructor requires the module name.
Definition: sy_process_constructors.hpp:1581
The zipX process with an array of inputs and one output.
Definition: sy_process_constructors.hpp:1571
fill(const sc_module_name &_name, const T &def_val)
The constructor requires the process name and a default value.
Definition: sy_process_constructors.hpp:875
The zip process with variable number of inputs and one output.
Definition: sy_process_constructors.hpp:1634
zip(const sc_module_name &_name)
The constructor requires the module name.
Definition: sy_process_constructors.hpp:1507
std::function< void(abst_ext< T0 > &, const std::array< abst_ext< T1 >, N > &)> functype
Type of the function to be passed to the process constructor.
Definition: sy_process_constructors.hpp:415