degate  0.1.2
ERCOpenPorts.cc
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 #include <RCBase.h>
00023 #include <ERCOpenPorts.h>
00024 
00025 using namespace degate;
00026 
00027 ERCOpenPorts::ERCOpenPorts() :
00028   RCBase("open_port", "Check for unconnected ports.", RC_WARNING) {
00029 }
00030 
00031 void ERCOpenPorts::run(LogicModel_shptr lmodel) {
00032   clear_rc_violations();
00033 
00034   if(lmodel == NULL) return;
00035 
00036   // iterate over Gates
00037   debug(TM, "\tRC: iterate over gates.");
00038 
00039   for(LogicModel::gate_collection::iterator g_iter = lmodel->gates_begin();
00040       g_iter != lmodel->gates_end(); ++g_iter) {
00041 
00042     Gate_shptr gate = g_iter->second;
00043     
00044     for(Gate::port_const_iterator p_iter = gate->ports_begin();
00045         p_iter != gate->ports_end(); ++p_iter) {
00046       
00047       GatePort_shptr port = *p_iter;
00048       assert(port != NULL);
00049       
00050       Net_shptr net = port->get_net();
00051       if(net == NULL || net->size() <= 1) {
00052         
00053         boost::format f("Port %1% is unconnected.");
00054         f % port->get_descriptive_identifier();
00055 
00056         debug(TM, "\tRC: found a vioation.");
00057         add_rc_violation(RCViolation_shptr(new RCViolation(port, f.str(),
00058                                                            get_rc_class_name())));
00059       }
00060     }
00061   }
00062 }
00063