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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [bootloaders/] [orpmon/] [coremark/] [core_portme.c] - Blame information for rev 501

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 355 julius
/*
2
        File : core_portme.c
3
*/
4
/*
5
        Author : Shay Gal-On, EEMBC
6
        Legal : TODO!
7
*/
8
#include "coremark.h"
9
#include "core_portme.h"
10
#include "spr-defs.h"
11
#include "board.h"
12
#include "support.h"
13
#include "common.h"
14
 
15
/*
16
#if VALIDATION_RUN
17
volatile ee_s32 seed1_volatile = 0x3415;
18
volatile ee_s32 seed2_volatile = 0x3415;
19
volatile ee_s32 seed3_volatile = 0x66;
20
#endif
21
#if PERFORMANCE_RUN
22
volatile ee_s32 seed1_volatile = 0x0;
23
volatile ee_s32 seed2_volatile = 0x0;
24
volatile ee_s32 seed3_volatile = 0x66;
25
#endif
26
#if PROFILE_RUN
27
volatile ee_s32 seed1_volatile = 0x8;
28
volatile ee_s32 seed2_volatile = 0x8;
29
volatile ee_s32 seed3_volatile = 0x8;
30
#endif
31
volatile ee_s32 seed4_volatile = ITERATIONS;
32
volatile ee_s32 seed5_volatile = 0;
33
*/
34
 
35
volatile ee_s32 seed1_volatile;
36
volatile ee_s32 seed2_volatile;
37
volatile ee_s32 seed3_volatile;
38 406 julius
volatile ee_s32 seed4_volatile = 0;      // Iterations defaults to 0
39 355 julius
volatile ee_s32 seed5_volatile = 0;
40
 
41
/* Porting : Timing functions
42
   How to capture time and convert to seconds must be ported to whatever is
43
   supported by the platform. e.g. Read value from on board RTC, read value
44
   from cpu clock cycles performance counter etc. Sample implementation for
45
   standard time.h and windows.h definitions included.
46
*/
47
CORETIMETYPE barebones_clock()
48
{
49
        //#error "You must implement a method to measure time in 
50 406 julius
        //barebones_clock()! This function should return current time.\n"
51 355 julius
        return timestamp;
52
}
53
 
54
/* Define : TIMER_RES_DIVIDER
55
   Divider to trade off timer resolution and total time that can be measured.
56
 
57
   Use lower values to increase resolution, but make sure that overflow does
58
   not occur. If there are issues with the return value overflowing, increase
59
   this value.
60
*/
61
#define GETMYTIME(_t) (*_t=barebones_clock())
62
#define MYTIMEDIFF(fin,ini) ((fin)-(ini))
63
#define TIMER_RES_DIVIDER 1     /* Unused */
64
#define SAMPLE_TIME_IMPLEMENTATION 1
65
#define EE_TICKS_PER_SEC TICKS_PER_SEC
66
 
67
/** Define Host specific (POSIX), or target specific global time variables. */
68
static CORETIMETYPE start_time_val, stop_time_val;
69
 
70
/* Function : start_time
71
   This function will be called right before starting the timed portion of the
72
   benchmark.
73
 
74
   Implementation may be capturing a system timer (as implemented in the
75
   example code) or zeroing some system parameters - e.g. setting the cpu
76
   clocks cycles to 0.
77
*/
78
void start_time(void)
79
{
80
        GETMYTIME(&start_time_val);
81
}
82
 
83
/* Function : stop_time
84
   This function will be called right after ending the timed portion of the
85
   benchmark.
86
 
87
   Implementation may be capturing a system timer (as implemented in the
88
   example code) or other system parameters - e.g. reading the current value of
89
   cpu cycles counter.
90
*/
91
void stop_time(void)
92
{
93
        GETMYTIME(&stop_time_val);
94
}
95
 
96
/* Function : get_time
97
   Return an abstract "ticks" number that signifies time on the system.
98
 
99
   Actual value returned may be cpu cycles, milliseconds or any other value,
100
   as long as it can be converted to seconds by <time_in_secs>.
101
   This methodology is taken to accomodate any hardware or simulated platform.
102
   The sample implementation returns millisecs by default,
103
   and the resolution is controlled by <TIMER_RES_DIVIDER>
104
*/
105
CORE_TICKS get_time(void)
106
{
107
        CORE_TICKS elapsed =
108
            (CORE_TICKS) (MYTIMEDIFF(stop_time_val, start_time_val));
109
        return elapsed;
110
}
111
 
112
/* Function : time_in_secs
113
   Convert the value returned by get_time to seconds.
114
 
115
   The <secs_ret> type is used to accomodate systems with no support for
116
   floating point. Default implementation implemented by the EE_TICKS_PER_SEC
117
   macro above.
118
*/
119
secs_ret time_in_secs(CORE_TICKS ticks)
120
{
121
        secs_ret retval = ((secs_ret) ticks) / (secs_ret) EE_TICKS_PER_SEC;
122
        return retval;
123
}
124
 
125
ee_u32 default_num_contexts = 1;
126
 
127
/* Function : portable_init
128
   Target specific initialization code
129
   Test for some common mistakes.
130
*/
131
void portable_init(core_portable * p, int *argc, char *argv[])
132
{
133
 
134 406 julius
        // In ORPmon - UART already initialised: uart_init(DEFAULT_UART);
135
        if (sizeof(ee_ptr_int) != sizeof(ee_u8 *)) {
136
                ee_printf
137
                    ("ERROR! Please define ee_ptr_int to a type that holds a pointer!\n");
138
                while (1) ;     // FINISH
139
        }
140
        if (sizeof(ee_u32) != 4) {
141
                ee_printf
142
                    ("ERROR! Please define ee_u32 to a 32b unsigned type!\n");
143
                while (1) ;     // FINISH
144
        }
145
        // In ORPmon - things already initialised
146
        // Clear timer variable
147
        //clear_timer_ticks();
148
        // init timer
149
        //enable_timer();
150 355 julius
 
151 406 julius
        //
152
 
153
        // Parse argv and figure out what kind of run we do
154
        if (argc > 0) {
155
                switch ((char)argv[0][0]) {
156
                case 'p':
157
                        //PERFORMANCE_RUN
158
                        seed1_volatile = 0x0;
159
                        seed2_volatile = 0x0;
160
                        seed3_volatile = 0x66;
161
                        break;
162
                case 'o':
163
                        //PROFILE_RUN
164
                        seed1_volatile = 0x8;
165
                        seed2_volatile = 0x8;
166
                        seed3_volatile = 0x8;
167
                        break;
168
                default:
169
                        //VALIDATION_RUN
170
                        seed1_volatile = 0x3415;
171
                        seed2_volatile = 0x3415;
172
                        seed3_volatile = 0x66;
173
                        break;
174
                }
175 355 julius
        }
176
 
177 406 julius
        if (argc > 1)
178
                seed4_volatile = strtoul(argv[1], 0, 0);  // Iterations as second argument
179
        else
180
                seed4_volatile = 0;      // Zero (test runs a minimum amount of time)
181
 
182
        seed5_volatile = 0;
183
 
184
        p->portable_id = 1;
185
 
186 355 julius
}
187
 
188
/* Function : portable_fini
189
        Target specific final code
190
*/
191
void portable_fini(core_portable * p)
192
{
193
        p->portable_id = 0;
194
}

powered by: WebSVN 2.1.0

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