sy_helpers_strict.hpp
Go to the documentation of this file.
1 /**********************************************************************
2  * sy_helpers_strict.hpp -- strict helper primitives in the SY MoC *
3  * *
4  * Author: Hosein Attarzadeh (shan2@kth.se) *
5  * *
6  * Purpose: Providing helper primitives for modeling in the SY MoC *
7  * *
8  * Usage: This file is included automatically *
9  * *
10  * License: BSD3 *
11  *******************************************************************/
12 
13 #ifndef SY_HELPERS_STRICT_HPP
14 #define SY_HELPERS_STRICT_HPP
15 
23 #include <functional>
24 #include <tuple>
25 
26 #include "abst_ext.hpp"
28 
29 namespace ForSyDe
30 {
31 
32 namespace SY
33 {
34 
35 using namespace sc_core;
36 
38 
44 template <class T0, template <class> class OIf,
45  class T1, template <class> class I1If>
46 inline scomb<T0,T1>* make_scomb(const std::string& pName,
47  const typename scomb<T0,T1>::functype& _func,
48  OIf<T0>& outS,
49  I1If<T1>& inp1S
50  )
51 {
52  auto p = new scomb<T0,T1>(pName.c_str(), _func);
53 
54  (*p).iport1(inp1S);
55  (*p).oport1(outS);
56 
57  return p;
58 }
59 
61 
67 template <class T0, template <class> class OIf,
68  class T1, template <class> class I1If,
69  class T2, template <class> class I2If>
70 inline scomb2<T0,T1,T2>* make_scomb2(const std::string& pName,
71  const typename scomb2<T0,T1,T2>::functype& _func,
72  OIf<T0>& outS,
73  I1If<T1>& inp1S,
74  I2If<T2>& inp2S
75  )
76 {
77  auto p = new scomb2<T0,T1,T2>(pName.c_str(), _func);
78 
79  (*p).iport1(inp1S);
80  (*p).iport2(inp2S);
81  (*p).oport1(outS);
82 
83  return p;
84 }
85 
87 
93 template <class T0, template <class> class OIf,
94  class T1, template <class> class I1If,
95  class T2, template <class> class I2If,
96  class T3, template <class> class I3If>
97 inline scomb3<T0,T1,T2,T3>* make_scomb3(const std::string& pName,
98  const typename scomb3<T0,T1,T2,T3>::functype& _func,
99  OIf<T0>& outS,
100  I1If<T1>& inp1S,
101  I2If<T2>& inp2S,
102  I3If<T3>& inp3S
103  )
104 {
105  auto p = new scomb3<T0,T1,T2,T3>(pName.c_str(), _func);
106 
107  (*p).iport1(inp1S);
108  (*p).iport2(inp2S);
109  (*p).iport3(inp3S);
110  (*p).oport1(outS);
111 
112  return p;
113 }
114 
116 
122 template <class T0, template <class> class OIf,
123  class T1, template <class> class I1If,
124  class T2, template <class> class I2If,
125  class T3, template <class> class I3If,
126  class T4, template <class> class I4If>
127 inline scomb4<T0,T1,T2,T3,T4>* make_scomb4(const std::string& pName,
128  const typename scomb4<T0,T1,T2,T3,T4>::functype& _func,
129  OIf<T0>& outS,
130  I1If<T1>& inp1S,
131  I2If<T2>& inp2S,
132  I3If<T3>& inp3S,
133  I4If<T4>& inp4S
134  )
135 {
136  auto p = new scomb4<T0,T1,T2,T3,T4>(pName.c_str(), _func);
137 
138  (*p).iport1(inp1S);
139  (*p).iport2(inp2S);
140  (*p).iport3(inp3S);
141  (*p).iport4(inp4S);
142  (*p).oport1(outS);
143 
144  return p;
145 }
146 
148 
154 template <class T0, template <class> class OIf,
155  class T1, template <class> class IIf,
156  std::size_t N>
157 inline scombX<T0,T1,N>* make_scombX(const std::string& pName,
158  const typename scombX<T0,T1,N>::functype& _func,
159  OIf<T0>& outS,
160  std::array<IIf<T1>,N>& inpS
161  )
162 {
163  auto p = new scombX<T0,T1,N>(pName.c_str(), _func);
164 
165  for (int i=0;i<N;i++)
166  (*p).iport[i](inpS[i]);
167  (*p).oport1(outS);
168 
169  return p;
170 }
171 
173 
179 template <class T0, template <class> class OIf,
180  class T1, template <class> class IIf,
181  std::size_t N>
182 inline sdpmap<T0,T1,N>* make_sdpmap(const std::string& pName,
183  const typename sdpmap<T0,T1,N>::functype& _func,
184  OIf<std::array<T0,N>>& outS,
185  IIf<std::array<T1,N>>& inpS
186  )
187 {
188  auto p = new sdpmap<T0,T1,N>(pName.c_str(), _func);
189 
190  (*p).iport1(inpS);
191  (*p).oport1(outS);
192 
193  return p;
194 }
195 
197 
203 template <class T0, template <class> class OIf,
204  template <class> class IIf,
205  std::size_t N>
206 inline sdpreduce<T0,N>* make_sdpreduce(const std::string& pName,
207  const typename sdpreduce<T0,N>::functype& _func,
208  OIf<T0>& outS,
209  IIf<std::array<T0,N>>& inpS
210  )
211 {
212  auto p = new sdpreduce<T0,N>(pName.c_str(), _func);
213 
214  (*p).iport1(inpS);
215  (*p).oport1(outS);
216 
217  return p;
218 }
219 
221 
227 template <class T0, template <class> class OIf,
228  class T1, template <class> class IIf,
229  std::size_t N>
230 inline sdpscan<T0,T1,N>* make_sdpscan(const std::string& pName,
231  const typename sdpscan<T0,T1,N>::functype& _func,
232  const T0& init_res,
233  OIf<std::array<T0,N>>& outS,
234  IIf<std::array<T1,N>>& inpS
235  )
236 {
237  auto p = new sdpscan<T0,T1,N>(pName.c_str(), _func, init_res);
238 
239  (*p).iport1(inpS);
240  (*p).oport1(outS);
241 
242  return p;
243 }
244 
246 
252 template <typename T, template <class> class IIf,
253  template <class> class OIf>
254 inline sdelay<T>* make_sdelay(const std::string& pName,
255  const T& initval,
256  OIf<T>& outS,
257  IIf<T>& inpS
258  )
259 {
260  auto p = new sdelay<T>(pName.c_str(), initval);
261 
262  (*p).iport1(inpS);
263  (*p).oport1(outS);
264 
265  return p;
266 }
267 
269 
275 template <typename T, template <class> class IIf,
276  template <class> class OIf>
277 inline sdelayn<T>* make_sdelayn(const std::string& pName,
278  const T& initval,
279  const unsigned int& n,
280  OIf<T>& outS,
281  IIf<T>& inpS
282  )
283 {
284  auto p = new sdelayn<T>(pName.c_str(), initval, n);
285 
286  (*p).iport1(inpS);
287  (*p).oport1(outS);
288 
289  return p;
290 }
291 
293 
299 template <typename IT, typename ST, typename OT,
300  template <class> class IIf,
301  template <class> class OIf>
302 inline smoore<IT,ST,OT>* make_smoore(const std::string& pName,
303  const typename smoore<IT,ST,OT>::ns_functype& _ns_func,
304  const typename smoore<IT,ST,OT>::od_functype& _od_func,
305  const ST& init_st,
306  OIf<OT>& outS,
307  IIf<IT>& inpS
308  )
309 {
310  auto p = new smoore<IT,ST,OT>(pName.c_str(), _ns_func, _od_func, init_st);
311 
312  (*p).iport1(inpS);
313  (*p).oport1(outS);
314 
315  return p;
316 }
317 
319 
325 template <typename IT, typename ST, typename OT,
326  template <class> class IIf,
327  template <class> class OIf>
328 inline smealy<IT,ST,OT>* make_smealy(const std::string& pName,
329  const typename smealy<IT,ST,OT>::ns_functype& _ns_func,
330  const typename smealy<IT,ST,OT>::od_functype& _od_func,
331  const ST& init_st,
332  OIf<OT>& outS,
333  IIf<IT>& inpS
334  )
335 {
336  auto p = new smealy<IT,ST,OT>(pName.c_str(), _ns_func, _od_func, init_st);
337 
338  (*p).iport1(inpS);
339  (*p).oport1(outS);
340 
341  return p;
342 }
343 
345 
351 template <typename T, template <class> class IIf,
352  template <class> class OIf>
353 inline sgroup<T>* make_sgroup(const std::string& pName,
354  const unsigned long& samples,
355  OIf<std::vector<T>>& outS,
356  IIf<T>& inpS
357  )
358 {
359  auto p = new sgroup<T>(pName.c_str(), samples);
360 
361  (*p).iport1(inpS);
362  (*p).oport1(outS);
363 
364  return p;
365 }
366 
368 
374 template <class T, template <class> class OIf>
375 inline sconstant<T>* make_sconstant(const std::string& pName,
376  const T& initval,
377  const unsigned long long& take,
378  OIf<T>& outS
379  )
380 {
381  auto p = new sconstant<T>(pName.c_str(), initval, take);
382 
383  (*p).oport1(outS);
384 
385  return p;
386 }
387 
389 
395 template <class T, template <class> class OIf>
396 inline ssource<T>* make_ssource(const std::string& pName,
397  const typename ssource<T>::functype& _func,
398  const T& initval,
399  const unsigned long long& take,
400  OIf<T>& outS
401  )
402 {
403  auto p = new ssource<T>(pName.c_str(), _func, initval, take);
404 
405  (*p).oport1(outS);
406 
407  return p;
408 }
409 
411 
417 template <class T, template <class> class OIf>
418 inline svsource<T>* make_svsource(const std::string& pName,
419  const std::vector<T>& in_vec,
420  OIf<T>& outS
421  )
422 {
423  auto p = new svsource<T>(pName.c_str(), in_vec);
424 
425  (*p).oport1(outS);
426 
427  return p;
428 }
429 
431 
437 template <class T, template <class> class IIf>
438 inline ssink<T>* make_ssink(const std::string& pName,
439  const typename ssink<T>::functype& _func,
440  IIf<T>& inS
441  )
442 {
443  auto p = new ssink<T>(pName.c_str(), _func);
444 
445  (*p).iport1(inS);
446 
447  return p;
448 }
449 
451 
457 template <class T1, template <class> class I1If,
458  class T2, template <class> class I2If,
459  template <class> class OIf>
460 inline szip<T1,T2>* make_szip(const std::string& pName,
461  OIf<std::tuple<T1,T2>>& outS,
462  I1If<T1>& inp1S,
463  I2If<T2>& inp2S
464  )
465 {
466  auto p = new szip<T1,T2>(pName.c_str());
467 
468  (*p).iport1(inp1S);
469  (*p).iport2(inp2S);
470  (*p).oport1(outS);
471 
472  return p;
473 }
474 
476 
483 template <class T1, std::size_t N,
484  template <class> class OIf>
485 inline szipX<T1,N>* make_szipX(const std::string& pName,
486  OIf<std::array<T1,N>>& outS
487  )
488 {
489  auto p = new szipX<T1,N>(pName.c_str());
490 
491  (*p).oport1(outS);
492 
493  return p;
494 }
495 
497 
503 template <template <class> class IIf,
504  class T1, template <class> class O1If,
505  class T2, template <class> class O2If>
506 inline sunzip<T1,T2>* make_sunzip(const std::string& pName,
507  IIf<std::tuple<T1,T2>>& inpS,
508  O1If<T1>& out1S,
509  O2If<T2>& out2S
510  )
511 {
512  auto p = new sunzip<T1,T2>(pName.c_str());
513 
514  (*p).iport1(inpS);
515  (*p).oport1(out1S);
516  (*p).oport2(out2S);
517 
518  return p;
519 }
520 
522 
529 template <template <class> class IIf,
530  class T1, std::size_t N>
531 inline unzipX<T1,N>* make_unzipX(const std::string& pName,
532  IIf<std::array<T1,N>>& inpS
533  )
534 {
535  auto p = new unzipX<T1,N>(pName.c_str());
536 
537  (*p).iport1(inpS);
538 
539  return p;
540 }
541 
542 }
543 }
544 
545 #endif
std::function< void(ST &, const ST &, const IT &)> ns_functype
Type of the next-state function to be passed to the process constructor.
Definition: sy_process_constructors_strict.hpp:950
sdelay< T > * make_sdelay(const std::string &pName, const T &initval, OIf< T > &outS, IIf< T > &inpS)
Helper function to construct a strict delay process.
Definition: sy_helpers_strict.hpp:254
scombX< T0, T1, N > * make_scombX(const std::string &pName, const typename scombX< T0, T1, N >::functype &_func, OIf< T0 > &outS, std::array< IIf< T1 >, N > &inpS)
Helper function to construct a strict combX process.
Definition: sy_helpers_strict.hpp:157
std::function< void(T &, const T &)> functype
Type of the function to be passed to the process constructor.
Definition: sy_process_constructors_strict.hpp:1242
ssource< T > * make_ssource(const std::string &pName, const typename ssource< T >::functype &_func, const T &initval, const unsigned long long &take, OIf< T > &outS)
Helper function to construct a strict source process.
Definition: sy_helpers_strict.hpp:396
SY_in< std::array< T1, N > > iport1
port for the input channel 1
Definition: sy_process_constructors_strict.hpp:511
SY_in< T > iport1
port for the input channel
Definition: sy_process_constructors_strict.hpp:787
Process constructor for a strict Moore machine.
Definition: sy_process_constructors_strict.hpp:943
Process constructor for a strict delay element.
Definition: sy_process_constructors_strict.hpp:784
SY_in< T > iport1
port for the input channel
Definition: sy_process_constructors_strict.hpp:1917
std::function< void(T0 &, const T1 &, const T2 &, const T3 &, const T4 &)> functype
Type of the function to be passed to the process constructor.
Definition: sy_process_constructors_strict.hpp:329
The strict unzip process with one input and two outputs.
Definition: sy_process_constructors_strict.hpp:1674
std::function< void(T0 &, const T1 &)> functype
Type of the function to be passed to the process constructor.
Definition: sy_process_constructors_strict.hpp:515
unzipX< T1, N > * make_unzipX(const std::string &pName, IIf< std::array< abst_ext< T1 >, N >> &inpS)
Helper function to construct an unzipX process.
Definition: sy_helpers.hpp:546
std::array< SY_in< T1 >, N > iport
port for the input channel 1
Definition: sy_process_constructors_strict.hpp:428
The strict group process with one input and one output.
Definition: sy_process_constructors_strict.hpp:1914
SY_out< T > oport1
port for the output channel
Definition: sy_process_constructors_strict.hpp:1167
The namespace for ForSyDe.
Definition: abssemantics.hpp:30
A data-parallel process constructor for a strict reduce process with an array of inputs and one outpu...
Definition: sy_process_constructors_strict.hpp:589
SY_in< std::tuple< T1, T2 > > iport1
port for the input channel
Definition: sy_process_constructors_strict.hpp:1677
Implements the Absent-extended values.
scomb< T0, T1 > * make_scomb(const std::string &pName, const typename scomb< T0, T1 >::functype &_func, OIf< T0 > &outS, I1If< T1 > &inp1S)
Helper function to construct a strict comb process.
Definition: sy_helpers_strict.hpp:46
svsource< T > * make_svsource(const std::string &pName, const std::vector< T > &in_vec, OIf< T > &outS)
Helper function to construct a strict vector source process.
Definition: sy_helpers_strict.hpp:418
SY_out< T > oport1
port for the output channel
Definition: sy_process_constructors_strict.hpp:1239
SY_in< T1 > iport1
port for the input channel
Definition: sy_process_constructors_strict.hpp:51
std::function< void(T0 &, const T1 &)> functype
Type of the function to be passed to the process constructor.
Definition: sy_process_constructors_strict.hpp:55
sdpscan< T0, T1, N > * make_sdpscan(const std::string &pName, const typename sdpscan< T0, T1, N >::functype &_func, const T0 &init_res, OIf< std::array< T0, N >> &outS, IIf< std::array< T1, N >> &inpS)
Helper function to construct a strict data parallel scan process.
Definition: sy_helpers_strict.hpp:230
SY_in< T1 > iport1
port for the input channel 1
Definition: sy_process_constructors_strict.hpp:1466
SY_in< T1 > iport1
port for the input channel 1
Definition: sy_process_constructors_strict.hpp:222
std::function< void(OT &, const ST &, const IT &)> od_functype
Type of the output-decoding function to be passed to the process constructor.
Definition: sy_process_constructors_strict.hpp:1069
The strict zip process with two inputs and one output.
Definition: sy_process_constructors_strict.hpp:1463
SY_out< T > oport1
port for the output channel
Definition: sy_process_constructors_strict.hpp:1329
szipX< T1, N > * make_szipX(const std::string &pName, OIf< std::array< T1, N >> &outS)
Helper function to construct a szipX process.
Definition: sy_helpers_strict.hpp:485
scomb2< T0, T1, T2 > * make_scomb2(const std::string &pName, const typename scomb2< T0, T1, T2 >::functype &_func, OIf< T0 > &outS, I1If< T1 > &inp1S, I2If< T2 > &inp2S)
Helper function to construct a strict comb2 process.
Definition: sy_helpers_strict.hpp:70
SY_in< IT > iport1
port for the input channel
Definition: sy_process_constructors_strict.hpp:946
A data-parallel process constructor for a strict scan process with input and output array types...
Definition: sy_process_constructors_strict.hpp:695
ssink< T > * make_ssink(const std::string &pName, const typename ssink< T >::functype &_func, IIf< T > &inS)
Helper function to construct a strict sink process.
Definition: sy_helpers_strict.hpp:438
A data-parallel process constructor for a strict combinational process with input and output array ty...
Definition: sy_process_constructors_strict.hpp:508
The strict zipX process with an array of inputs and one output.
Definition: sy_process_constructors_strict.hpp:1533
sdpmap< T0, T1, N > * make_sdpmap(const std::string &pName, const typename sdpmap< T0, T1, N >::functype &_func, OIf< std::array< T0, N >> &outS, IIf< std::array< T1, N >> &inpS)
Helper function to construct a strict data parallel comb process.
Definition: sy_helpers_strict.hpp:182
Process constructor for a strict combinational process with three inputs and one output.
Definition: sy_process_constructors_strict.hpp:219
sconstant< T > * make_sconstant(const std::string &pName, const T &initval, const unsigned long long &take, OIf< T > &outS)
Helper function to construct a strict constant source process.
Definition: sy_helpers_strict.hpp:375
SY_in< T1 > iport1
port for the input channel 1
Definition: sy_process_constructors_strict.hpp:133
std::function< void(T0 &, const T0 &, const T0 &)> functype
Type of the function to be passed to the process constructor.
Definition: sy_process_constructors_strict.hpp:596
SY_in< T1 > iport1
port for the input channel 1
Definition: sy_process_constructors_strict.hpp:321
sdpreduce< T0, N > * make_sdpreduce(const std::string &pName, const typename sdpreduce< T0, N >::functype &_func, OIf< T0 > &outS, IIf< std::array< T0, N >> &inpS)
Helper function to construct a strict reduce process.
Definition: sy_helpers_strict.hpp:206
smealy< IT, ST, OT > * make_smealy(const std::string &pName, const typename smealy< IT, ST, OT >::ns_functype &_ns_func, const typename smealy< IT, ST, OT >::od_functype &_od_func, const ST &init_st, OIf< OT > &outS, IIf< IT > &inpS)
Helper function to construct a strict mealy process.
Definition: sy_helpers_strict.hpp:328
std::function< void(T0 &, const T1 &, const T2 &)> functype
Type of the function to be passed to the process constructor.
Definition: sy_process_constructors_strict.hpp:138
SY_in< T > iport1
port for the input channel
Definition: sy_process_constructors_strict.hpp:1395
Implements the basic strict process constructors in the SY MoC.
sdelayn< T > * make_sdelayn(const std::string &pName, const T &initval, const unsigned int &n, OIf< T > &outS, IIf< T > &inpS)
Helper function to construct a strict delayn process.
Definition: sy_helpers_strict.hpp:277
std::function< void(T0 &, const T1 &, const T2 &, const T3 &)> functype
Type of the function to be passed to the process constructor.
Definition: sy_process_constructors_strict.hpp:229
szip< T1, T2 > * make_szip(const std::string &pName, OIf< std::tuple< T1, T2 >> &outS, I1If< T1 > &inp1S, I2If< T2 > &inp2S)
Helper function to construct a szip process.
Definition: sy_helpers_strict.hpp:460
SY_in< std::array< T1, N > > iport1
port for the input channel 1
Definition: sy_process_constructors_strict.hpp:698
SY_in< std::array< abst_ext< T1 >, N > > iport1
port for the input channel
Definition: sy_process_constructors.hpp:1784
smoore< IT, ST, OT > * make_smoore(const std::string &pName, const typename smoore< IT, ST, OT >::ns_functype &_ns_func, const typename smoore< IT, ST, OT >::od_functype &_od_func, const ST &init_st, OIf< OT > &outS, IIf< IT > &inpS)
Helper function to construct a moore process.
Definition: sy_helpers_strict.hpp:302
Process constructor for a strict combinational process with two inputs and one output.
Definition: sy_process_constructors_strict.hpp:130
Process constructor for a strict n-delay element.
Definition: sy_process_constructors_strict.hpp:862
Process constructor for a strict combinational process with four inputs and one output.
Definition: sy_process_constructors_strict.hpp:318
std::function< void(T0 &, const T0 &, const T1 &)> functype
Type of the function to be passed to the process constructor.
Definition: sy_process_constructors_strict.hpp:702
SY_in< T > iport1
port for the input channel
Definition: sy_process_constructors_strict.hpp:865
Process constructor for a strict sink process.
Definition: sy_process_constructors_strict.hpp:1392
Process constructor for a strict combinational process with an array of inputs and one output...
Definition: sy_process_constructors_strict.hpp:425
std::function< void(T0 &, const std::array< T1, N > &)> functype
Type of the function to be passed to the process constructor.
Definition: sy_process_constructors_strict.hpp:432
std::function< void(OT &, const ST &)> od_functype
Type of the output-decoding function to be passed to the process constructor.
Definition: sy_process_constructors_strict.hpp:953
sunzip< T1, T2 > * make_sunzip(const std::string &pName, IIf< std::tuple< T1, T2 >> &inpS, O1If< T1 > &out1S, O2If< T2 > &out2S)
Helper function to construct a sunzip process.
Definition: sy_helpers_strict.hpp:506
Process constructor for a strict source process with vector input.
Definition: sy_process_constructors_strict.hpp:1326
SY_in< std::array< T0, N > > iport1
port for the input channel 1
Definition: sy_process_constructors_strict.hpp:592
sgroup< T > * make_sgroup(const std::string &pName, const unsigned long &samples, OIf< std::vector< T >> &outS, IIf< T > &inpS)
Helper function to construct a strict group process.
Definition: sy_helpers_strict.hpp:353
std::function< void(const T &)> functype
Type of the function to be passed to the process constructor.
Definition: sy_process_constructors_strict.hpp:1398
The unzipX process with one input and an array of outputs.
Definition: sy_process_constructors.hpp:1781
scomb4< T0, T1, T2, T3, T4 > * make_scomb4(const std::string &pName, const typename scomb4< T0, T1, T2, T3, T4 >::functype &_func, OIf< T0 > &outS, I1If< T1 > &inp1S, I2If< T2 > &inp2S, I3If< T3 > &inp3S, I4If< T4 > &inp4S)
Helper function to construct a strict comb4 process.
Definition: sy_helpers_strict.hpp:127
SY_out< std::array< T1, N > > oport1
port for the output channel
Definition: sy_process_constructors_strict.hpp:1537
Process constructor for a strict source process.
Definition: sy_process_constructors_strict.hpp:1236
Process constructor for a strict constant source process.
Definition: sy_process_constructors_strict.hpp:1164
SY_in< IT > iport1
port for the input channel
Definition: sy_process_constructors_strict.hpp:1062
Process constructor for a strict combinational process with one input and one output.
Definition: sy_process_constructors_strict.hpp:48
Process constructor for a strict Mealy machine.
Definition: sy_process_constructors_strict.hpp:1059
scomb3< T0, T1, T2, T3 > * make_scomb3(const std::string &pName, const typename scomb3< T0, T1, T2, T3 >::functype &_func, OIf< T0 > &outS, I1If< T1 > &inp1S, I2If< T2 > &inp2S, I3If< T3 > &inp3S)
Helper function to construct a strict comb3 process.
Definition: sy_helpers_strict.hpp:97
std::function< void(ST &, const ST &, const IT &)> ns_functype
Type of the next-state function to be passed to the process constructor.
Definition: sy_process_constructors_strict.hpp:1066