1 | #ifndef morpheo_behavioural_Interface_h |
---|
2 | #define morpheo_behavioural_Interface_h |
---|
3 | |
---|
4 | /* |
---|
5 | * $Id$ |
---|
6 | * |
---|
7 | * [ Description ] |
---|
8 | * |
---|
9 | */ |
---|
10 | |
---|
11 | #ifdef SYSTEMC |
---|
12 | #include "systemc.h" |
---|
13 | #endif |
---|
14 | |
---|
15 | #include <stdint.h> |
---|
16 | #include <iostream> |
---|
17 | #include <list> |
---|
18 | #include "Behavioural/include/Signal.h" |
---|
19 | #include "Behavioural/include/Direction.h" |
---|
20 | #include "Behavioural/include/Localisation.h" |
---|
21 | #ifdef VHDL |
---|
22 | #include "Behavioural/include/Vhdl.h" |
---|
23 | #endif |
---|
24 | #include "Include/ToString.h" |
---|
25 | #include "Include/ErrorMorpheo.h" |
---|
26 | #include "Include/Debug.h" |
---|
27 | |
---|
28 | using namespace std; |
---|
29 | |
---|
30 | namespace morpheo { |
---|
31 | namespace behavioural { |
---|
32 | |
---|
33 | class Interface |
---|
34 | { |
---|
35 | friend class Interfaces; |
---|
36 | |
---|
37 | // -----[ fields ]---------------------------------------------------- |
---|
38 | protected : const string _name ; |
---|
39 | protected : const direction_t _direction ; |
---|
40 | protected : const localisation_t _localisation ; |
---|
41 | protected : string _comment ; |
---|
42 | |
---|
43 | protected : list<Signal *> * _list_signal ; |
---|
44 | |
---|
45 | #ifdef POSITION |
---|
46 | protected : bool _is_map ; |
---|
47 | protected : void * _entity_map ; // Entity -> erreur cyclique |
---|
48 | protected : void * _interface_map; // pour être homogène avec _entity_map |
---|
49 | #endif |
---|
50 | |
---|
51 | #ifdef VHDL_TESTBENCH |
---|
52 | private : uint32_t _nb_cycle ; |
---|
53 | #endif |
---|
54 | |
---|
55 | // -----[ methods ]--------------------------------------------------- |
---|
56 | public : Interface (string name , |
---|
57 | direction_t direction , |
---|
58 | localisation_t localisation); |
---|
59 | |
---|
60 | public : Interface (const Interface & interface); |
---|
61 | public : ~Interface (); |
---|
62 | |
---|
63 | public : void set_comment (string comment); |
---|
64 | protected : string get_comment (void ); |
---|
65 | |
---|
66 | protected : string signal_name (string name_interface, |
---|
67 | string name_signal , |
---|
68 | direction_t direction ); |
---|
69 | |
---|
70 | protected : string get_signal (void); |
---|
71 | public : Signal * set_signal (string name , |
---|
72 | direction_t direction, |
---|
73 | uint32_t size , |
---|
74 | presence_port_t presence_port = PORT_VHDL_YES_TESTBENCH_YES); |
---|
75 | |
---|
76 | #ifdef SYSTEMC |
---|
77 | public : sc_in_clk * set_signal_clk (string name , |
---|
78 | uint32_t size , |
---|
79 | presence_port_t presence_port=CLOCK_VHDL_YES) |
---|
80 | { |
---|
81 | log_printf(FUNC,Behavioural,"set_signal_clk","Begin"); |
---|
82 | |
---|
83 | if ((presence_port != CLOCK_VHDL_YES) and |
---|
84 | (presence_port != CLOCK_VHDL_NO )) |
---|
85 | throw ErrorMorpheo ("Signal \""+name+"\" is a clock, bad presence_port."); |
---|
86 | |
---|
87 | Signal * sig = set_signal (name, IN , size, presence_port); |
---|
88 | sc_in_clk * signal = new sc_in_clk (sig->_name.c_str()); |
---|
89 | |
---|
90 | log_printf(FUNC,Behavioural,"set_signal_clk","End"); |
---|
91 | |
---|
92 | return signal; |
---|
93 | }; |
---|
94 | |
---|
95 | public : template <typename T> |
---|
96 | sc_in <T> * set_signal_in (string name , |
---|
97 | uint32_t size , |
---|
98 | presence_port_t presence_port=PORT_VHDL_YES_TESTBENCH_YES) |
---|
99 | { |
---|
100 | log_printf(FUNC,Behavioural,"set_signal_in","Begin"); |
---|
101 | |
---|
102 | if ((presence_port == CLOCK_VHDL_YES) or |
---|
103 | (presence_port == CLOCK_VHDL_NO )) |
---|
104 | throw ErrorMorpheo ("Signal \""+name+"\" is not a clock, bad presence_port."); |
---|
105 | |
---|
106 | Signal * sig = set_signal (name, IN , size, presence_port); |
---|
107 | sc_in <T> * port = new sc_in <T> (sig->_name.c_str()); |
---|
108 | #ifdef VHDL_TESTBENCH |
---|
109 | sig->alloc<T> (static_cast<void *>(port)); |
---|
110 | #endif |
---|
111 | |
---|
112 | log_printf(FUNC,Behavioural,"set_signal_in","End"); |
---|
113 | |
---|
114 | return port; |
---|
115 | }; |
---|
116 | |
---|
117 | public : template <typename T> |
---|
118 | sc_out <T> * set_signal_out (string name , |
---|
119 | uint32_t size , |
---|
120 | presence_port_t presence_port=PORT_VHDL_YES_TESTBENCH_YES) |
---|
121 | { |
---|
122 | log_printf(FUNC,Behavioural,"set_signal_out","Begin"); |
---|
123 | |
---|
124 | if ((presence_port == CLOCK_VHDL_YES) or |
---|
125 | (presence_port == CLOCK_VHDL_NO )) |
---|
126 | throw ErrorMorpheo ("Signal \""+name+"\" is not a clock, bad presence_port."); |
---|
127 | |
---|
128 | Signal * sig = set_signal (name, OUT , size, presence_port); |
---|
129 | sc_out <T> * port = new sc_out <T> (sig->_name.c_str()); |
---|
130 | #ifdef VHDL_TESTBENCH |
---|
131 | sig->alloc<T> (static_cast<void *>(port)); |
---|
132 | #endif |
---|
133 | |
---|
134 | log_printf(FUNC,Behavioural,"set_signal_out","End"); |
---|
135 | |
---|
136 | return port; |
---|
137 | }; |
---|
138 | #endif |
---|
139 | |
---|
140 | #ifdef VHDL |
---|
141 | public : void set_port (Vhdl * & vhdl); |
---|
142 | #ifdef VHDL_TESTBENCH |
---|
143 | public : void set_signal (Vhdl * & vhdl); |
---|
144 | public : void get_signal (list<string> * & list_signal); |
---|
145 | #endif |
---|
146 | #endif |
---|
147 | #ifdef VHDL_TESTBENCH |
---|
148 | public : uint32_t get_cycle (void); |
---|
149 | public : string get_clock (void); |
---|
150 | |
---|
151 | public : void testbench (void); |
---|
152 | public : void testbench_cycle (void); |
---|
153 | public : void testbench_body (Vhdl * & vhdl , |
---|
154 | string counter_name ); |
---|
155 | public : string testbench_test (Vhdl * & vhdl , |
---|
156 | string counter_name); |
---|
157 | public : string testbench_test_ok (Vhdl * & vhdl ); |
---|
158 | protected : string testbench_test_name (Vhdl * & vhdl); |
---|
159 | protected : string testbench_test_ok_name(Vhdl * & vhdl); |
---|
160 | |
---|
161 | #endif |
---|
162 | |
---|
163 | #ifdef POSITION |
---|
164 | public : void port_map (void * entity, |
---|
165 | void * interface); |
---|
166 | #endif |
---|
167 | |
---|
168 | public : XML toXML (void); |
---|
169 | #ifdef POSITION |
---|
170 | public : XML toXML_mapping (void); |
---|
171 | #endif |
---|
172 | public : friend ostream& operator<< (ostream& output_stream, |
---|
173 | morpheo::behavioural::Interface & x); |
---|
174 | |
---|
175 | }; |
---|
176 | |
---|
177 | }; // end namespace behavioural |
---|
178 | }; // end namespace morpheo |
---|
179 | |
---|
180 | #endif |
---|