[1] | 1 | /*------------------------------------------------------------\ |
---|
[52] | 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 | \------------------------------------------------------------*/ |
---|
[1] | 13 | #ifndef __GEN_CODE_H__ |
---|
| 14 | #define __GEN_CODE_H__ |
---|
| 15 | |
---|
[27] | 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" |
---|
[1] | 22 | |
---|
| 23 | //------------------------------------------------------------------- |
---|
| 24 | #ifdef __GNUC__ |
---|
| 25 | #define INLINE __attribute__((always_inline)) |
---|
| 26 | #else |
---|
| 27 | #define INLINE |
---|
| 28 | #endif |
---|
| 29 | |
---|
| 30 | //------------------------------------------------------------------- |
---|
| 31 | namespace sc_core { |
---|
| 32 | |
---|
[52] | 33 | extern strong_component_list_t * strong; |
---|
[1] | 34 | |
---|
| 35 | /* compile scheduling code to link dynamically later */ |
---|
[52] | 36 | extern void compile_code(const char * base_name, const char * cflags2 = ""); |
---|
[1] | 37 | |
---|
| 38 | /* generate a scheduling code */ |
---|
| 39 | extern void gen_scheduling_code_for_quasistatic_func( |
---|
[52] | 40 | method_process_list_t &transition_list, |
---|
| 41 | method_process_list_t &moore_list, |
---|
| 42 | strong_component_list_t &mealy_list); |
---|
| 43 | |
---|
[1] | 44 | extern void gen_scheduling_code_for_static_func( |
---|
[52] | 45 | method_process_list_t &transition_list, |
---|
| 46 | method_process_list_t &moore_list, |
---|
| 47 | ProcessDependencyList &mealy_list); |
---|
[1] | 48 | |
---|
[52] | 49 | extern 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 | |
---|
| 54 | extern 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 | |
---|
[1] | 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 | |
---|
[52] | 66 | EXTERN void static_simulate_1_cycle(); |
---|
| 67 | EXTERN void static_mealy_generation(); |
---|
| 68 | EXTERN void quasistatic_simulate_1_cycle(); |
---|
| 69 | EXTERN void quasistatic_mealy_generation(); |
---|
[1] | 70 | |
---|
| 71 | /* internal functions */ |
---|
[52] | 72 | inline void switch_to_moore() INLINE; |
---|
| 73 | inline void internal_sc_cycle2() INLINE; |
---|
| 74 | inline void internal_sc_cycle1(int number_of_cycles) INLINE; |
---|
| 75 | inline void internal_sc_cycle0(double duration) INLINE; |
---|
[1] | 76 | |
---|
| 77 | /* ***************** */ |
---|
| 78 | /* inlined functions */ |
---|
| 79 | /* ***************** */ |
---|
| 80 | |
---|
[52] | 81 | inline void internal_sc_cycle2() { |
---|
[1] | 82 | #ifdef DUMP_STAGE |
---|
[52] | 83 | std::cerr << "begin of cycle #" << sc_simulation_time () << "\n"; |
---|
[1] | 84 | #endif |
---|
[52] | 85 | func_simulate_1_cycle(); |
---|
| 86 | ++nb_cycles; |
---|
[1] | 87 | #ifdef DUMP_STAGE |
---|
[52] | 88 | std::cerr << "end of cycle\n"; |
---|
[1] | 89 | #endif |
---|
| 90 | } |
---|
| 91 | |
---|
[52] | 92 | |
---|
| 93 | inline 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 | } |
---|
[1] | 101 | } |
---|
| 102 | |
---|
[52] | 103 | |
---|
| 104 | inline void internal_sc_cycle0(double duration) { |
---|
| 105 | // in default time units |
---|
| 106 | |
---|
[27] | 107 | #ifdef CONFIG_DEBUG |
---|
[52] | 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 | } |
---|
[1] | 112 | |
---|
[52] | 113 | if (duration < -1) { |
---|
| 114 | std::cerr << "Invalid duration.\n"; |
---|
| 115 | } |
---|
[1] | 116 | #endif |
---|
| 117 | |
---|
[52] | 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 | } |
---|
[1] | 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__ */ |
---|
[52] | 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 | |
---|