summaryrefslogtreecommitdiffstats
path: root/src/phys/place/place_io.c
blob: 16ad5339dca47842fd6d2ca79e67f410b999e9cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*===================================================================*/
//  
//     place_io.c
//
//        Aaron P. Hurst, 2003-2007
//              ahurst@eecs.berkeley.edu
//
/*===================================================================*/

#include <stdlib.h>
#include <limits.h>
#include <assert.h>
#include <string.h>
#include <stdio.h>

#include "place_base.h"

ABC_NAMESPACE_IMPL_START



// --------------------------------------------------------------------
// writeBookshelfNodes()
//
// --------------------------------------------------------------------
void writeBookshelfNodes(const char *filename) {
  
  int c = 0;
  int numNodes, numTerms;

  FILE *nodesFile = fopen(filename, "w");
  if (!nodesFile) {
    printf("ERROR: Could not open .nodes file\n");
    exit(1);
  }

  numNodes = numTerms = 0;
  for(c=0; c<g_place_numCells; c++) if (g_place_concreteCells[c]) {
      numNodes++;
      if (g_place_concreteCells[c]->m_parent->m_pad)
        numTerms++;
    }



  fprintf(nodesFile, "UCLA nodes 1.0\n");
  fprintf(nodesFile, "NumNodes : %d\n", numNodes);
  fprintf(nodesFile, "NumTerminals : %d\n", numTerms);

  for(c=0; c<g_place_numCells; c++) if (g_place_concreteCells[c]) {
    fprintf(nodesFile, "CELL%d %f %f %s\n", 
            g_place_concreteCells[c]->m_id,
            g_place_concreteCells[c]->m_parent->m_width,
            g_place_concreteCells[c]->m_parent->m_height,
            (g_place_concreteCells[c]->m_parent->m_pad ? " terminal" : ""));
  }

  fclose(nodesFile);  
}


// --------------------------------------------------------------------
// writeBookshelfPl()
//
// --------------------------------------------------------------------
void writeBookshelfPl(const char *filename) {
  
  int c = 0;

  FILE *plFile = fopen(filename, "w");
  if (!plFile) {
    printf("ERROR: Could not open .pl file\n");
    exit(1);
  }

  fprintf(plFile, "UCLA pl 1.0\n");
  for(c=0; c<g_place_numCells; c++)  if (g_place_concreteCells[c]) {
    fprintf(plFile, "CELL%d %f %f : N %s\n", 
            g_place_concreteCells[c]->m_id,
            g_place_concreteCells[c]->m_x,
            g_place_concreteCells[c]->m_y,
            (g_place_concreteCells[c]->m_fixed ? "\\FIXED" : ""));
  }

  fclose(plFile);  

}


// --------------------------------------------------------------------
// writeBookshelf()
//
// --------------------------------------------------------------------
void writeBookshelf(const char *filename) {
  writeBookshelfNodes("out.nodes");
  writeBookshelfPl("out.pl");
}
ABC_NAMESPACE_IMPL_END