OpenCores
URL https://opencores.org/ocsvn/openmsp430/openmsp430/trunk

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [core/] [sim/] [rtl_sim/] [src-c/] [dhrystone_4mcu/] [dhry.h] - Blame information for rev 200

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 olivier.gi
/*
2
 *************************************************************************
3
 *
4
 *                   "DHRYSTONE" Benchmark Program
5
 *                   -----------------------------
6
 *
7
 *  Version:    C, Version 2.1
8
 *
9
 *  File:       dhry.h (part 1 of 3)
10
 *
11
 *  Date:       May 25, 1988
12
 *
13
 *  Author:     Reinhold P. Weicker
14
 *              Siemens Nixdorf Inf. Syst.
15
 *              STM OS 32
16
 *              Otto-Hahn-Ring 6
17
 *              W-8000 Muenchen 83
18
 *              Germany
19
 *                      Phone:    [+49]-89-636-42436
20
 *                                (8-17 Central European Time)
21
 *                      UUCP:     weicker@ztivax.uucp@unido.uucp
22
 *                      Internet: weicker@ztivax.siemens.com
23
 *
24
 *              Original Version (in Ada) published in
25
 *              "Communications of the ACM" vol. 27., no. 10 (Oct. 1984),
26
 *              pp. 1013 - 1030, together with the statistics
27
 *              on which the distribution of statements etc. is based.
28
 *
29
 *              In this C version, the following C library functions are
30
 *              used:
31
 *              - strcpy, strcmp (inside the measurement loop)
32
 *              - printf, scanf (outside the measurement loop)
33
 *
34
 *  Collection of Results:
35
 *              Reinhold Weicker (address see above) and
36 200 olivier.gi
 *
37 145 olivier.gi
 *              Rick Richardson
38
 *              PC Research. Inc.
39
 *              94 Apple Orchard Drive
40
 *              Tinton Falls, NJ 07724
41
 *                      Phone:  (201) 834-1378 (9-17 EST)
42
 *                      UUCP:   ...!uunet!pcrat!rick
43
 *
44
 *      Please send results to Rick Richardson and/or Reinhold Weicker.
45
 *      Complete information should be given on hardware and software
46
 *      used. Hardware information includes: Machine type, CPU, type and
47
 *      size of caches; for microprocessors: clock frequency, memory speed
48
 *      (number of wait states). Software information includes: Compiler
49
 *      (and runtime library) manufacturer and version, compilation
50
 *      switches, OS version. The Operating System version may give an
51
 *      indication about the compiler; Dhrystone itself performs no OS
52
 *      calls in the measurement loop.
53
 *
54
 *      The complete output generated by the program should be mailed
55
 *      such that at least some checks for correctness can be made.
56
 *
57
 *************************************************************************
58
 *
59
 *  History:    This version C/2.1 has been made for two reasons:
60
 *
61
 *              1) There is an obvious need for a common C version of
62
 *              Dhrystone, since C is at present the most popular system
63
 *              programming language for the class of processors
64
 *              (microcomputers, minicomputers) where Dhrystone is used
65
 *              most. There should be, as far as possible, only one C
66
 *              version of Dhrystone such that results can be compared
67
 *              without restrictions. In the past, the C versions
68
 *              distributed by Rick Richardson (Version 1.1) and by
69
 *              Reinhold Weicker had small (though not significant)
70
 *              differences.
71
 *
72
 *              2) As far as it is possible without changes to the
73
 *              Dhrystone statistics, optimizing compilers should be
74
 *              prevented from removing significant statements.
75
 *
76
 *              This C version has been developed in cooperation with
77
 *              Rick Richardson (Tinton Falls, NJ), it incorporates many
78
 *              ideas from the "Version 1.1" distributed previously by
79
 *              him over the UNIX network Usenet.
80
 *              I also thank Chaim Benedelac (National Semiconductor),
81
 *              David Ditzel (SUN), Earl Killian and John Mashey (MIPS),
82
 *              Alan Smith and Rafael Saavedra-Barrera (UC at Berkeley)
83
 *              for their help with comments on earlier versions of the
84
 *              benchmark.
85
 *
86
 *  Changes:    In the initialization part, this version follows mostly
87
 *              Rick Richardson's version distributed via Usenet, not the
88
 *              version distributed earlier via floppy disk by Reinhold
89
 *              Weicker. As a concession to older compilers, names have
90
 *              been made unique within the first 8 characters. Inside the
91
 *              measurement loop, this version follows the version
92
 *              previously distributed by Reinhold Weicker.
93
 *
94
 *              At several places in the benchmark, code has been added,
95
 *              but within the measurement loop only in branches that
96
 *              are not executed. The intention is that optimizing
97
 *              compilers should be prevented from moving code out of the
98
 *              measurement loop, or from removing code altogether. Since
99
 *              the statements that are executed within the measurement
100
 *              loop have NOT been changed, the numbers defining the
101
 *              "Dhrystone distribution" (distribution of statements,
102
 *              operand types and locality) still hold. Except for
103
 *              sophisticated optimizing compilers, execution times for
104
 *              this version should be the same as for previous versions.
105
 *
106
 *              Since it has proven difficult to subtract the time for the
107
 *              measurement loop overhead in a correct way, the loop check
108
 *              has been made a part of the benchmark. This does have
109
 *              an impact - though a very minor one - on the distribution
110
 *              statistics which have been updated for this version.
111
 *
112
 *              All changes within the measurement loop are described
113
 *              and discussed in the companion paper "Rationale for
114
 *              Dhrystone version 2".
115
 *
116
 *              Because of the self-imposed limitation that the order and
117
 *              distribution of the executed statements should not be
118
 *              changed, there are still cases where optimizing compilers
119
 *              may not generate code for some statements. To a certain
120
 *              degree, this is unavoidable for small synthetic
121
 *              benchmarks. Users of the benchmark are advised to check
122
 *              code listings whether code is generated for all statements
123
 *              of Dhrystone.
124
 *
125
 *              Version 2.1 is identical to version 2.0 distributed via
126
 *              the UNIX network Usenet in March 1988 except that it
127
 *              corrects some minor deficiencies that were found by users
128
 *              of version 2.0. The only change within the measurement
129
 *              loop is that a non-executed "else" part was added to the
130
 *              "if" statement in Func_3, and a non-executed "else" part
131
 *              removed from Proc_3.
132
 *
133
 *************************************************************************
134
 *
135
 * Defines:     The following "Defines" are possible:
136
 *              -DROPT         (default: Not defined)
137
 *                      As an approximation to what an average C
138
 *                      programmer might do, the "register" storage class
139
 *                      is applied (if enabled by -DROPT)
140
 *                      - for local variables, if they are used
141
 *                        (dynamically) five or more times
142
 *                      - for parameters if they are used (dynamically)
143
 *                        six or more times
144
 *                      Note that an optimal "register" strategy is
145
 *                      compiler-dependent, and that "register"
146
 *                      declarations do not necessarily lead to faster
147
 *                      execution.
148
 *              -DNOSTRUCTASSIGN        (default: Not defined)
149
 *                      Define if the C compiler does not support
150
 *                      assignment of structures.
151
 *              -DNOENUMS               (default: Not defined)
152
 *                      Define if the C compiler does not support
153
 *                      enumeration types.
154
 *
155
 *************************************************************************
156
 *
157
 *  Compilation model and measurement (IMPORTANT):
158
 *
159
 *  This C version of Dhrystone consists of three files:
160
 *  - dhry.h (this file, containing global definitions and comments)
161
 *  - dhry_1.c (containing the code corresponding to Ada package Pack_1)
162
 *  - dhry_2.c (containing the code corresponding to Ada package Pack_2)
163
 *
164
 *  The following "ground rules" apply for measurements:
165
 *  - Separate compilation
166
 *  - No procedure merging
167
 *  - Otherwise, compiler optimizations are allowed but should be
168
 *    indicated
169
 *  - Default results are those without register declarations
170
 *  See the companion paper "Rationale for Dhrystone Version 2" for a more
171
 *  detailed discussion of these ground rules.
172
 *
173
 *  For 16-Bit processors (e.g. 80186, 80286), times for all compilation
174
 *  models ("small", "medium", "large" etc.) should be given if possible,
175
 *  together with a definition of these models for the compiler system
176
 *  used.
177
 *
178
 *************************************************************************
179
 *
180
 *  Dhrystone (C version) statistics:
181
 *
182
 *  [Comment from the first distribution, updated for version 2.
183
 *   Note that because of language differences, the numbers are slightly
184
 *   different from the Ada version.]
185
 *
186
 *  The following program contains statements of a high level programming
187
 *  language (here: C) in a distribution considered representative:
188
 *
189
 *    assignments                  52 (51.0 %)
190
 *    control statements           33 (32.4 %)
191
 *    procedure, function calls    17 (16.7 %)
192
 *
193
 *  103 statements are dynamically executed. The program is balanced with
194
 *  respect to the three aspects:
195
 *
196
 *    - statement type
197
 *    - operand type
198
 *    - operand locality
199
 *         operand global, local, parameter, or constant.
200
 *
201
 *  The combination of these three aspects is balanced only approximately.
202
 *
203
 *  1. Statement Type:
204
 *  -----------------             number
205
 *
206
 *     V1 = V2                     9
207
 *       (incl. V1 = F(..)
208
 *     V = Constant               12
209
 *     Assignment,                 7
210
 *       with array element
211
 *     Assignment,                 6
212
 *       with record component
213
 *                                --
214
 *                                34       34
215
 *
216
 *     X = Y +|-|"&&"|"|" Z        5
217
 *     X = Y +|-|"==" Constant     6
218
 *     X = X +|- 1                 3
219
 *     X = Y *|/ Z                 2
220
 *     X = Expression,             1
221
 *           two operators
222
 *     X = Expression,             1
223
 *           three operators
224
 *                                --
225
 *                                18       18
226
 *
227
 *     if ....                    14
228
 *       with "else"      7
229
 *       without "else"   7
230
 *           executed        3
231
 *           not executed    4
232
 *     for ...                     7  |  counted every time
233
 *     while ...                   4  |  the loop condition
234
 *     do ... while                1  |  is evaluated
235
 *     switch ...                  1
236
 *     break                       1
237
 *     declaration with            1
238
 *       initialization
239
 *                                --
240
 *                                34       34
241
 *
242
 *     P (...)  procedure call    11
243
 *       user procedure      10
244
 *       library procedure    1
245
 *     X = F (...)
246
 *             function  call      6
247
 *       user function        5
248
 *       library function     1
249
 *                                --
250
 *                                17       17
251
 *                                        ---
252
 *                                        103
253
 *
254
 *    The average number of parameters in procedure or function calls
255
 *    is 1.82 (not counting the function values as implicit parameters).
256
 *
257
 *
258
 *  2. Operators
259
 *  ------------
260
 *                          number    approximate
261
 *                                    percentage
262
 *
263
 *    Arithmetic             32          50.8
264
 *
265
 *       +                     21          33.3
266
 *       -                      7          11.1
267
 *       *                      3           4.8
268
 *       / (int div)            1           1.6
269
 *
270
 *    Comparison             27           42.8
271
 *
272
 *       ==                     9           14.3
273
 *       /=                     4            6.3
274
 *       >                      1            1.6
275
 *       <                      3            4.8
276
 *       >=                     1            1.6
277
 *       <=                     9           14.3
278
 *
279
 *    Logic                   4            6.3
280
 *
281
 *       && (AND-THEN)          1            1.6
282
 *       |  (OR)                1            1.6
283
 *       !  (NOT)               2            3.2
284 200 olivier.gi
 *
285 145 olivier.gi
 *                           --          -----
286
 *                           63          100.1
287
 *
288
 *
289
 *  3. Operand Type (counted once per operand reference):
290
 *  ---------------
291
 *                          number    approximate
292
 *                                    percentage
293
 *
294
 *     Integer               175        72.3 %
295
 *     Character              45        18.6 %
296
 *     Pointer                12         5.0 %
297
 *     String30                6         2.5 %
298
 *     Array                   2         0.8 %
299
 *     Record                  2         0.8 %
300
 *                           ---       -------
301
 *                           242       100.0 %
302
 *
303
 *  When there is an access path leading to the final operand (e.g. a
304
 *  record component), only the final data type on the access path is
305
 *  counted.
306
 *
307
 *
308
 *  4. Operand Locality:
309
 *  -------------------
310
 *                                number    approximate
311
 *                                          percentage
312
 *
313
 *     local variable              114        47.1 %
314
 *     global variable              22         9.1 %
315
 *     parameter                    45        18.6 %
316
 *        value                        23         9.5 %
317
 *        reference                    22         9.1 %
318
 *     function result               6         2.5 %
319
 *     constant                     55        22.7 %
320
 *                                 ---       -------
321
 *                                 242       100.0 %
322
 *
323
 *
324
 *  The program does not compute anything meaningful, but it is
325
 *  syntactically and semantically correct. All variables have a value
326
 *  assigned to them before they are used as a source operand.
327
 *
328
 *  There has been no explicit effort to account for the effects of a
329
 *  cache, or to balance the use of long or short displacements for code
330
 *  or data.
331
 *
332
 *************************************************************************
333
 */
334
#ifndef __MSP430__
335
#define __MSP430__
336
#endif
337
 
338
/*******************************************************************************
339
 * Adapted for embedded microcontrollers by Graham Davies, ECROS Technology.   *
340
 ******************************************************************************/
341
 
342
/* Compiler and system dependent definitions: */
343
 
344
#define Mic_secs_Per_Second     1000000.0
345
                /* Berkeley UNIX C returns process times in seconds/HZ */
346
 
347
#ifdef  NOSTRUCTASSIGN
348
#define structassign(d, s)      memcpy(&(d), &(s), sizeof(d))
349
#else
350
#define structassign(d, s)      d = s
351
#endif
352
 
353
#ifdef  NOENUM
354
#define Ident_1 0
355
#define Ident_2 1
356
#define Ident_3 2
357
#define Ident_4 3
358
#define Ident_5 4
359
  typedef int   Enumeration;
360
#else
361
  typedef       enum    {Ident_1, Ident_2, Ident_3, Ident_4, Ident_5}
362
                Enumeration;
363
#endif
364
        /* for boolean and enumeration types in Ada, Pascal */
365
 
366
/* General definitions: */
367
 
368
#include <stdio.h>
369
                /* for strcpy, strcmp */
370
 
371 200 olivier.gi
#define Null 0
372 145 olivier.gi
                /* Value of a Null pointer */
373
#define true  1
374
#define false 0
375
 
376
typedef int     One_Thirty;
377
typedef int     One_Fifty;
378
typedef char    Capital_Letter;
379
typedef int     Boolean;
380
typedef char    Str_30 [31];
381
typedef int     Arr_1_Dim [25];        /* <-- changed from 50 */
382
typedef int     Arr_2_Dim [25] [25];   /* <-- changed from 50 */
383
 
384 200 olivier.gi
typedef struct record
385 145 olivier.gi
    {
386
    struct record *Ptr_Comp;
387
    Enumeration    Discr;
388
    union {
389
          struct {
390
                  Enumeration Enum_Comp;
391
                  int         Int_Comp;
392
                  char        Str_Comp [31];
393
                  } var_1;
394
          struct {
395
                  Enumeration E_Comp_2;
396
                  char        Str_2_Comp [31];
397
                  } var_2;
398
          struct {
399
                  char        Ch_1_Comp;
400
                  char        Ch_2_Comp;
401
                  } var_3;
402
          } variant;
403
      } Rec_Type, *Rec_Pointer;
404
 
405
/*  Prototypes of function defined in dhry21b.c and called from dhry21a.c.
406
 */
407
void Proc_6( Enumeration Enum_Val_Par, Enumeration * Enum_Ref_Par );
408
void Proc_7( One_Fifty Int_1_Par_Val, One_Fifty Int_2_Par_Val,
409
                                                      One_Fifty * Int_Par_Ref );
410
void Proc_8( Arr_1_Dim Arr_1_Par_Ref, Arr_2_Dim Arr_2_Par_Ref,
411
                                         int Int_1_Par_Val, int Int_2_Par_Val );
412
Enumeration Func_1( Capital_Letter Ch_1_Par_Val, Capital_Letter Ch_2_Par_Val );
413
Boolean Func_2( Str_30 Str_1_Par_Ref, Str_30 Str_2_Par_Ref );
414
 
415
/*******************************************************************************
416
 * Additions for embedded microcontrollers follow ...
417
 
418
#ifdef printf
419
#undef printf
420 200 olivier.gi
#endif
421 145 olivier.gi
#define printf //
422
#ifdef fprintf
423
#undef fprintf
424 200 olivier.gi
#endif
425 145 olivier.gi
#define fprintf //
426
 */
427
 
428
extern void * emalloc( size_t nbytes );
429
 
430
#if defined( __AVR_ARCH__ )     /* Atmel AVR */
431
 
432
#include <avr/io.h>
433
#define SetPort( state ) PORTB = (state)
434
extern FILE * fopen( const char * filename, const char * mode );
435
 
436
#elif defined( __ENCORE__ )       /* ZiLOG Z8 Encore! */
437
 
438
#include <ez8.h>
439
#define SetPort( state ) PAOUT = (state)
440
typedef int FILE;
441
extern FILE * fopen( const char * filename, const char * mode );
442
extern int fclose( FILE * stream );
443
 
444
#elif defined( __MSP430__ )       /* MSP430 */
445
 
446 200 olivier.gi
#ifdef PFX_MSP430
447 145 olivier.gi
typedef int FILE;
448 200 olivier.gi
#endif
449 145 olivier.gi
 
450
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.