source: sources/src/gen_code.h @ 28

Last change on this file since 28 was 27, checked in by buchmann, 16 years ago

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 size: 4.6 KB
Line 
1/*------------------------------------------------------------\
2|                                                             |
3| Tool    :                  systemcass                       |
4|                                                             |
5| File    :                 gen_code.h                        |
6|                                                             |
7| Author  :                 Taktak Sami                       |
8|                           Buchmann Richard                  |
9|                                                             |
10| Date    :                   09_07_2004                      |
11|                                                             |
12\------------------------------------------------------------*/
13#ifndef __GEN_CODE_H__
14#define __GEN_CODE_H__
15
16#include "internal.h"
17#include "global_functions.h"
18#include "graph.h"
19#include "sc_port.h"
20#include "sc_trace.h"
21#include "process_dependency.h"
22
23//-------------------------------------------------------------------
24#ifdef __GNUC__
25#define INLINE __attribute__((always_inline))
26#else
27#define INLINE
28#endif
29
30//-------------------------------------------------------------------
31namespace sc_core {
32
33extern strong_component_list_t *strong;
34
35/* compile scheduling code to link dynamically later */
36extern void compile_code(const char *base_name, const char *cflags2 = "");
37
38/* generate a scheduling code */
39extern void  gen_scheduling_code_for_quasistatic_func(
40                      method_process_list_t   &transition_list,
41                      method_process_list_t   &moore_list,
42                            strong_component_list_t &mealy_list);
43extern void  gen_scheduling_code_for_static_func(
44                      method_process_list_t   &transition_list,
45                      method_process_list_t   &moore_list,
46                            ProcessDependencyList   &mealy_list);
47extern char *gen_scheduling_code_for_dynamic_link(
48                      method_process_list_t   &transition_list,
49                      method_process_list_t   &moore_list,
50                            ProcessDependencyList   &mealy_list);
51extern char *gen_scheduling_code_for_dynamic_link(
52                      method_process_list_t   &transition_list,
53                      method_process_list_t   &moore_list,
54                            strong_component_list_t &strongcomponents);
55
56/* function when any dynamic link is impossible */
57#ifdef __cplusplus
58#define EXTERN extern "C"
59#else
60#define EXTERN extern
61#endif
62
63EXTERN void static_simulate_1_cycle ();
64EXTERN void static_mealy_generation ();
65EXTERN void quasistatic_simulate_1_cycle ();
66EXTERN void quasistatic_mealy_generation ();
67
68/* internal functions */
69inline void switch_to_moore () INLINE;
70inline void internal_sc_cycle2 () INLINE;
71inline void internal_sc_cycle1 (int number_of_cycles) INLINE;
72inline void internal_sc_cycle0( double duration )  INLINE;
73
74/* ***************** */
75/* inlined functions */
76/* ***************** */
77
78inline void
79internal_sc_cycle2 ()
80{
81#ifdef DUMP_STAGE
82  std::cerr << "begin of cycle #" << sc_simulation_time () << "\n";
83#endif
84  func_simulate_1_cycle (); 
85  ++nb_cycles;
86#ifdef DUMP_STAGE
87  std::cerr << "end of cycle\n";
88#endif
89}
90
91inline void
92internal_sc_cycle1 (int number_of_cycles)
93{ 
94        //while ((! have_to_stop) && (number_of_cycles != 0)) {
95        while (!((have_to_stop) | (number_of_cycles == 0))) {
96        trace_all  (false);
97                internal_sc_cycle2 ();
98        trace_all  (true);
99                number_of_cycles = (number_of_cycles<0)?number_of_cycles:number_of_cycles-1;
100  }
101}
102
103inline
104void 
105internal_sc_cycle0( double duration )  // in default time units
106{
107#ifdef CONFIG_DEBUG
108        // Check dynamic linkage
109  if ((func_combinationals == NULL) || (func_simulate_1_cycle == NULL)) {
110    std::cerr << "Main execution loop is not yet generated.\n";
111  }
112
113        if (duration < -1)
114                std::cerr << "Invalid duration.\n";
115#endif
116       
117  if (is_posted_write ()) {
118                // update posted value to external signals             
119#if 0
120                std::cerr << "update\n";
121#endif
122        update ();
123#ifdef CONFIG_CHECK_FSM_RULES
124                casc_fsm_step = GEN_MEALY;
125#endif
126    func_combinationals ();
127  }
128       
129        internal_sc_cycle1 ((int)duration);
130
131  // don't need to do func_combinationals since 'unstable' flag is now false
132  if (is_posted_write ()) {
133    update ();
134#ifdef CONFIG_CHECK_FSM_RULES
135                casc_fsm_step = GEN_MEALY;
136#endif
137    func_combinationals ();
138  }
139}
140
141//-------------------------------------------------------------------
142
143// sc_cycle is for internal purpose only.
144// sc_cycle is deprecated since 1.0
145//extern void sc_cycle( double duration );  // in default time units
146
147/* time_unit is worth a cycle in every cases */
148//extern void sc_cycle( double duration, sc_time_unit time_unit );
149
150} // end of sc_core namespace
151
152#endif /* __GEN_CODE_H__ */
Note: See TracBrowser for help on using the repository browser.