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/sc_vcd_trace.cc

    r33 r52  
    3535 */
    3636
     37#include <cstdio>
     38#include <cassert>
     39#include <ctime>
     40#include <string>
    3741
    3842#include "sc_trace.h"
     
    4145#include "internal.h"
    4246
    43 #include <cstdio>
    44 #include <cassert>
    45 #include <ctime>
    46 #include <string>
    47 
    4847#ifdef HAVE_CONFIG_H
    4948#include "config.h"
    5049#endif
    5150
    52 //-----------------------------------------*/
    5351
    5452using namespace std;
     
    5856//-----------------------------------------*/
    5957
    60 sc_trace_file*
    61 sc_create_vcd_trace_file(const char * name)
    62 {
    63   if (notrace)
    64     return NULL;
    65   assert(name != NULL);
    66         string filename;
    67         filename = name;
    68         filename += ".vcd";
    69         //char varToday[1024];system(varToday=echo `date`);
    70        
    71         //création d'1 instance de la structure Sc_trace_file:
    72         sc_trace_file *traceFic=new sc_trace_file();
    73         traceFic->flag = VCD_FORMAT;   
    74        
    75         trace_file_list.push_back(traceFic);
    76        
    77         //en-tête du fichier VCD:
    78         char entete[]="$date\n\t%s\n$end\n\n$version\n\t%s\n$end\n\n$timescale\n\t1 ps\n$end\n\n$scope module SystemC $end\n";
    79        
    80         //ouverture du fichier nommé "*name":
    81         traceFic->pfic=fopen(filename.c_str(),"w+");//on a un pointeur sur le fichier
    82         if((traceFic->pfic)==NULL)
    83         {
    84                 /* fopen renvoie NULL si erreur */
    85                 fprintf(stderr,"\n\terreur ouverture outVcd\n");
    86                 exit(15);
    87         }
     58sc_trace_file * sc_create_vcd_trace_file(const char * name) {
     59    if (notrace) {
     60        return NULL;
     61    }
     62    assert(name != NULL);
     63    string filename;
     64    filename = name;
     65    filename += ".vcd";
    8866
    89   char date[128];       
    90   time_t timep = time (NULL);
    91   const struct tm *tm = localtime (&timep);
    92   strftime (date, 128, "%A %d %B %y %Z - %R:%S -", tm);
     67    // Création d'une instance de la structure Sc_trace_file:
     68    sc_trace_file * traceFic = new sc_trace_file();
     69    traceFic->flag = VCD_FORMAT;
    9370
    94         //écriture de l'en-tête du format VCD:
    95         if ((fprintf(traceFic->pfic,entete, date, sc_version ()))==0)
    96                 {
    97                         /* fprintf renvoie 0 si erreur */
    98                         cerr << "\n\terreur ecriture de l'entete \n";
    99                         exit(2);
    100                 }
    101        
    102         //on retourne un pointeur sur la structure traceFile
    103         //dont un des éléments pointe sur notre fichier VCD:
    104         return traceFic;
     71    trace_file_list.push_back(traceFic);
     72
     73    //en-tête du fichier VCD:
     74    char entete[] = "$date\n\t%s\n$end\n\n$version\n\t%s\n$end\n\n$timescale\n\t1 ps\n$end\n\n$scope module SystemC $end\n";
     75
     76    //ouverture du fichier nommé "*name":
     77    traceFic->pfic = fopen(filename.c_str(), "w+");//on a un pointeur sur le fichier
     78    if ((traceFic->pfic) == NULL) {
     79        /* fopen renvoie NULL si erreur */
     80        fprintf(stderr, "\n\terreur ouverture outVcd\n");
     81        exit(15);
     82    }
     83
     84    char date[128];
     85    time_t timep = time(NULL);
     86    const struct tm * tm = localtime(&timep);
     87    strftime(date, 128, "%A %d %B %y %Z - %R:%S -", tm);
     88
     89    //écriture de l'en-tête du format VCD:
     90    if ((fprintf(traceFic->pfic, entete, date, sc_version())) == 0) {
     91        /* fprintf renvoie 0 si erreur */
     92        cerr << "\n\terreur ecriture de l'entete \n";
     93        exit(2);
     94    }
     95
     96    //on retourne un pointeur sur la structure traceFile
     97    //dont un des éléments pointe sur notre fichier VCD:
     98    return traceFic;
    10599}
    106100
     
    108102//*************************************************************************
    109103
    110 void
    111 sc_close_vcd_trace_file( sc_trace_file* traceFic )
    112 {       
    113   if (notrace)
    114     return;
    115   if (!traceFic)
    116   {
    117     cerr << "Warning : Unable to close vcd trace file.\n";
    118     return;
    119   }
     104void sc_close_vcd_trace_file(sc_trace_file * traceFic) {
     105    if (notrace) {
     106        return;
     107    }
     108    if (!traceFic) {
     109        cerr << "Warning : Unable to close vcd trace file.\n";
     110        return;
     111    }
    120112
    121   if (cpt >= trace_start)
    122   {
    123     trace (*traceFic,false);
    124     cpt++;
    125     trace (*traceFic,true);
    126   }
     113    if (cpt >= trace_start) {
     114        trace (*traceFic, false);
     115        cpt++;
     116        trace (*traceFic, true);
     117    }
    127118
    128         //fermeture fichier VCD
    129         if (fclose(traceFic->pfic))
    130         {
    131                 /* fclose renvoie 0 si OK */
    132                 perror("\n\tclosing VCD file.");
    133                 exit(4);
    134         }
     119    //fermeture fichier VCD
     120    if (fclose(traceFic->pfic)) {
     121        /* fclose renvoie 0 si OK */
     122        perror("\n\tclosing VCD file.");
     123        exit(4);
     124    }
    135125
    136         //libération de l'instance de la structure en mémoire:
    137         delete traceFic;
     126    //libération de l'instance de la structure en mémoire:
     127    delete traceFic;
    138128
    139         vector<sc_trace_file*>::iterator i;
    140         for (i = trace_file_list.begin (); i != trace_file_list.end(); ++i)
    141                 if (*i == traceFic) {
    142                         trace_file_list.erase(i);
    143                         break;
    144                 }
     129    vector<sc_trace_file *>::iterator i;
     130    for (i = trace_file_list.begin(); i != trace_file_list.end(); ++i) {
     131        if (*i == traceFic) {
     132            trace_file_list.erase(i);
     133            break;
     134        }
     135    }
     136}
    145137
    146 }
    147138
    148139} // end of sc_core namespace
    149140
     141/*
     142# Local Variables:
     143# tab-width: 4;
     144# c-basic-offset: 4;
     145# c-file-offsets:((innamespace . 0)(inline-open . 0));
     146# indent-tabs-mode: nil;
     147# End:
     148#
     149# vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     150*/
     151
Note: See TracChangeset for help on using the changeset viewer.