Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • sources/src/gen_code.cc

    r27 r17  
    3434 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    3535 */
    36 #if defined(__linux__)
     36#ifndef _WIN32
    3737#include <linux/limits.h>
    38 #elif defined(WIN32)
     38#else
    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 #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"
     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"
    5955#else
    6056#define fsm_check_flag
    6157#endif
    6258
    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
     59#define casc_cflags CFLAGS " " fsm_check_flag
     60
     61#if defined(darwin)
     62#define macosx
     63#endif
    6764
    6865using namespace std;
     
    9491                << m.module->name() << "->" << m.name << "()\\n\");\n";
    9592  o << " p.integer = " << func << ";\n";
    96 #ifdef CPP_CALL
     93#if CPP_CALL
    9794  o << " (((sc_module*)(" << m.module << "))->*(p.pmf)) (); /* "
    9895                << m.module->name () << "->" << m.name << "() */\n";
     
    146143  }
    147144
    148 #ifdef CONFIG_DEBUG
     145#ifdef DEBUG
    149146  cerr << "opened temporary filename : " << temp << "\n";
    150147#endif
     
    271268
    272269  o << "// generated by " << sc_version () << endl
    273                 << "#include <casc.h>\n\n"
    274                 << "#include <cstdio>\n\n"
    275 //              << "#include <iostream>\n\n"
     270                << "#include<casc.h>\n\n"
     271                << "#include<cstdio>\n\n"
     272//              << "#include<iostream>\n\n"
    276273                << "namespace sc_core {\n"
    277274    << " typedef void (sc_module::*SC_ENTRY_FUNC)();\n"
     
    332329
    333330  o << "// generated by " << sc_version () << endl
    334                 << "#include <casc.h>\n\n"
    335                 << "#include <cstdio>\n\n"
    336 //              << "#include <iostream>\n\n"
     331                << "#include<casc.h>\n\n"
     332                << "#include<cstdio>\n\n"
     333//              << "#include<iostream>\n\n"
    337334                << "namespace sc_core {\n"
    338335    << " typedef void (sc_module::*SC_ENTRY_FUNC)();\n"
     
    380377//  const char *target_arch = getenv ("TARGET_ARCH");
    381378        const char *default_compiler =
    382 #ifdef CPP_CALL
     379#if CPP_CALL
    383380                "g++";
    384381#else
     
    421418  /* COMPILE */
    422419  /* ******* */
    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)"
     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);
    428439#else
    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);
     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
    440449
    441450  if (dump_stage)
     
    452461  sprintf (target_name, "%s.so", base_name);
    453462
    454 #ifdef CONFIG_OS_LINUX
     463#if defined(linux)
    455464  sprintf (source_name, "%s.lo", base_name);
    456465  sprintf(compil_str, "(cd %s ; pwd ; libtool --mode=link %s %s -shared -rdynamic -o %s %s)", /* -L. -L%s/lib-%s */
     
    551560  for (i = 0; i < n; ++i)
    552561  {
    553 #if 0 //defined(CONFIG_DEBUG)
     562#if 0 //defined(DEBUG)
    554563    sc_module *m = (sc_module*)(fc.instance[i]);
    555564    cerr << m->name () << endl;
     
    566575void static_simulate_1_cycle (void)
    567576{
    568 #ifdef CONFIG_CHECK_FSM_RULES
     577#ifdef CHECK_FSM_RULES
    569578        casc_fsm_step = TRANSITION;
    570579#endif
    571580  call_functions (pf[0]); // transition
    572581  update     ();
    573 #ifdef CONFIG_CHECK_FSM_RULES
     582#ifdef CHECK_FSM_RULES
    574583        casc_fsm_step = GEN_MOORE;
    575584#endif
    576585  call_functions (pf[1]); // moore generation
    577 #ifdef CONFIG_CHECK_FSM_RULES
     586#ifdef CHECK_FSM_RULES
    578587        casc_fsm_step = GEN_MEALY;
    579588#endif
    580589  call_functions (pf[2]); // mealy generation
    581 #ifdef CONFIG_CHECK_FSM_RULES
     590#ifdef CHECK_FSM_RULES
    582591        casc_fsm_step = STIMULI;
    583592#endif
     
    625634void quasistatic_simulate_1_cycle (void)
    626635{
    627 #ifdef CONFIG_CHECK_FSM_RULES
     636#ifdef CHECK_FSM_RULES
    628637        casc_fsm_step = TRANSITION;
    629638#endif
     
    635644  }
    636645  update     ();
    637 #ifdef CONFIG_CHECK_FSM_RULES
     646#ifdef CHECK_FSM_RULES
    638647        casc_fsm_step = GEN_MOORE;
    639648#endif
     
    643652    Call (m);
    644653  }
    645 #ifdef CONFIG_CHECK_FSM_RULES
     654#ifdef CHECK_FSM_RULES
    646655        casc_fsm_step = GEN_MEALY;
    647656#endif
    648657  quasistatic_mealy_generation ();
    649 #ifdef CONFIG_CHECK_FSM_RULES
     658#ifdef CHECK_FSM_RULES
    650659        casc_fsm_step = STIMULI;
    651660#endif
Note: See TracChangeset for help on using the changeset viewer.