source: sources/src/gen_code.h @ 56

Last change on this file since 56 was 52, checked in by meunier, 12 years ago

Code formatting in all source files.

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);
43
44extern void  gen_scheduling_code_for_static_func(
45      method_process_list_t   &transition_list,
46      method_process_list_t   &moore_list,
47      ProcessDependencyList   &mealy_list);
48
49extern char * gen_scheduling_code_for_dynamic_link(
50      method_process_list_t   &transition_list,
51      method_process_list_t   &moore_list,
52      ProcessDependencyList   &mealy_list);
53
54extern char * gen_scheduling_code_for_dynamic_link(
55      method_process_list_t   &transition_list,
56      method_process_list_t   &moore_list,
57      strong_component_list_t &strongcomponents);
58
59/* function when any dynamic link is impossible */
60#ifdef __cplusplus
61#define EXTERN extern "C"
62#else
63#define EXTERN extern
64#endif
65
66EXTERN void static_simulate_1_cycle();
67EXTERN void static_mealy_generation();
68EXTERN void quasistatic_simulate_1_cycle();
69EXTERN void quasistatic_mealy_generation();
70
71/* internal functions */
72inline void switch_to_moore() INLINE;
73inline void internal_sc_cycle2() INLINE;
74inline void internal_sc_cycle1(int number_of_cycles) INLINE;
75inline void internal_sc_cycle0(double duration)  INLINE;
76
77/* ***************** */
78/* inlined functions */
79/* ***************** */
80
81inline void internal_sc_cycle2() {
82#ifdef DUMP_STAGE
83    std::cerr << "begin of cycle #" << sc_simulation_time () << "\n";
84#endif
85    func_simulate_1_cycle(); 
86    ++nb_cycles;
87#ifdef DUMP_STAGE
88    std::cerr << "end of cycle\n";
89#endif
90}
91
92
93inline void internal_sc_cycle1(int number_of_cycles) { 
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
103
104inline void internal_sc_cycle0(double duration) {
105    // 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    }
116#endif
117
118    if (is_posted_write ()) {
119        // update posted value to external signals             
120        update ();
121        func_combinationals ();
122    }
123
124    internal_sc_cycle1 ((int) duration);
125
126    // don't need to do func_combinationals since 'unstable' flag is now false
127    if (is_posted_write()) {
128        update();
129        func_combinationals();
130    }
131}
132
133//-------------------------------------------------------------------
134
135// sc_cycle is for internal purpose only.
136// sc_cycle is deprecated since 1.0
137//extern void sc_cycle( double duration );  // in default time units
138
139/* time_unit is worth a cycle in every cases */
140//extern void sc_cycle( double duration, sc_time_unit time_unit );
141
142} // end of sc_core namespace
143
144#endif /* __GEN_CODE_H__ */
145
146/*
147# Local Variables:
148# tab-width: 4;
149# c-basic-offset: 4;
150# c-file-offsets:((innamespace . 0)(inline-open . 0));
151# indent-tabs-mode: nil;
152# End:
153#
154# vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
155*/
156
Note: See TracBrowser for help on using the repository browser.