1 | /* |
---|
2 | * $Id$ |
---|
3 | * |
---|
4 | * [ Description ] |
---|
5 | * |
---|
6 | * Test |
---|
7 | */ |
---|
8 | |
---|
9 | #include "Behavioural/Core/Multi_Front_end/Front_end/Ifetch_unit/Ifetch_unit_Glue/SelfTest/include/test.h" |
---|
10 | #include "Common/include/Test.h" |
---|
11 | #include "Behavioural/include/Allocation.h" |
---|
12 | |
---|
13 | #define NB_ITERATION 1 |
---|
14 | #define CYCLE_MAX (128*NB_ITERATION) |
---|
15 | |
---|
16 | #define LABEL(str...) \ |
---|
17 | { \ |
---|
18 | msg (_("{%d} "),static_cast<uint32_t>(sc_simulation_time())); \ |
---|
19 | msg (str); \ |
---|
20 | msg (_("\n")); \ |
---|
21 | } while(0) |
---|
22 | |
---|
23 | #define SC_START(cycle_offset) \ |
---|
24 | do \ |
---|
25 | { \ |
---|
26 | /*cout << "SC_START (begin)" << endl;*/ \ |
---|
27 | \ |
---|
28 | uint32_t cycle_current = static_cast<uint32_t>(sc_simulation_time()); \ |
---|
29 | if (cycle_offset != 0) \ |
---|
30 | { \ |
---|
31 | cout << "##########[ cycle "<< cycle_current+cycle_offset << " ]" << endl; \ |
---|
32 | } \ |
---|
33 | \ |
---|
34 | if (cycle_current > CYCLE_MAX) \ |
---|
35 | { \ |
---|
36 | TEST_KO("Maximal cycles Reached"); \ |
---|
37 | } \ |
---|
38 | \ |
---|
39 | sc_start(cycle_offset); \ |
---|
40 | \ |
---|
41 | /*cout << "SC_START (end )" << endl;*/ \ |
---|
42 | } while(0) |
---|
43 | |
---|
44 | void test (string name, |
---|
45 | morpheo::behavioural::core::multi_front_end::front_end::ifetch_unit::ifetch_unit_glue::Parameters * _param) |
---|
46 | { |
---|
47 | msg(_("<%s> : Simulation SystemC.\n"),name.c_str()); |
---|
48 | |
---|
49 | #ifdef STATISTICS |
---|
50 | morpheo::behavioural::Parameters_Statistics * _parameters_statistics = new morpheo::behavioural::Parameters_Statistics (5,50); |
---|
51 | #endif |
---|
52 | |
---|
53 | Ifetch_unit_Glue * _Ifetch_unit_Glue = new Ifetch_unit_Glue (name.c_str(), |
---|
54 | #ifdef STATISTICS |
---|
55 | _parameters_statistics, |
---|
56 | #endif |
---|
57 | _param); |
---|
58 | |
---|
59 | #ifdef SYSTEMC |
---|
60 | /********************************************************************* |
---|
61 | * Déclarations des signaux |
---|
62 | *********************************************************************/ |
---|
63 | string rename; |
---|
64 | |
---|
65 | sc_clock * in_CLOCK = new sc_clock ("clock", 1.0, 0.5); |
---|
66 | sc_signal<Tcontrol_t> * in_NRESET = new sc_signal<Tcontrol_t> ("NRESET"); |
---|
67 | |
---|
68 | ALLOC_SC_SIGNAL(out_ICACHE_REQ_VAL ,"out_ICACHE_REQ_VAL ",Tcontrol_t); |
---|
69 | ALLOC_SC_SIGNAL( in_ICACHE_REQ_ADDRESS_VAL," in_ICACHE_REQ_ADDRESS_VAL",Tcontrol_t); |
---|
70 | ALLOC_SC_SIGNAL(out_ICACHE_REQ_QUEUE_VAL ,"out_ICACHE_REQ_QUEUE_VAL ",Tcontrol_t); |
---|
71 | ALLOC_SC_SIGNAL( in_ICACHE_REQ_ACK ," in_ICACHE_REQ_ACK ",Tcontrol_t); |
---|
72 | ALLOC_SC_SIGNAL(out_ICACHE_REQ_ADDRESS_ACK,"out_ICACHE_REQ_ADDRESS_ACK",Tcontrol_t); |
---|
73 | ALLOC_SC_SIGNAL( in_ICACHE_REQ_QUEUE_ACK ," in_ICACHE_REQ_QUEUE_ACK ",Tcontrol_t); |
---|
74 | ALLOC_SC_SIGNAL(out_ICACHE_REQ_TYPE ,"out_ICACHE_REQ_TYPE ",Ticache_type_t); |
---|
75 | ALLOC_SC_SIGNAL( in_EVENT_VAL ," in_EVENT_VAL ",Tcontrol_t); |
---|
76 | ALLOC_SC_SIGNAL(out_EVENT_ADDRESS_VAL ,"out_EVENT_ADDRESS_VAL ",Tcontrol_t); |
---|
77 | ALLOC_SC_SIGNAL(out_EVENT_QUEUE_VAL ,"out_EVENT_QUEUE_VAL ",Tcontrol_t); |
---|
78 | ALLOC_SC_SIGNAL(out_EVENT_ACK ,"out_EVENT_ACK ",Tcontrol_t); |
---|
79 | ALLOC_SC_SIGNAL( in_EVENT_ADDRESS_ACK ," in_EVENT_ADDRESS_ACK ",Tcontrol_t); |
---|
80 | ALLOC_SC_SIGNAL( in_EVENT_QUEUE_ACK ," in_EVENT_QUEUE_ACK ",Tcontrol_t); |
---|
81 | |
---|
82 | /******************************************************** |
---|
83 | * Instanciation |
---|
84 | ********************************************************/ |
---|
85 | |
---|
86 | msg(_("<%s> : Instanciation of _Ifetch_unit_Glue.\n"),name.c_str()); |
---|
87 | |
---|
88 | (*(_Ifetch_unit_Glue->in_CLOCK)) (*(in_CLOCK)); |
---|
89 | (*(_Ifetch_unit_Glue->in_NRESET)) (*(in_NRESET)); |
---|
90 | |
---|
91 | INSTANCE_SC_SIGNAL(_Ifetch_unit_Glue,out_ICACHE_REQ_VAL ); |
---|
92 | INSTANCE_SC_SIGNAL(_Ifetch_unit_Glue, in_ICACHE_REQ_ADDRESS_VAL); |
---|
93 | INSTANCE_SC_SIGNAL(_Ifetch_unit_Glue,out_ICACHE_REQ_QUEUE_VAL ); |
---|
94 | INSTANCE_SC_SIGNAL(_Ifetch_unit_Glue, in_ICACHE_REQ_ACK ); |
---|
95 | INSTANCE_SC_SIGNAL(_Ifetch_unit_Glue,out_ICACHE_REQ_ADDRESS_ACK); |
---|
96 | INSTANCE_SC_SIGNAL(_Ifetch_unit_Glue, in_ICACHE_REQ_QUEUE_ACK ); |
---|
97 | INSTANCE_SC_SIGNAL(_Ifetch_unit_Glue,out_ICACHE_REQ_TYPE ); |
---|
98 | INSTANCE_SC_SIGNAL(_Ifetch_unit_Glue, in_EVENT_VAL ); |
---|
99 | INSTANCE_SC_SIGNAL(_Ifetch_unit_Glue,out_EVENT_ADDRESS_VAL ); |
---|
100 | INSTANCE_SC_SIGNAL(_Ifetch_unit_Glue,out_EVENT_QUEUE_VAL ); |
---|
101 | INSTANCE_SC_SIGNAL(_Ifetch_unit_Glue,out_EVENT_ACK ); |
---|
102 | INSTANCE_SC_SIGNAL(_Ifetch_unit_Glue, in_EVENT_ADDRESS_ACK ); |
---|
103 | INSTANCE_SC_SIGNAL(_Ifetch_unit_Glue, in_EVENT_QUEUE_ACK ); |
---|
104 | |
---|
105 | msg(_("<%s> : Start Simulation ............\n"),name.c_str()); |
---|
106 | |
---|
107 | Time * _time = new Time(); |
---|
108 | |
---|
109 | /******************************************************** |
---|
110 | * Simulation - Begin |
---|
111 | ********************************************************/ |
---|
112 | |
---|
113 | // Initialisation |
---|
114 | |
---|
115 | const uint32_t seed = 0; |
---|
116 | //const uint32_t seed = static_cast<uint32_t>(time(NULL)); |
---|
117 | |
---|
118 | srand(seed); |
---|
119 | |
---|
120 | SC_START(0); |
---|
121 | LABEL("Initialisation"); |
---|
122 | |
---|
123 | LABEL("Reset"); |
---|
124 | in_NRESET->write(0); |
---|
125 | SC_START(5); |
---|
126 | in_NRESET->write(1); |
---|
127 | |
---|
128 | LABEL("Loop of Test"); |
---|
129 | |
---|
130 | for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++) |
---|
131 | { |
---|
132 | LABEL("Iteration %d",iteration); |
---|
133 | |
---|
134 | SC_START(1); |
---|
135 | } |
---|
136 | |
---|
137 | /******************************************************** |
---|
138 | * Simulation - End |
---|
139 | ********************************************************/ |
---|
140 | |
---|
141 | TEST_OK ("End of Simulation"); |
---|
142 | delete _time; |
---|
143 | |
---|
144 | msg(_("<%s> : ............ Stop Simulation\n"),name.c_str()); |
---|
145 | |
---|
146 | delete in_CLOCK; |
---|
147 | delete in_NRESET; |
---|
148 | |
---|
149 | delete out_ICACHE_REQ_VAL ; |
---|
150 | delete in_ICACHE_REQ_ADDRESS_VAL; |
---|
151 | delete out_ICACHE_REQ_QUEUE_VAL ; |
---|
152 | delete in_ICACHE_REQ_ACK ; |
---|
153 | delete out_ICACHE_REQ_ADDRESS_ACK; |
---|
154 | delete in_ICACHE_REQ_QUEUE_ACK ; |
---|
155 | delete out_ICACHE_REQ_TYPE ; |
---|
156 | delete in_EVENT_VAL ; |
---|
157 | delete out_EVENT_ADDRESS_VAL ; |
---|
158 | delete out_EVENT_QUEUE_VAL ; |
---|
159 | delete out_EVENT_ACK ; |
---|
160 | delete in_EVENT_ADDRESS_ACK ; |
---|
161 | delete in_EVENT_QUEUE_ACK ; |
---|
162 | #endif |
---|
163 | |
---|
164 | delete _Ifetch_unit_Glue; |
---|
165 | #ifdef STATISTICS |
---|
166 | delete _parameters_statistics; |
---|
167 | #endif |
---|
168 | } |
---|