1 | /*------------------------------------------------------------\ |
---|
2 | | | |
---|
3 | | Tool : systemcass | |
---|
4 | | | |
---|
5 | | File : entity.h | |
---|
6 | | | |
---|
7 | | Author : Buchmann Richard | |
---|
8 | | Taktak Sami | |
---|
9 | | | |
---|
10 | | Date : 09_07_2004 | |
---|
11 | | | |
---|
12 | \------------------------------------------------------------*/ |
---|
13 | #ifndef __ENTITY_H__ |
---|
14 | #define __ENTITY_H__ |
---|
15 | |
---|
16 | #include <iostream> |
---|
17 | #include <list> |
---|
18 | #include "sc_fwd.h" |
---|
19 | #include "sc_port.h" |
---|
20 | #include "sc_signal.h" |
---|
21 | |
---|
22 | namespace sc_core { |
---|
23 | |
---|
24 | // Entity class |
---|
25 | struct entity { |
---|
26 | enum { SIGNAL, PORT } type; |
---|
27 | union { |
---|
28 | // port & signal aren't const because we need to modify |
---|
29 | // some fields in elaboration step. |
---|
30 | sc_port_base * port; |
---|
31 | sc_signal_base * signal; |
---|
32 | }; |
---|
33 | sc_object * object; |
---|
34 | sc_interface * interface; |
---|
35 | bool operator ==(const sc_port_base & port_) { |
---|
36 | return (type == PORT) && (&port_ == port); |
---|
37 | } |
---|
38 | |
---|
39 | bool operator ==(const sc_signal_base & signal_) { |
---|
40 | return (type == SIGNAL) && (&signal_ == signal); |
---|
41 | } |
---|
42 | |
---|
43 | bool operator <(const entity & e_) const { |
---|
44 | return (void *) this < (void *) &e_; |
---|
45 | } // casting to "unsigned int" causes warnings |
---|
46 | |
---|
47 | const char * kind() const { |
---|
48 | return object->kind(); |
---|
49 | } |
---|
50 | |
---|
51 | size_t data_size_in_bytes() const { |
---|
52 | return interface->data_size_in_bytes(); |
---|
53 | } |
---|
54 | |
---|
55 | entity(/*const */sc_port_base & port_) { |
---|
56 | type = PORT; |
---|
57 | port = &port_; |
---|
58 | object = &port_; |
---|
59 | interface = &port_; |
---|
60 | } |
---|
61 | |
---|
62 | entity(/*const */sc_signal_base & signal_) { |
---|
63 | type = SIGNAL; |
---|
64 | signal = &signal_; |
---|
65 | object = &signal_; |
---|
66 | interface = &signal_; |
---|
67 | } |
---|
68 | }; |
---|
69 | |
---|
70 | // list |
---|
71 | typedef std::list < entity > equi_t; |
---|
72 | typedef std::list < equi_t > equi_list_t; |
---|
73 | |
---|
74 | // Miscellanous functions |
---|
75 | equi_t & get_equi(const sc_interface &); |
---|
76 | equi_t & get_equi(const tab_t * pointer); |
---|
77 | bool has_equi(/*const */sc_port_base &); |
---|
78 | equi_t & merge_equi(const tab_t * pointer); |
---|
79 | sc_port_base * get_out_port(const equi_t &); |
---|
80 | const char * get_name(const equi_t &); |
---|
81 | const char * get_module_name(const equi_t &); |
---|
82 | std::ostream & operator <<(std::ostream &, const equi_t &); |
---|
83 | std::ostream & operator <<(std::ostream &, const entity &); |
---|
84 | |
---|
85 | const equi_list_t & get_equi_list(); |
---|
86 | int get_signal_table_size(); |
---|
87 | |
---|
88 | // Bind functions |
---|
89 | void bind(sc_port_base & p1, sc_port_base & p2); |
---|
90 | void bind(sc_port_base & p1, sc_signal_base & s1); |
---|
91 | |
---|
92 | } // end of sc_core namespace |
---|
93 | |
---|
94 | #endif /* __ENTITY_H__ */ |
---|
95 | |
---|
96 | /* |
---|
97 | # Local Variables: |
---|
98 | # tab-width: 4; |
---|
99 | # c-basic-offset: 4; |
---|
100 | # c-file-offsets:((innamespace . 0)(inline-open . 0)); |
---|
101 | # indent-tabs-mode: nil; |
---|
102 | # End: |
---|
103 | # |
---|
104 | # vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
105 | */ |
---|