| [1] | 1 | /*------------------------------------------------------------\
|
|---|
| [52] | 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 | \------------------------------------------------------------*/
|
|---|
| [1] | 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 |
|
|---|
| [52] | 24 | // Entity class
|
|---|
| 25 | struct entity {
|
|---|
| [1] | 26 | enum { SIGNAL, PORT } type;
|
|---|
| [52] | 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 | }
|
|---|
| [1] | 38 |
|
|---|
| [52] | 39 | bool operator ==(const sc_signal_base & signal_) {
|
|---|
| 40 | return (type == SIGNAL) && (&signal_ == signal);
|
|---|
| 41 | }
|
|---|
| [1] | 42 |
|
|---|
| [52] | 43 | bool operator <(const entity & e_) const {
|
|---|
| 44 | return (void *) this < (void *) &e_;
|
|---|
| 45 | } // casting to "unsigned int" causes warnings
|
|---|
| [1] | 46 |
|
|---|
| [52] | 47 | const char * kind() const {
|
|---|
| 48 | return object->kind();
|
|---|
| 49 | }
|
|---|
| [1] | 50 |
|
|---|
| [52] | 51 | size_t data_size_in_bytes() const {
|
|---|
| 52 | return interface->data_size_in_bytes();
|
|---|
| 53 | }
|
|---|
| [1] | 54 |
|
|---|
| [52] | 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 |
|
|---|
| [1] | 92 | } // end of sc_core namespace
|
|---|
| [52] | 93 |
|
|---|
| [1] | 94 | #endif /* __ENTITY_H__ */
|
|---|
| 95 |
|
|---|
| [52] | 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 | */
|
|---|