-
Notifications
You must be signed in to change notification settings - Fork 2
/
mux.h
48 lines (39 loc) · 811 Bytes
/
mux.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef MUXMOD_H
#define MUXMOD_H
/**
*
* 2:1 Mux module template.
*/
#include <systemc.h>
/**
* Mux module.
* Mux module models a generic 2:1 multiplexor of template type T.
* Implementation based on a template class.
*
* - input ports
* - \c T \c din0 - input
* - \c T \c din1 - input
* - \c bool \c sel - select
* - output ports
* - \c T \c dout - output
*/
template <class T> class mux: public sc_module
{
public:
sc_in< T > din0;
sc_in< T > din1;
sc_in< bool > sel;
sc_out< T > dout;
SC_CTOR(mux)
{
SC_METHOD(entry);
sensitive << din0 << din1 << sel;
}
void entry();
};
template <class T> void mux<T>::entry()
{
if(sel.read()) dout.write(din1.read());
else dout.write(din0.read());
}
#endif