Ignore:
Timestamp:
Jan 22, 2013, 4:23:22 PM (11 years ago)
Author:
meunier
Message:

Code formatting in all source files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sources/src/port_dependency.cc

    r27 r52  
    11/*------------------------------------------------------------\
    2 |                                                             |
    3 | Tool    :                  systemcass                       |
    4 |                                                             |
    5 | File    :                  port_dependency.cc               |
    6 |                                                             |
    7 | Author  :                 Buchmann Richard                  |
    8 |                                                             |
    9 | Date    :                   21_09_2004                      |
    10 |                                                             |
    11 \------------------------------------------------------------*/
     2  |                                                             |
     3  | Tool    :                  systemcass                       |
     4  |                                                             |
     5  | File    :                  port_dependency.cc               |
     6  |                                                             |
     7  | Author  :                 Buchmann Richard                  |
     8  |                                                             |
     9  | Date    :                   21_09_2004                      |
     10  |                                                             |
     11  \------------------------------------------------------------*/
    1212
    1313/*
     
    3838#include <iostream>
    3939#include <fstream>
     40
    4041#include "port_dependency.h"
    4142#include "simplify_string.h"
     
    4546#include "sc_port.h"
    4647#include "sc_ver_ext.h"
     48
    4749#ifdef HAVE_CONFIG_H
    4850#include "config.h"
     
    5557static PortDependencyGraph aPortDependencyGraph;
    5658
    57 const PortDependencyGraph&
    58 get_port_dependency_graph ()
    59 {
    60         return aPortDependencyGraph;
     59const PortDependencyGraph & get_port_dependency_graph() {
     60    return aPortDependencyGraph;
    6161}
    6262
    63 static
    64 void
    65 check_port_dependency_declaration (const sc_port_base* a,
    66                                    const sc_port_base& b)
    67 {
    68   const sc_module &moduleA = a->get_module ();
    69   const sc_module &moduleB = b.get_module  ();
    70   if (check_port_dependencies && (&moduleA != &moduleB))
    71   {
    72     const char *module_nameA = moduleA.basename ();
    73     const char *module_nameB = moduleB.basename ();
    74     if (strlen (module_nameA) == 0)
    75       module_nameA = "<top level>";
    76     cerr << "Error : Port dependency declaration in '"
    77          << module_name_stack.back () << "' constructor is wrong.\n"
    78          << "'" << a->name () << "' and '" << b.name ()
    79          << "' are ports of two differents modules ("
    80          << module_nameA << " and "
    81          << module_nameB << "). "
    82          << "You can't declare any port dependency like that.\n";
    83     exit (37); //15092005);
    84   }
    85   if (module_name_stack.empty ())
    86   {
    87     cerr << "Error : Port dependency declaration is wrong.\n"
    88          << "The dependency declaration of '"
    89          << a->name () << "' and '" << b.name ()
    90          << "' is not in any sc_module constructor.\n";
    91     exit (16092005);
    92   }
    93   if (method_process_list.empty ())
    94   {
    95     cerr << "Error : Port dependency declaration in '"
    96          << module_name_stack.back () << "' constructor is wrong.\n"
    97          << "The dependency of '" << a->name () << "' and '" << b.name ()
    98          << "' should be linked to a SC_METHOD.\n";         
    99     exit(165); //17092005);
    100   }
     63
     64static void check_port_dependency_declaration(const sc_port_base * a, const sc_port_base& b) {
     65    const sc_module & moduleA = a->get_module();
     66    const sc_module & moduleB = b.get_module();
     67    if (check_port_dependencies && (&moduleA != &moduleB)) {
     68        const char * module_nameA = moduleA.basename();
     69        const char * module_nameB = moduleB.basename();
     70        if (strlen(module_nameA) == 0) {
     71            module_nameA = "<top level>";
     72        }
     73        cerr << "Error : Port dependency declaration in '"
     74            << module_name_stack.back () << "' constructor is wrong.\n"
     75            << "'" << a->name () << "' and '" << b.name ()
     76            << "' are ports of two differents modules ("
     77            << module_nameA << " and "
     78            << module_nameB << "). "
     79            << "You can't declare any port dependency like that.\n";
     80        exit (37); //15092005);
     81    }
     82    if (module_name_stack.empty()) {
     83        cerr << "Error : Port dependency declaration is wrong.\n"
     84            << "The dependency declaration of '"
     85            << a->name () << "' and '" << b.name ()
     86            << "' is not in any sc_module constructor.\n";
     87        exit (16092005);
     88    }
     89    if (method_process_list.empty()) {
     90        cerr << "Error : Port dependency declaration in '"
     91            << module_name_stack.back () << "' constructor is wrong.\n"
     92            << "The dependency of '" << a->name () << "' and '" << b.name ()
     93            << "' should be linked to a SC_METHOD.\n";         
     94        exit(165); //17092005);
     95    }
    10196}
    10297
    103 void
    104 set_port_dependency          (const sc_port_base* a,
    105                               const sc_port_base& b)
    106 {
    107   check_port_dependency_declaration (a,b);
    108         PortDependency p;
    109         p.method = method_process_list.back();
    110         p.source = a;
    111         p.destination = &b;
    112         aPortDependencyGraph.push_back (p);
     98
     99void set_port_dependency(const sc_port_base * a, const sc_port_base & b) {
     100    check_port_dependency_declaration(a,b);
     101    PortDependency p;
     102    p.method = method_process_list.back();
     103    p.source = a;
     104    p.destination = &b;
     105    aPortDependencyGraph.push_back(p);
    113106#ifdef DUMP_PORT_DEPENDENCY
    114         if (a) {
    115                 cerr << "'" << ((sc_object&)b).name()
    116              << "' depends on '"
    117                            << ((sc_object*)a)->name ()
    118          << "' in '" << p.method->name << "' function.\n";
    119         } else
    120                 cerr << "'" << ((sc_object&)b).name()
    121              << "' doesn't depend on anything"
    122          << " in '" << p.method->name << "' function.\n";
     107    if (a) {
     108        cerr << "'" << ((sc_object&)b).name()
     109            << "' depends on '"
     110            << ((sc_object*)a)->name()
     111            << "' in '" << p.method->name << "' function.\n";
     112    }
     113    else {
     114        cerr << "'" << ((sc_object&)b).name()
     115            << "' doesn't depend on anything"
     116            << " in '" << p.method->name << "' function.\n";
     117    }
    123118#endif
    124119}
    125120
    126 static
    127 void
    128 dot_write (ofstream &o, const PortDependencyGraph &g)
    129 {
    130         string s;
    131         PortDependencyGraph::const_iterator it;
    132         for (it = g.begin (); it != g.end (); ++it)
    133         {
    134                 if (it->source == NULL)
    135                         continue;
    136                 const char *name;
    137                 name = ((sc_object*)it->source)->name();
    138                 o << simplify_name(name,s);
    139                 o       << " -> ";
    140                 name = ((sc_object*)it->destination)->name();
    141                 o << simplify_name(name,s);
    142           o << "\n";
    143         }
     121
     122static void dot_write (ofstream & o, const PortDependencyGraph & g) {
     123    string s;
     124    PortDependencyGraph::const_iterator it;
     125    for (it = g.begin (); it != g.end (); ++it) {
     126        if (it->source == NULL) {
     127            continue;
     128        }
     129        const char * name;
     130        name = ((sc_object *)it->source)->name();
     131        o << simplify_name(name,s);
     132        o << " -> ";
     133        name = ((sc_object *)it->destination)->name();
     134        o << simplify_name(name,s);
     135        o << "\n";
     136    }
    144137}
    145138
    146 bool
    147 PortDependencyGraph2dot (const char *name,
    148                          const PortDependencyGraph& g)
    149 {
    150         if (!name)
    151                 return false;
    152         string filename;
    153         filename =  name;
    154         filename += ".dot";
    155         ofstream o;
    156   o.open (filename.c_str(),ios::out | ios::trunc);
    157         if (o.is_open () == false)
    158                 return false;
    159         o << "// Port dependency graph\n"
    160        "// Generated by "
    161     << sc_version () << "\n";
    162         o << "strict digraph " << name << " {\n";
    163         dot_write (o,g);
    164         o << "}\n";
    165         o.close ();
    166   if (dump_stage)
    167     cerr << "Port Dependency Graph written into '"
    168          << filename << "'.\n";
    169         return true;
     139
     140bool PortDependencyGraph2dot (const char * name, const PortDependencyGraph & g) {
     141    if (!name) {
     142        return false;
     143    }
     144    string filename;
     145    filename = name;
     146    filename += ".dot";
     147    ofstream o;
     148    o.open(filename.c_str(),ios::out | ios::trunc);
     149    if (o.is_open () == false) {
     150        return false;
     151    }
     152    o << "// Port dependency graph\n"
     153        "// Generated by "
     154        << sc_version () << "\n";
     155    o << "strict digraph " << name << " {\n";
     156    dot_write (o,g);
     157    o << "}\n";
     158    o.close ();
     159    if (dump_stage) {
     160        cerr << "Port Dependency Graph written into '" << filename << "'.\n";
     161    }
     162    return true;
    170163}
    171164
    172165} // end of sc_core namespace
    173166
     167/*
     168# Local Variables:
     169# tab-width: 4;
     170# c-basic-offset: 4;
     171# c-file-offsets:((innamespace . 0)(inline-open . 0));
     172# indent-tabs-mode: nil;
     173# End:
     174#
     175# vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     176*/
     177
Note: See TracChangeset for help on using the changeset viewer.