Changeset 27 for sources/src/gen_code.cc


Ignore:
Timestamp:
May 4, 2009, 8:51:56 PM (15 years ago)
Author:
buchmann
Message:

SystemCASS now uses autoconf/automake to build the API. Regression tests still
use the old Makefiles.
(thanks to Nicolas Pouillon)

The library directory no longer is "lib-arch-system". The directory now is "lib-linux". Everyone needs to pay attention about SYSTEMCASS environment variable.

Changes:

  • system header includes
  • Add includes to config.h (generated by autoconf/automake)
  • test:
    • linux preprocessor macro instead of _WIN32
    • CONFIG_DEBUG instead of DEBUG

Removes:

  • Makefile
  • guess_endianness.cc
  • guess_os.sh
  • assert.h (we now use standard assert.h)
  • Options.def
File:
1 edited

Legend:

Unmodified
Added
Removed
  • sources/src/gen_code.cc

    r17 r27  
    3434 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    3535 */
    36 #ifndef _WIN32
     36#if defined(__linux__)
    3737#include <linux/limits.h>
    38 #else
     38#elif defined(WIN32)
    3939#include <windows.h>
    4040#endif
     
    4545#include<fstream>
    4646
    47 #include"internal.h"
    48 #include"gen_code.h"
    49 #include"sc_module.h"
    50 #include"sc_ver.h"
    51 #include"process_dependency.h"
    52 
    53 #ifdef CHECK_FSM_RULES
    54 #define fsm_check_flag "-DCHECK_FSM_RULES"
     47#include "internal.h"
     48#include "gen_code.h"
     49#include "sc_module.h"
     50#include "sc_ver.h"
     51#include "process_dependency.h"
     52#ifdef HAVE_CONFIG_H
     53#include "config.h"
     54#endif
     55
     56#ifdef CONFIG_CHECK_FSM_RULES
     57#include "fsm_rules.h"
     58#define fsm_check_flag "-DCONFIG_CHECK_FSM_RULES"
    5559#else
    5660#define fsm_check_flag
    5761#endif
    5862
    59 #define casc_cflags CFLAGS " " fsm_check_flag
    60 
    61 #if defined(darwin)
    62 #define macosx
    63 #endif
     63#define casc_cflags GENERATED_MODULE_CFLAGS " " fsm_check_flag
     64
     65// Enable CPP call, this is useful for typeinfo-enabled classes
     66#define CPP_CALL
    6467
    6568using namespace std;
     
    9194                << m.module->name() << "->" << m.name << "()\\n\");\n";
    9295  o << " p.integer = " << func << ";\n";
    93 #if CPP_CALL
     96#ifdef CPP_CALL
    9497  o << " (((sc_module*)(" << m.module << "))->*(p.pmf)) (); /* "
    9598                << m.module->name () << "->" << m.name << "() */\n";
     
    143146  }
    144147
    145 #ifdef DEBUG
     148#ifdef CONFIG_DEBUG
    146149  cerr << "opened temporary filename : " << temp << "\n";
    147150#endif
     
    268271
    269272  o << "// generated by " << sc_version () << endl
    270                 << "#include<casc.h>\n\n"
    271                 << "#include<cstdio>\n\n"
    272 //              << "#include<iostream>\n\n"
     273                << "#include <casc.h>\n\n"
     274                << "#include <cstdio>\n\n"
     275//              << "#include <iostream>\n\n"
    273276                << "namespace sc_core {\n"
    274277    << " typedef void (sc_module::*SC_ENTRY_FUNC)();\n"
     
    329332
    330333  o << "// generated by " << sc_version () << endl
    331                 << "#include<casc.h>\n\n"
    332                 << "#include<cstdio>\n\n"
    333 //              << "#include<iostream>\n\n"
     334                << "#include <casc.h>\n\n"
     335                << "#include <cstdio>\n\n"
     336//              << "#include <iostream>\n\n"
    334337                << "namespace sc_core {\n"
    335338    << " typedef void (sc_module::*SC_ENTRY_FUNC)();\n"
     
    377380//  const char *target_arch = getenv ("TARGET_ARCH");
    378381        const char *default_compiler =
    379 #if CPP_CALL
     382#ifdef CPP_CALL
    380383                "g++";
    381384#else
     
    418421  /* COMPILE */
    419422  /* ******* */
    420 #if defined(macosx)
    421     sprintf(compil_str,
    422                                 "(cd %s ; %s %s -DSCHEDULING_BY_CASC -I%s/include -fno-common -dynamic -o %s -c %s)",
    423         temporary_dir,
    424                                 compiler,
    425                                 casc_cflags,
    426                                 systemc_dir,
    427                                 target_name,
    428                                 source_name);
    429 //    sprintf(compil_str,"");
    430 #elif defined(linux)
    431     sprintf(compil_str,
    432                                 "(cd %s ; libtool --mode=compile %s %s -DSCHEDULING_BY_CASC -I%s/include -shared -o %s -c %s)",
    433         temporary_dir,
    434                                 compiler,
    435                                 casc_cflags,
    436                                 systemc_dir,
    437                                 target_name,
    438                                 source_name);
     423  const char *commandline_template =
     424#if defined(CONFIG_OS_DARWIN)
     425          "(cd %s ;"                     " %s %s -DSCHEDULING_BY_CASC -I%s/include -fno-common -dynamic -o %s -c %s)"
     426#elif defined(CONFIG_OS_LINUX)
     427          "(cd %s ; libtool --mode=compile %s %s -DSCHEDULING_BY_CASC -I%s/include -shared -o %s -c %s)"
    439428#else
    440     sprintf(compil_str,
    441                                 "(cd %s ; %s %s -DSCHEDULING_BY_CASC -I%s/include -dynamiclib -o %s -c %s)",
    442         temporary_dir,
    443                                 compiler,
    444                                 casc_cflags,
    445                                 systemc_dir,
    446                                 target_name,
    447                                 source_name);
    448 #endif
     429          "(cd %s ;"                     " %s %s -DSCHEDULING_BY_CASC -I%s/include -dynamiclib -o %s -c %s)"
     430#endif
     431          ;
     432  sprintf(compil_str,
     433                  commandline_template,
     434                  temporary_dir,
     435                  compiler,
     436                  casc_cflags,
     437                  systemc_dir,
     438                  target_name,
     439                  source_name);
    449440
    450441  if (dump_stage)
     
    461452  sprintf (target_name, "%s.so", base_name);
    462453
    463 #if defined(linux)
     454#ifdef CONFIG_OS_LINUX
    464455  sprintf (source_name, "%s.lo", base_name);
    465456  sprintf(compil_str, "(cd %s ; pwd ; libtool --mode=link %s %s -shared -rdynamic -o %s %s)", /* -L. -L%s/lib-%s */
     
    560551  for (i = 0; i < n; ++i)
    561552  {
    562 #if 0 //defined(DEBUG)
     553#if 0 //defined(CONFIG_DEBUG)
    563554    sc_module *m = (sc_module*)(fc.instance[i]);
    564555    cerr << m->name () << endl;
     
    575566void static_simulate_1_cycle (void)
    576567{
    577 #ifdef CHECK_FSM_RULES
     568#ifdef CONFIG_CHECK_FSM_RULES
    578569        casc_fsm_step = TRANSITION;
    579570#endif
    580571  call_functions (pf[0]); // transition
    581572  update     ();
    582 #ifdef CHECK_FSM_RULES
     573#ifdef CONFIG_CHECK_FSM_RULES
    583574        casc_fsm_step = GEN_MOORE;
    584575#endif
    585576  call_functions (pf[1]); // moore generation
    586 #ifdef CHECK_FSM_RULES
     577#ifdef CONFIG_CHECK_FSM_RULES
    587578        casc_fsm_step = GEN_MEALY;
    588579#endif
    589580  call_functions (pf[2]); // mealy generation
    590 #ifdef CHECK_FSM_RULES
     581#ifdef CONFIG_CHECK_FSM_RULES
    591582        casc_fsm_step = STIMULI;
    592583#endif
     
    634625void quasistatic_simulate_1_cycle (void)
    635626{
    636 #ifdef CHECK_FSM_RULES
     627#ifdef CONFIG_CHECK_FSM_RULES
    637628        casc_fsm_step = TRANSITION;
    638629#endif
     
    644635  }
    645636  update     ();
    646 #ifdef CHECK_FSM_RULES
     637#ifdef CONFIG_CHECK_FSM_RULES
    647638        casc_fsm_step = GEN_MOORE;
    648639#endif
     
    652643    Call (m);
    653644  }
    654 #ifdef CHECK_FSM_RULES
     645#ifdef CONFIG_CHECK_FSM_RULES
    655646        casc_fsm_step = GEN_MEALY;
    656647#endif
    657648  quasistatic_mealy_generation ();
    658 #ifdef CHECK_FSM_RULES
     649#ifdef CONFIG_CHECK_FSM_RULES
    659650        casc_fsm_step = STIMULI;
    660651#endif
Note: See TracChangeset for help on using the changeset viewer.