1 |
63 |
zero_gravi |
/*
|
2 |
|
|
****************************************************************************
|
3 |
|
|
*
|
4 |
|
|
* "DHRYSTONE" Benchmark Program
|
5 |
|
|
* -----------------------------
|
6 |
|
|
*
|
7 |
|
|
* Version: C, Version 2.1
|
8 |
|
|
*
|
9 |
|
|
* File: dhry_1.c (part 2 of 3)
|
10 |
|
|
*
|
11 |
|
|
* Date: May 25, 1988
|
12 |
|
|
*
|
13 |
|
|
* Author: Reinhold P. Weicker
|
14 |
|
|
*
|
15 |
|
|
****************************************************************************
|
16 |
|
|
*/
|
17 |
|
|
|
18 |
|
|
/*
|
19 |
|
|
Original from https://github.com/sifive/benchmark-dhrystone
|
20 |
|
|
Modified for the NEORV32 Processor
|
21 |
|
|
*/
|
22 |
|
|
|
23 |
|
|
#define TIME
|
24 |
|
|
|
25 |
|
|
#include <neorv32.h>
|
26 |
|
|
#include <string.h>
|
27 |
|
|
#include "dhry.h"
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
#ifndef DHRY_ITERS
|
31 |
|
|
#define DHRY_ITERS 2000
|
32 |
|
|
#endif
|
33 |
|
|
|
34 |
|
|
/* Global Variables: */
|
35 |
|
|
|
36 |
|
|
Rec_Pointer Ptr_Glob,
|
37 |
|
|
Next_Ptr_Glob;
|
38 |
|
|
int Int_Glob;
|
39 |
|
|
Boolean Bool_Glob;
|
40 |
|
|
char Ch_1_Glob,
|
41 |
|
|
Ch_2_Glob;
|
42 |
|
|
int Arr_1_Glob [50];
|
43 |
|
|
int Arr_2_Glob [50] [50];
|
44 |
|
|
|
45 |
|
|
//extern char *malloc ();
|
46 |
|
|
Enumeration Func_1 ();
|
47 |
|
|
/* forward declaration necessary since Enumeration may not simply be int */
|
48 |
|
|
|
49 |
|
|
#ifndef REG
|
50 |
|
|
Boolean Reg = false;
|
51 |
|
|
#define REG
|
52 |
|
|
/* REG becomes defined as empty */
|
53 |
|
|
/* i.e. no register variables */
|
54 |
|
|
#else
|
55 |
|
|
Boolean Reg = true;
|
56 |
|
|
#endif
|
57 |
|
|
|
58 |
|
|
/* variables for time measurement: */
|
59 |
|
|
|
60 |
|
|
#ifdef TIMES
|
61 |
|
|
struct tms time_info;
|
62 |
|
|
extern int times ();
|
63 |
|
|
/* see library function "times" */
|
64 |
|
|
#define Too_Small_Time (2*HZ)
|
65 |
|
|
/* Measurements should last at least about 2 seconds */
|
66 |
|
|
#endif
|
67 |
|
|
#ifdef TIME
|
68 |
|
|
extern long time();
|
69 |
|
|
/* see library function "time" */
|
70 |
|
|
#define Too_Small_Time 2
|
71 |
|
|
/* Measurements should last at least 2 seconds */
|
72 |
|
|
#endif
|
73 |
|
|
#ifdef MSC_CLOCK
|
74 |
|
|
extern clock_t clock();
|
75 |
|
|
#define Too_Small_Time (2*HZ)
|
76 |
|
|
#endif
|
77 |
|
|
|
78 |
|
|
long Begin_Time,
|
79 |
|
|
End_Time,
|
80 |
|
|
User_Time;
|
81 |
|
|
float Microseconds,
|
82 |
|
|
Dhrystones_Per_Second;
|
83 |
|
|
|
84 |
|
|
/* end of variables for time measurement */
|
85 |
|
|
|
86 |
|
|
|
87 |
|
|
int main (void)
|
88 |
|
|
/*****/
|
89 |
|
|
|
90 |
|
|
/* main program, corresponds to procedures */
|
91 |
|
|
/* Main and Proc_0 in the Ada version */
|
92 |
|
|
{
|
93 |
|
|
One_Fifty Int_1_Loc;
|
94 |
|
|
REG One_Fifty Int_2_Loc;
|
95 |
|
|
One_Fifty Int_3_Loc;
|
96 |
|
|
REG char Ch_Index;
|
97 |
|
|
Enumeration Enum_Loc;
|
98 |
|
|
Str_30 Str_1_Loc;
|
99 |
|
|
Str_30 Str_2_Loc;
|
100 |
|
|
REG int Run_Index;
|
101 |
|
|
REG int Number_Of_Runs;
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
{ /* ***** NEORV32-SPECIFIC ***** */
|
105 |
|
|
neorv32_cpu_dint(); // no interrupt, thanks
|
106 |
|
|
neorv32_rte_setup(); // capture all exceptions and give debug information, ho hw flow control
|
107 |
|
|
neorv32_uart_setup(19200, PARITY_NONE, FLOW_CONTROL_NONE);
|
108 |
|
|
// check available hardware extensions and compare with compiler flags
|
109 |
|
|
neorv32_rte_check_isa(0); // silent = 0 -> show message if isa mismatch
|
110 |
|
|
|
111 |
64 |
zero_gravi |
neorv32_uart_printf("NEORV32: Processor running at %u Hz\n", (uint32_t)NEORV32_SYSINFO.CLK);
|
112 |
63 |
zero_gravi |
neorv32_uart_printf("NEORV32: Executing Dhrystone (%u iterations). This may take some time...\n\n", (uint32_t)DHRY_ITERS);
|
113 |
|
|
|
114 |
|
|
// clear cycle counter
|
115 |
|
|
neorv32_cpu_set_mcycle(0);
|
116 |
|
|
|
117 |
|
|
#ifndef RUN_DHRYSTONE
|
118 |
|
|
#warning DHRYSTONE HAS NOT BEEN COMPILED! Use >>make USER_FLAGS+=-DRUN_DHRYSTONE clean_all exe<< to compile it.
|
119 |
|
|
|
120 |
|
|
// inform the user if you are actually executing this
|
121 |
|
|
neorv32_uart_printf("ERROR! CoreMark has not been compiled. Use >>make USER_FLAGS+=-DRUN_COREMARK clean_all exe<< to compile it.\n");
|
122 |
|
|
|
123 |
|
|
while(1);
|
124 |
|
|
#endif
|
125 |
|
|
} /* ***** /NEORV32-SPECIFIC ***** */
|
126 |
|
|
|
127 |
|
|
|
128 |
|
|
/* Initializations */
|
129 |
|
|
{ /* ***** NEORV32-SPECIFIC ***** */
|
130 |
|
|
// use static memory allocation, no dynamic malloc
|
131 |
|
|
//Next_Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type));
|
132 |
|
|
//Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type));
|
133 |
|
|
static Rec_Type Rec_Type_v0, Rec_Type_v1;
|
134 |
|
|
Next_Ptr_Glob = &Rec_Type_v0;
|
135 |
|
|
Ptr_Glob = &Rec_Type_v1;
|
136 |
|
|
} /* ***** /NEORV32-SPECIFIC ***** */
|
137 |
|
|
|
138 |
|
|
|
139 |
|
|
Ptr_Glob->Ptr_Comp = Next_Ptr_Glob;
|
140 |
|
|
Ptr_Glob->Discr = Ident_1;
|
141 |
|
|
Ptr_Glob->variant.var_1.Enum_Comp = Ident_3;
|
142 |
|
|
Ptr_Glob->variant.var_1.Int_Comp = 40;
|
143 |
|
|
strcpy (Ptr_Glob->variant.var_1.Str_Comp,
|
144 |
|
|
"DHRYSTONE PROGRAM, SOME STRING");
|
145 |
|
|
strcpy (Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING");
|
146 |
|
|
|
147 |
|
|
Arr_2_Glob [8][7] = 10;
|
148 |
|
|
/* Was missing in published program. Without this statement, */
|
149 |
|
|
/* Arr_2_Glob [8][7] would have an undefined value. */
|
150 |
|
|
/* Warning: With 16-Bit processors and Number_Of_Runs > 32000, */
|
151 |
|
|
/* overflow may occur for this array element. */
|
152 |
|
|
|
153 |
|
|
neorv32_uart_printf ("\n");
|
154 |
|
|
neorv32_uart_printf ("Dhrystone Benchmark, Version 2.1 (Language: C)\n");
|
155 |
|
|
neorv32_uart_printf ("\n");
|
156 |
|
|
if (Reg)
|
157 |
|
|
{
|
158 |
|
|
neorv32_uart_printf ("Program compiled with 'register' attribute\n");
|
159 |
|
|
neorv32_uart_printf ("\n");
|
160 |
|
|
}
|
161 |
|
|
else
|
162 |
|
|
{
|
163 |
|
|
neorv32_uart_printf ("Program compiled without 'register' attribute\n");
|
164 |
|
|
neorv32_uart_printf ("\n");
|
165 |
|
|
}
|
166 |
|
|
#ifdef DHRY_ITERS
|
167 |
|
|
Number_Of_Runs = DHRY_ITERS;
|
168 |
|
|
#else
|
169 |
|
|
neorv32_uart_printf ("Please give the number of runs through the benchmark: ");
|
170 |
|
|
{
|
171 |
|
|
int n;
|
172 |
|
|
scanf ("%d", &n);
|
173 |
|
|
Number_Of_Runs = n;
|
174 |
|
|
}
|
175 |
|
|
neorv32_uart_printf ("\n");
|
176 |
|
|
#endif
|
177 |
|
|
|
178 |
|
|
neorv32_uart_printf ("Execution starts, %u runs through Dhrystone\n", (uint32_t)Number_Of_Runs);
|
179 |
|
|
|
180 |
|
|
/***************/
|
181 |
|
|
/* Start timer */
|
182 |
|
|
/***************/
|
183 |
|
|
|
184 |
|
|
/*
|
185 |
|
|
#ifdef TIMES
|
186 |
|
|
times (&time_info);
|
187 |
|
|
Begin_Time = (long) time_info.tms_utime;
|
188 |
|
|
#endif
|
189 |
|
|
#ifdef TIME
|
190 |
|
|
Begin_Time = time ( (long *) 0);
|
191 |
|
|
#endif
|
192 |
|
|
#ifdef MSC_CLOCK
|
193 |
|
|
Begin_Time = clock();
|
194 |
|
|
#endif
|
195 |
|
|
*/
|
196 |
|
|
|
197 |
|
|
{ /* ***** NEORV32-SPECIFIC ***** */
|
198 |
|
|
Begin_Time = (long)neorv32_cpu_get_systime();
|
199 |
|
|
} /* ***** /NEORV32-SPECIFIC ***** */
|
200 |
|
|
|
201 |
|
|
for (Run_Index = 1; Run_Index <= Number_Of_Runs; ++Run_Index)
|
202 |
|
|
{
|
203 |
|
|
|
204 |
|
|
Proc_5();
|
205 |
|
|
Proc_4();
|
206 |
|
|
/* Ch_1_Glob == 'A', Ch_2_Glob == 'B', Bool_Glob == true */
|
207 |
|
|
Int_1_Loc = 2;
|
208 |
|
|
Int_2_Loc = 3;
|
209 |
|
|
strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING");
|
210 |
|
|
Enum_Loc = Ident_2;
|
211 |
|
|
Bool_Glob = ! Func_2 (Str_1_Loc, Str_2_Loc);
|
212 |
|
|
/* Bool_Glob == 1 */
|
213 |
|
|
while (Int_1_Loc < Int_2_Loc) /* loop body executed once */
|
214 |
|
|
{
|
215 |
|
|
Int_3_Loc = 5 * Int_1_Loc - Int_2_Loc;
|
216 |
|
|
/* Int_3_Loc == 7 */
|
217 |
|
|
Proc_7 (Int_1_Loc, Int_2_Loc, &Int_3_Loc);
|
218 |
|
|
/* Int_3_Loc == 7 */
|
219 |
|
|
Int_1_Loc += 1;
|
220 |
|
|
} /* while */
|
221 |
|
|
/* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
|
222 |
|
|
Proc_8 (Arr_1_Glob, Arr_2_Glob, Int_1_Loc, Int_3_Loc);
|
223 |
|
|
/* Int_Glob == 5 */
|
224 |
|
|
Proc_1 (Ptr_Glob);
|
225 |
|
|
for (Ch_Index = 'A'; Ch_Index <= Ch_2_Glob; ++Ch_Index)
|
226 |
|
|
/* loop body executed twice */
|
227 |
|
|
{
|
228 |
|
|
if (Enum_Loc == Func_1 (Ch_Index, 'C'))
|
229 |
|
|
/* then, not executed */
|
230 |
|
|
{
|
231 |
|
|
Proc_6 (Ident_1, &Enum_Loc);
|
232 |
|
|
strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 3'RD STRING");
|
233 |
|
|
Int_2_Loc = Run_Index;
|
234 |
|
|
Int_Glob = Run_Index;
|
235 |
|
|
}
|
236 |
|
|
}
|
237 |
|
|
/* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
|
238 |
|
|
Int_2_Loc = Int_2_Loc * Int_1_Loc;
|
239 |
|
|
Int_1_Loc = Int_2_Loc / Int_3_Loc;
|
240 |
|
|
Int_2_Loc = 7 * (Int_2_Loc - Int_3_Loc) - Int_1_Loc;
|
241 |
|
|
/* Int_1_Loc == 1, Int_2_Loc == 13, Int_3_Loc == 7 */
|
242 |
|
|
Proc_2 (&Int_1_Loc);
|
243 |
|
|
/* Int_1_Loc == 5 */
|
244 |
|
|
|
245 |
|
|
} /* loop "for Run_Index" */
|
246 |
|
|
|
247 |
|
|
/**************/
|
248 |
|
|
/* Stop timer */
|
249 |
|
|
/**************/
|
250 |
|
|
|
251 |
|
|
/*
|
252 |
|
|
#ifdef TIMES
|
253 |
|
|
times (&time_info);
|
254 |
|
|
End_Time = (long) time_info.tms_utime;
|
255 |
|
|
#endif
|
256 |
|
|
#ifdef TIME
|
257 |
|
|
End_Time = time ( (long *) 0);
|
258 |
|
|
#endif
|
259 |
|
|
#ifdef MSC_CLOCK
|
260 |
|
|
End_Time = clock();
|
261 |
|
|
#endif
|
262 |
|
|
*/
|
263 |
|
|
|
264 |
|
|
{ /* ***** NEORV32-SPECIFIC ***** */
|
265 |
|
|
End_Time = (long)neorv32_cpu_get_systime();
|
266 |
|
|
} /* ***** /NEORV32-SPECIFIC ***** */
|
267 |
|
|
|
268 |
|
|
|
269 |
|
|
neorv32_uart_printf ("Execution ends\n");
|
270 |
|
|
neorv32_uart_printf ("\n");
|
271 |
|
|
neorv32_uart_printf ("Final values of the variables used in the benchmark:\n");
|
272 |
|
|
neorv32_uart_printf ("\n");
|
273 |
|
|
neorv32_uart_printf ("Int_Glob: %u\n", (uint32_t)Int_Glob);
|
274 |
|
|
neorv32_uart_printf (" should be: %u\n", 5);
|
275 |
|
|
neorv32_uart_printf ("Bool_Glob: %u\n", (uint32_t)Bool_Glob);
|
276 |
|
|
neorv32_uart_printf (" should be: %u\n", 1);
|
277 |
|
|
neorv32_uart_printf ("Ch_1_Glob: %c\n", (uint32_t)Ch_1_Glob);
|
278 |
|
|
neorv32_uart_printf (" should be: %c\n", 'A');
|
279 |
|
|
neorv32_uart_printf ("Ch_2_Glob: %c\n", (uint32_t)Ch_2_Glob);
|
280 |
|
|
neorv32_uart_printf (" should be: %c\n", 'B');
|
281 |
|
|
neorv32_uart_printf ("Arr_1_Glob[8]: %u\n", (uint32_t)Arr_1_Glob[8]);
|
282 |
|
|
neorv32_uart_printf (" should be: %u\n", 7);
|
283 |
|
|
neorv32_uart_printf ("Arr_2_Glob[8][7]: %u\n", (uint32_t)Arr_2_Glob[8][7]);
|
284 |
|
|
neorv32_uart_printf (" should be: Number_Of_Runs + 10\n");
|
285 |
|
|
neorv32_uart_printf ("Ptr_Glob->\n");
|
286 |
|
|
neorv32_uart_printf (" Ptr_Comp: %u\n", (uint32_t) Ptr_Glob->Ptr_Comp);
|
287 |
|
|
neorv32_uart_printf (" should be: (implementation-dependent)\n");
|
288 |
|
|
neorv32_uart_printf (" Discr: %u\n", (uint32_t)Ptr_Glob->Discr);
|
289 |
|
|
neorv32_uart_printf (" should be: %u\n", 0);
|
290 |
|
|
neorv32_uart_printf (" Enum_Comp: %u\n", (uint32_t)Ptr_Glob->variant.var_1.Enum_Comp);
|
291 |
|
|
neorv32_uart_printf (" should be: %u\n", 2);
|
292 |
|
|
neorv32_uart_printf (" Int_Comp: %u\n", (uint32_t)Ptr_Glob->variant.var_1.Int_Comp);
|
293 |
|
|
neorv32_uart_printf (" should be: %u\n", 17);
|
294 |
|
|
neorv32_uart_printf (" Str_Comp: %s\n", Ptr_Glob->variant.var_1.Str_Comp);
|
295 |
|
|
neorv32_uart_printf (" should be: DHRYSTONE PROGRAM, SOME STRING\n");
|
296 |
|
|
neorv32_uart_printf ("Next_Ptr_Glob->\n");
|
297 |
|
|
neorv32_uart_printf (" Ptr_Comp: %u\n", (uint32_t) Next_Ptr_Glob->Ptr_Comp);
|
298 |
|
|
neorv32_uart_printf (" should be: (implementation-dependent), same as above\n");
|
299 |
|
|
neorv32_uart_printf (" Discr: %u\n", (uint32_t)Next_Ptr_Glob->Discr);
|
300 |
|
|
neorv32_uart_printf (" should be: %u\n", 0);
|
301 |
|
|
neorv32_uart_printf (" Enum_Comp: %u\n", (uint32_t)Next_Ptr_Glob->variant.var_1.Enum_Comp);
|
302 |
|
|
neorv32_uart_printf (" should be: %u\n", 1);
|
303 |
|
|
neorv32_uart_printf (" Int_Comp: %u\n", (uint32_t)Next_Ptr_Glob->variant.var_1.Int_Comp);
|
304 |
|
|
neorv32_uart_printf (" should be: %u\n", 18);
|
305 |
|
|
neorv32_uart_printf (" Str_Comp: %s\n",
|
306 |
|
|
Next_Ptr_Glob->variant.var_1.Str_Comp);
|
307 |
|
|
neorv32_uart_printf (" should be: DHRYSTONE PROGRAM, SOME STRING\n");
|
308 |
|
|
neorv32_uart_printf ("Int_1_Loc: %u\n", (uint32_t)Int_1_Loc);
|
309 |
|
|
neorv32_uart_printf (" should be: %u\n", 5);
|
310 |
|
|
neorv32_uart_printf ("Int_2_Loc: %u\n", (uint32_t)Int_2_Loc);
|
311 |
|
|
neorv32_uart_printf (" should be: %u\n", 13);
|
312 |
|
|
neorv32_uart_printf ("Int_3_Loc: %u\n", (uint32_t)Int_3_Loc);
|
313 |
|
|
neorv32_uart_printf (" should be: %u\n", 7);
|
314 |
|
|
neorv32_uart_printf ("Enum_Loc: %u\n", (uint32_t)Enum_Loc);
|
315 |
|
|
neorv32_uart_printf (" should be: %u\n", 1);
|
316 |
|
|
neorv32_uart_printf ("Str_1_Loc: %s\n", Str_1_Loc);
|
317 |
|
|
neorv32_uart_printf (" should be: DHRYSTONE PROGRAM, 1'ST STRING\n");
|
318 |
|
|
neorv32_uart_printf ("Str_2_Loc: %s\n", Str_2_Loc);
|
319 |
|
|
neorv32_uart_printf (" should be: DHRYSTONE PROGRAM, 2'ND STRING\n");
|
320 |
|
|
neorv32_uart_printf ("\n");
|
321 |
|
|
|
322 |
|
|
User_Time = End_Time - Begin_Time;
|
323 |
|
|
|
324 |
|
|
// if (User_Time < Too_Small_Time)
|
325 |
|
|
// {
|
326 |
|
|
// neorv32_uart_printf ("Measured time too small to obtain meaningful results\n");
|
327 |
|
|
// neorv32_uart_printf ("Please increase number of runs\n");
|
328 |
|
|
// neorv32_uart_printf ("\n");
|
329 |
|
|
// }
|
330 |
|
|
// else
|
331 |
|
|
{
|
332 |
|
|
/*
|
333 |
|
|
#ifdef TIME
|
334 |
|
|
Microseconds = (float) User_Time * Mic_secs_Per_Second
|
335 |
|
|
/ (float) Number_Of_Runs;
|
336 |
|
|
Dhrystones_Per_Second = (float) Number_Of_Runs / (float) User_Time;
|
337 |
|
|
#else
|
338 |
|
|
Microseconds = (float) User_Time * Mic_secs_Per_Second
|
339 |
|
|
/ ((float) HZ * ((float) Number_Of_Runs));
|
340 |
|
|
Dhrystones_Per_Second = ((float) HZ * (float) Number_Of_Runs)
|
341 |
|
|
/ (float) User_Time;
|
342 |
|
|
#endif
|
343 |
|
|
*/
|
344 |
|
|
{ /* ***** NEORV32-SPECIFIC ***** */
|
345 |
|
|
neorv32_uart_printf ("Microseconds for one run through Dhrystone: ");
|
346 |
64 |
zero_gravi |
neorv32_uart_printf ("%u \n", (uint32_t)(((User_Time/NEORV32_SYSINFO.CLK) * Mic_secs_Per_Second) / Number_Of_Runs));
|
347 |
63 |
zero_gravi |
neorv32_uart_printf ("Dhrystones per Second: ");
|
348 |
64 |
zero_gravi |
neorv32_uart_printf ("%u \n", (uint32_t)(Number_Of_Runs / (User_Time/NEORV32_SYSINFO.CLK)));
|
349 |
63 |
zero_gravi |
neorv32_uart_printf ("\n");
|
350 |
|
|
|
351 |
64 |
zero_gravi |
uint32_t dhry_per_sec = (uint32_t)(Number_Of_Runs / (User_Time/NEORV32_SYSINFO.CLK));
|
352 |
63 |
zero_gravi |
uint32_t vax_per_sec = dhry_per_sec / 1757;
|
353 |
|
|
|
354 |
|
|
neorv32_uart_printf("NEORV32: << DETAILED RESULTS (integer parts only) >>\n");
|
355 |
|
|
neorv32_uart_printf("NEORV32: Total cycles: %u\n", (uint32_t)User_Time);
|
356 |
64 |
zero_gravi |
neorv32_uart_printf("NEORV32: Cycles per second: %u\n", (uint32_t)NEORV32_SYSINFO.CLK);
|
357 |
63 |
zero_gravi |
neorv32_uart_printf("NEORV32: Total runs: %u\n", (uint32_t)Number_Of_Runs);
|
358 |
|
|
|
359 |
|
|
neorv32_uart_printf("\n");
|
360 |
|
|
neorv32_uart_printf("NEORV32: DMIPS/s: %u\n", (uint32_t)dhry_per_sec);
|
361 |
64 |
zero_gravi |
neorv32_uart_printf("NEORV32: DMIPS/MHz: %u\n", (uint32_t)(dhry_per_sec / (NEORV32_SYSINFO.CLK / 1000000)));
|
362 |
63 |
zero_gravi |
|
363 |
|
|
neorv32_uart_printf("\n");
|
364 |
|
|
neorv32_uart_printf("NEORV32: VAX DMIPS/s: %u\n", (uint32_t)vax_per_sec);
|
365 |
64 |
zero_gravi |
neorv32_uart_printf("NEORV32: VAX DMIPS/MHz: %u/%u\n", (uint32_t)vax_per_sec, (uint32_t)(NEORV32_SYSINFO.CLK / 1000000));
|
366 |
63 |
zero_gravi |
} /* ***** /NEORV32-SPECIFIC ***** */
|
367 |
|
|
/*
|
368 |
|
|
neorv32_uart_printf ("Microseconds for one run through Dhrystone: ");
|
369 |
|
|
//neorv32_uart_printf ("%6.1f \n", Microseconds);
|
370 |
|
|
neorv32_uart_printf ("%d \n", (int)Microseconds);
|
371 |
|
|
neorv32_uart_printf ("Dhrystones per Second: ");
|
372 |
|
|
//neorv32_uart_printf ("%6.1f \n", Dhrystones_Per_Second);
|
373 |
|
|
neorv32_uart_printf ("%d \n", (int)Dhrystones_Per_Second);
|
374 |
|
|
neorv32_uart_printf ("\n");
|
375 |
|
|
*/
|
376 |
|
|
}
|
377 |
|
|
|
378 |
|
|
return 0;
|
379 |
|
|
}
|
380 |
|
|
|
381 |
|
|
|
382 |
|
|
void Proc_1 (Ptr_Val_Par)
|
383 |
|
|
/******************/
|
384 |
|
|
|
385 |
|
|
REG Rec_Pointer Ptr_Val_Par;
|
386 |
|
|
/* executed once */
|
387 |
|
|
{
|
388 |
|
|
REG Rec_Pointer Next_Record = Ptr_Val_Par->Ptr_Comp;
|
389 |
|
|
/* == Ptr_Glob_Next */
|
390 |
|
|
/* Local variable, initialized with Ptr_Val_Par->Ptr_Comp, */
|
391 |
|
|
/* corresponds to "rename" in Ada, "with" in Pascal */
|
392 |
|
|
|
393 |
|
|
structassign (*Ptr_Val_Par->Ptr_Comp, *Ptr_Glob);
|
394 |
|
|
Ptr_Val_Par->variant.var_1.Int_Comp = 5;
|
395 |
|
|
Next_Record->variant.var_1.Int_Comp
|
396 |
|
|
= Ptr_Val_Par->variant.var_1.Int_Comp;
|
397 |
|
|
Next_Record->Ptr_Comp = Ptr_Val_Par->Ptr_Comp;
|
398 |
|
|
Proc_3 (&Next_Record->Ptr_Comp);
|
399 |
|
|
/* Ptr_Val_Par->Ptr_Comp->Ptr_Comp
|
400 |
|
|
== Ptr_Glob->Ptr_Comp */
|
401 |
|
|
if (Next_Record->Discr == Ident_1)
|
402 |
|
|
/* then, executed */
|
403 |
|
|
{
|
404 |
|
|
Next_Record->variant.var_1.Int_Comp = 6;
|
405 |
|
|
Proc_6 (Ptr_Val_Par->variant.var_1.Enum_Comp,
|
406 |
|
|
&Next_Record->variant.var_1.Enum_Comp);
|
407 |
|
|
Next_Record->Ptr_Comp = Ptr_Glob->Ptr_Comp;
|
408 |
|
|
Proc_7 (Next_Record->variant.var_1.Int_Comp, 10,
|
409 |
|
|
&Next_Record->variant.var_1.Int_Comp);
|
410 |
|
|
}
|
411 |
|
|
else /* not executed */
|
412 |
|
|
structassign (*Ptr_Val_Par, *Ptr_Val_Par->Ptr_Comp);
|
413 |
|
|
} /* Proc_1 */
|
414 |
|
|
|
415 |
|
|
|
416 |
|
|
void Proc_2 (Int_Par_Ref)
|
417 |
|
|
/******************/
|
418 |
|
|
/* executed once */
|
419 |
|
|
/* *Int_Par_Ref == 1, becomes 4 */
|
420 |
|
|
|
421 |
|
|
One_Fifty *Int_Par_Ref;
|
422 |
|
|
{
|
423 |
|
|
One_Fifty Int_Loc;
|
424 |
|
|
Enumeration Enum_Loc;
|
425 |
|
|
|
426 |
|
|
Int_Loc = *Int_Par_Ref + 10;
|
427 |
|
|
do /* executed once */
|
428 |
|
|
if (Ch_1_Glob == 'A')
|
429 |
|
|
/* then, executed */
|
430 |
|
|
{
|
431 |
|
|
Int_Loc -= 1;
|
432 |
|
|
*Int_Par_Ref = Int_Loc - Int_Glob;
|
433 |
|
|
Enum_Loc = Ident_1;
|
434 |
|
|
} /* if */
|
435 |
|
|
while (Enum_Loc != Ident_1); /* true */
|
436 |
|
|
} /* Proc_2 */
|
437 |
|
|
|
438 |
|
|
|
439 |
|
|
void Proc_3 (Ptr_Ref_Par)
|
440 |
|
|
/******************/
|
441 |
|
|
/* executed once */
|
442 |
|
|
/* Ptr_Ref_Par becomes Ptr_Glob */
|
443 |
|
|
|
444 |
|
|
Rec_Pointer *Ptr_Ref_Par;
|
445 |
|
|
|
446 |
|
|
{
|
447 |
|
|
if (Ptr_Glob != Null)
|
448 |
|
|
/* then, executed */
|
449 |
|
|
*Ptr_Ref_Par = Ptr_Glob->Ptr_Comp;
|
450 |
|
|
Proc_7 (10, Int_Glob, &Ptr_Glob->variant.var_1.Int_Comp);
|
451 |
|
|
} /* Proc_3 */
|
452 |
|
|
|
453 |
|
|
|
454 |
|
|
void Proc_4 (void) /* without parameters */
|
455 |
|
|
/*******/
|
456 |
|
|
/* executed once */
|
457 |
|
|
{
|
458 |
|
|
Boolean Bool_Loc;
|
459 |
|
|
|
460 |
|
|
Bool_Loc = Ch_1_Glob == 'A';
|
461 |
|
|
Bool_Glob = Bool_Loc | Bool_Glob;
|
462 |
|
|
Ch_2_Glob = 'B';
|
463 |
|
|
} /* Proc_4 */
|
464 |
|
|
|
465 |
|
|
|
466 |
|
|
void Proc_5 (void) /* without parameters */
|
467 |
|
|
/*******/
|
468 |
|
|
/* executed once */
|
469 |
|
|
{
|
470 |
|
|
Ch_1_Glob = 'A';
|
471 |
|
|
Bool_Glob = false;
|
472 |
|
|
} /* Proc_5 */
|
473 |
|
|
|
474 |
|
|
|
475 |
|
|
/* Procedure for the assignment of structures, */
|
476 |
|
|
/* if the C compiler doesn't support this feature */
|
477 |
|
|
#ifdef NOSTRUCTASSIGN
|
478 |
|
|
memcpy (d, s, l)
|
479 |
|
|
register char *d;
|
480 |
|
|
register char *s;
|
481 |
|
|
register int l;
|
482 |
|
|
{
|
483 |
|
|
while (l--) *d++ = *s++;
|
484 |
|
|
}
|
485 |
|
|
#endif
|
486 |
|
|
|
487 |
|
|
|
488 |
|
|
/* Compare S1 and S2, returning less than, equal to or
|
489 |
|
|
greater than zero if S1 is lexicographically less than,
|
490 |
|
|
equal to or greater than S2. [from glibc] */
|
491 |
|
|
int strcmp(const char *p1, const char *p2)
|
492 |
|
|
{
|
493 |
|
|
const unsigned char *s1 = (const unsigned char *) p1;
|
494 |
|
|
const unsigned char *s2 = (const unsigned char *) p2;
|
495 |
|
|
unsigned char c1, c2;
|
496 |
|
|
do
|
497 |
|
|
{
|
498 |
|
|
c1 = (unsigned char) *s1++;
|
499 |
|
|
c2 = (unsigned char) *s2++;
|
500 |
|
|
if (c1 == '\0')
|
501 |
|
|
return c1 - c2;
|
502 |
|
|
}
|
503 |
|
|
while (c1 == c2);
|
504 |
|
|
return c1 - c2;
|
505 |
|
|
}
|