Changeset 4 for sources/src


Ignore:
Timestamp:
Mar 10, 2008, 12:37:25 PM (17 years ago)
Author:
nipo
Message:

Towards SystemC-2.2 LRM:

  • Implement sc_time with units
  • Have a systemc header with no namespace pollution
Location:
sources/src
Files:
1 added
1 deleted
15 edited

Legend:

Unmodified
Added
Removed
  • sources/src/Makefile

    r3 r4  
    1010# |                                                             |
    1111# \------------------------------------------------------------*/
    12 ifndef SYSTEMC
    13 $(error SYSTEMC is not defined. This variable should be set to SystemCASS \
    14 directory when SYSTEMCASS variable is not set.)
    15 endif
    1612ifndef SYSTEMCASS
    1713$(error SYSTEMCASS is not defined. This variable has to be defined to install \
     
    186182
    187183EXTERNAL_INCLUDES = \
     184              ${SYSTEMCASS_INCLUDEDIR}/systemc \
    188185              ${SYSTEMCASS_INCLUDEDIR}/systemc.h \
    189186              ${SYSTEMCASS_INCLUDEDIR}/sc_fwd.h\
     
    289286        cp $*.h ${SYSTEMCASS_INCLUDEDIR}/$*.h
    290287
     288${SYSTEMCASS_INCLUDEDIR}/systemc: systemc
     289        cp $< $@
     290
    291291${SYSTEMCASS_DOCDIR}/%.pdf: %.pdf
    292292        cp $*.pdf ${SYSTEMCASS_DOCDIR}/$*.pdf
     
    348348        ./guess_endianness.x > ${SYSTEMCASS_INCLUDEDIR}/endianness.h
    349349
    350 include Makefile.deps
     350-include Makefile.deps
    351351
    352352##################
     
    374374#### CLEANING
    375375clean :
    376         echo > Makefile.deps
     376        rm -f Makefile.deps
    377377        rm -f *~
    378378        rm -f $(OBJECTS)
  • sources/src/casc.h

    r1 r4  
    1919#endif
    2020
     21#include <stdint.h>
     22
    2123EXTERN char unstable;
    22 EXTERN unsigned int pending_write_vector_nb;
     24EXTERN int32_t pending_write_vector_nb;
    2325
    2426namespace sc_core {
  • sources/src/dump_dot.cc

    r1 r4  
    4141#include "sc_ver.h" // sc_version
    4242
    43 typedef std::list<sc_port_base*> port_list_t;
     43typedef std::list<sc_core::sc_port_base*> port_list_t;
    4444using namespace std;
    4545
    4646namespace sc_core {
     47
     48using namespace sc_dt;
    4749
    4850// Build a port list owned by the module mod
  • sources/src/global_functions.cc

    r1 r4  
    357357
    358358void
    359 sc_start(double d_val) 
     359sc_start(double d_val)
    360360{
    361361        sc_cycle (d_val);
     
    368368}
    369369
     370void
     371sc_start()
     372{
     373        sc_cycle (-1);
     374#ifdef DUMP_SIGNAL_STATS
     375        print_registers_writing_stats (cerr);
     376#endif
     377#ifdef DUMP_SCHEDULE_STATS
     378        print_schedule_stats (cerr);
     379#endif
     380}
     381
    370382void
    371383sc_start (double       d_val,
     
    378390sc_start( const sc_time& duration )
    379391{
    380         sc_start ((double)duration);
     392        sc_cycle ((double)duration);
     393#ifdef DUMP_SIGNAL_STATS
     394        print_registers_writing_stats (cerr);
     395#endif
     396#ifdef DUMP_SCHEDULE_STATS
     397        print_schedule_stats (cerr);
     398#endif
    381399}
    382400
  • sources/src/global_functions.h

    r1 r4  
    3535
    3636//extern void next_cycle(void);
    37 extern void         sc_start         (double d_val = -1);
     37extern void         sc_start         (double d_val)  __attribute__((deprecated));
     38extern void         sc_start         ();
    3839extern void         sc_start         ( const sc_time& duration );
    3940extern void         sc_start         (double d_val, sc_time_unit d_tu);
  • sources/src/sc_event_finder.cc

    r1 r4  
    3737#include"sc_event_finder.h"
    3838
    39 sc_event_finder::sc_event_finder (/*const*/ sc_port_base &p)
     39namespace sc_core {
     40
     41sc_event_finder::sc_event_finder (/*const*/ sc_core::sc_port_base &p)
    4042  : a_port (p)
    4143{
     
    4648}
    4749
    48 /*const*/ sc_port_base&
     50/*const*/ sc_core::sc_port_base&
    4951sc_event_finder::port () /*const*/
    5052{
     
    5254}
    5355
     56}
  • sources/src/sc_event_finder.h

    r1 r4  
    1515#include"sc_fwd.h"
    1616
     17namespace sc_core {
     18
    1719class sc_event_finder {
    18   /*const*/sc_port_base &a_port;
     20  /*const*/sc_core::sc_port_base &a_port;
    1921public:
    20   sc_event_finder (/*const*/ sc_port_base&);
     22  sc_event_finder (/*const*/ sc_core::sc_port_base&);
    2123  virtual ~sc_event_finder ();
    2224
    2325  // methods
    24   /*const*/ sc_port_base& port () /*const*/;
     26  /*const*/ sc_core::sc_port_base& port () /*const*/;
    2527 
    2628  // operators
     
    3335};
    3436
     37}
     38
    3539#endif /* __SC_EVENT_FINDER_H__ */
  • sources/src/sc_fwd.h

    r1 r4  
    5656}
    5757
    58 using sc_core::method_process_t;
    59 using sc_core::sc_port_base;
    60 using sc_core::sc_object;
    61 using sc_core::sc_interface;
    62 using sc_core::sc_module;
    63 using sc_core::sc_module_name;
    64 using sc_core::sc_event;
    65 using sc_core::sc_event_finder;
    66 using sc_core::sc_sensitive;
    67 using sc_core::sc_sensitive_pos;
    68 using sc_core::sc_sensitive_neg;
    69 /////////////////////////////////////////////////
    70 // Ports & Signals
    71 //
    72 using sc_core::sc_time;
    73 
    74 using sc_core::sc_in;
    75 using sc_core::sc_inout;
    76 using sc_core::sc_out;
    77 using sc_core::sc_signal;
    78 using sc_core::sc_port_b;
    79 using sc_core::sc_signal_base;
    80 using sc_core::sc_clock;
    81 
    82 using sc_core::sc_trace_file;
    83 
    84 using sc_core::method_process_list_t;
    85 
    8658/////////////////////////////////////////////////
    8759// Data Types
     
    10173}
    10274
    103 using sc_dt::sc_bit;
    104 using sc_dt::sc_bv;
    105 using sc_dt::sc_logic;
    106 using sc_dt::sc_lv;
    107 using sc_dt::sc_unsigned;
    108 using sc_dt::sc_signed;
    109 //using sc_dt::sc_int_base;
    110 using sc_dt::sc_int;
    111 using sc_dt::sc_uint;
    112 using sc_dt::sc_bigint;
    113 using sc_dt::sc_biguint;
    114 //using sc_dt::sc_uint_base;
    115 
    11675#endif
    11776
  • sources/src/sc_main.cc

    r1 r4  
    5151//
    5252using namespace std;
     53using namespace sc_core;
    5354//
    5455typedef list<sc_module* >         module_list_t;
     
    5859
    5960bool        check_port_dependencies = false;
    60 bool        dynamic_link_of_scheduling_code = true;
     61bool        dynamic_link_of_scheduling_code = false;
    6162bool        dump_netlist_info       = false;
    6263bool        dump_funclist_info      = false;
  • sources/src/sc_port.cc

    r1 r4  
    5151        extern char unstable;
    5252  char unstable = 0; // not in sc_core namespace because dynamic link support C linkage only
    53   unsigned int pending_write_vector_nb = 0;
     53  int32_t pending_write_vector_nb = 0;
    5454}
    5555
  • sources/src/sc_port_ext.h

    r1 r4  
    4343namespace sc_core {
    4444//
     45
     46        using namespace sc_dt;
     47
    4548const char *get_name        (const tab_t *pointer);
    4649
     
    269272sc_inout<T>::init ()
    270273{
    271         set_pointer ((tab_t*)&val);
     274        set_pointer ((tab_t*)(void*)&val);
    272275        sc_object::set_kind    (sc_inout_string);
    273276        sc_interface::init (sizeof (data_type));
  • sources/src/sc_time.cc

    r1 r4  
    3939#include <sys/time.h>
    4040#include <string>
    41 
    42 using namespace std;
     41#include <sstream>
    4342
    4443namespace sc_core {
    4544
    46 uint64 nb_cycles = 0;
     45static const char *const unit_repr_string[6] =
     46{
     47        "FS", "PS", "NS", "US", "MS", "SEC"
     48};
     49
     50uint64_t nb_cycles = 0;
    4751
    4852const sc_time SC_ZERO_TIME(0,SC_NS);
     
    5155sc_time::sc_time (const sc_time &t)
    5256{
    53   time = t.time;
     57        *this = t;
    5458}
    5559
    5660sc_time::sc_time (double val, sc_time_unit tu)
    5761{
    58   time = (long long int) val;
     62  time = (uint64_t) val;
     63  unit = tu;
    5964}
    6065
     
    6469{
    6570  time = t.time;
     71  unit = t.unit;
     72  return *this;
    6673}
    6774
    6875
    69 const string
     76const std::string
    7077sc_time::to_string () const
    7178{
    72         char  res[32];
    73   const char* unit;
    74         if (time == 0)
    75   {
    76     unit = "s";
    77   } else
    78     unit = "ns";
    79   sprintf (res, "%lld %s", time, unit);
    80   return (string)res;
     79        std::ostringstream o;
     80        o << time << ' ' << unit_repr_string[unit];
     81        return o.str();
    8182}
    8283
  • sources/src/sc_time.h

    r1 r4  
    1313#define __SC_TIME_H__
    1414
    15 #include <iostream>
    1615#include <string>
    17 #include "sc_nbdefs.h"
    18 #include "internal_ext.h"
     16#include <stdint.h>
    1917
    2018namespace sc_core {
     
    4139extern sc_time SC_CURRENT_TIME;
    4240
    43 extern uint64 nb_cycles;
     41extern uint64_t nb_cycles;
    4442
    4543inline double sc_simulation_time()   // in default time units
     
    5452{
    5553  friend const sc_time &sc_time_stamp ();
    56   long long int time;
     54  uint64_t time;
     55  enum sc_time_unit unit;
    5756public:
    58 //  sc_time (); LRM 2.1
    5957  sc_time (double val, sc_time_unit tu);
    6058  sc_time (const sc_time& = SC_ZERO_TIME);
     
    6260  sc_time& operator= (const sc_time &);
    6361 
    64   /*sc_dt::*/uint64 value     () const { return (/*sc_dt::*/uint64) time;}
    65   double        to_double () const { return time * 1000;}
    66   double        to_seconds() const { return time / (double)1000000000;};
    67   operator      double    () const { return to_double ();};
     62  uint64_t      value     () const { return time;}
     63  inline double        to_double () const;
     64  inline double        to_seconds() const;
     65  inline operator      double    () const { return to_double ();}
    6866  const std::string to_string () const;
    6967};
     
    7573}
    7674
     75double
     76sc_time::to_double () const
     77{
     78        double fact = 1;
     79        switch(unit) {
     80        case SC_FS: fact = 1e-6; break;
     81        case SC_PS: fact = 1e-3; break;
     82        case SC_NS: fact = 1; break;
     83        case SC_US: fact = 1e3; break;
     84        case SC_MS: fact = 1e6; break;
     85        case SC_SEC: fact = 1e9; break;
     86        }
     87        return (double)time * fact;
     88}
     89
     90double
     91sc_time::to_seconds() const
     92{
     93        double fact = 1;
     94        switch(unit) {
     95        case SC_FS: fact = 1e-15; break;
     96        case SC_PS: fact = 1e-12; break;
     97        case SC_NS: fact = 1e-9; break;
     98        case SC_US: fact = 1e-6; break;
     99        case SC_MS: fact = 1e-3; break;
     100        case SC_SEC: fact = 1; break;
     101        }
     102        return (double)time * fact;
     103}
     104
    77105} // end of namespace sc_core
    78106
    79 using sc_core::sc_simulation_time;
    80 using sc_core::sc_time;
    81 using sc_core::sc_time_stamp;
    82 
    83107#endif /* __SC_TIME_H__ */
  • sources/src/sc_trace_ext.h

    r1 r4  
    5151
    5252namespace sc_core {
     53
     54        using namespace sc_dt;
    5355
    5456//---------------------------------------------------------------------------
  • sources/src/systemc.h

    r1 r4  
    3838#define __SYSTEMC_H__
    3939
    40 #define SYSTEMCASS_SPECIFIC
    41 //#define SOCVIEW // we can't define SOCVIEW macro because we don't support
    42 //some features like "debug" function
    43 #define STATESAVER_SYSTEM
    44 #define NONAME_RENAME
    45 #define PORT_DEPENDANCIES_ENABLED
     40#include <systemc>
    4641
    47 #include"sc_fwd.h"
    4842
    49 #include"global_functions.h"
    50 #include"sc_nbdefs.h"
    51 #include"sc_ver_ext.h"
    52 #include"sc_module_name.h"
    53 #include"sc_module_ext.h"
    54 #include"sc_module_name.h"
    55 #include"module_hierarchy_ext.h"
    56 #include"serialization_ext.h"
    57 #include"sc_port_ext.h"
    58 #include"sc_signal.h"
    59 #include"sc_clock_ext.h"
    60 #include"sc_sensitive.h"
     43using sc_core::method_process_t;
     44using sc_core::sc_port_base;
     45using sc_core::sc_object;
     46using sc_core::sc_interface;
     47using sc_core::sc_module;
     48using sc_core::sc_module_name;
     49using sc_core::sc_event;
     50using sc_core::sc_event_finder;
     51using sc_core::sc_sensitive;
     52using sc_core::sc_sensitive_pos;
     53using sc_core::sc_sensitive_neg;
     54/////////////////////////////////////////////////
     55// Ports & Signals
     56//
     57using sc_core::sc_time;
     58using sc_core::sc_simulation_time;
     59using sc_core::sc_time_stamp;
    6160
    62 #include"sc_time.h"
    63 #include"sc_unit.h"
    64 #include"sc_trace_ext.h"
    65 #include"sc_vcd_trace.h"
    66 #include"sc_pat_trace.h"
    67 #include"endianness.h"
     61using sc_core::sc_in;
     62using sc_core::sc_inout;
     63using sc_core::sc_out;
     64using sc_core::sc_signal;
     65using sc_core::sc_port_b;
     66using sc_core::sc_signal_base;
     67using sc_core::sc_clock;
     68
     69using sc_core::sc_trace_file;
     70
     71using sc_core::method_process_list_t;
     72
     73using sc_dt::sc_bit;
     74using sc_dt::sc_bv;
     75using sc_dt::sc_logic;
     76using sc_dt::sc_lv;
     77using sc_dt::sc_unsigned;
     78using sc_dt::sc_signed;
     79//using sc_dt::sc_int_base;
     80using sc_dt::sc_int;
     81using sc_dt::sc_uint;
     82using sc_dt::sc_bigint;
     83using sc_dt::sc_biguint;
     84//using sc_dt::sc_uint_base;
    6885
    6986using std::ios;
Note: See TracChangeset for help on using the changeset viewer.