[29] | 1 | #ifndef morpheo_behavioural_Signal_h |
---|
| 2 | #define morpheo_behavioural_Signal_h |
---|
| 3 | |
---|
| 4 | /* |
---|
| 5 | * $Id$ |
---|
| 6 | * |
---|
| 7 | * [ Description ] |
---|
| 8 | * |
---|
| 9 | */ |
---|
| 10 | |
---|
[38] | 11 | #ifdef SYSTEMC |
---|
| 12 | #include "systemc.h" |
---|
| 13 | #endif |
---|
| 14 | |
---|
[29] | 15 | #include <stdint.h> |
---|
| 16 | #include <iostream> |
---|
[38] | 17 | |
---|
| 18 | #ifdef VHDL_TESTBENCH |
---|
| 19 | #include "Behavioural/include/Vhdl_Testbench.h" |
---|
| 20 | #endif |
---|
| 21 | |
---|
[29] | 22 | #include "Behavioural/include/Direction.h" |
---|
| 23 | #include "Behavioural/include/XML.h" |
---|
[38] | 24 | #include "Include/ErrorMorpheo.h" |
---|
[29] | 25 | #include "Include/ToString.h" |
---|
| 26 | #include "Include/Debug.h" |
---|
| 27 | |
---|
| 28 | using namespace std; |
---|
| 29 | |
---|
| 30 | namespace morpheo { |
---|
| 31 | namespace behavioural { |
---|
| 32 | |
---|
[38] | 33 | typedef enum {UNKNOW , |
---|
| 34 | BOOL , |
---|
| 35 | UINT8_T , |
---|
| 36 | UINT16_T , |
---|
| 37 | UINT32_T , |
---|
| 38 | UINT64_T } type_info_t; |
---|
| 39 | |
---|
[29] | 40 | typedef enum {PORT_VHDL_YES_TESTBENCH_YES, |
---|
| 41 | PORT_VHDL_YES_TESTBENCH_NO , |
---|
| 42 | PORT_VHDL_NO_TESTBENCH_YES , |
---|
| 43 | PORT_VHDL_NO_TESTBENCH_NO } presence_port_t; |
---|
| 44 | |
---|
| 45 | class Signal |
---|
| 46 | { |
---|
[31] | 47 | friend class Interface; |
---|
| 48 | |
---|
[29] | 49 | // -----[ fields ]---------------------------------------------------- |
---|
[31] | 50 | private : const string _name ; |
---|
| 51 | private : const direction_t _direction ; |
---|
| 52 | private : const uint32_t _size ; |
---|
| 53 | private : const presence_port_t _presence_port; |
---|
[29] | 54 | |
---|
[38] | 55 | #ifdef VHDL_TESTBENCH |
---|
| 56 | private : void * _signal ; |
---|
| 57 | private : type_info_t _type_info ; |
---|
| 58 | #endif |
---|
| 59 | |
---|
[29] | 60 | // -----[ methods ]--------------------------------------------------- |
---|
| 61 | public : Signal (string name , |
---|
| 62 | direction_t direction , |
---|
| 63 | uint32_t size , |
---|
| 64 | presence_port_t presence_port = PORT_VHDL_YES_TESTBENCH_YES); |
---|
[31] | 65 | public : Signal (const Signal &); |
---|
[29] | 66 | public : ~Signal (); |
---|
| 67 | |
---|
[38] | 68 | #ifdef VHDL_TESTBENCH |
---|
| 69 | public : void testbench (Vhdl_Testbench * & vhdl_testbench); |
---|
| 70 | |
---|
| 71 | public : template <typename T> |
---|
| 72 | void alloc (void * port) |
---|
| 73 | { |
---|
| 74 | if (_type_info != UNKNOW) |
---|
| 75 | throw (ErrorMorpheo ("Signal \""+_name+"\" : already allocate.")); |
---|
| 76 | |
---|
| 77 | _signal = port; |
---|
| 78 | |
---|
| 79 | if (typeid(T) == typeid(bool )) |
---|
| 80 | _type_info = BOOL; |
---|
| 81 | else |
---|
| 82 | if (typeid(T) == typeid(uint8_t )) |
---|
| 83 | _type_info = UINT8_T; |
---|
| 84 | else |
---|
| 85 | if (typeid(T) == typeid(uint16_t)) |
---|
| 86 | _type_info = UINT16_T; |
---|
| 87 | else |
---|
| 88 | if (typeid(T) == typeid(uint32_t)) |
---|
| 89 | _type_info = UINT32_T; |
---|
| 90 | else |
---|
| 91 | if (typeid(T) == typeid(uint64_t)) |
---|
| 92 | _type_info = UINT64_T; |
---|
| 93 | else |
---|
| 94 | _type_info = UNKNOW; |
---|
| 95 | } |
---|
| 96 | #endif |
---|
| 97 | |
---|
[29] | 98 | public : XML toXML (void); |
---|
| 99 | |
---|
| 100 | public : friend ostream& operator<< (ostream& output_stream, |
---|
| 101 | morpheo::behavioural::Signal & x); |
---|
| 102 | |
---|
| 103 | }; |
---|
| 104 | }; // end namespace behavioural |
---|
| 105 | |
---|
| 106 | template<> inline std::string toString<morpheo::behavioural::presence_port_t>(const morpheo::behavioural::presence_port_t& x) |
---|
| 107 | { |
---|
| 108 | switch (x) |
---|
| 109 | { |
---|
| 110 | case morpheo::behavioural::PORT_VHDL_YES_TESTBENCH_YES : return "Port is in VHDL's model and TestBench's model" ; break; |
---|
| 111 | case morpheo::behavioural::PORT_VHDL_YES_TESTBENCH_NO : return "Port is in VHDL's model " ; break; |
---|
| 112 | case morpheo::behavioural::PORT_VHDL_NO_TESTBENCH_YES : return "Port is in TestBench's model" ; break; |
---|
| 113 | case morpheo::behavioural::PORT_VHDL_NO_TESTBENCH_NO : return "Port is in none model " ; break; |
---|
| 114 | default : return ""; break; |
---|
| 115 | } |
---|
| 116 | } |
---|
| 117 | |
---|
| 118 | }; // end namespace morpheo |
---|
| 119 | |
---|
| 120 | #endif |
---|