Ignore:
Timestamp:
Dec 10, 2008, 7:31:39 PM (16 years ago)
Author:
rosiere
Message:

Almost complete design
with Test and test platform

Location:
trunk/IPs/systemC/processor/Morpheo/Common/include
Files:
1 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/IPs/systemC/processor/Morpheo/Common/include/Address.h

    r81 r88  
    1 #ifndef morpheo_Address
    2 #define morpheo_Address
     1#ifndef Morpheo_Address_h
     2#define Morpheo_Address_h
    33
    44/*
  • trunk/IPs/systemC/processor/Morpheo/Common/include/Average.h

    r81 r88  
    1 #ifndef morpheo_Average
    2 #define morpheo_Average
     1#ifndef Morpheo_Average_h
     2#define Morpheo_Average_h
    33
    44/*
  • trunk/IPs/systemC/processor/Morpheo/Common/include/BitManipulation.h

    r81 r88  
    1 #ifndef morpheo_BitManipulation
    2 #define morpheo_BitManipulation
     1#ifndef Morpheo_BitManipulation_h
     2#define Morpheo_BitManipulation_h
    33
    44/*
  • trunk/IPs/systemC/processor/Morpheo/Common/include/ChangeCase.h

    r81 r88  
    1 #ifndef morpheo_changecase
    2 #define morpheo_changecase
     1#ifndef Morpheo_ChangeCase_h
     2#define Morpheo_ChangeCase_h
    33
    44/*
  • trunk/IPs/systemC/processor/Morpheo/Common/include/Debug.h

    r83 r88  
    1 #ifndef DEBUG_H
    2 #define DEBUG_H
     1#ifndef Morpheo_Debug_h
     2#define Morpheo_Debug_h
    33
    44/*
     
    1313 *  - log_begin
    1414 *  - log_end
     15 *  - log_function
     16 *  - msg_print
    1517 *  - breakpoint
    1618 *
     
    2527#include "Common/include/Message.h"
    2628#include "Behavioural/include/Debug_component.h"
    27 #include "Behavioural/include/Environment.h"
     29#include <systemc.h>
    2830#include <stdio.h>
    2931#include <string.h>
     
    3133#include <sstream>
    3234#include <string>
     35
     36namespace morpheo {
    3337
    3438enum _debug_verbosity
     
    5458           ( DEBUG_ ## component == true )) )                           \
    5559        {                                                               \
     60          if (DEBUG_ ## level <= DEBUG_INFO)                            \
     61            {                                                           \
     62              msg("%s ",MSG_INFORMATION);                               \
     63            }                                                           \
     64          else                                                          \
     65            {                                                           \
     66              msg("%s ",MSG_DEBUG);                                     \
     67            }                                                           \
     68                                                                        \
    5669          if (DEBUG >= DEBUG_FUNC)                                      \
    5770            {                                                           \
    58               msg(_("%s"),debug_tab().c_str());                         \
     71              msg("%s",debug_tab().c_str());                            \
    5972            }                                                           \
    6073          if (DEBUG >= DEBUG_ALL )                                      \
     
    7285          if (DEBUG >= DEBUG_FUNC)                                      \
    7386            {                                                           \
    74               msg(_("<%s> "),func);                                     \
    75               msg(_("In file %s, "),__FILE__);                          \
    76               msg(_("at line %d " ),__LINE__);                          \
    77               msg(_(": "));                                             \
    78             }                                                           \
    79           msg(str);                                                     \
    80           msg(_("\n"));                                                 \
    81           fflush (stdout);                                              \
     87              msg(  "<%s> " ,func);                                     \
     88              msg(_("In file %s, "),__FILE__);                          \
     89              msg(_("at line %d " ),__LINE__);                          \
     90              msg(  ": " );                                             \
     91            }                                                           \
     92          msg(str);                                                     \
     93          msg("\n");                                                    \
    8294        }                                                               \
    8395    } while(0)
     
    8799    {                                                                   \
    88100      debug_tab_inc ();                                                 \
    89       log_printf(FUNC,component,func,"Begin");                          \
     101      log_printf(FUNC,component,func,_("Begin"));                       \
    90102    } while(0)
    91103
     
    93105  do                                                                    \
    94106    {                                                                   \
    95       log_printf(FUNC,component,func,"End");                            \
     107      log_printf(FUNC,component,func,_("End"));                         \
    96108      debug_tab_dec ();                                                 \
    97109    } while(0)
     
    115127#endif // DEBUG
    116128
     129# define log_function(component,func,name)                              \
     130  do                                                                    \
     131    {                                                                   \
     132      log_printf(TRACE,component,func,_("[%d] %s.%s"),static_cast<uint32_t>(sc_simulation_time()),name,func); \
     133    } while(0)
     134
     135
     136#define msg_printf(type,str...)                                         \
     137  do                                                                    \
     138    {                                                                   \
     139      msg("%s ",MSG_ ## type);                                          \
     140      msg(str);                                                         \
     141      msg("\n");                                                        \
     142    } while(0)
     143
     144
    117145#define breakpoint(str...)                                              \
    118146  do                                                                    \
    119147    {                                                                   \
    120       msg(_("Breakpoint : file %s, line %d. Enter Any key to continue\n"),__FILE__,__LINE__); \
    121       msg(str);                                                         \
     148      fprintf(stdout,_("%s "),MSG_BREAKPOINT);                                     \
     149      fprintf(stdout,_("Breakpoint in file %s, line %d.\n"),__FILE__,__LINE__);    \
     150      fprintf(stdout,_("%s "),MSG_NONE);                                           \
     151      fprintf(stdout,str);                                                              \
     152      fprintf(stdout,_("\n"));                                                     \
     153      fprintf(stdout,_("%s "),MSG_NONE);                                           \
     154      fprintf(stdout,_("Enter any key to continue\n"));                            \
    122155      getchar();                                                        \
    123156    } while(0)
     
    128161    {                                                                   \
    129162      if (x == NULL)                                                    \
    130         err(_("%s File %s, Line %d, this pointeur is null\n"),MSG_ERROR,__FILE__,__LINE__); \
     163        err(_("File %s, Line %d, this pointeur is null\n"),__FILE__,__LINE__); \
    131164    }                                                                   \
    132165  while (0)
     
    139172#endif
    140173
    141 
     174}; // end namespace morpheo
    142175#endif // !DEBUG_H
  • trunk/IPs/systemC/processor/Morpheo/Common/include/ErrorMorpheo.h

    r82 r88  
    1 #ifndef morpheo_ErrorMorpheo
    2 #define morpheo_ErrorMorpheo
     1#ifndef Morpheo_ErrorMorpheo_h
     2#define Morpheo_ErrorMorpheo_h
    33
    44/*
     
    99 */
    1010
    11 #include "ToString.h"
     11#include "Common/include/ToString.h"
     12#include "Common/include/Translation.h"
     13#include "Common/include/Message.h"
     14
    1215#include <iostream>
    1316#include <exception>
     
    2326   
    2427    // -----[ methods ]---------------------------------------------------
    25   public  :             ErrorMorpheo  ()                throw() {_msg="Exception detected ...";}
    26   public  :             ErrorMorpheo  (std::string msg) throw() {_msg=msg;}
     28  public  :             ErrorMorpheo  ()                throw() {_msg = toString("%s ",MSG_ERROR); _msg+="Exception detected ...";}
     29  public  :             ErrorMorpheo  (std::string msg) throw() {_msg = toString("%s ",MSG_ERROR); _msg+=msg;}
    2730  public  :             ErrorMorpheo  (std::string funcname,
    2831                                       std::string msg     ,
     
    3033                                       std::string file    ) throw()
    3134    {
    32       _msg = toString("<%s> at line %d, in file %s : %s",funcname.c_str(),line,file.c_str(),msg.c_str());
     35#ifdef DEBUG
     36      _msg = toString(_("%s <%s> at line %d, in file %s : %s"),MSG_ERROR,funcname.c_str(),line,file.c_str(),msg.c_str());
     37#else
     38      _msg = toString(_("%s %s"),MSG_ERROR,msg.c_str());
     39#endif
    3340    }
    3441  public  :             ~ErrorMorpheo (void)       throw() {}
     
    4350   
    4451    // -----[ methods ]---------------------------------------------------
    45   public  :             TestMorpheo   ()                throw() {_msg="Test error ...";}
     52  public  :             TestMorpheo   ()                throw() {_msg=_("Test error ...");}
    4653  public  :             TestMorpheo   (std::string msg) throw() {_msg=msg;}
    4754  public  :             ~TestMorpheo  (void)            throw() {}
  • trunk/IPs/systemC/processor/Morpheo/Common/include/FromString.h

    r81 r88  
    1 #ifndef morpheo_fromstring
    2 #define morpheo_fromstring
     1#ifndef Morpheo_FromString_h
     2#define Morpheo_FromString_h
    33
    44/*
     
    2727  }
    2828
     29  template<>           inline uint64_t fromString<uint64_t>   (const std::string& x)
     30  {
     31    return static_cast<uint64_t>(atoll(x.c_str()));
     32  }
     33
     34  template<>           inline double   fromString<double>     (const std::string& x)
     35  {
     36    return static_cast<double>(atof(x.c_str()));
     37  }
     38
    2939  template<>           inline bool     fromString<bool>       (const std::string& x)
    3040  {
  • trunk/IPs/systemC/processor/Morpheo/Common/include/Log2.h

    r81 r88  
    1 #ifndef morpheo_Log2
    2 #define morpheo_Log2
     1#ifndef Morpheo_Log2_h
     2#define Morpheo_Log2_h
    33
    44/*
  • trunk/IPs/systemC/processor/Morpheo/Common/include/Max.h

    r87 r88  
    1 #ifndef morpheo_max
    2 #define morpheo_max
     1#ifndef Morpheo_Max_h
     2#define Morpheo_Max_h
    33
    44/*
     
    1313namespace morpheo {
    1414
    15   template<typename T> inline T max (const T * x, uint32_t size)
     15  template<typename T> inline T max (T * x, uint32_t size)
    1616  {
    1717    T res = x[0];
    1818
    1919    for (uint32_t i=1; i<size; i++)
    20       if (res<x[i])
    21         res = x[i];
     20      {
     21        T tmp = x[i];
     22        if (res<tmp)
     23          res = tmp;
     24      }
    2225
    2326    return res;
    2427  }
    2528
    26   template<typename T> inline T max (const T * x, uint32_t size, uint32_t n)
     29  template<typename T> inline T max (T ** x, uint32_t size1, uint32_t size2)
     30  {
     31    T res = max(x[0],size2);
     32
     33    for (uint32_t i=1; i<size1; i++)
     34      {
     35        T tmp = max(x[i],size2);
     36        if (res<tmp)
     37          res = tmp;
     38      }
     39
     40    return res;
     41  }
     42
     43  template<typename T> inline T max (T ** x, uint32_t size1, uint32_t * size2)
     44  {
     45    T res = max(x[0],size2[0]);
     46
     47    for (uint32_t i=1; i<size1; i++)
     48      {
     49        T tmp = max(x[i],size2[i]);
     50        if (res<tmp)
     51          res = tmp;
     52      }
     53
     54    return res;
     55  }
     56
     57
     58  template<typename T> inline T max (T * x, uint32_t size, uint32_t n)
    2759  {
    2860    if ((n==0) or (n>size))
  • trunk/IPs/systemC/processor/Morpheo/Common/include/Message.h

    r83 r88  
    1 #ifndef MESSAGE_H
    2 #define MESSAGE_H
     1#ifndef Morpheo_Message_h
     2#define Morpheo_Message_h
    33/*
    44 * $Id$
     
    1515namespace morpheo {
    1616
    17 #define MSG_ERROR         _("[   ERROR   ]")
    18 #define MSG_WARNING       _("[  WARNING  ]")
    19 #define MSG_INFORMATION   _("[INFORMATION]")
     17  // Color
     18  // 31 : rouge
     19  // 32 : vert
     20  // 33 : jaune
     21  // 34 : bleu
     22  // 35 : rose
     23  // 36 : cyan
     24  // 37 : blanc
     25  // 38 : noir souligne
     26  // 39 : noir
    2027
    21 #define msg(arg...)                             \
     28#  define MSG_NONE          _("             ")
     29#ifdef PRINT_COLOR
     30#  define MSG_DEBUG         _("[1;34m[   DEBUG   ][0m")
     31#  define MSG_ERROR         _("[1;31m[   ERROR   ][0m")
     32#  define MSG_WARNING       _("[1;35m[  WARNING  ][0m")
     33#  define MSG_INFORMATION   _("[1;32m[INFORMATION][0m")
     34#  define MSG_BREAKPOINT    _("[1;38m[   BREAK   ][0m")
     35#else
     36#  define MSG_DEBUG         _("[   DEBUG   ]")
     37#  define MSG_ERROR         _("[   ERROR   ]")
     38#  define MSG_WARNING       _("[  WARNING  ]")
     39#  define MSG_INFORMATION   _("[INFORMATION]")
     40#  define MSG_BREAKPOINT    _("[   BREAK   ]")
     41#endif
     42
     43#ifdef LOG_FILE
     44extern FILE * log_stream;
     45void log_init (void);
     46
     47#define fmsg(stream,arg...)                     \
    2248  do                                            \
    2349    {                                           \
    24       fprintf(stdout,arg);                      \
     50      log_init();                               \
     51      fprintf(log_stream,arg);                  \
     52      fflush(log_stream);                       \
     53    } while (0)
     54
     55#else
     56
     57#define fmsg(stream,arg...)                     \
     58  do                                            \
     59    {                                           \
     60      fprintf(stream,arg);                      \
     61      fflush(stream);                           \
    2562    } while (0)
    2663
    27 #define err(arg...)                             \
     64#endif
     65
     66#define fmsgDebug(stream,arg...)                \
    2867  do                                            \
    2968    {                                           \
    30       fprintf(stderr,arg);                      \
     69      fmsg(stream,"%s ",MSG_DEBUG);             \
     70      fmsg(stream,arg);                         \
    3171    } while (0)
    3272
     73#define fmsgError(stream,arg...)                \
     74  do                                            \
     75    {                                           \
     76      fmsg(stream,"%s ",MSG_ERROR);             \
     77      fmsg(stream,arg);                         \
     78    } while (0)
     79
     80#define fmsgWarning(stream,arg...)              \
     81  do                                            \
     82    {                                           \
     83      fmsg(stream,"%s ",MSG_WARNING);           \
     84      fmsg(stream,arg);                         \
     85    } while (0)
     86
     87#define fmsgInformation(stream,arg...)          \
     88  do                                            \
     89    {                                           \
     90      fmsg(stream,"%s ",MSG_INFORMATION);       \
     91      fmsg(stream,arg);                         \
     92    } while (0)
     93
     94#define msg(arg...)             fmsg(stdout,arg)
     95#define msgDebug(arg...)        fmsgDebug(stdout,arg)
     96#define msgError(arg...)        fmsgError(stdout,arg)
     97#define msgWarning(arg...)      fmsgWarning(stdout,arg)
     98#define msgInformation(arg...)  fmsgInformation(stdout,arg)
     99#define err(arg...)             fmsgError(stderr,arg)
    33100
    34101}; // end namespace morpheo
  • trunk/IPs/systemC/processor/Morpheo/Common/include/Percent.h

    r81 r88  
    1 #ifndef morpheo_Percent
    2 #define morpheo_Percent
     1#ifndef Morpheo_Percent_h
     2#define Morpheo_Percent_h
    33
    44/*
  • trunk/IPs/systemC/processor/Morpheo/Common/include/Test.h

    r83 r88  
    1 #ifndef TEST_H
    2 #define TEST_H
     1#ifndef Morpheo_Test_h
     2#define Morpheo_Test_h
     3
     4/*
     5 * $Id$
     6 *
     7 * [ Description ]
     8 *
     9 * Macro / function to test
     10 */
    311
    412#include <iostream>
     
    1119namespace morpheo {
    1220
    13 //-----[ Routine de test ]---------------------------------------
     21#define STR_OK "Test OK"
     22#define STR_KO "Test KO"
    1423
    1524static uint32_t num_test;
     
    2433inline void test_ko (char * file, uint32_t line, T exp1, T exp2)
    2534{
    26   std::cerr << "[" << num_test << "] : Test KO"
     35  fflush (stdout);
     36  fflush (stderr);
     37
     38  std::cerr << "[" << num_test << "] : " << STR_KO
    2739       << "\tline " << line                      << std::endl
    2840       << " * Localisation"                      << std::endl
     
    3850inline void test_ko (char * file, uint32_t line)
    3951{
    40   std::cerr << "[" << num_test << "] : Test KO"
     52  fflush (stdout);
     53  fflush (stderr);
     54
     55  std::cerr << "[" << num_test << "] : " << STR_KO
    4156       << "\tline " << line                           << std::endl
    4257       << " * Localisation"                           << std::endl
     
    4964inline void test_ok ()
    5065{
    51   msg (_("[%d] : Test OK\n"), num_test);
     66  fflush (stdout);
     67  fflush (stderr);
     68
     69  msg (_("[%d] : %s\n"), num_test,STR_OK);
    5270
    5371  num_test ++;
     
    5674inline void test_ok (char * file, uint32_t line)
    5775{
    58   msg (_("[%d] : Test OK\n"), num_test);
     76  fflush (stdout);
     77  fflush (stderr);
     78
     79  msg (_("[%d] : %s\n"), num_test,STR_OK);
    5980  msg (_("\tline %d\n"), line);
    6081
     
    6586inline void test_ok (char * file, uint32_t line, T exp)
    6687{
    67   msg (_("[%d] : Test OK\n"), num_test);
     88  fflush (stdout);
     89  fflush (stderr);
     90
     91  msg (_("[%d] : %s\n"), num_test, STR_OK);
    6892  msg (_("\tline %d\n"), line);
    6993  msg (_("\tvalue %s\n"), (morpheo::toString(exp)).c_str());
     
    91115    msg (str);                                                          \
    92116    msg (_("\n"));                                                      \
     117    fflush (stdout);                                                    \
    93118  } while(0)
    94 
    95119
    96120#ifndef CYCLE_MAX
     
    109133        }                                                               \
    110134                                                                        \
    111       if (cycle_current > CYCLE_MAX)                                    \
     135      if ((CYCLE_MAX != 0) and (cycle_current > CYCLE_MAX))             \
    112136        {                                                               \
    113137          TEST_KO("Maximal cycles Reached");                            \
  • trunk/IPs/systemC/processor/Morpheo/Common/include/Time.h

    r81 r88  
    1 #ifndef TIME_H
    2 #define TIME_H
     1#ifndef Morpheo_Time_h
     2#define Morpheo_Time_h
    33
    44#ifdef SYSTEMC
     
    1010#include <sys/time.h>
    1111
     12namespace morpheo {
     13
    1214class Time
    1315{
    14 private : timeval time_begin;
     16#ifdef SYSTEMC
     17private : double   nb_cycles_begin;
     18#endif
     19private : timeval  time_begin;
    1520// private : timeval time_end;
    1621 
    1722public  : Time ()
    18   {
    19     gettimeofday(&time_begin     ,NULL);
     23  {
     24#ifdef SYSTEMC
     25    nb_cycles_begin = sc_simulation_time();
     26#endif
     27    gettimeofday(&time_begin,NULL);
    2028  };
    21 
     29 
    2230public  : ~Time ()
    2331  {
     
    2533  };
    2634
    27 public  : friend std::ostream& operator<< (std::ostream& output_stream,
     35public  : friend std::ostream& operator<< (std::ostream& output,
    2836                                           const Time & x)
    2937  {
    3038    timeval time_end;
    3139   
    32     gettimeofday(&time_end       ,NULL);
     40    gettimeofday(&time_end,NULL);
    3341   
    34     uint32_t nb_cycles = static_cast<uint32_t>(sc_simulation_time());
    35 
    36     double average = static_cast<double>(nb_cycles) / static_cast<double>(time_end.tv_sec-x.time_begin.tv_sec+1);
     42#ifdef SYSTEMC
     43    double nb_cycles_end = sc_simulation_time();
     44    double average       = static_cast<double>(nb_cycles_end-x.nb_cycles_begin+1) / static_cast<double>(time_end.tv_sec-x.time_begin.tv_sec+1);
    3745   
    38     output_stream << "Timing : " << nb_cycles << " cycles \t(" << average << " cycles/s)" << std::endl;
    39 
    40     return output_stream;
     46    output << "Timing : " << nb_cycles_end << " cycles \t(" << average << " cycles/s)" << std::endl;
     47#else
     48    double average       = static_cast<double>(time_end.tv_sec-x.time_begin.tv_sec+1);
     49   
     50    output << "Timing : " average << " s" << std::endl;
     51#endif
     52   
     53    return output;
    4154  }
    4255};
    4356
     57}; // end namespace morpheo
     58
    4459#endif
  • trunk/IPs/systemC/processor/Morpheo/Common/include/ToBase2.h

    r81 r88  
    1 #ifndef morpheo_ToBase2
    2 #define morpheo_ToBase2
     1#ifndef Morpheo_ToBase2_h
     2#define Morpheo_ToBase2_h
    33
    44/*
  • trunk/IPs/systemC/processor/Morpheo/Common/include/ToString.h

    r82 r88  
    1 #ifndef morpheo_tostring
    2 #define morpheo_tostring
     1#ifndef Morpheo_ToString_h
     2#define Morpheo_ToString_h
    33
    44/*
  • trunk/IPs/systemC/processor/Morpheo/Common/include/Translation.h

    r82 r88  
    1 #ifndef morpheo_Translation_H
    2 #define morpheo_Translation_H
     1#ifndef Morpheo_Translation_h
     2#define Morpheo_Translation_h
    33/*
    44 * $Id$
     
    1616#define MORPHEO_PACKAGE "morpheo"
    1717
    18 #ifdef NO_TRANSLATION
     18#ifdef TRANSLATION
     19# define _(str) dgettext (MORPHEO_PACKAGE,str)
     20#else
    1921# define _(str) (str)
    20 #else
    21 # define _(str) dgettext (MORPHEO_PACKAGE,str)
    2222#endif
    2323
    2424namespace morpheo
    2525{
    26   class Translation
    27   {
    28   public :  Translation (void);
    29   public : ~Translation (void);
    30   };
    31 
     26  void translation (void);
    3227}; // end namespace morpheo
    3328#endif
  • trunk/IPs/systemC/processor/Morpheo/Common/include/Types.h

    r81 r88  
    1 #ifndef morpheo_Type
    2 #define morpheo_Type
     1#ifndef Morpheo_Type_h
     2#define Morpheo_Type_h
    33
    44/*
     
    3434// #endif
    3535
    36 #define SC_CLOCK                 sc_in_clk       
    37 // #define SC_INTERNAL(type)        type
    38 // #define SC_REGISTER(type)        sc_signal<type >
    39 // #define SC_SIGNAL(type)          sc_signal<type >
    40 #define SC_IN(type)              sc_in    <type >
    41 #define SC_OUT(type)             sc_out   <type >
     36#  define SC_CLOCK                 sc_in_clk       
     37//#define SC_INTERNAL(type)        type
     38//#define SC_REGISTER(type)        sc_signal<type >
     39//#define SC_SIGNAL(type)          sc_signal<type >
     40#  define SC_IN(type)              sc_in    <type >
     41#  define SC_OUT(type)             sc_out   <type >
    4242                                 
    43 #define PORT_READ(sig)           sig->read()
    44 #define PORT_WRITE(sig,val)      sig->write(val)
    45 // #define INTERNAL_READ(sig)       (*sig)
    46 // #define INTERNAL_WRITE(sig,val)  (*sig) = val
    47 // #define SIGNAL_READ(sig)         sig->read()
    48 // #define SIGNAL_WRITE(sig,val)    sig->write(val)
    49 // #define REGISTER_READ(sig)       sig->read()
    50 // #define REGISTER_WRITE(sig,val)  sig->write(val)
     43#  define PORT_READ(sig)           sig->read()
     44#  define PORT_WRITE(sig,val)      sig->write(val)
     45//#define INTERNAL_READ(sig)       (*sig)
     46//#define INTERNAL_WRITE(sig,val)  (*sig) = val
     47//#define SIGNAL_READ(sig)         sig->read()
     48//#define SIGNAL_WRITE(sig,val)    sig->write(val)
     49//#define REGISTER_READ(sig)       sig->read()
     50//#define REGISTER_WRITE(sig,val)  sig->write(val)
    5151
    5252#endif 
Note: See TracChangeset for help on using the changeset viewer.