Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / tas / stm / stm_prop.c
1 /****************************************************************************/
2 /* */
3 /* Chaine de CAO & VLSI AVERTEC */
4 /* */
5 /* Produit : STM Version 1.00 */
6 /* Fichier : stm_prop.c */
7 /* */
8 /* (c) copyright 2000 AVERTEC */
9 /* Tous droits reserves */
10 /* */
11 /* Auteur(s) : Gilles Augustins */
12 /* */
13 /****************************************************************************/
14
15 /****************************************************************************/
16 /* includes */
17 /****************************************************************************/
18
19 #include "stm.h"
20
21 timing_props *STM_PROPERTIES = NULL;
22 /****************************************************************************/
23 /* functions */
24 /****************************************************************************/
25
26 timing_props *stm_get_prop()
27 {
28 return STM_PROPERTIES;
29 }
30
31 timing_props *stm_prop_create (timing_model *resmodel, timing_model *capmodel)
32 {
33 timing_props *properties;
34
35 properties = (timing_props*)mbkalloc (sizeof (struct timing_props));
36
37 properties->RESMODEL = resmodel;
38 properties->CAPMODEL = capmodel;
39
40 STM_PROPERTIES = properties;
41
42 return properties;
43 }
44
45 /****************************************************************************/
46
47 void stm_addresmodel (timing_props *properties, timing_model *resmodel)
48 {
49 properties->RESMODEL = resmodel;
50 }
51
52 /****************************************************************************/
53
54 void stm_addcapmodel (timing_props *properties, timing_model *capmodel)
55 {
56 properties->CAPMODEL = capmodel;
57 }
58
59 /****************************************************************************/
60
61 void stm_scale_loadmodel (timing_model *model, float scale)
62 {
63 int i;
64 timing_table *table;
65
66 if(model){
67 table = model->UMODEL.TABLE;
68 for(i = 0; i < table->NX; i++)
69 table->SET1D[i] = table->SET1D[i] * scale;
70 }
71 }
72
73 /****************************************************************************/
74
75 void stm_prop_destroy (timing_props *properties)
76 {
77
78 if (properties) {
79 if (properties->RESMODEL)
80 mbkfree (properties->RESMODEL);
81 if (properties->CAPMODEL)
82 mbkfree (properties->CAPMODEL);
83 mbkfree (properties);
84 }
85 }
86
87 /****************************************************************************/
88
89 timing_table *stm_prop_seg2tbl (chain_list *chainseg, char type)
90 {
91 timing_table *table;
92 int i = 0;
93 chain_list * chain;
94 float x0, x1, inter, slo;
95
96 for(chain = chainseg; chain; chain = chain->NEXT){
97 if(!i)
98 i++;
99 i++;
100 }
101
102 table = stm_modtbl_create (i, 0, type, STM_NOTYPE);
103 i = 0;
104
105 for(chain = chainseg; chain; chain = chain->NEXT){
106 x0 = ((segment*)(chain->DATA))->X0;
107 x1 = ((segment*)(chain->DATA))->X1;
108 inter = ((segment*)(chain->DATA))->INTER;
109 slo = ((segment*)(chain->DATA))->SLO;
110 if(!i){
111 table->XRANGE[i] = x0;
112 table->SET1D[i] = (x0 * slo) + inter;
113 }
114 table->XRANGE[i + 1] = x1;
115 table->SET1D[i + 1] = (x1 * slo) + inter;
116 i++;
117 }
118 return table;
119 }