[1] | 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 | |
---|
[27] | 16 | #include <iostream> |
---|
| 17 | #include <list> |
---|
| 18 | #include "sc_fwd.h" |
---|
| 19 | #include "sc_port.h" |
---|
| 20 | #include "sc_signal.h" |
---|
[1] | 21 | |
---|
| 22 | namespace sc_core { |
---|
| 23 | |
---|
| 24 | // Entity class |
---|
| 25 | struct entity { |
---|
| 26 | enum { SIGNAL, PORT } type; |
---|
| 27 | union { // port & signal aren't const because we need to modify |
---|
| 28 | // some fields in elaboration step. |
---|
| 29 | sc_port_base *port; |
---|
| 30 | sc_signal_base *signal; |
---|
| 31 | }; |
---|
| 32 | sc_object *object; |
---|
| 33 | sc_interface *interface; |
---|
| 34 | // tab_t *pointer; |
---|
| 35 | bool operator == (const sc_port_base &port_) |
---|
| 36 | { return (type == PORT) && (&port_ == port); } |
---|
| 37 | bool operator == (const sc_signal_base &signal_) |
---|
| 38 | { return (type == SIGNAL) && (&signal_ == signal); } |
---|
| 39 | bool operator < (const entity &e_) const |
---|
| 40 | { return (void*) this < (void*) &e_; } // casting to "unsigned int" causes warnings |
---|
| 41 | const char *kind () const |
---|
| 42 | { return object->kind (); } |
---|
| 43 | size_t data_size_in_bytes () const |
---|
| 44 | { return interface->data_size_in_bytes (); } |
---|
| 45 | entity (/*const*/ sc_port_base &port_) |
---|
| 46 | { type = PORT; port = &port_; object = &port_; interface = &port_; } |
---|
| 47 | entity (/*const*/ sc_signal_base &signal_) |
---|
| 48 | { type = SIGNAL; signal = &signal_; object = &signal_; interface = &signal_; } |
---|
| 49 | }; |
---|
| 50 | |
---|
| 51 | // list |
---|
| 52 | typedef std::list<entity> equi_t; |
---|
| 53 | typedef std::list<equi_t> equi_list_t; |
---|
| 54 | |
---|
| 55 | // Miscellanous functions |
---|
| 56 | equi_t& get_equi (const sc_interface &); |
---|
| 57 | equi_t& get_equi (const tab_t *pointer); |
---|
| 58 | bool has_equi (/*const*/ sc_port_base &); |
---|
| 59 | equi_t& merge_equi (const tab_t *pointer); |
---|
| 60 | sc_port_base *get_out_port (const equi_t&); |
---|
| 61 | const char *get_name (const equi_t&); |
---|
| 62 | const char* get_module_name (const equi_t &); |
---|
| 63 | std::ostream& operator << (std::ostream &, const equi_t &); |
---|
| 64 | std::ostream& operator << (std::ostream &, const entity &); |
---|
| 65 | |
---|
| 66 | const equi_list_t &get_equi_list (); |
---|
| 67 | int get_signal_table_size (); |
---|
| 68 | |
---|
| 69 | // Bind functions |
---|
| 70 | void bind (sc_port_base& p1,sc_port_base& p2); |
---|
| 71 | void bind (sc_port_base& p1,sc_signal_base& s1); |
---|
| 72 | |
---|
| 73 | } // end of sc_core namespace |
---|
| 74 | |
---|
| 75 | #endif /* __ENTITY_H__ */ |
---|
| 76 | |
---|