scf_vector_t* pins;
scf_vector_t* childs;
+
ses_path_t* parent;
+ int parent_p0;
+ int parent_p1;
double r0;
double jr0;
ses_path_t* ses_path_alloc();
void ses_path_free (ses_path_t* path);
void ses_path_print(ses_path_t* path);
+int ses_path_add (ses_path_t* path, ses_path_t* child);
ses_flow_t* ses_flow_alloc();
void ses_flow_free (ses_flow_t* flow);
static int _topo_layers(scf_vector_t* paths)
{
- ses_path_t* path0;
- ses_path_t* path1;
- ses_path_t* path2;
+ ses_path_t* child;
+ ses_path_t* parent;
ScfEpin* p0;
ScfEpin* p1;
- ScfEpin* p2;
- ScfEpin* p3;
ScfEpin* p;
int i;
int k;
for (i = 0; i < paths->size; i++) {
- path0 = paths->data[i];
- path0->index = i;
+ child = paths->data[i];
+ child->index = i;
}
for (i = paths->size - 1; i >= 1; i--) {
- path0 = paths->data[i];
+ child = paths->data[i];
- assert(path0->pins->size >= 2);
+ assert(child->pins->size >= 2);
- p0 = path0->pins->data[0];
- p1 = path0->pins->data[path0->pins->size - 1];
+ p0 = child->pins->data[0];
+ p1 = child->pins->data[child->pins->size - 1];
- for (j = i - 1; j >= 0; j--) {
- path1 = paths->data[j];
+ for (j = i - 1; j >= 0; j--) {
+ parent = paths->data[j];
- int n = 0;
+ int n = 0;
- for (k = 0; k < path1->pins->size; k++) {
- p = path1->pins->data[k];
+ for (k = 0; k < parent->pins->size; k++) {
+ p = parent->pins->data[k];
if (p->lid == p0->lid)
n |= 0x1;
continue;
branch:
- if (!path1->childs) {
- path1->childs = scf_vector_alloc();
- if (!path1->childs)
- return -ENOMEM;
-
- } else {
- for (j = 0; j < path1->childs->size; j++) {
- path2 = path1->childs->data[j];
-
- p2 = path2->pins->data[0];
- p3 = path2->pins->data[path2->pins->size - 1];
-
- if (p2->lid == p0->lid && p3->lid == p1->lid) {
- path1 = path2;
- break;
- }
- }
- }
-
- if (scf_vector_del(paths, path0) < 0)
+ if (scf_vector_del(paths, child) < 0)
return -1;
- scf_loge("path0: %d, path1: %d\n", path0->index, path1->index);
-
- if (scf_vector_add(path1->childs, path0) < 0) {
- ses_path_free(path0);
+ if (ses_path_add(parent, child) < 0) {
+ ses_path_free(child);
return -ENOMEM;
}
-
- path0->parent = path1;
- path0->type = SES_PATH_BRANCH;
}
return 0;
}
}
+int ses_path_add(ses_path_t* parent, ses_path_t* child)
+{
+ if (!parent || !child)
+ return -EINVAL;
+
+ if (!parent->childs) {
+ parent->childs = scf_vector_alloc();
+ if (!parent->childs)
+ return -ENOMEM;
+ }
+
+ ses_path_t* path;
+ ScfEpin* p0;
+ ScfEpin* p1;
+ ScfEpin* cp0 = child->pins->data[0];
+ ScfEpin* cp1 = child->pins->data[child->pins->size - 1];
+
+ int j;
+
+ for (j = 0; j < parent->childs->size; j++) {
+ path = parent->childs->data[j];
+
+ p0 = path->pins->data[0];
+ p1 = path->pins->data[path->pins->size - 1];
+
+ if (p0->lid == cp0->lid && p1->lid == cp1->lid)
+ return ses_path_add(path, child);
+ }
+
+ if (scf_vector_add(parent->childs, child) < 0)
+ return -ENOMEM;
+
+ for (j = 0; j < parent->pins->size; j++) {
+ p0 = parent->pins->data[j];
+
+ if (p0->lid == cp0->lid)
+ child->parent_p0 = j;
+
+ if (p0->lid == cp1->lid) {
+ child->parent_p1 = j;
+ break;
+ }
+ }
+ assert(child->parent_p0 >= 0 && child->parent_p1 >= 0);
+
+ child->parent = parent;
+ child->type = SES_PATH_BRANCH;
+ return 0;
+}
+
ses_ctx_t* ses_ctx_alloc()
{
ses_ctx_t* ctx = calloc(1, sizeof(ses_ctx_t));