3D-ICE 3.0.0
floorplan_element.c
1/******************************************************************************
2 * This file is part of 3D-ICE, version 3.1.0 . *
3 * *
4 * 3D-ICE is free software: you can redistribute it and/or modify it under *
5 * the terms of the GNU General Public License as published by the Free *
6 * Software Foundation, either version 3 of the License, or any later *
7 * version. *
8 * *
9 * 3D-ICE is distributed in the hope that it will be useful, but WITHOUT *
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
12 * more details. *
13 * *
14 * You should have received a copy of the GNU General Public License along *
15 * with 3D-ICE. If not, see <http://www.gnu.org/licenses/>. *
16 * *
17 * Copyright (C) 2021 *
18 * Embedded Systems Laboratory - Ecole Polytechnique Federale de Lausanne *
19 * All Rights Reserved. *
20 * *
21 * Authors: Arvind Sridhar Alessandro Vincenzi *
22 * Giseong Bak Martino Ruggiero *
23 * Thomas Brunschwiler Eder Zulian *
24 * Federico Terraneo Darong Huang *
25 * Luis Costero Marina Zapater *
26 * David Atienza *
27 * *
28 * For any comment, suggestion or request about 3D-ICE, please register and *
29 * write to the mailing list (see http://listes.epfl.ch/doc.cgi?liste=3d-ice) *
30 * Any usage of 3D-ICE for research, commercial or other purposes must be *
31 * properly acknowledged in the resulting products or publications. *
32 * *
33 * EPFL-STI-IEL-ESL Mail : 3d-ice@listes.epfl.ch *
34 * Batiment ELG, ELG 130 (SUBSCRIPTION IS NECESSARY) *
35 * Station 11 *
36 * 1015 Lausanne, Switzerland Url : http://esl.epfl.ch/3d-ice *
37 ******************************************************************************/
38
39#include <stdlib.h> // For the memory functions malloc/free
40
41#include "floorplan_element.h"
42#include "macros.h"
43
44/******************************************************************************/
45
47{
48 string_init (&flpel->Id) ;
49
50 flpel->NICElements = (Quantity_t) 0u ;
51
52 ic_element_list_init (&flpel->ICElements) ;
53
54 flpel->Area = (ChipDimension_t) 0.0 ;
55 flpel->PowerValues = NULL ;
56}
57
58/******************************************************************************/
59
61(
64)
65{
67
68 string_copy (&dst->Id, &src->Id) ;
69
70 dst->NICElements = src->NICElements ;
71 dst->Area = src->Area ;
72
73 ic_element_list_copy (&dst->ICElements, &src->ICElements) ;
74
75 dst->PowerValues = powers_queue_clone (src->PowerValues) ;
76}
77
78/******************************************************************************/
79
81{
82 string_destroy (&flpel->Id) ;
83
84 ic_element_list_destroy (&flpel->ICElements) ;
85
87
89}
90
91/******************************************************************************/
92
94{
95 FloorplanElement_t *flpel =
96
97 (FloorplanElement_t *) malloc (sizeof(FloorplanElement_t));
98
99 if (flpel != NULL)
100
101 floorplan_element_init (flpel) ;
102
103 return flpel ;
104}
105
106/*****************************************************************************/
107
109{
110 if (flpel == NULL)
111
112 return NULL ;
113
115
116 if (newf != NULL)
117
118 floorplan_element_copy (newf, flpel) ;
119
120 return newf ;
121}
122
123/*****************************************************************************/
124
126{
127 if (flpel == NULL)
128
129 return ;
130
132
133 free (flpel) ;
134}
135
136/******************************************************************************/
137
139(
140 FloorplanElement_t *flpel,
141 FloorplanElement_t *other
142)
143{
144 return string_equal (&flpel->Id, &other->Id) ;
145}
146
147/******************************************************************************/
148
150(
151 FloorplanElement_t *flpel,
152 FILE *stream,
153 String_t prefix
154)
155{
156 fprintf (stream,
157 "%s%s:\n",
158 prefix, flpel->Id) ;
159
160 ic_element_list_print
161
162 (&flpel->ICElements, stream, prefix) ;
163
164 fprintf (stream,
165 "%s power values ",
166 prefix) ;
167
168 powers_queue_print (flpel->PowerValues, stream, (String_t)"") ;
169
170 fprintf (stream, " ;\n%s\n", prefix) ;
171}
172
173/******************************************************************************/
174
176(
177 FloorplanElement_t *flpel,
178 PowersQueue_t *pvalues
179)
180{
181 if (is_empty_powers_queue(pvalues) == true)
182
183 return TDICE_FAILURE ;
184
186
187 return TDICE_SUCCESS ;
188}
189
190/******************************************************************************/
191
193(
194 FloorplanElement_t *flpel,
195 Dimensions_t *dimensions,
196 Temperature_t *temperatures
197)
198{
199 Temperature_t tmp, max = 0.0 ;
200
201 ICElement_t *icel ;
202 ICElementListNode_t *iceln = ic_element_list_begin (&flpel->ICElements) ;
203
204 if (iceln != NULL)
205 {
206 icel = ic_element_list_data (iceln) ;
207
208 max = get_max_temperature_ic_element (icel, dimensions, temperatures) ;
209 }
210 else
211
212 return max ;
213
214 for (iceln = ic_element_list_next (iceln) ;
215 iceln != NULL ;
216 iceln = ic_element_list_next (iceln))
217 {
218 icel = ic_element_list_data (iceln) ;
219
220 tmp = get_max_temperature_ic_element (icel, dimensions, temperatures) ;
221
222 if (tmp > max) max = tmp ;
223 }
224
225 return max ;
226}
227
228/******************************************************************************/
229
231(
232 FloorplanElement_t *flpel,
233 Dimensions_t *dimensions,
234 Temperature_t *temperatures
235)
236{
237 Temperature_t tmp, min = 0.0 ;
238
239 ICElement_t *icel ;
240 ICElementListNode_t *iceln = ic_element_list_begin (&flpel->ICElements) ;
241
242 if (iceln != NULL)
243 {
244 icel = ic_element_list_data (iceln) ;
245
246 min = get_min_temperature_ic_element (icel, dimensions, temperatures) ;
247 }
248 else
249
250 return min ;
251
252 for (iceln = ic_element_list_next (iceln) ;
253 iceln != NULL ;
254 iceln = ic_element_list_next (iceln))
255 {
256 icel = ic_element_list_data (iceln) ;
257
258 tmp = get_min_temperature_ic_element (icel, dimensions, temperatures) ;
259
260 if (tmp < min) min = tmp ;
261 }
262
263 return min ;
264}
265
266/******************************************************************************/
267
269(
270 FloorplanElement_t *flpel,
271 Dimensions_t *dimensions,
272 Temperature_t *temperatures
273)
274{
275 Temperature_t avg = 0.0 ;
276
277 ICElement_t *icel ;
278 ICElementListNode_t *iceln ;
279
280 for (iceln = ic_element_list_begin (&flpel->ICElements) ;
281 iceln != NULL ;
282 iceln = ic_element_list_next (iceln))
283 {
284 icel = ic_element_list_data (iceln) ;
285
286 avg += get_avg_temperature_ic_element (icel, dimensions, temperatures) ;
287 }
288
289 return avg / (Temperature_t) flpel->NICElements ;
290}
291
292/******************************************************************************/
293
295(
296 FloorplanElement_t *flpel,
297 Dimensions_t *dimensions,
298 Temperature_t *temperatures
299)
300{
301 Temperature_t tmpi, tmpa, min = 0.0, max = 0.0 ;
302
303 ICElement_t *icel ;
304 ICElementListNode_t *iceln = ic_element_list_begin (&flpel->ICElements) ;
305
306 if (iceln != NULL)
307 {
308 icel = ic_element_list_data (iceln) ;
309
310 min = get_min_temperature_ic_element (icel, dimensions, temperatures) ;
311 max = get_max_temperature_ic_element (icel, dimensions, temperatures) ;
312 }
313 else
314
315 return min ;
316
317 for (iceln = ic_element_list_next (iceln) ;
318 iceln != NULL ;
319 iceln = ic_element_list_next (iceln))
320 {
321 icel = ic_element_list_data (iceln) ;
322
323 tmpi = get_min_temperature_ic_element (icel, dimensions, temperatures) ;
324 tmpa = get_max_temperature_ic_element (icel, dimensions, temperatures) ;
325
326 min = MIN (min, tmpi) ;
327 max = MAX (max, tmpa) ;
328 }
329
330 return max - min ;
331}
332
333/******************************************************************************/
Temperature_t get_gradient_temperature_floorplan_element(FloorplanElement_t *flpel, Dimensions_t *dimensions, Temperature_t *temperatures)
Temperature_t get_min_temperature_floorplan_element(FloorplanElement_t *flpel, Dimensions_t *dimensions, Temperature_t *temperatures)
void floorplan_element_print(FloorplanElement_t *flpel, FILE *stream, String_t prefix)
FloorplanElement_t * floorplan_element_calloc(void)
void floorplan_element_init(FloorplanElement_t *flpel)
Error_t insert_power_values_floorplan_element(FloorplanElement_t *flpel, PowersQueue_t *pvalues)
void floorplan_element_copy(FloorplanElement_t *dst, FloorplanElement_t *src)
FloorplanElement_t * floorplan_element_clone(FloorplanElement_t *flpel)
bool floorplan_element_same_id(FloorplanElement_t *flpel, FloorplanElement_t *other)
Temperature_t get_avg_temperature_floorplan_element(FloorplanElement_t *flpel, Dimensions_t *dimensions, Temperature_t *temperatures)
void floorplan_element_destroy(FloorplanElement_t *flpel)
void floorplan_element_free(FloorplanElement_t *flpel)
Temperature_t get_max_temperature_floorplan_element(FloorplanElement_t *flpel, Dimensions_t *dimensions, Temperature_t *temperatures)
Temperature_t get_avg_temperature_ic_element(ICElement_t *icel, Dimensions_t *dimensions, Temperature_t *temperatures)
Definition: ic_element.c:365
Temperature_t get_min_temperature_ic_element(ICElement_t *icel, Dimensions_t *dimensions, Temperature_t *temperatures)
Definition: ic_element.c:313
Temperature_t get_max_temperature_ic_element(ICElement_t *icel, Dimensions_t *dimensions, Temperature_t *temperatures)
Definition: ic_element.c:265
#define MIN(a, b)
Definition: macros.h:78
#define MAX(a, b)
Definition: macros.h:69
PowersQueue_t * powers_queue_clone(PowersQueue_t *pqueue)
Definition: powers_queue.c:132
bool is_empty_powers_queue(PowersQueue_t *pqueue)
Definition: powers_queue.c:190
void powers_queue_print(PowersQueue_t *pqueue, FILE *stream, String_t prefix)
Definition: powers_queue.c:163
void powers_queue_free(PowersQueue_t *pqueue)
Definition: powers_queue.c:149
Power_t get_from_powers_queue(PowersQueue_t *pqueue)
Definition: powers_queue.c:244
void put_into_powers_queue(PowersQueue_t *pqueue, Power_t power)
Definition: powers_queue.c:204
char * String_t
Definition: string_t.h:55
void string_init(String_t *string)
Definition: string_t.c:46
bool string_equal(String_t *string, String_t *other)
Definition: string_t.c:71
void string_destroy(String_t *string)
Definition: string_t.c:78
void string_copy(String_t *dst, String_t *src)
Definition: string_t.c:53
Collections of all the structures that are needed for the thermal simulation.
Definition: dimensions.h:311
Structure containing information about a floorplan element.
ChipDimension_t Area
PowersQueue_t * PowerValues
ICElementList_t ICElements
A First In - First Out circular queue to store power values.
Definition: powers_queue.h:63
Error_t
Definition: types.h:401
@ TDICE_SUCCESS
The function returns with success.
Definition: types.h:402
@ TDICE_FAILURE
The function retuerns with a generic error.
Definition: types.h:403
double ChipDimension_t
Definition: types.h:187
double Temperature_t
Definition: types.h:71
uint32_t Quantity_t
Definition: types.h:59