degate  0.1.2
AutoNameGates.h
Go to the documentation of this file.
00001 /* -*-c++-*-
00002 
00003   This file is part of the IC reverse engineering tool degate.
00004 
00005   Copyright 2008, 2009, 2010 by Martin Schobert
00006 
00007   Degate is free software: you can redistribute it and/or modify
00008   it under the terms of the GNU General Public License as published by
00009   the Free Software Foundation, either version 3 of the License, or
00010   any later version.
00011 
00012   Degate is distributed in the hope that it will be useful,
00013   but WITHOUT ANY WARRANTY; without even the implied warranty of
00014   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015   GNU General Public License for more details.
00016 
00017   You should have received a copy of the GNU General Public License
00018   along with degate. If not, see <http://www.gnu.org/licenses/>.
00019 
00020 */
00021 
00022 #ifndef __AUTONAMEGATES_H__
00023 #define __AUTONAMEGATES_H__
00024 
00025 #include <LogicModel.h>
00026 
00027 namespace degate {
00028 
00029   /**
00030    * This class helps to generate names for gates depending on their position.
00031    *
00032    * Gates are usually placed in rows or columns. It might be useful to name
00033    * them by their position. The class AutoNameGates generates names in the
00034    * format ${row}.${column}. E.g. the gate name "5.23" indicates that this
00035    * gate is placed in the 5th row and the 23th column.
00036    *
00037    */
00038   class AutoNameGates {
00039 
00040   public:
00041 
00042     enum ORIENTATION {
00043       ALONG_ROWS = 1,
00044       ALONG_COLS = 2
00045     };
00046 
00047     AutoNameGates(LogicModel_shptr lmodel, ORIENTATION orientation);
00048 
00049     void run();
00050 
00051   private:
00052     void rename_gates(std::vector<unsigned int> const & histogram, 
00053                       ORIENTATION orientation,
00054                       std::list<int> const& scan_lines) const;
00055 
00056     void fill_histogram(LogicModel_shptr lmodel,
00057                         std::vector<unsigned int> & histogram, 
00058                         ORIENTATION orientation) const;
00059 
00060     std::list<int> scan_histogram(std::vector<unsigned int> const & histogram) const;
00061 
00062   private:
00063     LogicModel_shptr _lmodel;
00064     ORIENTATION _orientation;
00065     Layer_shptr layer;  
00066 
00067   };
00068 
00069 }
00070 
00071 #endif