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 "Common/include/ToString.h" |
---|
25 | #include "Common/include/ErrorMorpheo.h" |
---|
26 | #include "Common/include/Debug.h" |
---|
27 | |
---|
28 | using namespace std; |
---|
29 | |
---|
30 | namespace morpheo { |
---|
31 | namespace behavioural { |
---|
32 | |
---|
33 | class Interface |
---|
34 | { |
---|
35 | // -----[ fields ]---------------------------------------------------- |
---|
36 | protected : const string _name ; |
---|
37 | #ifdef POSITION |
---|
38 | protected : const direction_t _direction ; |
---|
39 | protected : const localisation_t _localisation ; |
---|
40 | protected : string _comment ; |
---|
41 | #endif |
---|
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 | #ifdef POSITION |
---|
58 | ,direction_t direction |
---|
59 | ,localisation_t localisation |
---|
60 | #endif |
---|
61 | ); |
---|
62 | |
---|
63 | public : Interface (const Interface & interface); |
---|
64 | public : ~Interface (); |
---|
65 | |
---|
66 | public : string get_name (); |
---|
67 | |
---|
68 | #ifdef POSITION |
---|
69 | public : void set_comment (string comment); |
---|
70 | protected : string get_comment (void ); |
---|
71 | #endif |
---|
72 | |
---|
73 | protected : string signal_name (string name_interface, |
---|
74 | string name_signal , |
---|
75 | direction_t direction ); |
---|
76 | |
---|
77 | public : Signal * find_signal (string name); |
---|
78 | public : bool find_signal (Signal * signal); |
---|
79 | |
---|
80 | protected : string get_signal (void); |
---|
81 | public : Signal * set_signal (string name , |
---|
82 | direction_t direction, |
---|
83 | uint32_t size , |
---|
84 | presence_port_t presence_port = PORT_VHDL_YES_TESTBENCH_YES); |
---|
85 | public : list<Signal *> * get_signal_list (void); |
---|
86 | |
---|
87 | #ifdef SYSTEMC |
---|
88 | public : sc_in_clk * set_signal_clk (string name , |
---|
89 | uint32_t size , |
---|
90 | presence_port_t presence_port=CLOCK_VHDL_YES) |
---|
91 | { |
---|
92 | log_printf(FUNC,Behavioural,"set_signal_clk","Begin"); |
---|
93 | |
---|
94 | if ((presence_port != CLOCK_VHDL_YES) and |
---|
95 | (presence_port != CLOCK_VHDL_NO )) |
---|
96 | throw ErrorMorpheo ("Signal \""+name+"\" is a clock, bad presence_port."); |
---|
97 | |
---|
98 | Signal * sig = set_signal (name, IN , size, presence_port); |
---|
99 | sc_in_clk * port = new sc_in_clk (sig->_name.c_str()); |
---|
100 | |
---|
101 | sig->alloc<bool> (static_cast<void *>(port)); |
---|
102 | |
---|
103 | log_printf(FUNC,Behavioural,"set_signal_clk","End"); |
---|
104 | |
---|
105 | return port; |
---|
106 | }; |
---|
107 | |
---|
108 | public : template <typename T> |
---|
109 | sc_in <T> * set_signal_in (string name , |
---|
110 | uint32_t size , |
---|
111 | presence_port_t presence_port=PORT_VHDL_YES_TESTBENCH_YES) |
---|
112 | { |
---|
113 | log_printf(FUNC,Behavioural,"set_signal_in","Begin"); |
---|
114 | |
---|
115 | if ((presence_port == CLOCK_VHDL_YES) or |
---|
116 | (presence_port == CLOCK_VHDL_NO )) |
---|
117 | throw ErrorMorpheo ("Signal \""+name+"\" is not a clock, bad presence_port."); |
---|
118 | |
---|
119 | Signal * sig = set_signal (name, IN , size, presence_port); |
---|
120 | sc_in <T> * port = new sc_in <T> (sig->_name.c_str()); |
---|
121 | |
---|
122 | sig->alloc<T> (static_cast<void *>(port)); |
---|
123 | |
---|
124 | log_printf(FUNC,Behavioural,"set_signal_in","End"); |
---|
125 | |
---|
126 | return port; |
---|
127 | }; |
---|
128 | |
---|
129 | public : template <typename T> |
---|
130 | sc_out <T> * set_signal_out (string name , |
---|
131 | uint32_t size , |
---|
132 | presence_port_t presence_port=PORT_VHDL_YES_TESTBENCH_YES) |
---|
133 | { |
---|
134 | log_printf(FUNC,Behavioural,"set_signal_out","Begin"); |
---|
135 | |
---|
136 | if ((presence_port == CLOCK_VHDL_YES) or |
---|
137 | (presence_port == CLOCK_VHDL_NO )) |
---|
138 | throw ErrorMorpheo ("Signal \""+name+"\" is not a clock, bad presence_port."); |
---|
139 | |
---|
140 | Signal * sig = set_signal (name, OUT , size, presence_port); |
---|
141 | sc_out <T> * port = new sc_out <T> (sig->_name.c_str()); |
---|
142 | |
---|
143 | sig->alloc<T> (static_cast<void *>(port)); |
---|
144 | |
---|
145 | log_printf(FUNC,Behavioural,"set_signal_out","End"); |
---|
146 | |
---|
147 | return port; |
---|
148 | }; |
---|
149 | |
---|
150 | public : template <typename T> |
---|
151 | sc_signal <T> * set_signal_internal (string name, |
---|
152 | uint32_t size) |
---|
153 | { |
---|
154 | log_printf(FUNC,Behavioural,"set_signal_internal","Begin"); |
---|
155 | |
---|
156 | Signal * sig = set_signal (name, INTERNAL , size, PORT_VHDL_NO_TESTBENCH_NO); |
---|
157 | sc_signal <T> * port = new sc_signal <T> (sig->_name.c_str()); |
---|
158 | |
---|
159 | sig->alloc<T> (static_cast<void *>(port)); |
---|
160 | |
---|
161 | log_printf(FUNC,Behavioural,"set_signal_internal","End"); |
---|
162 | |
---|
163 | return port; |
---|
164 | }; |
---|
165 | |
---|
166 | #endif |
---|
167 | |
---|
168 | #ifdef VHDL |
---|
169 | public : void set_port (Vhdl * & vhdl); |
---|
170 | # ifdef VHDL_TESTBENCH |
---|
171 | public : void set_signal (Vhdl * & vhdl); |
---|
172 | public : void get_signal (list<string> * & list_signal); |
---|
173 | # endif |
---|
174 | #endif |
---|
175 | #ifdef VHDL_TESTBENCH |
---|
176 | public : uint32_t get_cycle (void); |
---|
177 | public : Signal * get_clock (void); |
---|
178 | public : Signal * get_reset (void); |
---|
179 | |
---|
180 | public : void testbench (void); |
---|
181 | public : void testbench_cycle (void); |
---|
182 | public : void testbench_body (Vhdl * & vhdl , |
---|
183 | string counter_name , |
---|
184 | string reset_name ); |
---|
185 | public : string testbench_test (Vhdl * & vhdl , |
---|
186 | string counter_name, |
---|
187 | string reset_name); |
---|
188 | public : string testbench_test_ok (Vhdl * & vhdl ); |
---|
189 | protected : string testbench_test_name (Vhdl * & vhdl); |
---|
190 | protected : string testbench_test_ok_name(Vhdl * & vhdl); |
---|
191 | protected : string testbench_test_transaction_name(Vhdl * & vhdl); |
---|
192 | #endif |
---|
193 | |
---|
194 | #ifdef POSITION |
---|
195 | public : void interface_map (void * entity, |
---|
196 | void * interface); |
---|
197 | public : XML toXML (void); |
---|
198 | public : XML toXML_mapping (void); |
---|
199 | #endif |
---|
200 | public : friend ostream& operator<< (ostream& output_stream, |
---|
201 | morpheo::behavioural::Interface & x); |
---|
202 | |
---|
203 | }; |
---|
204 | |
---|
205 | }; // end namespace behavioural |
---|
206 | }; // end namespace morpheo |
---|
207 | |
---|
208 | #endif |
---|