3D-ICE 3.0.0
die.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 "die.h"
42
43/******************************************************************************/
44
45void die_init (Die_t *die)
46{
47 string_init (&die->Id) ;
48
49 die->NLayers = (CellIndex_t) 0u ;
50 die->SourceLayerOffset = (CellIndex_t) 0u ;
51
52 layer_list_init (&die->Layers) ;
53
55
56 die->Discr_X = (CellIndex_t) 0u ;
57 die->Discr_Y = (CellIndex_t) 0u ;
58}
59
60/******************************************************************************/
61
62void die_copy (Die_t *dst, Die_t *src)
63{
64 die_destroy (dst) ;
65
66 string_copy (&dst->Id, &src->Id) ;
67
68 dst->NLayers = src->NLayers ;
69 dst->SourceLayerOffset = src->SourceLayerOffset ;
70
71 layer_list_copy (&dst->Layers, &src->Layers) ;
72
73 floorplan_copy (&dst->Floorplan, &src->Floorplan) ;
74
75 dst->Discr_X = src->Discr_X ;
76 dst->Discr_Y = src->Discr_Y ;
77}
78
79/******************************************************************************/
80
81void die_destroy (Die_t *die)
82{
83 string_destroy (&die->Id) ;
84 layer_list_destroy (&die->Layers) ;
86
87 die_init (die) ;
88}
89
90/******************************************************************************/
91
93{
94 Die_t *die = (Die_t *) malloc (sizeof(Die_t)) ;
95
96 if (die != NULL)
97
98 die_init (die) ;
99
100 return die ;
101}
102
103/******************************************************************************/
104
106{
107 if (die == NULL)
108
109 return NULL ;
110
111 Die_t *newd = die_calloc ( ) ;
112
113 if (newd != NULL)
114
115 die_copy (newd, die) ;
116
117 return newd ;
118}
119
120/******************************************************************************/
121
122void die_free (Die_t *die)
123{
124 if (die == NULL)
125
126 return ;
127
128 die_destroy (die) ;
129
130 free (die) ;
131}
132
133/******************************************************************************/
134
135bool die_same_id (Die_t *die, Die_t *other)
136{
137 return string_equal (&die->Id, &other->Id) ;
138}
139
140/******************************************************************************/
141
142void die_print (Die_t *die, FILE *stream, String_t prefix)
143{
144 fprintf (stream, "%sdie %s :\n", prefix, die->Id) ;
145
146 Quantity_t counter = die->NLayers ;
147
148 LayerListNode_t *lnd ;
149
150 for (lnd = layer_list_begin (&die->Layers) ;
151 lnd != NULL ;
152 lnd = layer_list_next (lnd))
153 {
154 if (--counter == die->SourceLayerOffset)
155
156 fprintf (stream,
157 "%s source %4.1f %s ;\n",
158 prefix,
159 layer_list_data(lnd)->Height,
160 layer_list_data(lnd)->Material.Id) ;
161
162 else
163
164 fprintf (stream,
165 "%s layer %4.1f %s ;\n",
166 prefix,
167 layer_list_data(lnd)->Height,
168 layer_list_data(lnd)->Material.Id) ;
169 }
170}
171
172/******************************************************************************/
void die_print(Die_t *die, FILE *stream, String_t prefix)
Definition: die.c:142
void die_copy(Die_t *dst, Die_t *src)
Definition: die.c:62
void die_destroy(Die_t *die)
Definition: die.c:81
Die_t * die_calloc(void)
Definition: die.c:92
bool die_same_id(Die_t *die, Die_t *other)
Definition: die.c:135
void die_free(Die_t *die)
Definition: die.c:122
Die_t * die_clone(Die_t *die)
Definition: die.c:105
void die_init(Die_t *die)
Definition: die.c:45
void floorplan_copy(Floorplan_t *dst, Floorplan_t *src)
Definition: floorplan.c:60
void floorplan_destroy(Floorplan_t *floorplan)
Definition: floorplan.c:93
void floorplan_init(Floorplan_t *floorplan)
Definition: floorplan.c:47
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
Structure used to store data about the dies that compose the 2D/3D stack.
Definition: die.h:70
String_t Id
Definition: die.h:73
CellIndex_t NLayers
Definition: die.h:77
CellIndex_t SourceLayerOffset
Definition: die.h:81
Floorplan_t Floorplan
Definition: die.h:94
CellIndex_t Discr_X
Definition: die.h:98
LayerList_t Layers
Definition: die.h:90
CellIndex_t Discr_Y
Definition: die.h:102
uint32_t Quantity_t
Definition: types.h:59
uint32_t CellIndex_t
Definition: types.h:213