Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
uvahotspot
GitHub Repository: uvahotspot/HotSpot
Path: blob/master/shape.h
612 views
1
#ifndef __SHAPE_H_
2
#define __SHAPE_H_
3
4
#include "flp.h"
5
#include "npe.h"
6
7
#define MAX_STACK 128
8
9
/* piecewise linear shape curve */
10
typedef struct shape_t_st
11
{
12
double *x; /* width */
13
double *y; /* height */
14
/*
15
* if this is not a leaf in an flp,
16
* the position of the orientations
17
* in the contributing shape curve
18
*/
19
int *left_pos;
20
int *right_pos;
21
/*
22
* the position of the demarcation
23
* in the combined shape curve
24
*/
25
double *median;
26
int size;
27
}shape_t;
28
29
/* slicing tree node */
30
typedef struct tree_node_t_st
31
{
32
shape_t *curve;
33
union {
34
int cut_type;
35
int unit;
36
}label;
37
struct tree_node_t_st *left;
38
struct tree_node_t_st *right;
39
}tree_node_t;
40
41
/* tree node stack */
42
typedef struct tree_node_stack_t_st
43
{
44
tree_node_t *array[MAX_STACK];
45
int top;
46
}tree_node_stack_t;
47
48
/*
49
* make a shape curve from area and aspect ratios
50
* - allocates memory internally
51
*/
52
shape_t *shape_from_aspect(double area, double min,
53
double max, int rotable,
54
int n_orients);
55
/* shape curve arithmetic */
56
shape_t *shape_add(shape_t *shape1, shape_t *shape2, int cut_type);
57
/* uninitialization */
58
void free_shape(shape_t *shape);
59
/* position in the shape curve with minimum area */
60
int min_area_pos(shape_t *curve);
61
/* debug print */
62
void print_shape(shape_t *shape);
63
64
/* stack operations */
65
tree_node_stack_t *new_tree_node_stack(void);
66
void tree_node_stack_push(tree_node_stack_t *stack, tree_node_t *node);
67
tree_node_t *tree_node_stack_pop(tree_node_stack_t *stack);
68
int tree_node_stack_isfull(tree_node_stack_t *stack);
69
int tree_node_stack_isempty(tree_node_stack_t *stack);
70
void free_tree_node_stack(tree_node_stack_t *stack);
71
void tree_node_stack_clear(tree_node_stack_t *stack);
72
73
/* tree operations */
74
/* construct floorplan slicing tree from NPE */
75
tree_node_t *tree_from_NPE(flp_desc_t *flp_desc,
76
tree_node_stack_t *stack,
77
NPE_t *expr);
78
void free_tree(tree_node_t *root);
79
void print_tree(tree_node_t *root, flp_desc_t *flp_desc);
80
/*
81
* print only the portion of the shape curves
82
* corresponding to the `pos'th entry of root->curve
83
*/
84
void print_tree_relevant(tree_node_t *root, int pos, flp_desc_t *flp_desc);
85
/*
86
* convert slicing tree into actual floorplan
87
* returns the number of dead blocks compacted
88
*/
89
int tree_to_flp(tree_node_t *root, flp_t *flp, int compact_dead,
90
double compact_ratio);
91
#endif
92
93