Changeset 59


Ignore:
Timestamp:
Feb 6, 2017, 11:35:42 AM (7 years ago)
Author:
meunier
Message:
  • Fixed memory leaks
  • Fixed indentation in some files
Location:
sources
Files:
35 edited

Legend:

Unmodified
Added
Removed
  • sources/README

    r43 r59  
    11SystemCASS Installation
    22=======================
     3
     4Commande pour compiler : se placer dans le répertoire voulu (ici sandbox_test/objdir), puis :
     5$ ../../configure --prefix=$(pwd) --enable-debug
    36
    47Please use automake/autoconf to install SystemCASS.
  • sources/src/alias.cc

    r52 r59  
    4141
    4242const char * alias () {
    43         static int i = 0;
    44         char * buf = new char[4];       
    45         buf[3] = '\0';
    46         buf[2] = 'a' + i % 26;
    47         buf[1] = 'a' + (i / 26) % 26;
    48         buf[0] = 'a' + ((i / 26) / 26) % 26;
    49         i++;   
    50         return buf;
     43    static int i = 0;
     44    char * buf = new char[4];
     45    buf[3] = '\0';
     46    buf[2] = 'a' + i % 26;
     47    buf[1] = 'a' + (i / 26) % 26;
     48    buf[0] = 'a' + ((i / 26) / 26) % 26;
     49    i++;
     50    return buf;
    5151}
    5252
  • sources/src/casc.h

    r52 r59  
    2121
    2222#include <cstdio>
    23 #include <stdint.h>
     23//#include <stdint.h>
    2424
    2525EXTERN char unstable;
    26 EXTERN int32_t pending_write_vector_nb;
     26EXTERN int32 pending_write_vector_nb;
    2727
    2828namespace sc_core {
  • sources/src/entity.cc

    r52 r59  
    122122}
    123123
    124 static sc_port_base *get_localvar(equi_t & eq) {
     124static sc_port_base * get_localvar(equi_t & eq) {
    125125    equi_t::iterator i;
    126126    for (i = eq.begin(); i != eq.end(); ++i) {
     
    134134
    135135
    136 static sc_port_base *get_signal(equi_t & eq) {
     136static sc_port_base * get_signal(equi_t & eq) {
    137137    equi_t::iterator i;
    138138    for (i = eq.begin(); i != eq.end(); ++i) {
     
    167167    assert(pointer != NULL);
    168168
    169     // boost
    170169    tab_t2equi_it_t:: /*const_ */ iterator it = tab2equi_map.find(pointer);
    171170    if (it != tab2equi_map.end()) {
     
    274273
    275274template < typename T > static equi_list_t::iterator get_equi(T & e) {
     275    // QM debug
     276    //cout << "equi_map : " << equi_map << endl;
     277
    276278    entity2equi_it_t::iterator it = equi_map.find(entity(e));
    277279    if (it == equi_map.end()) {
  • sources/src/gen_code.cc

    r57 r59  
    582582    SC_ENTRY_FUNC func = m.func;
    583583    //  CASC_ENTRY_FUNC   func = reinterpret_cast<CASC_ENTRY_FUNC> (m.func);
     584    // QM
     585    //cerr << "Exec " << mod->name() << "->" << m.name << endl;
    584586    (mod->*func) ();
    585587}
  • sources/src/gen_code.h

    r52 r59  
    9393inline void internal_sc_cycle1(int number_of_cycles) { 
    9494    //while ((! have_to_stop) && (number_of_cycles != 0)) {
    95     while (!((have_to_stop) | (number_of_cycles == 0))) {
     95    while (!((have_to_stop) || (number_of_cycles == 0))) {
    9696        trace_all(false);
    9797        internal_sc_cycle2();
    9898        trace_all(true);
    99         number_of_cycles = (number_of_cycles<0) ? number_of_cycles:number_of_cycles - 1;
     99        number_of_cycles = (number_of_cycles < 0) ? number_of_cycles : number_of_cycles - 1;
    100100    }
    101101}
     
    116116#endif
    117117
    118     if (is_posted_write ()) {
    119         // update posted value to external signals             
    120         update ();
    121         func_combinationals ();
     118    if (is_posted_write()) {
     119        // update posted value to external signals
     120        update();
     121        func_combinationals();
    122122    }
    123123
    124     internal_sc_cycle1 ((int) duration);
     124    internal_sc_cycle1((int) duration);
    125125
    126126    // don't need to do func_combinationals since 'unstable' flag is now false
  • sources/src/global_functions.cc

    r52 r59  
    3838#include <iostream>
    3939#include <dlfcn.h>
     40#include <signal.h>
    4041
    4142#include "schedulers.h"   // get_scheduling & run_schedule_editor
     
    326327    check_and_initialize();
    327328    sc_core::internal_sc_cycle0(duration);
     329    if (have_to_stop) {
     330        std::vector<method_process_t *>::iterator i;
     331        for (i = sc_core::method_process_list.begin(); i != sc_core::method_process_list.end(); i++) {
     332            delete *i;
     333        }
     334        std::vector<const char *>::iterator j;
     335        for (j = sc_core::allocated_names.begin(); j != sc_core::allocated_names.end(); j++) {
     336            free((char *) *j);
     337        }
     338    }
    328339}
    329340
     
    332343    check_and_initialize();
    333344    sc_core::internal_sc_cycle0(duration);
     345    if (have_to_stop) {
     346        std::vector<method_process_t *>::iterator i;
     347        for (i = sc_core::method_process_list.begin(); i != sc_core::method_process_list.end(); i++) {
     348            delete *i;
     349        }
     350        std::vector<const char *>::iterator j;
     351        for (j = sc_core::allocated_names.begin(); j != sc_core::allocated_names.end(); j++) {
     352            free((char *) *j);
     353        }
     354    }
    334355}
    335356
  • sources/src/internal.h

    r52 r59  
    1717#include <string>
    1818#include <vector>
     19//#include <stdint.h>
    1920
    2021namespace sc_core {
     
    2728typedef std::vector<std::string> module_name_stack_t;
    2829extern module_name_stack_t module_name_stack;
     30extern std::vector<const char *> allocated_names;
    2931
    3032// Hash Table Port -> Module
  • sources/src/internal_ext.h

    r52 r59  
    3838
    3939#include <list>
     40//#include <stdint.h>
    4041
    4142#include "sc_fwd.h"
     
    7172#else
    7273    typedef uint32 tab_t;
    73 // typedef smallest_uint tab_t; // signals of 64 bits are wrong in trace file
     74    //typedef smallest_uint tab_t; // signals of 64 bits are wrong in trace file
    7475#endif
    7576typedef tab_t * equi_table_t;
  • sources/src/module_hierarchy2dot.cc

    r27 r59  
    11/*------------------------------------------------------------\
    2 |                                                             |
    3 | Tool    :                  systemcass                       |
    4 |                                                             |
    5 | File    :                  module_hierarchy2dot.cc          |
    6 |                                                             |
    7 | Author  :                 Buchmann Richard                  |
    8 |                                                             |
    9 | Date    :                   26_01_2006                      |
    10 |                                                             |
    11 \------------------------------------------------------------*/
     2  |                                                             |
     3  | Tool    :                  systemcass                       |
     4  |                                                             |
     5  | File    :                  module_hierarchy2dot.cc          |
     6  |                                                             |
     7  | Author  :                 Buchmann Richard                  |
     8  |                                                             |
     9  | Date    :                   26_01_2006                      |
     10  |                                                             |
     11  \------------------------------------------------------------*/
    1212
    1313/*
     
    5353namespace sc_core {
    5454
    55 /*
    56 static
    57 const char*
    58 get_parent_name (const sc_object &obj)
    59 {
    60   const sc_object *parent = NULL;//get_parent_object (obj);
    61   if (parent == NULL)
    62     return "";
    63   return parent->basename ();
    64 }
    65 */
    66 
    6755typedef set<const char*> node_set_t;
    6856node_set_t node_set;
    6957
    70 static
    71 void
    72 print_edge (ostream &o)
     58static void print_edge (ostream &o)
    7359{
    74   typedef map<const char*, const char*> edge_t;
    75   edge_t edges;
    76   const equi_list_t &eq_list = get_equi_list ();
    77   equi_list_t::const_iterator jt;
    78   for (jt = eq_list.begin (); jt != eq_list.end (); ++jt)
    79   {
    80     const equi_t &eq = (*jt);
    81     sc_port_base *out   = get_out_port (eq);
    82     if (out == NULL)
    83       continue;
    84     if (is_clock (*out))
    85       continue;
    86     const sc_module &out_mod = out->get_module ();
    87     const char *out_mod_name = out_mod.basename ();
    88     equi_t::const_iterator it;
    89     for (it = eq.begin (); it != eq.end (); ++it)
     60    typedef map<const char*, const char*> edge_t;
     61    edge_t edges;
     62    const equi_list_t &eq_list = get_equi_list ();
     63    equi_list_t::const_iterator jt;
     64    for (jt = eq_list.begin (); jt != eq_list.end (); ++jt)
    9065    {
    91       const entity &in_entity  = *it;
    92       sc_object    *in_obj     = in_entity.object;
    93       assert(in_obj != NULL);
    94       const sc_module *in_parent = NULL;
    95       switch (in_entity.type) {
    96       case entity::PORT :
    97         in_parent = &(in_entity.port->get_module ());
    98         if (&out_mod == in_parent)
    99           continue;
    100         break;
    101       case entity::SIGNAL :
    102       default :
    103         continue;
    104       }
    105       edges[out_mod_name] = in_parent->basename ();
    106       node_set.insert(out_mod_name);
    107       node_set.insert(in_parent->basename ());
     66        const equi_t & eq = (*jt);
     67        sc_port_base * out   = get_out_port (eq);
     68        if (out == NULL) {
     69            continue;
     70        }
     71        if (is_clock(*out)) {
     72            continue;
     73        }
     74        const sc_module &out_mod = out->get_module ();
     75        const char *out_mod_name = out_mod.basename ();
     76        equi_t::const_iterator it;
     77        for (it = eq.begin (); it != eq.end (); ++it)
     78        {
     79            const entity &in_entity  = *it;
     80            sc_object    *in_obj     = in_entity.object;
     81            assert(in_obj != NULL);
     82            const sc_module *in_parent = NULL;
     83            switch (in_entity.type) {
     84                case entity::PORT :
     85                    in_parent = &(in_entity.port->get_module ());
     86                    if (&out_mod == in_parent) {
     87                        continue;
     88                    }
     89                    break;
     90                case entity::SIGNAL :
     91                default :
     92                    continue;
     93            }
     94            edges[out_mod_name] = in_parent->basename ();
     95            node_set.insert(out_mod_name);
     96            node_set.insert(in_parent->basename ());
     97        }
    10898    }
    109   }
    11099#if 0
    111   const equi_t &signal_eq = *(eq_list.begin ());
    112   const char *signal_name = get_name (signal_eq);
    113   o << "edge [label=\"" << signal_name << "\"]\n";
     100    const equi_t &signal_eq = *(eq_list.begin ());
     101    const char *signal_name = get_name (signal_eq);
     102    o << "edge [label=\"" << signal_name << "\"]\n";
    114103#endif
    115   edge_t::const_iterator i;
    116   for (i = edges.begin (); i != edges.end (); ++i)
    117   {
    118     o << i->first
    119       << " -> "
    120       << i->second
    121       << ";\n";
    122   }
     104    edge_t::const_iterator i;
     105    for (i = edges.begin (); i != edges.end (); ++i)
     106    {
     107        o << i->first
     108          << " -> "
     109          << i->second
     110          << ";\n";
     111    }
    123112}
    124113
     
    126115
    127116static
    128 void
     117    void
    129118print_node (ostream         &o,
    130             const sc_object &obj)
     119        const sc_object &obj)
    131120{
    132   const vector<sc_object*> &obj_list = get_child_objects (obj);
    133   bool subgraph = (obj_list.empty() == false);
    134 //                  && (get_parent_object (obj) != NULL);
    135   if (subgraph) {
    136     const char *name = obj.basename ();
    137     o << "subgraph \"cluster" << name << "\" {\n"
    138       << "label=\"" << name << "\";\n";
    139     print_node (o, obj_list);
    140     o << "}\n";
    141   } /*else*/ {
    142 //    if (obj.kind () == sc_module::kind_string)
    143     if (node_set.find (obj.basename ()) != node_set.end())
    144       o << obj.basename () << endl;
    145   }
     121    const vector<sc_object*> &obj_list = get_child_objects (obj);
     122    bool subgraph = (obj_list.empty() == false);
     123    //                  && (get_parent_object (obj) != NULL);
     124    if (subgraph) {
     125        const char *name = obj.basename ();
     126        o << "subgraph \"cluster" << name << "\" {\n"
     127            << "label=\"" << name << "\";\n";
     128        print_node (o, obj_list);
     129        o << "}\n";
     130    } /*else*/ {
     131        //    if (obj.kind () == sc_module::kind_string)
     132        if (node_set.find (obj.basename ()) != node_set.end()) {
     133            o << obj.basename () << endl;
     134        }
     135    }
    146136}
    147137
    148138static
    149 void
     139    void
    150140print_node (ostream                  &o,
    151             const vector<sc_object*> &obj_list)
     141        const vector<sc_object*> &obj_list)
    152142{
    153   vector<sc_object*>::const_iterator it;
    154   for (it = obj_list.begin(); it != obj_list.end(); ++it)
    155   {
    156     sc_object *obj = *it;
    157     print_node (o, *obj);
    158   }
     143    vector<sc_object*>::const_iterator it;
     144    for (it = obj_list.begin(); it != obj_list.end(); ++it)
     145    {
     146        sc_object *obj = *it;
     147        print_node (o, *obj);
     148    }
    159149}
    160150
    161 bool
     151    bool
    162152module_hierarchy2dot (const char *name)
    163153{
    164         if (!name)
    165                 return false;
    166         string filename;
    167         filename =  name;
    168         filename += ".dot";
    169         ofstream o;
    170   o.open (filename.c_str(),ios::out | ios::trunc);
    171         if (o.is_open () == false)
    172                 return false;
    173         o << "strict digraph " << name << " {\n";
    174   o << "node [shape=box];\n";
    175   print_edge (o);
    176         print_node (o,sc_get_top_level_objects ());
    177         o << "}\n";
    178         o.close ();
    179         return true;
     154    if (!name) {
     155        return false;
     156    }
     157    string filename;
     158    filename =  name;
     159    filename += ".dot";
     160    ofstream o;
     161    o.open (filename.c_str(),ios::out | ios::trunc);
     162    if (o.is_open () == false) {
     163        return false;
     164    }
     165    o << "strict digraph " << name << " {\n";
     166    o << "node [shape=box];\n";
     167    print_edge (o);
     168    print_node (o,sc_get_top_level_objects ());
     169    o << "}\n";
     170    o.close ();
     171    return true;
    180172}
    181173
  • sources/src/mouchard_scheduling.cc

    r52 r59  
    4646#include "sc_module.h"
    4747#include "sc_ver.h"
     48
    4849
    4950#ifdef HAVE_CONFIG_H
  • sources/src/sc_bigint.h

    r52 r59  
    1616#include <sc_logic.h>
    1717#include <sc_bv.h>
     18//#include <stdint.h>
    1819
    1920// ----------------------------------------------------------------------------
  • sources/src/sc_biguint.h

    r52 r59  
    1919
    2020#include "sc_nbdefs.h"
     21//#include <stdint.h>
    2122
    2223namespace sc_dt {
  • sources/src/sc_bv.h

    r52 r59  
    1717//
    1818// ----------------------------------------------------------------------------
     19
     20//#include <stdint.h>
    1921
    2022#include "sc_nbdefs.h"
     
    4143    sc_bv_base & operator = (const sc_unsigned & a);
    4244    sc_bv_base & operator = (const sc_signed & a);
     45    sc_bv_base & operator = (unsigned int a);
    4346    sc_bv_base & operator = (unsigned long a);
    4447    sc_bv_base & operator = (long a);
    45     sc_bv_base & operator = (unsigned int a);
    4648    sc_bv_base & operator = (int a);
    4749    sc_bv_base & operator = (uint64 a);
     
    6668    sc_bv (const sc_unsigned & a);
    6769    sc_bv (const sc_signed & a);
     70    sc_bv (unsigned int a);
    6871    sc_bv (unsigned long a);
    6972    sc_bv (long a);
    70     sc_bv (unsigned int a);
    7173    sc_bv (int a);
    7274    sc_bv (uint64 a);
     
    8284    sc_bv < W > & operator = (const sc_unsigned & a);
    8385    sc_bv < W > & operator = (const sc_signed & a);
     86    sc_bv < W > & operator = (unsigned int a);
    8487    sc_bv < W > & operator = (unsigned long a);
    8588    sc_bv < W > & operator = (long a);
    86     sc_bv < W > & operator = (unsigned int a);
    8789    sc_bv < W > & operator = (int a);
    8890    sc_bv < W > & operator = (uint64 a);
  • sources/src/sc_clock_ext.h

    r52 r59  
    7373             bool            posedge_first_ = true);
    7474
    75     sc_clock(const char *name_,
     75    sc_clock(const char * name_,
    7676             double period_,
    7777             double duty_cycle_ = 0.5,
  • sources/src/sc_int.h

    r52 r59  
    1919#include <sc_bv.h>
    2020#include <cstdlib>
     21//#include <stdint.h>
    2122
    2223// ----------------------------------------------------------------------------
     
    3738
    3839
    39 #define MASK32(W) ((~ (const uint32)0) >> (sizeof (uint32) * 8 - W))
    40 #define MASK64(W) ((~ (const uint64)0) >> (sizeof (uint64) * 8 - W))
     40#define MASK32(W) ((~ (const uint32) 0) >> (sizeof (uint32) * 8 - W))
     41#define MASK64(W) ((~ (const uint64) 0) >> (sizeof (uint64) * 8 - W))
    4142
    4243template<int W> struct s_int_type { typedef int64 int_type; };
    4344
    44 #define DECLAR_INT_TYPE(W) template<> struct s_int_type<W> { typedef smallest_int int_type; } // not declared as in8 because << operator threats like a character
     45#define DECLAR_INT_TYPE(W) template<> struct s_int_type<W> { typedef smallest_int int_type; } // not declared as int8 because << operator threats like a character
    4546DECLAR_INT_TYPE(1);
    4647DECLAR_INT_TYPE(2);
     
    5455
    5556#define DECLAR_INT_TYPE(W) template<> struct s_int_type<W> { typedef int16 int_type; }
    56 DECLAR_INT_TYPE( 9);
     57DECLAR_INT_TYPE(9);
    5758DECLAR_INT_TYPE(10);
    5859DECLAR_INT_TYPE(11);
     
    9697    int64 val;
    9798    sc_int_subref_r(int64 val_, int left_, int right_) {
    98         val = val_; left = left_; right = right_;
     99        val = val_;
     100        left = left_;
     101        right = right_;
    99102    }
    100103   
    101     inline int64 read () const { return val; }
    102     inline const sc_int_subref_r& operator | (const sc_int_subref_r &v) const {
    103         print_warning ();
     104    inline int64 read() const { return val; }
     105    inline const sc_int_subref_r & operator | (const sc_int_subref_r & v) const {
     106        print_warning();
    104107        return *this;
    105108    }
    106109
    107110    private :
    108     void print_warning () const;
     111    void print_warning() const;
    109112
    110113};
     
    116119class sc_int_subref_r;
    117120
    118 template< int W /* = SC_INTWIDTH */>
     121template < int W /* = SC_INTWIDTH */>
    119122class sc_int {
    120123
     
    123126    /***********************/
    124127    typedef sc_int<W> this_type;
     128    public:
    125129    typedef typename s_int_type<W>::int_type data_type;
    126 
     130    private:
    127131    typedef data_type sc_int_subref;
    128132
    129133    // internal
    130134    union {
    131         val_field<W, (sizeof (data_type) * 8) - W,data_type> vf; /* To compute */
     135        val_field<W, (sizeof(data_type) * 8) - W,data_type> vf; /* To compute */
    132136        data_type val;          /* To return an int reference (read function) */
    133137    };
     
    138142    /***********************/
    139143    public:
    140     sc_int()                  { val = 0; }
    141     sc_int (const char * a)   { val = 0; write (std::atoi (a)); }
    142     sc_int (unsigned short a) { val = 0; write (a); }
    143     sc_int (short a)          { val = 0; write (a); }
    144     sc_int (unsigned long a)  { val = 0; write (a); }
    145     sc_int (long a)           { val = 0; write (a); }
    146     sc_int (unsigned int a)   { val = 0; write (a); }
    147     sc_int (int a)            { val = 0; write (a); }
    148     sc_int (int64 a)          { val = 0; write (a); }
    149     sc_int (uint64 a)         { val = 0; write (a); }
    150     sc_int (double a)         { val = 0; write (a); }
     144    sc_int()                 { val = 0; }
     145    sc_int(const char * a)   { val = 0; write(std::atoi(a)); }
     146    sc_int(unsigned short a) { val = 0; write(a); }
     147    sc_int(short a)          { val = 0; write(a); }
     148    sc_int(unsigned long a)  { val = 0; write(a); }
     149    sc_int(long a)           { val = 0; write(a); }
     150    sc_int(unsigned int a)   { val = 0; write(a); }
     151    sc_int(int a)            { val = 0; write(a); }
     152    sc_int(int64 a)        { val = 0; write(a); }
     153    sc_int(uint64 a)       { val = 0; write(a); }
     154    sc_int(double a)         { val = 0; write(a); }
    151155
    152156    template <int W2> sc_int (const sc_int<W2> &val_) { val = 0; write (val_.read());}
     
    155159     */
    156160
    157     sc_int (const sc_int &val_) { val = val_.val; }
    158     sc_int (const sc_int_subref_r & a) { val = 0; write (a); }
     161    sc_int(const sc_int & val_) { val = val_.val; }
     162    sc_int(const sc_int_subref_r & a) { val = 0; write(a); }
    159163    /* the user needs to cast explicitly result of range () method. */
    160164
     
    165169
    166170    // read/write
    167     inline const data_type& read() const { return val; }
    168     inline void write(data_type val_)    { vf.valW = val_; }
    169     template <int W2> inline void write (const sc_int<W2> val_) { write (val_.read ()); }
    170     inline void write (const sc_int_subref_r& s) { write (s.read()); }
     171    inline const data_type & read() const { return val; }
     172    inline void write(data_type val_) { vf.valW = val_; }
     173    template <int W2> void write(const sc_int<W2> val_) { write (val_.read ()); }
     174    inline void write(const sc_int_subref_r & s) {
     175        write (s.read());
     176    }
    171177
    172178    /***********************/
     
    176182    // operators
    177183    inline operator const data_type & () const {
    178         return read ();
    179     }
    180 
    181     template <typename T> inline sc_int& operator = (const T& val_) {
    182         write (val_);
     184        return read();
     185    }
     186
     187    template < typename T > inline sc_int & operator = (const T & val_) {
     188        write(val_);
    183189        return *this;
    184190    }
    185191
    186     inline sc_int & operator = (const sc_int_subref_r& a) {
    187         write (a);
     192    inline sc_int & operator = (const sc_int_subref_r & a) {
     193        write(a);
    188194        return *this;
    189195    }
     
    199205        return sc_dt::to_string (val, W, numrep);
    200206    }
    201     const sc_string to_dec() const { return to_string (SC_DEC); }
    202     const sc_string to_bin() const { return to_string (SC_BIN); }
    203     const sc_string to_oct() const { return to_string (SC_OCT); }
    204     const sc_string to_hex() const { return to_string (SC_HEX); }
     207    const sc_string to_dec() const { return to_string(SC_DEC); }
     208    const sc_string to_bin() const { return to_string(SC_BIN); }
     209    const sc_string to_oct() const { return to_string(SC_OCT); }
     210    const sc_string to_hex() const { return to_string(SC_HEX); }
    205211
    206212    // arithmetic
     
    231237    template <int W2>
    232238    inline sc_int<W + W2> operator , (const sc_int<W2> & b) const {
    233         sc_int<W + W2> res = read() << W2; res += b.read();
     239        sc_int<W + W2> res = read() << W2;
     240        res += b.read();
    234241        return res;
    235242    }
     
    241248
    242249    template <int W2>
    243     inline sc_int<W2> operator , (const sc_int_subref_r &v) const {
     250    inline sc_int<W2> operator , (const sc_int_subref_r & v) const {
    244251        std::cerr << "Warning : \n";
    245252        return sc_int<W2> (v.read());
    246253    }
    247254
    248     inline sc_int_subref range (int left, int right) {
     255    inline sc_int_subref range(int left, int right) {
    249256        return (data_type)((data_type) (((data_type)~(0)) >> (sizeof (data_type) * 8 - left - 1)) & val) >> right;
    250257    }
    251258
    252     inline sc_int_subref_r range (int left, int right) const {
    253         return sc_int_subref_r (((data_type) (((data_type)~(0)) >> (sizeof (data_type) * 8 - left - 1)) & val) >> right, left, right);
    254     }
     259    inline sc_int_subref_r range(int left, int right) const {
     260        return sc_int_subref_r(((data_type) (((data_type)~(0)) >> (sizeof (data_type) * 8 - left - 1)) & val) >> right, left, right);
     261    }
     262
    255263#if 0
    256264    std::cerr << "range(" << left << "," << right << ")\n";
     
    263271};
    264272
    265 inline std::ostream & operator << (std::ostream &o, const sc_int_subref_r & s) {
     273inline std::ostream & operator << (std::ostream & o, const sc_int_subref_r & s) {
    266274    return o << s.val;
    267275}
  • sources/src/sc_lv.h

    r52 r59  
    1818//
    1919// ----------------------------------------------------------------------------
     20
     21//#include <stdint.h>
    2022
    2123#include "sc_nbdefs.h"
     
    122124    sc_lv(const sc_unsigned & a) { val = 0; write(a); }
    123125    sc_lv(const sc_signed & a)   { val = 0; write(a); }
    124     sc_lv(unsigned long a)       { val = 0; write(a); } 
     126    sc_lv(unsigned int a)        { val = 0; write(a); }
     127    sc_lv(unsigned long a)       { val = 0; write(a); }
    125128    sc_lv(long a)                { val = 0; write(a); }
    126     sc_lv(unsigned int a)        { val = 0; write(a); }
    127129    sc_lv(int a)                 { val = 0; write(a); }
    128130    sc_lv(uint64 a)              { val = 0; write(a); }
     
    142144#endif // LRM
    143145
    144     template <typename T> inline sc_lv& operator = (const T& val_) {
     146    template < typename T > inline sc_lv& operator = (const T& val_) {
    145147        write (val_);
    146148        return *this;
  • sources/src/sc_module.cc

    r52 r59  
    6767instances_list_t temp_list;   
    6868method_process_list_t method_process_list;
     69std::vector<const char *> allocated_names;
    6970module_name_stack_t module_name_stack;
    7071modules_stack_t modules_stack;
     
    7374void declare_method_process(const char * name, SC_ENTRY_FUNC func, sc_module & module) {
    7475  method = create_method_process(name, func, module);
    75   method_process_list.push_back(method); 
     76  method_process_list.push_back(method);
    7677}
    7778
  • sources/src/sc_nbdefs.h

    r52 r59  
    1414#define __SC_DEFS_H__
    1515
    16 #ifndef WIN32
     16//#include <stdint.h>
     17
    1718typedef signed long long int64;
    1819typedef unsigned long long uint64;
    19 #else
    20 typedef signed __int64 int64;
    21 typedef unsigned __int64 uint64;
    22 #endif
    2320
    2421typedef long  int32;
     
    2825typedef unsigned short uint16;
    2926typedef unsigned char  uint8;
     27
     28
     29//typedef uint16_t smallest_uint;
     30//typedef int16_t  smallest_int;
    3031
    3132typedef uint16 smallest_uint;
  • sources/src/sc_numrep.h

    r52 r59  
    5555            char t[64];
    5656            char format[64];
    57             sprintf(format, "0x0%%0%dx", nbits / 4);
     57            sprintf(format, "0x0%%0%dx", (int) nbits / 4);
    5858            sprintf(t, format, val);
    5959            s = t;
  • sources/src/sc_object.cc

    r52 r59  
    107107    string s;
    108108    gen_name(basename_,s);
    109     return strdup (s.c_str());
     109    const char * ret = strdup(s.c_str());
     110    sc_core::allocated_names.push_back(ret);
     111    return ret;
    110112}
    111113
  • sources/src/sc_object.h

    r52 r59  
    2626
    2727class sc_object {
    28        
     28
    2929    ///////////
    30         // Internal
     30    // Internal
    3131    // ////////
    32         protected:
     32    protected:
    3333    void init();
    3434    void set_kind(const char *);
  • sources/src/sc_pat_trace.cc

    r52 r59  
    7070    //création d'1 instance de la structure Sc_trace_file:
    7171    sc_trace_file * traceFic = new sc_trace_file();
    72     traceFic->flag = PAT_FORMAT;       
     72    traceFic->flag = PAT_FORMAT;
    7373
    7474    trace_file_list.push_back(traceFic);
     
    8383//*************************************************************************
    8484
    85 void sc_close_pat_trace_file(sc_trace_file * traceFic ) {       
     85void sc_close_pat_trace_file(sc_trace_file * traceFic ) {
    8686    if (notrace) {
    8787        return;
  • sources/src/sc_port.cc

    r58 r59  
    5353    extern char unstable;
    5454    char unstable = 0; // not in sc_core namespace because dynamic link support C linkage only
    55     unsigned int pending_write_vector_nb = 0;
     55    int32 pending_write_vector_nb = 0;
    5656}
    5757
     
    6767extern equi_list_t equi_list;
    6868
    69 const char * get_module_name (const tab_t * pointer) {
    70         const equi_t & eq = get_equi (pointer);
    71     return get_module_name (eq);
     69const char * get_module_name(const tab_t * pointer) {
     70    const equi_t & eq = get_equi(pointer);
     71    return get_module_name(eq);
    7272}
    7373
     
    8787
    8888sc_port_base::sc_port_base() {
    89         init ();
     89    init ();
    9090}
    9191
     
    216216            // stl vectors are too slow
    217217            // memcopy is not better
    218             // signal table sorting doesn't give any better performance 
     218            // signal table sorting doesn't give any better performance
    219219#if defined(DUMP_STAGE)
    220220            cerr << "(" << pending_write_vector_nb
     
    229229                    exit (8);
    230230                }
    231 #endif 
     231#endif
    232232#ifdef DUMP_SIGNAL_STATS
    233233                if (*(iter.pointer) == iter.value) {
     
    236236                counter[iter.pointer]++;
    237237#endif
    238                 *(iter.pointer) = iter.value;   
     238                *(iter.pointer) = iter.value;
    239239#undef iter
    240240            }
     
    277277    for (k = counter.begin(); k != counter.end(); ++k) {
    278278        string module_name = get_module_name (k->first);
    279         counter_by_module[module_name] += k->second;   
     279        counter_by_module[module_name] += k->second;
    280280    }
    281281    o << "module name / usage\n";
     
    290290#endif
    291291}
     292
    292293
    293294static bool is_bound(/*const*/ sc_port_base & port) {
     
    297298        return false; // case : sc_in not bound
    298299    }
    299     return has_equi (port);
    300 }
     300    return has_equi(port);
     301}
     302
    301303
    302304static void check_port(/*const*/ sc_port_base & port) {
    303     if (!is_bound (port)) {
     305    if (!is_bound(port)) {
    304306        cerr << "Error : '" << port.name() << "' port"
    305307            " (" << port.kind() << ")"
     
    316318    port2module_t::/*const_*/iterator i;
    317319    for (i = port2module.begin(); i != port2module.end(); ++i) {
    318         /*const*/ sc_port_base *port = i->first;
     320        /*const*/ sc_port_base * port = i->first;
    319321        assert(port != NULL);
    320322        check_port(*port);
  • sources/src/sc_signal.h

    r52 r59  
    1818#include <iostream>
    1919#include <cstdlib>
     20#include <typeinfo> // for typeid
    2021
    2122#include "sc_fwd.h"
     
    5354    base_type * pointer;
    5455    base_type value;
    55     //pending_write_t(base_type * const pointer_, const base_type value_) {
    56     //    pointer = pointer_;
    57     //    value = value_;
    58     //}
    5956   
    6057    friend std::ostream & operator << (std::ostream & o, const pending_write_t & p) {
     
    7673
    7774template < typename T >
    78 inline void post_write(base_type * const pointer_, const T value_) /*INLINE*/;
    79 
    80 template < typename T >
    81 inline void post_multiwrite(base_type * const pointer_, const T value_) {
     75inline void post_write(base_type * const pointer_, const T & value_) /*INLINE*/;
     76
     77template < typename T >
     78inline void post_multiwrite(base_type * const pointer_, const T & value_) {
    8279    size_t size = (sizeof(T) - 1) / sizeof(base_type);
    8380    size_t i = 0;
    84     const base_type * pvalue = (const base_type *) (void *) (& value_);
     81    const base_type * pvalue = (const base_type *) (void *) (&value_);
    8582    do {
    8683        post_write(pointer_ + i, pvalue[i]);
     
    8986
    9087template < typename T >
    91 inline void post_write(base_type * const pointer_, const T value_) {
     88inline void post_write(base_type * const pointer_, const T & value_) {
    9289    if (sizeof(T) > sizeof(base_type)) {
    93         post_multiwrite(pointer_,value_);
     90        post_multiwrite(pointer_, value_);
    9491    }
    9592    else {
     
    166163
    167164    private:
     165
    168166    T val;
     167
    169168    typedef T data_type;
    170169    typedef sc_signal < T > this_type;
     
    182181    // constructors, destructor
    183182    sc_signal() {
     183        if (typeid(data_type) == typeid(double) || typeid(data_type) == typeid(float)) {
     184            std::cerr << "Error: SystemCASS does not support sc_signal<T> with T of type " << typeid(data_type).name() << std::endl;
     185            exit(1);
     186        }
    184187        init();
    185188    }
     
    215218    }
    216219
    217     const data_type & get_new_value() const;
     220    const data_type & get_new_value() const {
     221        // Warning: untested and doesn't support variable size
     222        unsigned int i = 0;
     223        for (i = 0; i < pending_write_vector_capacity; i++) {
     224            if (pending_write_vector[i].pointer == get_pointer()) {
     225                return pending_write_vector[i].value;
     226            }
     227        }
     228        return val;
     229    }
    218230
    219231    //  void trace (sc_trace_file * tf) const;
     
    235247    set_kind(kind_string);
    236248    sc_interface::init(sizeof(data_type));
    237     val = 0; /* The simulator initializes the signal/register to 0.    */
     249    val = (T) 0; /* The simulator initializes the signal/register to 0.    */
    238250    /* However, hardware initialization still has to be done. */
    239251    /* This kind of initialization is for trace diffing.      */
     
    245257/*virtual*/ inline const T & sc_signal< T >::read() const {
    246258#ifdef DUMP_READ
    247     std::cerr << "read " << READ_SIGNAL(const T, get_pointer()) << " on signal " << name() << "\n";
    248 #endif
    249     return READ_SIGNAL(const T, get_pointer());
     259    std::cerr << "read " << READ_SIGNAL(const data_type, get_pointer()) << " on signal " << name() << "\n";
     260#endif
     261    // QM
     262    return READ_SIGNAL(T, get_pointer());
    250263}
    251264
     
    266279    std::cerr << "write (posted) " << value_ << " on sc_signal (writing into register) '" << name() << "'\n";
    267280#endif
     281   
    268282    post_write(/*(tab_t*)&val*/ get_pointer(), value_);
    269283}
  • sources/src/sc_time.cc

    r52 r59  
    5151
    5252static const char *const unit_repr_string[6] = {
    53         "FS", "PS", "NS", "US", "MS", "SEC"
     53    "FS", "PS", "NS", "US", "MS", "SEC"
    5454};
    5555
    56 uint64_t nb_cycles = 0;
     56uint64 nb_cycles = 0;
    5757
    5858const sc_time SC_ZERO_TIME(0, SC_NS);
     
    6666
    6767sc_time::sc_time (double val, sc_time_unit tu) {
    68     time = (uint64_t) val;
     68    time = (uint64) val;
    6969    unit = tu;
    7070}
  • sources/src/sc_time.h

    r52 r59  
    1515
    1616#include <string>
    17 #include <stdint.h>
     17//#include <stdint.h>
     18
     19#include "sc_nbdefs.h"
    1820
    1921namespace sc_core {
     
    4042extern sc_time SC_CURRENT_TIME;
    4143
    42 extern uint64_t nb_cycles;
     44extern uint64 nb_cycles;
    4345
    4446inline double sc_simulation_time() {
     
    5557
    5658    friend const sc_time & sc_time_stamp();
    57     uint64_t time;
     59    uint64 time;
    5860    enum sc_time_unit unit;
    5961
     
    6466    sc_time & operator= (const sc_time &);
    6567
    66     uint64_t value() const {
     68    uint64 value() const {
    6769        return time;
    6870    }
  • sources/src/sc_trace.cc

    r52 r59  
    4040#include <iostream>
    4141#include <cstring> //strlen
     42//#include <stdint.h>
    4243
    4344#include "sc_port.h"
  • sources/src/sc_trace.h

    r52 r59  
    3838
    3939#include <vector>
     40//#include <stdint.h>
    4041
    4142#include "sc_trace_ext.h"
     
    6061
    6162struct sc_trace_file {
    62         TRACE_FORMAT flag;
    63         FILE * pfic;
    64         std::vector<signal2trace> sig_list;
    65         std::vector<signal2trace> clk_list;
     63    TRACE_FORMAT flag;
     64    FILE * pfic;
     65    std::vector<signal2trace> sig_list;
     66    std::vector<signal2trace> clk_list;
    6667};
    6768
  • sources/src/sc_trace_ext.h

    r52 r59  
    4242#include <string>
    4343#include <sstream>
     44//#include <stdint.h>
    4445
    4546#include "sc_fwd.h"
     
    9091BITS_NUMBER_GETTER_DEF(, sc_signed     , 8 * sizeof(int));
    9192BITS_NUMBER_GETTER_DEF(, double        , 8 * sizeof(val_t));
    92 BITS_NUMBER_GETTER_DEF(, uint64        , 8 * sizeof(val_t));
    93 BITS_NUMBER_GETTER_DEF(, int64         , 8 * sizeof(val_t));
     93BITS_NUMBER_GETTER_DEF(, uint64      , 8 * sizeof(val_t));
     94BITS_NUMBER_GETTER_DEF(, int64       , 8 * sizeof(val_t));
    9495BITS_NUMBER_GETTER_DEF(typename inval_t, sc_in<inval_t>    , bits_number_getter<inval_t>::get());
    9596BITS_NUMBER_GETTER_DEF(typename inval_t, sc_out<inval_t>   , bits_number_getter<inval_t>::get());
  • sources/src/sc_uint.h

    r52 r59  
    2020#include <sc_bv.h>
    2121#include <cstdlib>
     22//#include <stdint.h>
    2223
    2324// ----------------------------------------------------------------------------
     
    7576};
    7677
    77 #define DECLAR_UINT_TYPE(W) template<> struct s_uint_type<W> { typedef smallest_uint uint_type; }// not declared as uint16 because << operator threats like a character
     78#define DECLAR_UINT_TYPE(W) template<> struct s_uint_type<W> { typedef smallest_uint uint_type; }// not declared as uint8 because << operator threats like a character
    7879DECLAR_UINT_TYPE(1);
    7980DECLAR_UINT_TYPE(2);
     
    280281    template <int W2>
    281282    inline sc_uint<W2> operator , (const sc_uint_subref_r & v) const {
    282         std::cerr << "Warning : \n"; // ??
    283283        return sc_uint<W2> (v.read());
    284284    }
  • sources/src/schedulers.cc

    r52 r59  
    215215    }
    216216
    217     /* Schedule */ 
     217    /* Schedule */
    218218    string base_name;
    219219    switch (scheduling_method) {
  • sources/src/serialization.cc

    r52 r59  
    3737#include <map>
    3838#include <fstream>
     39//#include <stdint.h>
    3940
    4041#include "internal_ext.h" // tab_t
  • sources/test_regression/19042005/Makefile

    r56 r59  
    1919                        $(ECHO) -e "$(OK)" ; \
    2020                else \
    21                         $(ECHO) -e "$(KO) 1" ; \
     21                        $(ECHO) -e "$(KO) SC" ; \
    2222                fi ; \
    2323        else \
    24                 $(ECHO) -e "$(KO) 2" ; \
     24                $(ECHO) -e "$(KO) SCASS" ; \
    2525        fi ;
    2626
  • sources/test_regression/Makefile

    r56 r59  
    7171      09092005b \
    7272      09092005c \
    73                 11062007  \
     73      11062007  \
    7474      14092005  \
    7575      15042009a \
    7676      15042009b \
    7777      15042009c \
    78                 15062006  \
     78      15062006  \
    7979      15092005a \
    8080      15092005b \
    8181      15092005c \
    8282      15092005d \
    83                 17022006  \
     83      17022006  \
    8484      17032005  \
    8585      20122006  \
    8686      21062005  \
    87                 24082009  \
     87      24082009  \
    8888      25032005  \
    8989      28102005  \
Note: See TracChangeset for help on using the changeset viewer.