degate  0.1.2
Public Types | Public Member Functions | Private Member Functions | Private Attributes
degate::AutoNameGates Class Reference

This class helps to generate names for gates depending on their position. More...

#include <AutoNameGates.h>

List of all members.

Public Types

enum  ORIENTATION {
  ALONG_ROWS = 1,
  ALONG_COLS = 2
}

Public Member Functions

 AutoNameGates (LogicModel_shptr lmodel, ORIENTATION orientation)
void run ()

Private Member Functions

void rename_gates (std::vector< unsigned int > const &histogram, ORIENTATION orientation, std::list< int > const &scan_lines) const
void fill_histogram (LogicModel_shptr lmodel, std::vector< unsigned int > &histogram, ORIENTATION orientation) const
std::list< int > scan_histogram (std::vector< unsigned int > const &histogram) const

Private Attributes

LogicModel_shptr _lmodel
ORIENTATION _orientation
Layer_shptr layer

Detailed Description

This class helps to generate names for gates depending on their position.

Gates are usually placed in rows or columns. It might be useful to name them by their position. The class AutoNameGates generates names in the format ${row}.${column}. E.g. the gate name "5.23" indicates that this gate is placed in the 5th row and the 23th column.

Definition at line 38 of file AutoNameGates.h.


Member Enumeration Documentation

Enumerator:
ALONG_ROWS 
ALONG_COLS 

Definition at line 42 of file AutoNameGates.h.

                     {
      ALONG_ROWS = 1,
      ALONG_COLS = 2
    };

Constructor & Destructor Documentation

Definition at line 17 of file AutoNameGates.cc.

References degate::get_first_logic_layer(), and layer.

                                                                             :
  _lmodel(lmodel),
  _orientation(orientation) {
  layer = get_first_logic_layer(lmodel);
}

Here is the call graph for this function:


Member Function Documentation

void AutoNameGates::fill_histogram ( LogicModel_shptr  lmodel,
std::vector< unsigned int > &  histogram,
ORIENTATION  orientation 
) const [private]

Definition at line 80 of file AutoNameGates.cc.

References _orientation, ALONG_COLS, and ALONG_ROWS.

Referenced by run().

                                                                  {

  int x, y;

  // iterate over gates
  for(LogicModel::gate_collection::iterator iter = lmodel->gates_begin();
      iter != lmodel->gates_end(); ++iter) {
    Gate_shptr gate = (*iter).second;
    assert(gate != NULL);
    
    if(_orientation == ALONG_COLS) 
      for(x = gate->get_min_x(); x < gate->get_max_x(); x++)
        histogram[x]++;

    if(_orientation == ALONG_ROWS) 
      for(y = gate->get_min_y(); y < gate->get_max_y(); y++)
        histogram[y]++;
  }
}

Here is the caller graph for this function:

void AutoNameGates::rename_gates ( std::vector< unsigned int > const &  histogram,
ORIENTATION  orientation,
std::list< int > const &  scan_lines 
) const [private]

Definition at line 32 of file AutoNameGates.cc.

References _orientation, ALONG_COLS, ALONG_ROWS, compare_min_x(), compare_min_y(), and layer.

Referenced by run().

                                                                       {
  
  unsigned int col_num = 0;
  unsigned int row_num = 0;

  BOOST_FOREACH(int i, scan_lines) {

    // naming = along-rows => histogram along y-axis, following scanlines along x-axis

    
    // collect all gates placed along scanline
    
    std::list<Gate_shptr> gate_list;
    
    BoundingBox bbox(orientation == ALONG_ROWS ? 0 : i, 
                     orientation == ALONG_ROWS ? layer->get_width() - 1 : i, 
                     orientation == ALONG_COLS ? 0 : i, 
                     orientation == ALONG_COLS ? layer->get_height() - 1 : i);
    
    for(Layer::qt_region_iterator iter = layer->region_begin(bbox); 
        iter != layer->region_end(); ++iter) {
      if(Gate_shptr gate = std::dynamic_pointer_cast<Gate>(*iter))
        gate_list.push_back(gate);
    }
    
    // sort gate list according to their min_x or min_y
    if(orientation == ALONG_ROWS) gate_list.sort(compare_min_x);
    else gate_list.sort(compare_min_y);
    
    // rename gates
    BOOST_FOREACH(Gate_shptr gate, gate_list) {
      boost::format f("%1%.%2%");
      f % row_num % col_num;
      gate->set_name(f.str());
      
      // next row or col
      if(_orientation == ALONG_ROWS) col_num++;
      else row_num++;      
    }
    
    // next row or col
    if(_orientation == ALONG_ROWS) { row_num++; col_num = 0; }
    else { col_num++; row_num = 0; }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 23 of file AutoNameGates.cc.

References _lmodel, _orientation, fill_histogram(), rename_gates(), and scan_histogram().

                        {
  std::vector<unsigned int> histogram(std::max(_lmodel->get_width(), 
                                               _lmodel->get_height()));

  fill_histogram(_lmodel, histogram, _orientation);
  std::list<int> scan_lines = scan_histogram(histogram);
  rename_gates(histogram, _orientation, scan_lines);
}

Here is the call graph for this function:

std::list< int > AutoNameGates::scan_histogram ( std::vector< unsigned int > const &  histogram) const [private]

Definition at line 102 of file AutoNameGates.cc.

Referenced by run().

                                                                                          {

  std::list<int> scan_lines;

  unsigned int from = 0;
  unsigned int i;
  for(i = 0; i < histogram.size(); i++) {
    if(histogram[i] > 0 && from == 0) from = i;
    if(histogram[i] == 0 && from > 0) {
      scan_lines.push_back(from + (i - from)/2);
      from = 0;
    }
  }
  return scan_lines;
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 63 of file AutoNameGates.h.

Referenced by run().

Definition at line 64 of file AutoNameGates.h.

Referenced by fill_histogram(), rename_gates(), and run().

Definition at line 65 of file AutoNameGates.h.

Referenced by AutoNameGates(), and rename_gates().


The documentation for this class was generated from the following files: